Skip to content

Commit

Permalink
Restore original cookies after test.
Browse files Browse the repository at this point in the history
  • Loading branch information
suralc committed Aug 15, 2012
1 parent 91e4587 commit dd56a77
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/framework/web/CCookieCollectionTest.php
Expand Up @@ -7,7 +7,7 @@ class CCookieCollectionTest extends CTestCase
{
protected $request;
protected $cookies;
private $_testCookies = array(
protected $testCookies = array(
'testCookieOne' => 'testValue',
'someEmptyCookie' => '',
'IntegerValue' => 1242,
Expand All @@ -17,12 +17,18 @@ class CCookieCollectionTest extends CTestCase
'expire' => 12422,
),
);
protected $cookieBefore;
public function setUp()
{
$this->cookieBefore = $_COOKIE;
$_COOKIE['testGlobal'] = 'value';
$this->request = new TestHttpRequest;
$this->cookies = $this->request->cookies;
}
public function tearDown()
{
$_COOKIE = $this->cookieBefore;
}
/**
* @covers CCookieCollection::getCookies
* @covers CCookieCollection::__construct
Expand Down Expand Up @@ -61,7 +67,7 @@ public function testAdd()
public function testRemove()
{
// add some cookies to have something to base the tests (remove)
foreach($this->_testCookies as $name=>$options)
foreach($this->testCookies as $name=>$options)
{
if(is_array($options))
{
Expand All @@ -79,7 +85,7 @@ public function testRemove()
$this->assertTrue($this->cookies->contains('someEmptyCookie'),'A default cookie is missing! Check the testcase!');
$this->assertTrue($this->cookies->contains('cookieWithOptions'),'A default cookie is missing! Check the testcase!');
// Real tests below:
foreach($this->_testCookies as $name=>$options)
foreach($this->testCookies as $name=>$options)
{
if(is_array($options))
{
Expand Down

0 comments on commit dd56a77

Please sign in to comment.