hi ,
i have implemented what you said in the post above but it still fails , included in my post here the
1-test method
2-test result from the console
public function users_search_returns_results_for_existing_data(array $payload)
{
$users = User::factory()->createMany($payload);
$user = $users->find($users[0]->id);
$response = $this
->withHeader("Accept", 'application/json')
->actingAs($user)
->getJson(route('authors.index', ['search' => 'b']));
$response->assertStatus(200);
$response->assertJsonCount(1, 'data');
}
test Results
/bin/php /home/mina/Desktop/Tickets/vendor/phpunit/phpunit/phpunit --configuration /home/mina/Desktop/Tickets/phpunit.xml --filter "/(Tests\\Feature\\AuthorTest::users_search_returns_results_for_existing_data)( .*)?$/" --test-suffix AuthorTest.php /home/mina/Desktop/Tickets/tests/Feature --teamcity
Testing started at 2:03 AM ...
PHP Warning: PHP Startup: Unable to load dynamic library 'couchbase' (tried: /usr/lib/php/20240924/couchbase (/usr/lib/php/20240924/couchbase: cannot open shared object file: No such file or directory), /usr/lib/php/20240924/couchbase.so (/usr/lib/php/20240924/couchbase.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHPUnit 11.5.46 by Sebastian Bergmann and contributors.
Runtime: PHP 8.4.15
Configuration: /home/mina/Desktop/Tickets/phpunit.xml
Failed to assert that the response count matched the expected 1
Failed asserting that actual size 0 matches expected size 1.
/home/mina/Desktop/Tickets/vendor/laravel/framework/src/Illuminate/Testing/AssertableJsonString.php:74
/home/mina/Desktop/Tickets/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:1006
/home/mina/Desktop/Tickets/tests/Feature/AuthorTest.php:81
Time: 00:07.109, Memory: 44.50 MB
There was 1 failure:
1) Tests\Feature\AuthorTest::users_search_returns_results_for_existing_data with data set "users_to_create" ([['mina', 'remon', '[email protected]', 'mina20088'], ['beshoy', 'shaker', '[email protected]', 'beshoy20088']])
Failed to assert that the response count matched the expected 1
Failed asserting that actual size 0 matches expected size 1.
/home/mina/Desktop/Tickets/vendor/laravel/framework/src/Illuminate/Testing/AssertableJsonString.php:74
/home/mina/Desktop/Tickets/vendor/laravel/framework/src/Illuminate/Testing/TestResponse.php:1006
/home/mina/Desktop/Tickets/tests/Feature/AuthorTest.php:81
FAILURES!
Tests: 1, Assertions: 2, Failures: 1.
Process finished with exit code 1