PHPUnit throws error on mountain lion - phpunit

I've followed the instructions exactly described as here
http://phpunit.de/getting-started.html
Everything went fine but when i execute the following command
phpunit --bootstrap src/autoload.php tests/MoneyTest
It throws following error
PHPUnit 4.0.4 by Sebastian Bergmann.
PHP Fatal error: Class 'SebastianBergmann\Money\Money' not found in /Users/myname/Sites/lab/unittesting/tests/MoneyTest.php on line 54
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:581
PHP 3. PHPUnit_TextUI_Command->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:132
PHP 4. PHPUnit_TextUI_TestRunner->doRun() phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:179
PHP 5. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/phpunit/phpunit/TextUI/TestRunner.php:419
PHP 6. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestSuite.php:722
PHP 7. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:764
PHP 8. PHPUnit_Framework_TestCase->runBare() phar:///usr/local/bin/phpunit/phpunit/Framework/TestResult.php:692
PHP 9. PHPUnit_Framework_TestCase->runTest() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:824
PHP 10. ReflectionMethod->invokeArgs() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:956
PHP 11. SebastianBergmann\Money\MoneyTest->testExceptionIsRaisedForInvalidConstructorArguments() phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php:956
Any idea what might be the cause?
Thanks

The following instructions worked for me:
$ git clone https://github.com/sebastianbergmann/money
$ cd money
$ phpunit --bootstrap src/autoload.php tests/MoneyTest
PHPUnit 3.7.32 by Sebastian Bergmann.
......................
Time: 882 ms, Memory: 3.25Mb
OK (22 tests, 41 assertions)
Be aware that I using 3.7.32 and you are using 4.0.4. If its still not working then it could be a bug.

Related

How can we run the unit tests of civicrm from script?

I execute this commande line to run a unit tests :
hatem.hadrich#pc_Hatem_Hadrich:/projet/tools$ php /scripts/phpunit CRM_AllTests
I have this error when i run a unit test from my local instance and i can not find a way to resolve it anyone can help me to fix this bug.
PHP Fatal error: Class 'CiviTestSuite' not found in /projet/../civicrm/tests/phpunit/CRM/AllTests.php on line 39
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:569
PHP 3. PHPUnit_TextUI_Command->run()
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:115
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest()
phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:137
PHP 5. PHPUnit_Runner_BaseTestRunner->loadSuiteClass()
phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php:65
PHP 6. PHPUnit_Runner_StandardTestSuiteLoader->load()
phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php:124
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/local/bin/phpunit/phpunit/Runner/StandardTestSuiteLoader.php:39
PHP 8. PHPUnit_Util_Fileloader::load() phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:38
PHP 9. include_once() phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:56
i have find a way to fix this bug, you must require_one for the bootstrap file inside CiviTest :
define('DRUPAL_ROOT', '/path_to_project');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

PHP Fatal error returned when creating a new Symfony3 Project [duplicate]

Am new to symfony and from last month am continuously installing new symfony project using following command on ubuntu from the terminal
# Linux, Mac OS X
$ symfony new my_project_name
and it was working perfectly until today, but than just checked the new version release, but now it started giving me following error
Downloading Symfony...
4.93 MB/4.93 MB ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100%
Preparing project...
PHP Warning: require(/var/www/projectname/app/SymfonyRequirements.php): failed to open stream: No such file or directory in phar:///usr/local/bin/symfony/src/Symfony/Installer/DownloadCommand.php on line 265
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/symfony:0
PHP 2. require() /usr/local/bin/symfony:10
PHP 3. Symfony\Component\Console\Application->run() phar:///usr/local/bin/symfony/symfony:35
PHP 4. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:126
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:195
PHP 6. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:878
PHP 7. Symfony\Installer\NewCommand->execute() phar:///usr/local/bin/symfony/vendor/symfony/console/Command/Command.php:259
PHP 8. Symfony\Installer\DownloadCommand->checkSymfonyRequirements() phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php:65
PHP Fatal error: require(): Failed opening required '/var/www/projectname/app/SymfonyRequirements.php' (include_path='.:/usr/share/php:/usr/share/pear') in phar:///usr/local/bin/symfony/src/Symfony/Installer/DownloadCommand.php on line 265
PHP Stack trace:
PHP 1. {main}() /usr/local/bin/symfony:0
PHP 2. require() /usr/local/bin/symfony:10
PHP 3. Symfony\Component\Console\Application->run() phar:///usr/local/bin/symfony/symfony:35
PHP 4. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:126
PHP 5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:195
PHP 6. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/symfony/vendor/symfony/console/Application.php:878
PHP 7. Symfony\Installer\NewCommand->execute() phar:///usr/local/bin/symfony/vendor/symfony/console/Command/Command.php:259
PHP 8. Symfony\Installer\DownloadCommand->checkSymfonyRequirements() phar:///usr/local/bin/symfony/src/Symfony/Installer/NewCommand.php:65
I have even check the symfony at location usr/local/bin/symfony and it was there.
It is a resolved issue that you need to specify the version you want to install. As described here and here, you need to:
Update your installer
>symfony self-update
or with sudo, depending on how you install it:
>sudo symfony self-update
Specify the version:
>symfony new my_project_name 3.0
Hope this helps.
UPDATE
With the correct resolutions of the bug on the Symfony installer, now the 3.0 is the default version. In other case, you can specify the complete version (with minor and major) as follows:
>symfony new my_project_name 3.0.0

Unable to run phpunit since upgrade to Symfony 2.8/3.0

Since upgrading to Symfony 2.8, I get the following error when I run phpunit in the Symfony root:
PHP Fatal error: Class 'PHPUnit_Util_ErrorHandler' not found in /var/www/foo/symfony/vendor/symfony/phpunit-bridge/DeprecationErrorHandler.php on line 40
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_Command->handleArguments() /usr/share/php/PHPUnit/TextUI/Command.php:138
PHP 5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /usr/share/php/PHPUnit/TextUI/Command.php:657
PHP 6. PHPUnit_Util_Configuration->getTestSuite() /usr/share/php/PHPUnit/Util/Configuration.php:789
PHP 7. PHPUnit_Framework_TestSuite->addTestFiles() /usr/share/php/PHPUnit/Util/Configuration.php:873
PHP 8. PHPUnit_Framework_TestSuite->addTestFile() /usr/share/php/PHPUnit/Framework/TestSuite.php:416
PHP 9. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/Framework/TestSuite.php:355
PHP 10. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:76
PHP 11. Symfony\Bridge\PhpUnit\DeprecationErrorHandler::Symfony\Bridge\PhpUnit\{closure}() /usr/share/php/PHPUnit/Util/Fileloader.php:92
THE ERROR HANDLER HAS CHANGED!
This also occurs under Symfony 3.0. Should I now be running phpunit in a different manner?
I just ran into this problem using Symfony 2.8.
Just update your local install of phpunit.
Run this.
phpunit --self-update
That should do it.
I was running phpunit version 4.7.*, but Symfony wanted to see phpunit 5.1.3.
You should clear the app/cache/test directory.
You could also make your global phpunit symlink to the one provided by Symfony located in vendor/phpunit/phpunit/phpunit
Update: I'm not sure what this error is referring to, I still get it, but seems to occur when I have a problem with a test. At the least, it's a confusing message.

PhpStorm 7.1.3, XDebug 2.2.3, Symfony 2.4 - WebTestCase not found

I'm getting the following error when attempting to run my own Symfony unit tests in PhpStorm:
/usr/bin/php /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php
PHP Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php on line 8
PHP Stack trace:
PHP 1. {main}() /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php:0
Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found in /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php on line 8
Call Stack:
0.0002 234112 1. {main}() /home/kevin/www/src/Blah/MyBundle/Tests/Controller/HomeControllerTest.php:0
Process finished with exit code 255
Some research has informed me that I may have to point PhpStorm/Xdebug to Symfony's bootstrap and/or test suite XML file, but I'm not sure how to do that in PhpStorm. Nothing is jumping out at me in the various config screens. Please help.
Although I'm using IntelliJ IDEA, the configuration is the same, so:
Settings -> PHP -> PHPUnit - there are inputs for bootstrap and config

Fixtures installation error in sylius?

I want to install fixtures in sylius i used below command to install it that are as below
php app/console sylius:install --fixtures
when i ran above command i get error as
>PHP Fatal error: Class 'ResourceBundle' not found in C:\wamp\www\sylius\sylius\vendor\symfony\symfony\src\Symfony\Component\Locale\Locale.php on line 51
PHP Stack trace:
PHP 1. {main}() C:\wamp\www\sylius\sylius\app\console:0
PHP 2. Symfony\Component\Console\Application->run() C:\wamp\www\sylius\sylius\app\console:28
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\wamp\www\sylius\sylius\vendor\symfon
y\symfony\src\Symfony\Component\Console\Application.php:106
PHP 4. Symfony\Component\Console\Application->doRun() C:\wamp\www\sylius\sylius\vendor\symfony\symfony\src
\Symfony\Bundle\FrameworkBundle\Console\Application.php:78
PHP 5. Symfony\Component\Console\Command\Command->run() C:\wamp\www\sylius\sylius\vendor\symfony\symfony\s
rc\Symfony\Component\Console\Application.php:193
PHP 6. Sylius\Bundle\CoreBundle\Command\InstallCommand->execute() C:\wamp\www\sylius\sylius\vendor\symfony
\symfony\src\Symfony\Component\Console\Command\Command.php:242
PHP 7. Symfony\Component\Console\Command\Command->run() C:\wamp\www\sylius\sylius\src\Sylius\Bundle\CoreBu
ndle\Command\InstallCommand.php:80
PHP 8. Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() C:\wamp\www\syliu
s\sylius\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:242
PHP 9. Doctrine\Common\DataFixtures\Executor\ORMExecutor->execute() C:\wamp\www\sylius\sylius\vendor\doctr
ine\doctrine-fixtures-bundle\Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand.php:106
PHP 10. Doctrine\ORM\EntityManager->transactional() C:\wamp\www\sylius\sylius\vendor\doctrine\data-fixtures
\lib\Doctrine\Common\DataFixtures\Executor\ORMExecutor.php:85
PHP 11. call_user_func() C:\wamp\www\sylius\sylius\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php:2
23
PHP 12. Doctrine\Common\DataFixtures\Executor\ORMExecutor->Doctrine\Common\DataFixtures\Executor\{closure}(
) C:\wamp\www\sylius\sylius\vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager.php:223
PHP 13. Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() C:\wamp\www\sylius\sylius\vendor\doc
trine\data-fixtures\lib\Doctrine\Common\DataFixtures\Executor\ORMExecutor.php:83
PHP 14. Sylius\Bundle\CoreBundle\DataFixtures\ORM\LoadCountriesData->load() C:\wamp\www\sylius\sylius\vendo
r\doctrine\data-fixtures\lib\Doctrine\Common\DataFixtures\Executor\AbstractExecutor.php:120
PHP 15. Symfony\Component\Locale\Locale::getDisplayCountries() C:\wamp\www\sylius\sylius\src\Sylius\Bundle\
CoreBundle\DataFixtures\ORM\LoadCountriesData.php:31
I try to install resource bundle when i got the above error but it also failed to install.
Is there any other way is avilable to install fixtures in sylius?
Please share some knowledge..Thanks in advance.
You need to have intl installed on your environment. Symfony does not provide a stub class for "en" locale.

Resources