whole running your test what it gives you error? can you show it pealse!
Oct 5, 2022
5
Level 1
Unit test escapeWhenCastingToString issue
Hi all im writing a unit test to check that the view has the collection data
#TEST
$appliedUsers = AppliedJobPosts::query()
->where('job_posts_id', $jobPost->id)
->with('user', function ($query) {
$query->select('id', 'name', 'surname');
})
->latest('created_at')
->limit(5)
->get();
Livewire::actingAs($user)
->test(UserJobSearchAppliedUsers::class, ['jobPostId' => $jobPost->id])
->assertViewHas('lastAppliedUsers', $appliedUsers);
# view code
@foreach($lastAppliedUsers as $appliedUser)
<x-job-seeker.user-job-seeker-applied-user-list-item
:applied-user="$appliedUser"
:is-not-odd="!$loop->odd"
/>
@endforeach
However im getting a Failed asserting that two objects are equal. as a result that expected is 'escapeWhenCastingToString' => false and the actual is 'escapeWhenCastingToString' => true...
Why is this happening and how can i fix it or correct the test?
Please or to participate in this conversation.