Issues

ZF-2629: Unittests problem with Session namespace

Description

Problem running Unittests for Zend_Session:


C:\Voxtronic\3rdParty\Zend Framework\tests>phpunit --verbose Zend_Session_AllTests
PHPUnit 3.2.7 by Sebastian Bergmann.

Zend Framework - Zend_Session
 Zend_SessionTest
 .......................FFFFIF


Time: 02:25

There were 5 failures:

1) testSetExpirationSeconds(Zend_SessionTest)
iteration over default Zend_Session namespace failed; expecting result === ';a =
== apple;o === orange;p === pear', but got ''
Failed asserting that  is true.
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:764

2) testSetExpireSessionHops(Zend_SessionTest)
iteration over default Zend_Session namespace failed (result=''; hop #1)
Failed asserting that  is true.
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:815

3) testSetExpireSessionVarsByHops1(Zend_SessionTest)
iteration over named Zend_Session namespace failed (result=''; hop #1)
Failed asserting that  is true.
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:866
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:828

4) testSetExpireSessionVarsByHops2(Zend_SessionTest)
iteration over named Zend_Session namespace failed (result=''; hop #1)
Failed asserting that  is true.
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:866
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:838

5) testSetExpireSessionVarsByHopsOnUse(Zend_SessionTest)
unexpected results iterating over named Zend_Session namespace (result=''; expec
ted ';g === guava;p === plum'; hop #1)
Failed asserting that  is true.
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:928

--

There was 1 incomplete test:

1) testArrays(Zend_SessionTest)
C:\Voxtronic\3rdParty\Zend Framework\tests\Zend\Session\SessionTest.php:879

FAILURES!
Tests: 29, Failures: 5, Incomplete: 1.

Testbed: WindowsXP, PHP 5.2.5, Standard installation

Comments

Thomas,

Are you still getting this issue? I just ran the tests and they did indeed run fine.. do you think this can be a windows issue?


~/Projects/code-zendframework/repo-trunk/tests$ svn info  
Path: .
URL: http://framework.zend.com/svn/framework/…
Repository Root: http://framework.zend.com/svn/framework
Repository UUID: 44c647ce-9c0f-0410-b52a-842ac1e357ba
Revision: 7995
Node Kind: directory
Schedule: normal
Last Changed Author: matthew
Last Changed Rev: 7992
Last Changed Date: 2008-02-14 08:56:22 -0600 (Thu, 14 Feb 2008)

~/Projects/code-zendframework/repo-trunk/tests$ php -v
PHP 5.2.5 (cli) (built: Feb  6 2008 11:04:46) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with Xdebug v2.0.2, Copyright (c) 2002-2007, by Derick Rethans
~/Projects/code-zendframework/repo-trunk/tests$ phpunit Zend_Session_AllTests
PHPUnit 3.2.11 by Sebastian Bergmann.

...........................I.

Time: 16 seconds


OK, but incomplete or skipped tests!
Tests: 29, Incomplete: 1.
~/Projects/code-zendframework/repo-trunk/tests$ 

I just tested with the latest release 8008 and the errors are still there. So it must be eighter a php-version or an OS problem.

Thomas,

I am passing this to darby to look at b/c I simply cannot duplicate.

I installed php 5.2.5, phpunit and pulled down r8216.

Changed no ini files, my setup is running stock.. this is what i get still:


C:\Users\Media Center\Desktop\ZF\tests>phpunit --verbose Zend_Session_AllTests
PHPUnit 3.2.14 by Sebastian Bergmann.
Zend Framework - Zend_Session
 Zend_SessionTest
 ...........................I.
Time: 23 seconds
There was 1 incomplete test:
1) testArrays(Zend_SessionTest)
C:\Users\Media Center\Desktop\ZF\tests\Zend\Session\SessionTest.php:879
OK, but incomplete or skipped tests!
Tests: 29, Incomplete: 1.
C:\Users\Media Center\Desktop\ZF\tests>svn info
'svn' is not recognized as an internal or external command,
operable program or batch file.

I am not sure how to proceed since I cannot duplicate.

Darby claims to be able to get the same exact results as you though, so.. Darby, any ideas?

-ralph

I cannot reproduce, any ideas?

-ralph

I can reproduce the results problem exactly with PHP 5.1.4 on WinXP, though I'm unsure exactly what's happening at this point. A cursory look gives me some hints:

  • Only the last 6 tests do not pass
  • {{testUnsetAllNamespace()}} is the last test that succeeds
  • All of the tests that fail have to do with expiration
  • There have been some reports on the mailing lists lately regarding apparent premature session data expiration (indirectly, some reports refer to usage of Zend_Auth)
  • Maybe recent changes to allow destruction and recreation of the session have cascaded into the unit tests somehow?
  • Keep in mind the mystery of why it succeeds on some platforms and why it does not on others; there may be a reason for this that directly points to the cause of the test failures
  • Examine the Zend_Session code and test suite to understand it and narrow the scope of the problem...

The only thing I am noticing is that all tests after testUnsetAllNamespace() make use of exec() to complete their tests.

Is it possible your setup is disallowing exec() or, perhaps php is not in the include path?

Perhaps if someone could see if the test is failing around line 759 of SessionTest.php

-ralph

I also got the following error from running "{{phpunit --verbose AllTests}}" on r8521 of the trunk:

101) testRegenerateId(Zend_SessionTest)
Zend_Session_Exception: The session has already been started.  The session id must be set first.
c:\Documents and Settings\dfelton\My Documents\SVN Remote\Zend Framework\trunk\tests\Zend\Session\SessionTest.php:126

This issue should have been fixed for the 1.5 release.

Fixed with SVN r9178 and r9179.

The problem still exists

The output I get now on Linux system:

{panel} PHPUnit 3.2.19 by Sebastian Bergmann.

.......................FFFFIF

Time: 23 seconds

There were 5 failures:

1) testSetExpirationSeconds(Zend_SessionTest) iteration over default Zend_Session namespace failed; expecting result === ';a === apple;o === orange;p === pear', but got '' Failed asserting that is true. iteration over default Zend_Session namespace failed; expecting result === ';a === apple;o === orange;p === pear', but got '' Failed asserting that is true.

2) testSetExpireSessionHops(Zend_SessionTest) iteration over default Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true. iteration over default Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true.

3) testSetExpireSessionVarsByHops1(Zend_SessionTest) iteration over named Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true. iteration over named Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true.

4) testSetExpireSessionVarsByHops2(Zend_SessionTest) iteration over named Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true. iteration over named Zend_Session namespace failed (result=''; hop #1) Failed asserting that is true.

5) testSetExpireSessionVarsByHopsOnUse(Zend_SessionTest) unexpected results iterating over named Zend_Session namespace (result=''; expected ';g === guava;p === plum'; hop #1) Failed asserting that is true. unexpected results iterating over named Zend_Session namespace (result=''; expected ';g === guava;p === plum'; hop #1) Failed asserting that is true.

FAILURES! Tests: 29, Failures: 5, Incomplete: 1. {panel}

The problem was in the wrong assumptions about an 'exec()' execution time.

'SessionTestHelper.php' script includes 'tests/TestHelper.php' script with other heavy includes from PHPUnit package. It slows down 'SessionTestHelper.php' script execution time to 2 seconds in Linux environment and to ~35 seconds (!!!) in Windows environment.

Then, testSetExpirationSeconds() failure stops testSetExpirationSeconds() execution and leave session in the inconsistent state. That produced other four failures.

Changes also merged into release-1.5 branch.

Updating for the 1.6.0 release.