Bug #60372
closedStandalone phpunit fails when LocalizationUtility:translate is called
0%
Description
Calling the standalone phpunit results in:
vagrant@precise32:/var/www/html$ php vendor/bin/phpunit -c typo3conf/ext/placements/Tests/Build/UnitTests.xml PHPUnit 4.1.3 by Sebastian Bergmann. Configuration read from /var/www/html/typo3conf/ext/placements/Tests/Build/UnitTests.xml I ............PHP Fatal error: Call to a member function exec_SELECTgetSingleRow() on a non-object in /var/www/typo3/typo3_src-6.2.4/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php on line 172 PHP Stack trace: PHP 1. {main}() /var/www/html/vendor/phpunit/phpunit/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /var/www/html/vendor/phpunit/phpunit/phpunit:55 PHP 3. PHPUnit_TextUI_Command->run() /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:132 PHP 4. PHPUnit_TextUI_TestRunner->doRun() /var/www/html/vendor/phpunit/phpunit/src/TextUI/Command.php:179 PHP 5. PHPUnit_Framework_TestSuite->run() /var/www/html/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:426 PHP 6. PHPUnit_Framework_TestSuite->run() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:675 PHP 7. PHPUnit_Framework_TestCase->run() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestSuite.php:675 PHP 8. PHPUnit_Framework_TestResult->run() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:753 PHP 9. PHPUnit_Framework_TestCase->runBare() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:686 PHP 10. PHPUnit_Framework_TestCase->runTest() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:817 PHP 11. ReflectionMethod->invokeArgs() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:951 PHP 12. Webfox\Placements\Tests\AbstractControllerTest->updateFilePropertyAddsErrorMessageForMaximumServerFileSize() /var/www/html/vendor/phpunit/phpunit/src/Framework/TestCase.php:951 PHP 13. Tx_Phpunit_AccessibleProxy53c7a002b1b04->_call() /var/www/html/typo3conf/ext/placements/Tests/Unit/Controller/AbstractControllerTest.php:321 PHP 14. call_user_func_array:{/var/www/typo3/typo3_src-6.2.4/typo3/sysext/core/Tests/BaseTestCase.php(212) : eval()'d code:1}() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/core/Tests/BaseTestCase.php(212) : eval()'d code:1 PHP 15. Webfox\Placements\Controller\AbstractController->updateFileProperty() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/core/Tests/BaseTestCase.php(212) : 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.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:86 PHP 18. TYPO3\CMS\Extbase\Utility\LocalizationUtility::loadTypoScriptLabels() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:167 PHP 19. TYPO3\CMS\Extbase\Utility\LocalizationUtility::getConfigurationManager() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:208 PHP 20. TYPO3\CMS\Extbase\Object\ObjectManager->get() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php:296 PHP 21. TYPO3\CMS\Extbase\Object\Container\Container->getInstance() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Object/ObjectManager.php:94 PHP 22. TYPO3\CMS\Extbase\Object\Container\Container->getInstanceInternal() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Object/Container/Container.php:108 PHP 23. TYPO3\CMS\Extbase\Object\Container\Container->getClassInfo() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Object/Container/Container.php:153 PHP 24. TYPO3\CMS\Extbase\Object\Container\ClassInfoCache->get() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Object/Container/Container.php:309 PHP 25. TYPO3\CMS\Core\Cache\Frontend\VariableFrontend->get() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/extbase/Classes/Object/Container/ClassInfoCache.php:58 PHP 26. TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend->get() /var/www/typo3/typo3_src-6.2.4/typo3/sysext/core/Classes/Cache/Frontend/VariableFrontend.php:95
The configuration is:
<phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="../../../../../typo3/sysext/core/Build/UnitTestsBootstrap.php" colors="true" convertErrorsToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" strict="false" verbose="false"> <testsuites> <testsuite name="EXT:placements tests"> <directory>../Unit/</directory> </testsuite> </testsuites> </phpunit>
phpunit has been installed via composer. My composer.json contains:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/satooshi/php-coveralls" } ], "require-dev": { "satooshi/php-coveralls": "dev-master" }, "require": { "phpunit/phpunit": "~4", "phpunit/php-code-coverage": "~2", "phpunit/phpunit-selenium": "~1", "mikey179/vfsStream": "~1" } }
The test case covers a method which uses
$errorMessage = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'placements'); if($errorMessage) { $this->addFlashMessage($errorMessage); } else { $this->addFlashMessage($key); }
to add a flash message.
The same tests do not fail when called via cli_dispatch or in BE.
Updated by Markus Klein over 10 years ago
- Status changed from New to Needs Feedback
Can't reproduce this.
But why do you have a vendor-folder? There seems something wrong with your setup.
After composer update, I get PHPUnit 4.2-g513bc07
# cd /var/www/html/master/ # bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml
Updated by Dirk Wenzel over 10 years ago
The vendor folder has been created by composer. I do use a local composer.phar.
My setup is a default TYPO3 with sources from git:
git clone --branch master --depth 1 https://github.com/TYPO3/TYPO3.CMS.git typo3_core
Seems I missed some instruction. I've never seen a bin directory in a TYPO3 instance before.
This is my root directory
drwxrwxrwx 8 www-data www-data 4096 Jul 17 20:43 ./ drwxr-xr-x 4 root root 4096 Jun 19 10:42 ../ drwxrwxr-x 4 vagrant vagrant 4096 Jul 17 11:36 build/ -rw-r--r-- 1 root root 46 Mar 7 2013 clear.gif -rw-rw-r-- 1 vagrant vagrant 416 Jul 16 22:48 composer.json -rw-rw-r-- 1 vagrant vagrant 44822 Jul 16 22:50 composer.lock -rwxr-xr-x 1 vagrant vagrant 966364 Jul 16 17:50 composer.phar* -rw-rw-r-- 1 vagrant vagrant 136 Jun 21 08:10 .coveralls.yml drwxrwxrwx 7 root root 4096 Jul 10 14:09 fileadmin/ -rw-r--r-- 1 root root 4810 Mar 7 2013 .htaccess lrwxrwxrwx 1 root root 19 Mar 7 2013 index.php -> typo3_src/index.php lrwxrwxrwx 1 root root 15 Mar 7 2013 typo3 -> typo3_src/typo3/ drwxrwxrwx 7 www-data www-data 4096 Jul 10 08:29 typo3conf/ lrwxrwxrwx 1 vagrant vagrant 24 Jul 16 20:16 typo3_src -> ../typo3/typo3_src-6.2.4/ drwxrwxrwx 7 root root 4096 Jul 17 17:45 typo3temp/ drwxrwxrwx 23 root root 4096 Jul 10 08:29 uploads/ drwxrwxr-x 11 vagrant vagrant 4096 Jul 17 09:55 vendor/
And this the vendor directory
drwxrwxr-x 11 vagrant vagrant 4096 Jul 17 09:55 ./ drwxrwxrwx 8 www-data www-data 4096 Jul 17 20:43 ../ -rw-rw-r-- 1 vagrant vagrant 183 Jul 17 09:55 autoload.php drwxrwxr-x 2 vagrant vagrant 4096 Jul 16 17:58 bin/ drwxrwxr-x 2 vagrant vagrant 4096 Jul 16 22:50 composer/ drwxrwxr-x 3 vagrant vagrant 4096 Jun 21 07:48 guzzle/ drwxrwxr-x 3 vagrant vagrant 4096 Jul 16 22:50 mikey179/ drwxrwxr-x 10 vagrant vagrant 4096 Jul 16 22:50 phpunit/ drwxrwxr-x 3 vagrant vagrant 4096 Jun 21 07:48 psr/ drwxrwxr-x 3 vagrant vagrant 4096 Jun 21 07:48 satooshi/ drwxrwxr-x 7 vagrant vagrant 4096 Jul 16 17:56 sebastian/ drwxrwxr-x 8 vagrant vagrant 4096 Jun 21 07:48 symfony/
Updated by Dirk Wenzel over 10 years ago
I finally managed to prevent this error by better mocking... So it can be closed.
Anyway I would be glad for any hint on how to setup a test environment for standalone unit tests.
Thank you and cheers!
Dirk
Updated by Markus Klein over 10 years ago
Basic setup:
http://wiki.typo3.org/Functional_testing#Setup
bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml
Ensure your composer is up to date (composer self-update)
Updated by Wouter Wolters over 10 years ago
- Status changed from Needs Feedback to Closed