I try running this command :
php bin/phpunit
I get this error :
PHP Fatal error: Uncaught Error: Call to undefined method
PHPUnit\TextUI\TestRunner::doRun() in
C:\wamp64\www\Test___Hanff_Web\bin.phpunit\phpunit-7.5-0\src\TextUI\Command.php:206
I see that it is using phpunit 7.5, but i have require phpunit 9.2 in my composer.json :
// composer.json
"require": {
"php": "^7.4",
...
"phpunit/phpunit": "^9.2", <-- here
"sensio/framework-extra-bundle": "^5.1",
"spatie/enum": "^2.3",
"symfony/asset": "^5.1",
...
"symfony/framework-bundle": "5.1.*",
...
},
"require-dev": {
"dama/doctrine-test-bundle": "^6.3",
"doctrine/doctrine-fixtures-bundle": "^3.3",
"symfony/browser-kit": "^5.1",
"symfony/css-selector": "^5.1",
"symfony/debug-pack": "^1.0",
"symfony/phpunit-bridge": "^5.1", <-- Also here because symfony doc told me to import that
"symfony/stopwatch": "^5.1",
"symfony/twig-bundle": "^5.1",
"symfony/web-profiler-bundle": "^5.1"
},
When i trying to execute this :
> vendor\bin\phpunit --version
PHPUnit 9.2.6 by Sebastian Bergmann and contributors.
I get version 9.2 instead of this :
> php bin/phpunit --version
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
So i try to run composer update but it don't change anything.
Then i try to self update phpunit as described here but nothing do !
I'm actually only being able to run my php test by execute this command :
> vendor\bin\phpunit tests/Controller/WebTest_ArticleController.php
It execute all the tests in one TestCase file, but i can't execute all the test for all the tests/* directory.
I would like to be able to run all my test as :
> php bin/phpunit
... Runing all test
Or something like :
> vendor\bin\phpunit tests/*
... Runing all test in tests/ directory
I have also read this PHPunit Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()
But it doesn't provide me any satisfying solution
You have to use
vendor\bin\phpunit and name your test case in tests folder something like XXXXXXXtest.php else, phpunit would not find it.
tests/
Controller/
ArticleController_WebTest.php
MenuController_WebTest.php
SecurityController_WebTest.php
...
Repository/
ArticleRepository_KernelTest.php
...
Services/
Service_UnitTest.php
...
Utils/
Util_UnitTest.php
...
This is why i wasn't being able to execute all of my test just by running \vendor\bin\phpunit
Related
When I try to run "Composer > Install" from PhpStorm I get the following error:
In PluginManager.php line 762:
icanhazstring/composer-unused (installed globally) contains a Composer
plug in which is blocked by your allow-plugins config. You may add it
to the list if you consider it safe.
You can run composer global config --no-plugins allow-plugins.icanhazstring/composer-unused [true|false] to enable it
(true) or disable it explicitly and suppress this exception (false)
See https://getcomposer.org/allow-plugins
What might be the reason for this error message above?
I have tried to run
/etc/php8/bin/php composer.phar global config --no-plugins allow-plugins.icanhazstrin true
and I have also tried to add the following to the composer.json file
"config": {
"allow-plugins": true,
but still I get the same error message.
My composer.json is something like:
{
"name": "test/version1",
"description":"Test Version 1",
"keywords":[],
"config": {
"allow-plugins": true,
"secure-http":false
},
"scripts": {
"test": "phpunit --config tests/phpunit.xml"
},
"require": {
"php": ">=7.3",
"monolog/monolog": "1.26.*",
...
"require-dev": {
"php": ">=8.1",
"phpunit/phpunit": "^9.5.0",
"friendsofphp/php-cs-fixer": "^2.16",
"icanhazstring/composer-unused": "^0.7.5"
}
}
Run the following command
/etc/php8/bin/php composer.phar global show -i
Then it will ask if you want to trust icanhazstring/composer-unused. Type y and press the enter button. That's it.
Then if you go to /home/yourUbuntuUsername/.config/composer/ there you will see another composer.json file with the following content:
{
"require": {
"icanhazstring/composer-unused": "^0.7.5"
},
"config": {
"allow-plugins": {
"icanhazstrin": true,
"icanhazstring/composer-unused": true
}
}
}
Apparently there is something called global Composer packages 🤷
Using pluhttps://github.com/spatie/browsershot I try to save html content to jpg file and I need to set rendered image in
full height(content can be in several pages in pdf file is generated).
Is there is way for it, as default generated image is cut by height.
I tried by :
use Spatie\Browsershot\Browsershot;
...
Browsershot::html( htmlspecialchars_decode($content) )
->showBackground()
->fit(\Manipulations::FIT_CONTAIN, 200, 200)
->save($save_to_file);
and got error :
Class 'App\Http\Controllers\Manipulations' not found
Which declarations did I miss? I did not find have I to add any devlarations into config/app.php ?
composer.json :
"require": {
"laravel/framework": "5.8.*",
"spatie/browsershot": "^3.27",
"spatie/laravel-image-optimizer": "^1.4",
package.json:
"dependencies": {
"puppeteer": "^1.14.0",
"pusher-js": "^4.3.1"
}
the package spatie/browsershot has a dependency spatie/image package.
to fix your problem, you should add the path to Manipulations class into your controller :
use Spatie\Image\Manipulations;
I want to use the following composer package "spatie/laravel-medialibrary" (https://github.com/spatie/laravel-medialibrary)
How to include it with test cases? Neither require nor require-dev work for me:
"require": {
"spatie/laravel-medialibrary": "^5.0"
},
or
"require-dev": {
"spatie/laravel-medialibrary": "^5.0"
},
I just want to run the testcases included in the package.
You need to install this package from source - dist archive does not contain test nor documentation. Add this to your composer.json:
"config": {
"preferred-install": {
"spatie/laravel-medialibrary": "source"
}
}
And then remove this package from vendor directory and install again:
rm -rf vendor/spatie/laravel-medialibrary/
composer install
I seem to be having a problem installing Laravel Passport, when running the command php artisan passport:install --force, I get the following error.
Symfony\Component\Debug\Exception\FatalThrowableError : Access to undeclared static property: Laravel\Passport\Passport::$client
at /Applications/MAMP/htdocs/xxxxxxxxx/alpha.platform.vuex/vendor/laravel/passport/src/Passport.php:413
409| * #return \Laravel\Passport\Client
410| */
411| public static function client()
412| {
> 413| return new static::$client;
414| }
415|
416| /**
417| * Set the personal access client model class name.
Not sure what has happened since running this command last night when it was working fine.
So i have found the problem.
Old composer
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/passport": "^6.0",
"laravel/tinker": "^1.0"
},
New composer
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"laravel/passport": "^4.0.3",
"laravel/tinker": "^1.0"
},
Rolled back the passport version and all seems to work as planned.
** Edit
After checking out the repo, updates where made 3 days back causing the break, now rolled back to 6.0.0 , this issue has been flagged on github.
Im trying to do a real simple test going with Laravel 4 but getting errors.
Here is my super simple test.
class SignupTest extends TestCase {
public function testIndex()
{
$this->call('GET', '/');
$this->assertResponseOk();
}
}
Error Stack Trace
PHP Fatal error: Call to undefined method SignupTest::assertTrue() in /home/domain/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php on line 135
PHP Stack trace:
PHP 1. {main}() /home/domain/vendor/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /home/domain/vendor/bin/phpunit:63
PHP 3. PHPUnit_TextUI_Command->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP 6. PHPUnit_Framework_TestSuite->runTest() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 7. PHPUnit_Framework_TestCase->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 8. PHPUnit_Framework_TestResult->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP 9. PHPUnit_Framework_TestCase->runBare() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 10. PHPUnit_Framework_TestCase->runTest() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
PHP 11. ReflectionMethod->invokeArgs() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 12. SignupTest->testIndex() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 13. Illuminate\Foundation\Testing\TestCase->assertResponseOk() /home/domain/app/tests/Unit/Controllers/SignupTest.php:9
You can see I'm extending the TestCase so I should have access to the assertTrue method.
Composer Part Incase it help.s
"require-dev": {
"phpunit/phpunit": "3.7.*",
"way/laravel-test-helpers": "dev-master",
"fzaninotto/faker": "dev-master",
"mockery/mockery": "dev-master#dev"
},
I have dumped autoload and cleared compiled.
Hope you can advise.
It turns out the phpunit was an old version and I had to re-install all vendor files.