A free open source IT asset/license management system
Implement test
Marcus Moorea7c5899c1659
diff --git a/tests/Feature/Assets/Api/AssignedAssetsTest.php b/tests/Feature/Assets/Api/AssignedAssetsTest.phpindex 2a6c9ea80c..e4693accdd 100644--- a/tests/Feature/Assets/Api/AssignedAssetsTest.php+++ b/tests/Feature/Assets/Api/AssignedAssetsTest.php@@ -36,11 +36,10 @@ class AssignedAssetsTest extends TestCase->getJson(route('api.assets.assigned_assets', $asset))->assertOk()->dump()+ ->assertResponseContainsInRows($assetsAssignedToAsset, 'serial')+ ->assertResponseDoesNotContainInRows($unassociatedAsset, 'serial')->assertJson(function (AssertableJson $json) {$json->etc();});-- // assert assigned asset included in response- // assert unassociated asset not in response}}diff --git a/tests/Support/CustomTestMacros.php b/tests/Support/CustomTestMacros.phpindex 956235f461..0d5df8faa3 100644--- a/tests/Support/CustomTestMacros.php+++ b/tests/Support/CustomTestMacros.php@@ -21,13 +21,21 @@ trait CustomTestMacrosTestResponse::macro('assertResponseContainsInRows',- function (Model $model, string $property = 'name') use ($guardAgainstNullProperty) {- $guardAgainstNullProperty($model, $property);+ function (iterable|Model $models, string $property = 'name') use ($guardAgainstNullProperty) {+ if ($models instanceof Model) {+ $models = [$models];+ }- Assert::assertTrue(- collect($this['rows'])->pluck($property)->contains(e($model->{$property})),- "Response did not contain the expected value: {$model->{$property}}"- );+ foreach ($models as $model) {++ $guardAgainstNullProperty($model, $property);++ Assert::assertTrue(+ collect($this['rows'])->pluck($property)->contains(e($model->{$property})),+ "Response did not contain the expected value: {$model->{$property}}"+ );++ }return $this;}