I'm currently trying to run PHPUnit on my Ubuntu 12.04 virtual machine and when I run phpunit under my application root that has phpunit.xml.dist file it reads from the config but I'm getting below error and it fails:
PHP Fatal error: Call to undefined method PHPUnit_Util_Test::getHookMethods() in phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php on line 633
Is there a reason why this is happening?
I had a similar issue in a different environment.
The problem was that another library's loader was registered too early which also contained another version of PHPUnit which had no that method. The proper order of autoloaders solved the problem.
Related
I have a symfony 2 project. It was running just fine two different ubuntu systems. Now I have deployed it to an OpenShift instance and get this error:
PHP Fatal error: Class 'Doctrine\\DBAL\\Platforms\\MySqlPlatform' not found in /var/lib/openshift/552ba6ecfcf93371e600007a/app-root/runtime/repo/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php on line 80
I have no idea where to look for the error. Any ideas?
Please check the file permissions. Is it executable? Does it exist at all?
The solution was:
- remove folder "vendor"
- remove file composer.lock
php composer.phar self-update
php composer.phar install
All good now
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 have some test under features directory. But when I try to run behat I get the following error:
$ ls
behat.yml features
$ behat
PHP Warning: Module 'memcache' already loaded in Unknown on line 0
PHP Warning: require_once(PHPUnit/Autoload.php): failed to open stream: No such file or directory in $HOME/workspace/ums/api/trunk/tests/functional/features/bootstrap/FeatureContext.php on line 24
PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:/usr/share/pear:/usr/share/php') in $HOME/workspace/ums/api/trunk/tests/functional/features/bootstrap/FeatureContext.php on line 24
Since PHPUnit is no longer available to install using PEAR, I finally use Composer. So have my PHPUnit libraries installed under
$ sudo find / -name PHPUnit
/HOME/.composer/vendor/phpunit/phpunit/PHPUnit
/HOME/.composer/vendor/phpunit/phpunit-mock-objects/PHPUnit
/tmp/ZendFramework-1.11.0/library/Zend/Test/PHPUnit
/tmp/ZendFramework-1.11.0/tests/Zend/Test/PHPUnit
/usr/share/php/Zend/Test/PHPUnit
/usr/share/php/Zend-2.0/Test/PHPUnit
Which is the best way to set include_path without changing php.ini file and not use set_include_path() method in each FeatureContext.php example type class ?
Any help would be appreciated!
I ran into the same error using phpunit along with Behat, I did manage to overcome it with the following code:
require_once __DIR__.'/../../vendor/autoload.php';
require_once __DIR__.'/../../vendor/phpunit/phpunit/src/Framework/Assert/Functions.php';
Given that the 'bootstrap' folder is only one two folders away from the root of the project. Hopes it helps.
Usually I have PHPUnit installed globally (via composer) on my dev and test (CI server) machines so I wont run into any trouble when running the tests. Also, in order to have the auto completion properly working of my favorite IDE (PhpStorm) I include the library in the composer.json of the project as a dev requirement. In the case of a project that uses Behat and is developed by a team the best way is to include it in the project so no developer would run into trouble when running the test.
You want to use the autoloader that comes with composer. Try adding
require_once 'path/to/vendor/autoload.php'
before using PHPUnit
I am experiencing a fatal error while using artisan on the (fantastic) Laravel PHP framework.
I recently downloaded v3.2.1 of Laravel, and I tried running the following command line from within the directory that artisan resides:
php artisan key:generate
This should create a random key for me in my applications/application.php file. (Please see http://laravel.com/docs/artisan/commands for a specific reference to this command.)
However, when I run this command from the shell I receive the following error:
Warning: chdir(): No such file or directory (errno 2) in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/paths.php on line 62
Parse error: syntax error, unexpected T_STRING in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/laravel/core.php on line 1
This is what's on line 62 of paths.php:
chdir(__DIR__);
This is what's on line 1 of core.php:
<?php namespace Laravel;
My question is this: Are there any specific environment, directory, or other permissions that I should modify to get artisan up and running.
A little background:
I installed Laravel 3.2.1 yesterday for the first time
I can run a simple web application successfully on my system (i.e. I can route a request to a controller and load up the associated blade properly)
I simply downloaded the Laravel 3.2.1 (laravel-laravel-v3.2.1-8-gaae8b62.zip) from GitHub and extracted it on my server
My environment:
PHP 5.3.13 on a shared host at Dreamhost
FireSSH to run the commands
My root directory: (permissions in parenthesis)
/application (775)
/bundles (775)
/laravel (775)
/public (775)
/storage (775)
/artisan (664)
/paths.php (777)
Please let me know if there are any other details about my setup that relevant. I'm really not sure what will help in troubleshooting this issue.
--
UPDATE: I also posted this issue to Laravel's GitHub issue tracker. (https://github.com/laravel/laravel/issues/820)
First off, thanks #KingCrunch, your first response led me down the correct path toward resolving this issue. Additionally, I received an excellent response from Dreamhost technical support (specifically Gary S), who gave me the concise answer I was looking for.
The issue was: I was running PHP 5.2.17 at the CLI, whereas my web server was running PHP 5.3.13.
The resolution is: Use
/usr/local/php53/bin/php artisan <command>
when running artisan commands at the CLI. This will ensure that all of my artisan commands are run using PHP 5.3 and above, which satisfies Laravel's PHP 5.3+ requirements.
Namespaces and the __DIR__-pseud-constant were introduced in PHP 5.3. It seems you are running an old version. You should update to at least 5.3.
php -v
I am learning building php unit tests using PHPUnit . There they have a manual and I encountered this example Where they use assertEmpty(), but when I run this code in command line I get this error : Call to undefined method StackTest::assertEmpty() in /var/www/.../tests/StackTest.php on line 20. So if this method is deprecated or something why they use it , also is there another method for this? (of course I can try this $this->assertEquals(0, count($stack));) but anyways...
The same with assertNotEmpty().
I'm on debian, and it looks like the default install of PHPunit is a bit old (3.4.14).
If you search for "assertEmpty" in this url, you will see what version it was added in (3.5.0-1).
http://packages.debian.org/changelogs/pool/main/p/phpunit/phpunit_3.6.10-1/changelog.html
What worked for me was removing phpunit from the system with apt, and installing it with pear
http://www.santiagolizardo.com/article/how-to-install-pear-and-phpunit-in-debianubuntu/57001
These links also helped me.
"Fatal error: Call to undefined method PHPUnit_Util_Filter::addfiletofilter() in /usr/bin/phpunit on line 48"
Cannot get PHPunit working
Are you running the unit test from the command line with the phpunit command line tools?
phpunit --verbose StackTest stacktest.php