codeception error after inserting laravel5 module - laravel

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.

Related

DDEV/Laravel/PHPUnit: Problems with setup in PhpStorm

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.

Cannot open file "/tests/ExampleTest.php" Laravel5 using Windows10

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"

How do I get phpunit to work in cloud9 IDE?

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.

Travis CI build fails for PHP 5.4 while trying to run composer

I am creating an open source project written in PHP and I'm starting to use Travis CI for testing on PHP versions 5.4, 5.5, 5.6 and HHVM.
The tests for 5.5, 5.6 and HHVM pass without any issues, but I get an error on PHP 5.4.
The error is listed here: https://travis-ci.org/CodeRichard/simple-config/jobs/58154496
I noticed it had something to do with the PHPUnit package which I use for local development and pulled in using Composer. This version requires symfony/yaml ~2.1|~3.0. After a bit of googling, I found out the pipe symbol is used as an OR symbol. This bit confuses me a little.
When I read ~2.1|~3.0 I assume it'll try to pull in one and if it fails, the other. I know symfony/yaml 3.* requires PHP 5.5.9, whereas 2.* requires 5.3.9.
What I don't understand is why it fails. Isn't it supposed to pull in symfony/yaml 2.* instead?
Right now, I'm requiring PHPUnit 4.6.* for development. The requirement for PHPUnit is PHP 5.3.3. However, Composer fails when trying Travis CI is trying to test for PHP 5.4. This makes absolutely no sense. If it would crash on PHP 5.4 and PHPUnit 4.6 requires symfony/yaml 3.0, shouldn't the requirement be 5.5?
I know I can just downgrade PHPUnit to 4.5, but I wish to remain up to date, so I'd rather not.
That error message is simple: Composer cannot install a component that got recorded in the composer.lock file, but doesn't match the requirements of THIS PHP:
symfony/yaml 3.0.x-dev requires php >=5.5.9
This will not work with PHP 5.4.
Downgrading your development machine to 5.4 and run composer update again will fix it.
Running composer update instead of composer install in Travis CI will also fix it. If you decide to do this, you should also run Travis with composer update --prefer-lowest to test that your declared minimum versions are correctly working.
You should also try to avoid "minimum-stability":"dev", unless you are really sure that you need bleeding-edge packages. Currently you are using no other packages, so it's not necessary to deal with the issues of unstable dev versions.
Remove composer.lock
This is what I have in my .travis.yml
# ...
before_script:
- rm composer.lock
- composer install --no-interaction --prefer-source
# ...
Issue: #2823

Using phpunit in laravel 4 without /vendor/bin/

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.

Resources