sending a cookie in the simpletest browser

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by greggles on May 13, 2009 at 2:08am

I need to test cookie integration with a 3rd party site.

The 3rd party site sets a cookie, Drupal sees this cookie, validates it, and logs in the user. I planned to test this by setting a cookie in my simpletest

I tried a couple of variations on:

<?php
$this
->drupalGet('node', NULL, array('Cookie: cookiename=cookievalue;'));
?>

but the "cookiename=cookievalue" bits always got jammed onto the end of the SESS... cookie.

I grepped through core and didn't find any situations where we are sending a cookie along with the drupalGet. Any advice?

Comments

Couldn't browse to a menu

Posted by moshe weitzman on May 13, 2009 at 1:12pm

Couldn't you browse to a menu callback thats sets the cookie and then to /node (in your example).

could do

Posted by greggles on May 13, 2009 at 1:51pm

I certainly could do that, I thought of a few other potential solutions to the problem based around adding test specific code to my regular application but rejected them on principle. Do we have other situations where code for testing exists outside of the .test files? Is there a style guideline for that?

--
Growing Venture Solutions | Drupal Dashboard | Learn more about Drupal - buy a Drupal Book

We have lots of testing

Posted by moshe weitzman on May 13, 2009 at 5:11pm

We have lots of testing modules under simpletest/tests. These are hidden from the admin/build/modules page with a .info param. Does that qualify as "ode for testing exists outside of the .test files".

This may not be possible

Posted by grendzy on May 13, 2009 at 3:54pm

This may not be possible with the current simpletest infrastructure. Even cURL itself seems to lack the ability to set or otherwise interact with cookies. I've started http://drupal.org/node/457804, please let us know if you discover anything.

Use mock_web?

Posted by b508 on May 18, 2009 at 10:45pm

I think I could easily add cookie settings to mock_web. See recent posting here. Would this work for you?

seems decent

Posted by greggles on May 18, 2009 at 11:26pm

The mock_web idea seems solid. I definitely think it would be worth adding to the core simpletest features.

--
Growing Venture Solutions | Drupal Dashboard | Learn more about Drupal - buy a Drupal Book

cookie

Posted by kenorb on October 24, 2011 at 2:50pm

Testing and Quality Assurance

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /