Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
[TESTS] Get all Zend\Session tests working
Browse files Browse the repository at this point in the history
- Fixed all test failures/errors
  • Loading branch information
weierophinney committed Oct 6, 2011
1 parent 75ad66a commit b24267c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/SessionManager.php
Expand Up @@ -78,6 +78,9 @@ public function sessionExists()
if ($sid !== false && $this->getId()) {
return true;
}
if (headers_sent()) {
return true;
}
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Storage/ArrayStorage.php
Expand Up @@ -23,7 +23,8 @@
*/
namespace Zend\Session\Storage;

use Zend\Session\Storage as Storable,
use ArrayObject,
Zend\Session\Storage as Storable,
Zend\Session\Exception;

/**
Expand All @@ -38,7 +39,7 @@
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ArrayStorage extends \ArrayObject implements Storable
class ArrayStorage extends ArrayObject implements Storable
{
/**
* Is storage marked immutable?
Expand Down
2 changes: 1 addition & 1 deletion test/ContainerTest.php
Expand Up @@ -68,12 +68,12 @@ protected function forceAutoloader()
* @see http://matthewturland.com/2010/08/19/process-isolation-in-phpunit/
* @param PHPUnit_Framework_TestResult $result
* @return void
*/
public function run(\PHPUnit_Framework_TestResult $result = NULL)
{
$this->setPreserveGlobalState(false);
return parent::run($result);
}
*/

public function testInstantiationStartsSession()
{
Expand Down
16 changes: 11 additions & 5 deletions test/SessionManagerTest.php
Expand Up @@ -395,7 +395,7 @@ public function testDestroyDoesNotClearSessionStorageByDefault()
$storage = $this->manager->getStorage();
$storage['foo'] = 'bar';
$this->manager->destroy();
$this->manager->start();
$this->assertTrue(isset($storage['foo']));
$this->assertEquals('bar', $storage['foo']);
}

Expand Down Expand Up @@ -622,10 +622,16 @@ public function testForgetMeShouldSendCookieWithZeroTimestamp()
public function testStartingSessionThatFailsAValidatorShouldRaiseException()
{
$chain = $this->manager->getValidatorChain();
$chain->attach('session.validate', function() {
return false;
});
$this->setExpectedException('Zend\Session\Exception\InvalidArgumentException', 'xxx');
$chain->attach('session.validate', array($this, 'validateSession'));
$this->setExpectedException('Zend\Session\Exception\RuntimeException', 'failed');
$this->manager->start();
}

/**
* @see testStartingSessionThatFailsAValidatorShouldRaiseException()
*/
public static function validateSession()
{
return false;
}
}

0 comments on commit b24267c

Please sign in to comment.