When writing an automated test case for Lighthouse 5, phpstorm cannot be completed automatically (unable to find the statement to go to)
1. When writing the automated test cases of Lighthouse 5, phpstorm cannot be completed automatically. When you click $response->assetJSON, you cannot find the statement you want to go to. fashionAssertJSONNot found in \illuminate\testing\testResponse. as shown in Figure 1
2. Print the $response object, its actual path is:\illuminate\foundation\testing\testResponse. as shown in Figure 2
PS E:\wwwroot\object> ./vendor/bin/phpunit --process-isolation .\Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest.php
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
E.. 3 / 3 (100%)
Time: 11.89 seconds, Memory: 16.00 MB
There was 1 error:
1) Modules\ThemeStore\Tests\Functional\GraphQl\OnlineStoreThemeGraphQlApiTest::testGetThemeById
PHPUnit\Framework\Exception: Illuminate\Foundation\Testing\TestResponse Object
(
[baseResponse] => Illuminate\Http\Response Object
(
[headers] => Symfony\Component\HttpFoundation\ResponseHeaderBag Object
(
[computedCacheControl:protected] => Array
(
[no-cache] => 1
[private] => 1
)
[cookies:protected] => Array
(
)
[headerNames:protected] => Array
(
[cache-control] => Cache-Control
[date] => Date
[content-type] => Content-Type
)
[headers:protected] => Array
(
[cache-control] => Array
(
[0] => no-cache, private
)
[date] => Array
(
[0] => Thu, 17 Feb 2022 06:16:07 GMT
)
[content-type] => Array
(
[0] => application/json
)
)
[cacheControl:protected] => Array
(
)
)
[content:protected] => {"data":{"onlineStoreTheme":{"id":"vogue","editable":false,"createdAt":"2022-02-17 14:16:07","name":"vogue"}}}
[version:protected] => 1.1
[statusCode:protected] => 200
[statusText:protected] => OK
[charset:protected] =>
[original] => Array
(
[data] => Array
(
[onlineStoreTheme] => Array
(
[id] => vogue
[editable] =>
[createdAt] => 2022-02-17 14:16:07
[name] => vogue
)
)
)
[exception] =>
)
[streamedContent:protected] =>
)
phpvfscomposer://E:\wwwroot\object\vendor\phpunit\phpunit\phpunit:60
3. In another project, phpstorm can be completed automatically. as shown in Figure 3
4. In another project, print the $response object, and its actual path is:\Illuminate\testing\testResponse. \Foundation is missing from items that cannot locate the method. as shown in Figure 4
PS E:\wwwroot\lighthouse-tutorial> ./vendor/bin/phpunit --process-isolation .\tests\Feature\PostsGraphQlApiTest.php
PHPUnit 9.5.11 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 00:07.704, Memory: 12.00 MB
There was 1 error:
1) Tests\Feature\PostsGraphQlApiTest::testQueriesPosts
PHPUnit\Framework\Exception: Illuminate\Testing\TestResponse Object
(
[baseResponse] => Illuminate\Http\Response Object
(
[headers] => Symfony\Component\HttpFoundation\ResponseHeaderBag Object
(
[computedCacheControl:protected] => Array
(
[no-cache] => 1
[private] => 1
)
[cookies:protected] => Array
(
)
[headerNames:protected] => Array
(
[cache-control] => Cache-Control
[date] => Date
[content-type] => Content-Type
)
[headers:protected] => Array
(
[cache-control] => Array
(
[0] => no-cache, private
)
[date] => Array
(
[0] => Thu, 17 Feb 2022 06:25:24 GMT
)
[content-type] => Array
(
[0] => application/json
)
)
[cacheControl:protected] => Array
(
)
)
5. Reference URL:https://www.shuijingwanwq.com/en/2022/01/26/9945/, which is suspected to be similar to this problem. In Laravel Framework 6.20.44, Nuwave/LightHouse v5.36.0, the version mismatch is caused. Because in another project, the versions are: Laravel Framework 8.78.1, NuWave/Lighthouse v5.35.0, the version is matched.
6. In the current project, go back to ~4.10.1 in Nuwave/Lighthouse V5.36.0. Execute the composer remove nuwave/lighthouse command to uninstall nuwave/lighthouse. Execute the composer require nuwave/lighthouse:~4.10.1 command to install nuwave/lighthouse. After rolling back to Nuwave/Lighthouse v4.10.2, it can already be completed automatically. as shown in Figure 5
7. Click to jump, and its file path is:\Illuminate\Foundation\Testing\TestResponse. as shown in Figure 6
8. Search in Issues:\Illuminate\Testing\TestResponse to confirm that someone has encountered a similar problem: Refine Test helper return types for static analysis. as shown in Figure 7
9. Because Laravel moved TestResponse in V7. Officially recommended to use:https://github.com/nuwave/lighthouse/releases/tag/v4.12.2. Works perfectly with Laravel 7. Still compatible with Laravel 6. as shown in Figure 8







