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.
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 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"
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.
I am new to Laravel and Composer, and am following some guides including LaraCasts.com . One of the things that need to be done is use Composer to require packages to use in the Laravel project. However, this doesn't work for me.
I installed Laravel using the composer create-project method (http://laravel.com/docs/5.0), and so far everything was fine. However, any package I "require" now actually goes into the C:\Users\user\vendor folder, and the composer.json file is in C:\Users\user.
I understand that Composer is supposed to separate between projects as opposed to being global like PEAR. So how do I specify that I'm working on a specific project and require everything into that project? Also, what is the actual path where I'm supposed to put packages in Laravel, in case I want to do it manually?
I am using Windows 7 and Xampp.
When you run composer require {pacakage}, make sure you use the cd command (Change Directory - I think) into the project you want to install the package for. So if you're in Xampp it could be something like cd C:\xampp\htdocs\my-laravel-project\ or whatever the path to your project is, then run your composer require {pacakage}.
I believe it's installing it in C:\Users\user\vendor as when you open your terminal/command prompt the default location is C:\Users\{username}\.
Please make sure you ran the composer create-project in your web root, for Xampp I think it's C:\xampp\htdocs\ but it could be different depending on how you set up Xampp when you installed it.
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.