0
votes

I'm trying to test an application I'm making in Laravel 5.4 but when I type the phpunit command on the console I get this error:

PHP Warning: is_dir() expects parameter 1 to be a valid path, object given in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php on line 56

Warning: is_dir() expects parameter 1 to be a valid path, object given in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php on line 56 PHP Recoverable fatal error: Object of class PHPUnit\Framework\TestSuite could not be converted to string in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 32

Recoverable fatal error: Object of class PHPUnit\Framework\TestSuite could not be converted to string in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 32 ~/code/intranet $ phpunit PHP Warning: is_dir() expects parameter 1 to be a valid path, object given in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php on line 56

Warning: is_dir() expects parameter 1 to be a valid path, object given in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php on line 56 PHP Recoverable fatal error: Object of class PHPUnit\Framework\TestSuite could not be converted to string in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 32

Recoverable fatal error: Object of class PHPUnit\Framework\TestSuite could not be converted to string in /Users/nico/.composer/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 32 ~/code/intranet $

The parameter to which the error refers to and the $suiteClassName variable that somewhere in the code is transformed into an object instead of a string as supposed

public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '')
    {
        if (\is_dir($suiteClassName) &&
            !\is_file($suiteClassName . '.php') && empty($suiteClassFile)) {
            $facade = new File_Iterator_Facade;
            $files  = $facade->getFilesAsArray(
                $suiteClassName,
                $suffixes
            );

            $suite = new TestSuite($suiteClassName);
            $suite->addTestFiles($files);

            return $suite;
        }

Thank you in advance for the help

1
Not sure what the question is. The error is self-explanatory, so stop passing an object. - Jonnix
Pass the suiteClassFile name instead of suiteClassName - user5633496
Thanks for the answers guys, The problem is that $suiteClassFile is an empty string and I can not figure out where these two variables are being instantiated. I do not think I have edited Laravel's vendor directory so everything should be as default. - Nico Anastasio

1 Answers

0
votes

The reason is you have upgraded your php version to 7.0+ . So you need to fix your composer.json . Use "~6.3" instead of "~5.x" on phpunit option. Version 5.x is working with php 5.4, but it's not working with php 7.0+