Project

General

Profile

Actions

Bug #60372

closed

Standalone phpunit fails when LocalizationUtility:translate is called

Added by Dirk Wenzel over 10 years ago. Updated over 10 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2014-07-17
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.5
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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.

Actions

Also available in: Atom PDF