i am running phpunit testing in laravel5 on windows 10,and getting this error by running the following command.
Cannot open file "/tests/ExampleTest.php",
D:\wamp64\www\forum\vendor\bin>phpunit /tests/ ExampleTest.php
Can you please suggest me what could be the issue?
Its seems that "phpunit" is not installed globally,try run this command from cli to install it globally and then you can use unit testing globally.
"composer global require phpunit/phpunit"
Related
Using Laravel with DDEV/Docker on a Mac, I am stuck getting PhpStorm to run directly PHPUnit with coverage. I am following these instructions: https://ddev.readthedocs.io/en/stable/users/topics/phpstorm/
I started the setup with
curl -s "https://laravel.build/myproject?with=mysql,redis,memcached" | bash
Everything's is working fine, including debugging with Xdebug after I turned on Xdebug with
ddev xdebug on
PHPUnit works fine via console as well:
ddev exec phpunit
Composer version is 2.1.4.
Following the instructions named above, I am stuck at point 6.
What am I missing out? PHPUnit is located within the directory and it is composer-installed as well:
With composer version 2.2 the phpunit executable in vendor/bin is not a symlink anymore. It‘s a PHP file which includes the original executable with help of stream-wrapper, but including phpunit is not allowed: https://github.com/sebastianbergmann/phpunit/issues/4096#issuecomment-585900398
The bug is solved in composer:
https://github.com/composer/composer/issues/10387#issuecomment-1000246631
Use the following to get the latest dev version until this fix was official released:
composer self-update --snapshot
Further you can configure PhpStorm to use the original file instead:
vendor/phpunit/phpunit/phpunit
Thanks to all of you guys, I really appreciate your help.
Here is how I solved it:
I installed ddev-edge to avoid composer 2.1.x. I could not change it to 2.2 in config.yaml without failing ddev to restart when using stable version of ddev. It only worked on an active docker instance.
Then configurated ddev to use latest PHP-version 8.1 (for a new project from scratch, it makes sense anyway).
Then the error with PHPUnit changed to an error telling me that the PHP version is too old for the PHPUnit version. That was because PHPStorm automatically picked PHP 7.4 as default when connecting to Docker and checking the CLI remote interpreter.
So I changed the PHP executable from "php" to "php8.1"
See screenshots.
Now running PHPUnit from PHPStorm works fine, even with coverage.
I have pushed my local app to openshift and now get the following error message
PHP Fatal error: Class 'Illuminate\Html\HtmlServiceProvider' not found in /var/lib/openshift/5728b9782d5271802600015c/app-root/runtime/repo/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 150
How do I fix this on Openshift?
The solution locally would be to run composer update but how do I run that command on Openshift? I know there is rhc command line tool but is it possible to do a composer update with rhc?
You should check for the files first. You may have corrupted/missing files during upload. If you do not have vendor directory, you shoudl run composer update.
If files are there, run composer dumpauto on the server.
You can connect to you server with SSH and run these commands from terminal.
If you do not have access to SSH, you could try to run there commands using small PHP script with shell_exec('composer update'); clause in it, or just upload all vendor files manually.
I got ssh access and did the commands necessary to correct the problems
i have installed codeception globally. it works fine when i run codecept run functional command. when i insert laravel5 module into functional.suite.yml as per instruction from codeception website documentation, it gives me error like this.
when i remove laravel5 module codecept run works normally. anyone knows how to tackle that error? should i install codeception locally instead of globally?
Note : i don't use homestead/vagrant
This error doesn't seem to be related to Laravel5 module.
Your problem is that you have 2 conflicting versions of PHPUnit installed.
You have PHPUnit 5.2.12 installed in vendor directory,
but your global Codeception install is bundled with PHPUnit 4.8.23.
There are 2 ways to solve it:
a) uninstall PHPUnit from your project.
b) install Codeception with Composer.
Just started out a laravel project on cloud9 IDE but I can't get phpunit to work. Every time I run the PHPUnit command I get a
command not found
response. From the file structure in the project I can see phpunit files. I have never used cloud 9 for a laravel project before so I can't really tell if thats how it's supposed to behave. Has anyone successfully used phpunit on cloud9 before?
You can install phpunit globally using composer (available in the default C9 workspace). Phpunit 4.8.* works with PHP 5.5.
sudo composer global require phpunit/phpunit:4.8.*
The phpunit executable will be installed in ~/.composer/vendor/bin/ so add the following line at the end of the ~/.profile file to make the command available elsewhere.
export PATH=~/.composer/vendor/bin:$PATH
Run source ~/.profile afterwards to register the new path then simply run phpunit in your Laravel installation folder.
I have installed phpunit in this instance of laravel using composer. The files are present in the laravel/vendor/bin folder. when I run vendor/bin/phpunit the example test runs. In all the tutorials I am watching on unit testing in laravel the tutors simply run phpunit and it runs the test.
In the laravel documentation it says that I should be able to simply run phpunit to initiate the tests.
Is the documentation refering to phpunit being installed system wide and do the tutors in the video simply have it installed system wide or am I missing something?
In linux, get phpunit path by typing which phpunit in the terminal. Its probably in the /usr/bin/ dir. execute
alias phpunit='/usr/bin/phpunit'
in the terminal.
They have it installed system wide.
If you are in Windows, you can modify your PATH system variable to include the path to phpunit. For example on mine, I've appended ;C:\wamp\www\rel\vendor\bin to it.
Then you'd just have to navigate to the folder your project is in which should have the phpunit.xml file that was included with laravel and run phpunit on your command prompt.
Unfortunately, I am not completely sure how to do this on Linux or OSX.
In Mac OS, just go to your Laravel project directory via Terminal and then enter this command:
alias phpunit="~/Your Project Directory Name/vendor/bin/phpunit"
From now on you can run PHPUnit by just simply typing phpunit.