运行 Lighthouse 的测试用例时,报错:Class ‘Overtrue\LaravelVersionable\ServiceProvider’ not found
1、运行 Lighthouse 的测试用例时,报错:Class ‘Overtrue\LaravelVersionable\ServiceProvider’ not found。如图1
PS E:\wwwroot\object> ./vendor/bin/phpunit .\Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest.php PHPUnit 7.5.20 by Sebastian Bergmann and contributors. E 1 / 1 (100%) Time: 350 ms, Memory: 30.00 MB There was 1 error: 1) Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest::testGetThemeById Error: Class 'Overtrue\LaravelVersionable\ServiceProvider' not found E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php:208 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php:144 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php:61 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:593 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\RegisterProviders.php:17 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Application.php:219 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:320 E:\wwwroot\object\tests\CreatesApplication.php:18 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestCase.php:102 E:\wwwroot\object\vendor\laravel\framework\src\Illuminate\Foundation\Testing\TestCase.php:81 E:\wwwroot\object\Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest.php:76 phpvfscomposer://E:\wwwroot\object\vendor\phpunit\phpunit\phpunit:60 ERRORS! Tests: 1, Assertions: 0, Errors: 1. PS E:\wwwroot\object>
2、在 IDE 中搜索类:Overtrue\LaravelVersionable\ServiceProvider,未找到。如图2
3、在项目中查找代码:LaravelVersionable,发现 文件 /bootstrap/cache/packages.phpunit.php 中存在:Overtrue\\LaravelVersionable\\ServiceProvider 。如图3
4、查看目录:/vendor/overtrue,不存在 文件夹 laravel-versionable。确认此软件包并未安装,但是在缓存中又有声明。如图4
5、查看 /bootstrap/cache 下现有的缓存文件,如图5
6、原因应该在于之前进行了 Git 的本地重置,进而导致缓存有误。缓存本不应该放入 Git 中的。最终决定手动删除目录 /bootstrap/cache 下的缓存文件。运行测试,测试通过。如图6
PS E:\wwwroot\object> ./vendor/bin/phpunit .\Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest.php PHPUnit 7.5.20 by Sebastian Bergmann and contributors. . 1 / 1 (100%) Time: 9.42 seconds, Memory: 60.00 MB OK (1 test, 14 assertions) PS E:\wwwroot\object>
近期评论