TravisCI and composer exec stdout - composer-php

When I run my test suite in travis I like to see the output.
With php ./vendor/bin/phpunit tests this works fine, but with with composer exec phpunit tests it doesn't show the output. At most you see "Script phpunit handling the __exec_command event returned with error code 255" when it fails but this doesn't tell you anything about what failed.
Why? It works on my local machine just fine.

Looks like composer changed default verbosity level for phpunit output. Not sure, when did they do it - in composer 1.2.0 everything works ok
As a solution you can just use
composer exec phpunit -v

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.

phpunit testing not working on Laravel 5.4

I am new to using phpunit in Laravel for testing. When I tried and typed in phpunit in commandline, I got an
error.
I even tried to to use ./vendor/bin/phpunit like most people suggested and it still doesn't work. Here are all the errors that I have gotten. enter image description here
You need first to run composer, after this you have to run phpunit using the convention of your OS, I saw you are in Windows, so you need to run vendor\bin\phpunit or you can use gitbash to emulate Unix system.

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"

codeception error after inserting laravel5 module

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.

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.

Resources