I am using the Symfony3 plugin in PhpStorm. My PHP Interpreter is 7.0.18. I have PHPUnit 6.3.0 configured in PhpStorm by having the .phar file in the root directory of my project.
Unit test work like a charm inside the IDE however performing any operation on the server (like bin/console server:start) triggers the following messages:
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in
/1tb/programming/PhpstormProjects/binary_search/src/AppBundle/Search/BinarySearchTest.php on line 13
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in
/1tb/programming/PhpstormProjects/binary_search/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Tests/TestCase.php
on line 17
BinarySearchTest.php:
<?php
namespace AppBundle\Search;
use PHPUnit\Framework\TestCase;
class BinarySearchTest extends TestCase
{
}
TestCase.php:
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
class TestCase extends PHPUnitTestCase
{
}
I have read many posts with problems similar but none of them describe the problem the way I do. Then I tried running PHPUnit with phpunit . in the root directory of the folder with this error:
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not
found in
/1tb/programming/PhpstormProjects/binary_search/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php
on line 10
It seems whatever I do I just run into more errors. I only just got started with Symfony and read a bit of the documentation but I can't get a grip on this thing, I have been at it for two days. Any suggestions for me?
I have PHPUnit 6.3.0 configured ... by having the .phar file in the root directory of my project
Such a bad idea. PHPUnit should not be installed on your (production?) server.
If this is a local staging server that you're trying to test on, then you need to install the phar in the path.
To globally install the PHAR:
$ wget https://phar.phpunit.de/phpunit-6.2.phar
$ chmod +x phpunit-6.2.phar
$ sudo mv phpunit-6.2.phar /usr/local/bin/phpunit
$ phpunit --version
Also, consider upgrading PHP to the newest version. There are several vulnerabilities in the one you're using. (See: change log for versions between yours and current).
EDIT:
Why are you running bin/console server:start on your server? Also not meant to be on a production server.
My guess here is that it is seeing the phar in your document root and trying to execute it, which is what is causing all the errors.
Installation of PHPUnit via composer worked. It turns out my composer installation went wrong in some way. After composer was successfully installed, I let it handle installing PHPUnit. After that it just worked. Tests work fine in the IDE and the server is responsive again. Thanks LazyOne.
Related
I'm working with Symfony 5 and I installed phpunit-bridge with the command included in the documentation : composer require --dev symfony/phpunit-bridge.
When I run phpunit with this command, php bin/phpunit, I have this error :
PHP Fatal error : Uncaught Error: Call to undefined method
PHPUnit\TextUI\TestRunner::doRun()
I'll try to guess.
You also have a bundle like liip/functional-test-bundle or other, which require PHPUnit in requirements (or even you require PHPUnit directly in your composer.json together with phpunit-bridge).
As a result you have two different version of PHPUnit installed in project, with two different api.
If installed liip/functional-test-bundle is your case and you do not want to remove it, you need to install by bridge same PHPUnit version as installed by Liip bundle dependency. You can set version through SYMFONY_PHPUNIT_VERSION env variable or directly in bin/phpunit file. Or you can redefine path to already installed PHPUnit version (in vendors/) through SYMFONY_PHPUNIT_DIR env or directly in bin/phpunit.
Note: you can not set SYMFONY_PHPUNIT_VERSION or SYMFONY_PHPUNIT_DIR through .env.* files, since bin/phpunit not read this files. So it should be real env vars.
I had a similar issue with symfony 5.1. I tried upgrading all dev packages related to testing but it didn't work.
Once I completely remove all dev (testing related) packages and reinstalling the symfony phpunit bridge package it worked.
You have to remove the phpunit file inside the root/bin directory
Steps to follow
Remove all dev test packages (Eg: composer remove symfony/browser-kit)
Remove if there are following packages : phpunit/phpunit, symfony/phpunit-bridge, symfony/css-selector, symfony/browser-kit
Install the brdge package again by running composer require --dev symfony/phpunit-bridge
I'm working on an existing symfony project and need to use php unit.
When I tried to install it through composer with this command:
composer require --dev phpunit/phpunit ^5
But I got this error:
proc_open (): CreateProcess failed, error code -267
See screenshot here
If you refer to MS's error code reference, you'll see that error code 267 means that the directory name is invalid. So you've probably got an invalid directory reference in your configuration file.
Symfony has its own PHPunit bridge component that adds features on top of the library.
Install it by running this command at the root of your project:
composer require --dev symfony/phpunit-bridge
You should then be able to run your test scripts with:
./vendor/bin/simple-phpunit
My meteor application works locally. When I bundle it (using meteor bundle myapp.tgz), upload it on my server and launch it, I have the following error upon opening the page on Chrome console:
Uncaught SyntaxError: Unexpected token <
On Firefox console:
SyntaxError: syntax error
[Break On This Error]
<!DOCTYPE html>
In order to try to find the origin of the error, I used an old bundle that was working. I can see the problem is that the files in static_cachable are not found.
Meteor is still trying to use the files from the old bundle.
If I rename the new bundled files in static_cachable to the old name then It works.
I checked in all files contained by the root of the bundle folder and references are correct (they are pointing to the new names).
It there some cache somewhere that keep the reference to the old static_caches files ?
To avoid the error, one has to restart Meteor after deployement :
rm -rf bundle
tar -zxf myapp.tar.gz
cd bundle/server/node_modules/
rm -r fibers
npm install fibers#1.0.0
export PORT=32632
export MONGO_URL=mongodb://meteor:**#localhost:18700/moviegrid
export ROOT_URL='mydomain.com'
nohup node bundle/main.js &
Look at the javascript console when you load your app locally and check if there is no error. If there is some, correct them before bundling/deploy.
This may not be your problem but according to http://docs.meteor.com/#deploying:
For now, bundles will only run on the platform that the bundle was created on. To run on a different platform, you'll need to rebuild the native packages included in the bundle. To do that, make sure you have npm available, and run the following:
$ cd bundle/server/node_modules
$ rm -r fibers
$ npm install fibers#1.0.0
Consider installing meteor on your server, cloning your app directory and using meteor run inside the directory to see if the app runs in development on the server.
If it successfully launches in development then bundle it on the server and use those files. Or just run with meteor --production
After having successfully installed and updated all vendors in my project folder for Sylius i tried running this code :
app/console sylius:install --fixtures
I get this error :
PHP Fatal error: Class 'ResourceBundle' not found in C:\wamp\www\sylius\vendor\
symfony\symfony\src\Symfony\Component\Locale\Locale.php on line 51
Then i tried all possible solutions given here
Installed intl extension in php (working successfully).Then ran this command
php build-data.php 'your ICU version'
On running the above command i get this:
'which' is not recognized as an internal or external command,
operable program or batch file.
The command "svn" is not installed
I want to know if there is another workaround to this issue.
Please help and thanks in advance.
P.S. - No SVN runs on my system. And i'm using icu*46.dll
Anyone came across this??
This error relates to be PHP intl-extension. Make sure it is enabled and you have the LATEST version.
quick test:
<?php
var_dump(extension_loaded('intl'));
Make sure your PHP folder is correctly registered in your %PATH% environment variable.
Control Panel - System - Advanced - ...
Without that, the ICU dlls are not loaded by PHP as Apache module - no error message is displayed, but the extension is not enabled.
Check aswell from phpinfo() ! not with ...
php -m
... or ( windows = findstr, linux/cygwin = grep )
php -i | findstr intl
check that the extension is enabled in your php.ini ( dont know WAMP's extenion path so adjust it please )
extension=php_intl.dll
As i can see you are on Windows and using WAMP you will have to get a precompiled version of the extension.
The packages on http://windows.php.net/download/ all contain the php_intl.dll in the ext folder.
Make sure that the ICU is compiled with the same version of MSVC that PHP is.
You run into problems if the ICU was compiled with VC10 and PHP was with VC9.
Although php -m and php -i detect the INTL it wouldn't show up in phpinfo().
So I am a new to doctrine, but I am not able to install a bundle at all. I am following the guide, but the "error" which I am getting is very unusual.
Anyhow, I add this lines into deps file:
[FOSRestBundle]
git=http://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
Then I do:
./bin/vendors install
And I get:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/sqlite.so' - /usr/lib/php5/20090626+lfs/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
Your project seems to be based on a Standard Edition that includes vendors.
Try to run ./bin/vendors install --reinstall
So on this standard way I am not able to install it at all. Can somebody explain me what is the problem, because to me it looks like, the symfony vendors script doesnt recognize changes in deps file at all.
This happens when you've downloaded the Symfony2 Standard Edition from the website. The vendor install script checks to see if the vendor directories are git repositories, and if not, will throw this error. You can fix the situation in one of two ways:
you can either run the command that it suggests: php bin/vendors install --reinstall
or, you can remove the vendors directory, then run php bin/vendors install, which amounts to about the same thing
No need to install that. Just follow the steps in the url : http://mmoreramerino.github.com/GearmanBundle/installation.html