Extract and use helper methods

This commit is contained in:
Marcus Moore
2023-06-07 16:16:30 -07:00
parent 27d4d107bb
commit abaf59c990
5 changed files with 75 additions and 91 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace Tests\Support;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Testing\TestResponse;
trait InteractsWithResponses
{
private function assertResponseContainsInRows(TestResponse $response, Model $model, string $field = 'name')
{
$this->assertTrue(collect($response['rows'])->pluck($field)->contains($model->{$field}));
}
private function assertResponseDoesNotContainInRows(TestResponse $response, Model $model, string $field = 'name')
{
$this->assertFalse(collect($response['rows'])->pluck($field)->contains($model->{$field}));
}
}