>>> > <snip>
>>> >
>>> > > I've discovered the Zend_Session::$_unitTestEnabled flag, but why I am
>>> > > asking is, that, e.g. my tearDown() looks like this:
>>> > >
>>> > > public function tearDown()
>>> > > {
>>> > > Zend_Session::namespaceUnset('fooSession');
>>> > > Zend_Session::expireSessionCookie();
>>> > > Zend_Session::stop();
>>> > > Zend_Session::destroy(true);
>>> > >
>>> > > unset($this->bootstrap);
>>> > > }
>>> > >
>>> > > Yet, all consecutive tests fail because it says:
>>> > > Zend_Session_Exception: A session namespace object already exists for
>>> > > this namespace ('fooSession'), and no additional accessors (session
>>> > > namespace objects) for this namespace are permitted.
>>> > >
>>> > > I'm opening fooSession in my bootstrap, but from what I gather my
>>> > > tearDown() doesn't get rid off everything.
>>> > >
>>> > > That's another thing I've been wrestling with. ;-)
>>> >
>>> > Get rid of your tearDown() method. The bootstrap() method calls reset(),
>>> > which resets the $_SESSION superglobal as well as Zend_Session. What
>>> > you've done in your tearDown() is redundant.
>>> >
>>> > What happens if you remove it?
>>>
>>> Well, nothing -- the error stays. I've tried all kind of things in
>>> "tearDown()" because I got the error about the namespace. I wouldn't
>>> mind getting rid off it if it worked without it.
>>
>> Are you calling dispatch() multiple times in the same method by any
>> chance?
>
> You mean, inside the same testFoo() method? - No.
>
> My tests:
>
> public function testIfHomeExists()
> {
> $this->dispatch('/');
> $this->assertModule('default');
> $this->assertController('index');
> $this->assertAction('index');
> }
>
> public function testIfShortIsbnReturnsError()
> {
> $this->request->setQuery(array('isbn' => 123));
> $this->dispatch('/rest/isbn');
>
> $this->assertResponseCode(500);
> $this->assertController('rest');
> $this->assertAction('isbn');
>
> //$this->resetRequest()->resetResponse();
> //$this->request->setQuery(array());
> }
>
> The first works, the 2nd fails with the namespace error. I disabled
> the tearDown() method, so there's nothing interfering.
This is freaky, say I have two controllers, and my bootstrap with a
Zend_Session_Namespace.
BarControllerTest.php
FooControllerTest.php
Each controller has one test-method.
BarControllerTest::testBar()
FooControllerTest::testFoo()
FooControllerTest::testFoo() will fail with:
Zend_Session_Exception: A session namespace object already exists for
this namespace ('fooSession'), and no additional accessors (session
namespace objects) for this namespace are permitted.
/path/library/Zend/Session/Namespace.php:114
/path/bootstrap.php:246
/path/bootstrap.php:395
/path/bootstrap.php:140
/path/library/Zend/Test/PHPUnit/ControllerTestCase.php:125
/path/library/Zend/Test/PHPUnit/ControllerTestCase.php:106
/path/tests/controller/FooControllerTest.php:15
I think I could test if the namespace is already set in my bootstrap,
but that's not/never needed for my app itself -- so I guess that could
be a shortcut, but I'd rather not. Any other ideas?
Till