[TYPO3-dev] Unit tests and localization
Dirk Wenzel
wenzel at webfox03.de
Wed Jul 16 12:45:48 CEST 2014
Hi,
I tried running my unit tests using a standalone phpunit with bootstrap [1].
One of them fails due to a call of
\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate() with
PHP Fatal error: Call to a member function parse_charset() on a
non-object in
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
on line 96
(Please see below for the stack trace [2]. The error does not occur when
running my tests via cli_dispatch.)
How could I avoid this?
I really won't see this in my tests even if it should be a bug in
AbstractXmlParser or a missing initialization in bootstrap.
Mocking the static call is no longer an option since this feature has
been removed from current phpunit.
The only solution I see is wrapping those static calls and stub the
wrapper method in my tests.
What would you do?
Cheers
Dirk
[1] http://wiki.typo3.org/Blueprints/StandaloneUnitTests
[2]
PHP Fatal error: Call to a member function parse_charset() on a
non-object in
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
on line 96
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:583
PHP 3. PHPUnit_TextUI_Command->run()
phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132
PHP 4. PHPUnit_TextUI_TestRunner->doRun()
phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:179
PHP 5. PHPUnit_Framework_TestSuite->run()
phar:///usr/bin/phpunit/phpunit/TextUI/TestRunner.php:421
PHP 6. PHPUnit_Framework_TestSuite->run()
phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 7. PHPUnit_Framework_TestCase->run()
phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:675
PHP 8. PHPUnit_Framework_TestResult->run()
phar:///usr/bin/phpunit/phpunit/Framework/TestCase.php:754
PHP 9. PHPUnit_Framework_TestCase->runBare()
phar:///usr/bin/phpunit/phpunit/Framework/TestResult.php:686
PHP 10. PHPUnit_Framework_TestCase->runTest()
phar:///usr/bin/phpunit/phpunit/Framework/TestCase.php:818
PHP 11. ReflectionMethod->invokeArgs()
phar:///usr/bin/phpunit/phpunit/Framework/TestCase.php:952
PHP 12.
Webfox\Placements\Tests\AbstractControllerTest->updateFilePropertyAddsErrorMessageForMaximumServerFileSize()
phar:///usr/bin/phpunit/phpunit/Framework/TestCase.php:952
PHP 13. Tx_Phpunit_AccessibleProxy53c6539ccd418->_call()
/var/www/html/typo3conf/ext/placements/Tests/Unit/Controller/AbstractControllerTest.php:319
PHP 14.
call_user_func_array:{/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Tests/BaseTestCase.php(222)
: eval()'d code:1}()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Tests/BaseTestCase.php(222)
: eval()'d code:1
PHP 15.
Webfox\Placements\Controller\AbstractController->updateFileProperty()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Tests/BaseTestCase.php(222)
: eval()'d code:1
PHP 16. TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate()
/var/www/html/typo3conf/ext/placements/Classes/Controller/AbstractController.php:153
PHP 17.
TYPO3\CMS\Extbase\Utility\LocalizationUtility::initializeLocalization()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:100
PHP 18. TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:174
PHP 19.
TYPO3\CMS\Core\Localization\LocalizationFactory->getParsedData()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Classes/Utility/GeneralUtility.php:4029
PHP 20.
TYPO3\CMS\Core\Localization\Parser\AbstractXmlParser->getParsedData()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Classes/Localization/LocalizationFactory.php:111
PHP 21.
TYPO3\CMS\Core\Localization\Parser\AbstractXmlParser->getCharset()
/var/www/typo3/typo3_src-6.2.3/typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php:63
More information about the TYPO3-dev
mailing list