public function afterStep(\Codeception\Event\Step $e)
 {
     if (!$this->module) {
         return;
     }
     if ($error = $this->module->grabCookie('CODECEPTION_CODECOVERAGE_ERROR')) {
         throw new RemoteException($error);
     }
 }
 public function testSetCookieByHeader()
 {
     $this->module->amOnPage('/cookies2');
     $this->module->seeResponseCodeIs(200);
     $this->module->seeCookie('a');
     $this->assertEquals('b', $this->module->grabCookie('a'));
 }
	public function testSetMultipleCookies() {
        $cookie_name_1  = 'test_cookie';
        $cookie_value_1 = 'this is a test';
        $this->module->setCookie($cookie_name_1, $cookie_value_1);

        $cookie_name_2  = '2_test_cookie';
        $cookie_value_2 = '2 this is a test';
        $this->module->setCookie($cookie_name_2, $cookie_value_2);

        $this->module->seeCookie($cookie_name_1);
        $this->module->seeCookie($cookie_name_2);
        $this->module->dontSeeCookie('evil_cookie');

        $cookie1 = $this->module->grabCookie($cookie_name_1);
        $this->assertEquals($cookie_value_1, $cookie1);

        $cookie2 = $this->module->grabCookie($cookie_name_2);
        $this->assertEquals($cookie_value_2, $cookie2);

        $this->module->resetCookie($cookie_name_1);
        $this->module->dontSeeCookie($cookie_name_1);
        $this->module->seeCookie($cookie_name_2);
        $this->module->resetCookie($cookie_name_2);
        $this->module->dontSeeCookie($cookie_name_2);
    }
Example #4
0
 public function testCookies()
 {
     $cookie_name = 'test_cookie';
     $cookie_value = 'this is a test';
     $this->module->setCookie($cookie_name, $cookie_value);
     $this->module->seeCookie($cookie_name);
     $this->module->dontSeeCookie('evil_cookie');
     $cookie = $this->module->grabCookie($cookie_name);
     $this->assertEquals($cookie_value, $cookie);
     $this->module->resetCookie($cookie_name);
     $this->module->dontSeeCookie($cookie_name);
 }
 public function testCookiesWithPath()
 {
     $cookie_name = 'cookie';
     $cookie_value = 'tasty';
     $this->module->amOnPage('/info');
     $this->module->setCookie($cookie_name, $cookie_value, ['path' => '/info']);
     $this->module->seeCookie($cookie_name, ['path' => '/info']);
     $this->module->dontSeeCookie('evil_cookie');
     $cookie = $this->module->grabCookie($cookie_name, ['path' => '/info']);
     $this->assertEquals($cookie_value, $cookie);
     $this->module->resetCookie($cookie_name, ['path' => '/info']);
     $this->module->dontSeeCookie($cookie_name, ['path' => '/info']);
     $this->module->dontSeeCookie($cookie_name);
 }