Random thoughts and musings. Part of an oliology.

oliology.diary

Donnerstag, August 23, 2007

PHPUnit with eAccelerator in TYPO3
PHPUnit mit eAccelerator in TYPO3

I recently tested the PHPUnit extension for TYPO3 for one of my extension (using PHP 5.2.1). Unfortunately, PHPunit kept crashing with the following error message:

tx_phpunit_basetestsuite: tx_t3unit_testcase: Fatal error: Uncaught exception 'PHPUnit_Framework_AssertionFailedError' with message 'No tests found in class "tx_t3unit_testcase".' in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php:959 Stack trace: #0 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Warning.php(89): PHPUnit_Framework_Assert::fail('No tests found ...') #1 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(243): PHPUnit_Framework_Warning->runTest() #2 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestResult.php(529): PHPUnit_Framework_TestCase->runBare() #3 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(223): PHPUnit_Framework_TestResult->run(Object(PHPUnit_Framework_Warning)) #4 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestSuite.php(510): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult)) #5 /home/klee/public in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php on line 959

Okay, so I created an empty testcase in the corresponding class in class.tx_phpunit_testcase.php. Now PHPUnit crashed on each failed assertion:

Fatal error: Uncaught exception 'PHPUnit_Framework_ExpectationFailedException' with message 'Failed asserting that is equal to .' in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Constraint/IsEqual.php:116 Stack trace: #0 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php(693): PHPUnit_Framework_Constraint_IsEqual->fail(0, '') #1 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php(252): PHPUnit_Framework_Assert::assertThat(0, Object(PHPUnit_Framework_Constraint_IsEqual), '') #2 /home/klee/public_html/typo4test/typo3conf/ext/oelib/tests/tx_oelib_salutationswitcher_testcase.php(49): PHPUnit_Framework_Assert::assertEquals(1, 0) #3 [internal function]: tx_oelib_salutationswitcher_testcase->testOkay() #4 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(300): ReflectionMethod->invoke(Object(tx_oelib_salutationswitcher_testcase)) #5 /home/klee/public_html/ in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Constraint/IsEqual.php on line 116

Some googling revealed that PHPUnit and eAccelerator don't go together well. After disabling eAccelerator for PHPUnit in the file /etc/php5/apache2/conf.d/eaccelerator.ini, everything worked fine.Thi is the corresponding line:

eaccelerator.filter = "!*/phpunit/*"

Ich habe mal die PHPUnit-Extension für TYPO3 für eine meiner Extensions ausprobiert (unter PHP 5.2.1). Allerdings stürzte PHPUnit immer mit der folgenden Fehlermeldung ab:

tx_phpunit_basetestsuite: tx_t3unit_testcase: Fatal error: Uncaught exception 'PHPUnit_Framework_AssertionFailedError' with message 'No tests found in class "tx_t3unit_testcase".' in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php:959 Stack trace: #0 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Warning.php(89): PHPUnit_Framework_Assert::fail('No tests found ...') #1 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(243): PHPUnit_Framework_Warning->runTest() #2 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestResult.php(529): PHPUnit_Framework_TestCase->runBare() #3 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(223): PHPUnit_Framework_TestResult->run(Object(PHPUnit_Framework_Warning)) #4 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestSuite.php(510): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult)) #5 /home/klee/public in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php on line 959

Okay, also einen leeren Testcase in die entsprechende Klasse in class.tx_phpunit_testcase.php hinzugefügt. Jetzt stürzte PHPUnit bei jeder fehlgeschlagegenen Assertion ab:

Fatal error: Uncaught exception 'PHPUnit_Framework_ExpectationFailedException' with message 'Failed asserting that is equal to .' in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Constraint/IsEqual.php:116 Stack trace: #0 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php(693): PHPUnit_Framework_Constraint_IsEqual->fail(0, '') #1 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Assert.php(252): PHPUnit_Framework_Assert::assertThat(0, Object(PHPUnit_Framework_Constraint_IsEqual), '') #2 /home/klee/public_html/typo4test/typo3conf/ext/oelib/tests/tx_oelib_salutationswitcher_testcase.php(49): PHPUnit_Framework_Assert::assertEquals(1, 0) #3 [internal function]: tx_oelib_salutationswitcher_testcase->testOkay() #4 /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/TestCase.php(300): ReflectionMethod->invoke(Object(tx_oelib_salutationswitcher_testcase)) #5 /home/klee/public_html/ in /home/klee/public_html/typo4test/typo3conf/ext/phpunit/phpunit-3.0.5/Framework/Constraint/IsEqual.php on line 116

Ein bisschen Googeln ergab, dass PHPUnit und der eAccelerator sich wohl nicht so ganz mögen. Nachdem ich ich der Datei /etc/php5/apache2/conf.d/eaccelerator.ini den eAccelerator für PHPUnit ausgeschaltet hatte, ging's. Das hier ist die entsprechende Zeile:

eaccelerator.filter = "!*/phpunit/*"

Oliver @ 11:32 | Permalink | 0 comments/Kommentare

|

Good people

Good Software

Archive