0

When trying this command docker-compose exec app php ./vendor/bin/phpunit

Or inside container like /vendor/bin/phpunit

Results are like:

PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

 ..F..FFFEE

While I'd need more details like time of test and failures info. I'm able to get some info by enabling stopOnFailure = true

But it's not ideal because it stops on the first one but I would need all of test to run and see the result.

I would need something like:

PHPUnit 8.5.4 by Sebastian Bergmann and contributors.

.......................E.......................................  63 / 116 ( 54%)
.....................................................           116 / 116 (100%)

Time: 1.2 minutes, Memory: 48.50 MB

There was 1 error:
ERRORS!
Tests: 116, Assertions: 219, Errors: 1.
Mahdi Younesi
  • 6,889
  • 2
  • 20
  • 51
  • I'm not sure PHPUnit supports displaying the time of test out the box. See the available options here: https://phpunit.readthedocs.io/en/9.0/textui.html If necessary you could also create your own formatter: http://php5.laurent-laville.org/compatinfo/blog/201505-PHPUnit-ResultPrinter.html – Matt Inamdar May 22 '20 at 20:03
  • @MattInamdar Ofcourse it does, I have no problem when running tests out of Docker container. every things work fine. – Mahdi Younesi May 22 '20 at 20:07

1 Answers1

0

Since you are using a docker, the php.ini configurations to display errors are disabled by default.

Solution 1:

Update the PHP configuration for you docker with:

error_reporting = E_ALL
display_errors = On
display_startup_errors = On

By referring to https://stackoverflow.com/a/40120445/494907

Solution 2:

Link a bootstrap file in phpunit.xml as

<phpunit bootstrap="init.php">

Create init.php in the directory of phpunit.xml:

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
Community
  • 1
  • 1
Ketan Yekale
  • 2,108
  • 3
  • 26
  • 33
  • I tried solution 1 but unfortunately it did not work – Mahdi Younesi May 22 '20 at 21:12
  • To confirm please check the values using phpinfo()? – Ketan Yekale May 22 '20 at 21:14
  • Values have not changed. the odd thing is that it work on machine with fresh Laravel, but not on other machine with Laravel 6 ! – Mahdi Younesi May 22 '20 at 21:56
  • I have followed https://www.digitalocean.com/community/tutorials/how-to-set-up-laravel-nginx-and-mysql-with-docker-compose I really need help. I'd appreciate any help – Mahdi Younesi May 22 '20 at 21:57
  • I followed the tutorial, installed it on mac and I am able to run the tests with the errors directly. Please share the phpunit.xml so that Ii can compare it with mine. – Ketan Yekale May 24 '20 at 23:24
  • this will likely not solve the problem at hand but as an alternative to the answer, phpunit php ini values can be configured in the phpunit.xml configuration file: [Setting PHP INI settings, Constants and Global Variables - 3. The XML Configuration File - PHPUnit](https://phpunit.readthedocs.io/en/7.3/configuration.html#setting-php-ini-settings-constants-and-global-variables) – hakre May 26 '20 at 23:56