-
Notifications
You must be signed in to change notification settings - Fork 266
Description
Hi, I'm trying to use the has and where test helpers and I can't understand why the following test is failing.
users.data is returned from Laravel's paginate method and I'm trying to assert that there is 1 result and then scope into that result and assert that the email of that user is [email protected].
$response
->assertStatus(200)
->assertInertia(fn (InertiaAssert $page) => $page
->has('users.data', 1, fn (InertiaAssert $page) => $page
->where('email', '[email protected]')
)
);
I then get the following test failure which lists the other properties on the users model but without the email property.
1) Tests\Feature\User\UserTest::test_can_search_users
Unexpected Inertia properties were found in scope [users.data.0].
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
-Array &0 ()
+Array &0 (
+ 0 => 'id'
+ 1 => 'username'
+ 2 => 'first_name'
+ 3 => 'surname'
+ 5 => 'email_verified_at'
+ 6 => 'blocked'
+ 7 => 'created_at'
+ 8 => 'updated_at'
+)
I've dumped the $page variable and it does include the correct email address. I'm not sure if this is a bug or I'm using the helpers incorrectly.
For reference I can make the test pass using the following assertions but I'd like to combine the count and then scope straight into the first result as mentioned in the documentation.
$response
->assertStatus(200)
->assertInertia(fn (InertiaAssert $page) => $page
->has('users.data', 1)
->has('users.data', fn (InertiaAssert $page) => $page
->where('0.email', '[email protected]')
)
);
Thanks for your help.