I have installed PHPUnit with the composer. I have below line in composer.json
"require-dev": {
"phpunit/phpunit": "~4.3"
},
When I run my test case I am getting below error. I have searched for this error but I could not find possible related solutions in web:
Vishal#VISHAL-PC c:\xampp\htdocs\V4\test\Core
phpunit ResponseTest
PHPUnit 4.3.5 by Sebastian Bergmann.
Fatal error: Class PHPUnit_Util_DeprecatedFeature_Logger contains 1 abstract met
hod and must therefore be declared abstract or implement the remaining methods (
PHPUnit_Framework_TestListener::addRiskyTest) in C:\xampp\php\pear\PHPUnit\Util\
DeprecatedFeature\Logger.php on line 201
I have no clue where this is coming from. Any suggestions, link or comment will be much appreciated guys.
The PHPUnit_Util_DeprecatedFeature_Logger class was removed in PHPUnit 4.2. If your installation of PHPUnit 4.3 tries to use that class this means that you're installation is messed up somehow.
You still continue to run your phpunit from previously installed location. To run it from composer add following allias to your .bashrc file
sudo nano ~/.bashrc
alias phpunit="/{path_to_project}/vendor/bin/phpunit"
Related
On my Travis CI builds ive phpunit failures when testing in HHVM. This is the full exception:
PHPUnit_Framework_Exception: Fatal error: Class undefined: PHP_Token_HASHBANG in phar://phpunit-4.5.0.phar/php-token-stream/Token/Stream.php on line 185
Running PHPUnit 4.8.14 with the following commandline:
phpunit --verbose --coverage-clover build/logs/clover.xml
How to fix this?
The issue isn't very clear to me, anyway it was related to the PHPUnit version in HHVM. In order to fix this i've added phpunit as a dependency to my project
"require-dev": {
"phpunit/phpunit": "4.*"
},
so that it is updated to the latest 4.x version, than updated my travis script
script:
- vendor/bin/phpunit
This fixed.
Me and my coworker are trying to use local git repo for our Laravel project.
I am using Ubuntu, with PHP 5.5.9-1ubuntu4.9, and he is using Debian with PHP 5.4.39.
When I pulled his committed version, I get an error when trying to run composer update:
user#ubuntu:/var/www/frontend$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
PHP Fatal error: Class 'Illuminate\Support\Arr' not found in /var/www/frontend/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 182
Script php artisan clear-compiled handling the post-install-cmd event returned with an error [RuntimeException]
Error Output: PHP Fatal error: Class 'Illuminate\Support\Arr' not found in /var/www/frontend/vendor/laravel/framework/src/Illuminate/Support/helpers.php on line 182
We have vendor folder on git, since not having it isn't an option for us.
I guess the problem is different php versions. Is there a way of setting up php version manually, so composer gets the right dependencies?
you can set php version in composer.json file in require portion
"require": {
"php": ">=5.3.0",
},
The problem was probably this:
User checked in the project, including the vendor folder.
Later vendor somehow got added to .gitignore
Nobody noticed that new files were not being added to the repo and magic made sure everything still worked as it did :D
I'm a newbie in Laravel. I just cloned my co-worker git and try to php artisan list but it gives me error
PHP Fatal error: Class 'Bllim\Datatables\DatatablesServiceProvider' not found in /Users/path-to-project/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157
I can't find any documentations about this error and search results don't really help.
Any of you ever met this problem and care to help me fix this? Thank you.
Asking your coworker would be a first good step :)
That said, the error you're getting indicates that PHP can't find or autoload a Laravel Service provider class. If your coworker is following Laravel best practices, you should be able to fix this by running the following command from your root project directory (or the directory with a composer.json file)
$ composer install
or ...
$ composer.phhar install
The format of the command (phar or no phar) will depend on how you've installed composer, the dependency/package manager used in Laravel.
I'm trying to testing my app made with Symfony. I wrote a test and when I launch it, i get the following error:
Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle'
not found in /.../app/AppKernel.php on line 17
I had the same error with Symfony's MonologBundle, AsseticBundle and SwiftmailerBundle: then I've manually added these bundles into my app, so pheraps I have fixed those errors, but with Doctrine I've not found any solutions yet.
It looks like maybe you did not install the Doctrine bundle.
Try to go to the root of your project where the composer.phar is located through a console, and try to run it like this:
php composer.phar
It will install all dependencies of Symfony2,and hopefully everything is going to work :)
I'm developing a project in symfony2 and I'm new with unit testing.
I have installed PHPUnit 3.6.10 via PEAR and it works from the terminal when I digit the phpunit command.
I wrote my first test class following the SensioLab suggestions (http://symfony.com/doc/current/book/testing.html) but when I use the command
php -c app src/My/CalendarBundle/Tests/Calendar/CalendarTest.php
I got
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /Library/WebServer/Documents/calendar/src/My/CalendarBundle/Tests/Calendar/CalendarTest.php on line 7
Here you are my test class:
<?php
namespace My\CalendarBundle\Tests\Calendar;
use My\CalendarBundle\Calendar\Calendar;
class CalendarTest extends \PHPUnit_Framework_TestCase
{
public function testGetNextMonth()
{
$calendar = new Calendar('09', '2012', null);
$result = $calendar->getNextMonth();
$this->assertEquals(10, $result);
}
}
I read this discussion Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? but the symfony documentation doesn't say to include PHPUnit...
What I'm doing wrong?
Thank you
I just had a similar issue (with DoctrineFixturesBundle), and solved it by adding PHPUnit to Symfony (as opposed to installing PHPUnit via PEAR).
What worked for me was:
1) add "phpunit/phpunit": "4.0.*" to the require section of composer.json:
{
"require": {
...
"phpunit/phpunit": "4.0.*"
}
}
2) running from the commandline:
php composer.phar update phpunit/phpunit
In case someone runs into a similar issue.
1- Install PHPUnit following this procedure:
$ pear config-set auto_discover 1
$ pear install pear.phpunit.de/PHPUnit
2- Run your tests as described here:
$ phpunit -c app/ src/My/CalendarBundle/Tests/Calendar/CalendarTest.php
The -c app/ option will be looking for a configuration file in the app/ directory. This configuration file is app/phpunit.xml.dist.