sending a cookie in the simpletest browser

greggles's picture

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?

Login to post comments

Couldn't browse to a menu

moshe weitzman's picture
moshe weitzman - Wed, 2009-05-13 13:12

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


could do

greggles's picture
greggles - Wed, 2009-05-13 13:51

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

moshe weitzman's picture
moshe weitzman - Wed, 2009-05-13 17:11

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

grendzy's picture
grendzy - Wed, 2009-05-13 15:54

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?

Jim Hollcraft's picture
Jim Hollcraft - Mon, 2009-05-18 22:45

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


seems decent

greggles's picture
greggles - Mon, 2009-05-18 23:26

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