+ Reply to Thread
Results 1 to 2 of 2

Thread: set a cookie during a test

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    28

    set a cookie during a test

    I have a application that uses an external service via a cookie set to my applications domain. During development I create this cookie by hand but in production this cookie would be generated via a login. Is there any way to use the cookie I set during development before I run my tests for this external service?

    I have been using the PHPUNIT :
    Code:
    [class extending PHPUnit_Extensions_SeleniumTestCase]
    public function testCanGetTheCurrentAuthenticatedUser()
    {
        $this->open('http://my/local/virtual/host/api/getCurrentUser');
        $json = json_decode($this->getBodyText());
        $this->assertEquals('25', $json->response->id); 
    
    }

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    30
    The Selenium has method createCookie(), just use the below code , the cookie age is 5 minutes
    Code:
    $this->createCookie('login=frank.wilson', 'max_age=300');

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts