A free open source IT asset/license management system
WIP: improve test
Marcus Moore801cef8048a3
diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.phpindex 101be3bcc9..ddf6a2fd08 100644--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php@@ -560,12 +560,14 @@ class CustomComponentReportTest extends TestCasepublic function test_does_not_included_assignments_by_default(){+ $this->markTestIncomplete();+[$assetA, $assetB] = Asset::factory()->count(2)->sequence(['name' => 'Asset 001'],['name' => 'Asset 002'],- )->create();+ )->create()->all();Component::factory()->create(['name' => 'Component A']);Component::factory()->checkedOutToAsset($assetA)->create(['name' => 'Component B']);@@ -580,7 +582,8 @@ class CustomComponentReportTest extends TestCase->assertSeeTextInStreamedResponse('Component B')->assertSeeTextInStreamedResponse('Component C')->assertDontSeeTextInStreamedResponse('Asset 001')- ->assertDontSeeTextInStreamedResponse('Asset 002');+ ->assertDontSeeTextInStreamedResponse('Asset 002')+ ->assertRowCountInStreamedResponse(3);}public function test_can_include_assignments()@@ -590,7 +593,7 @@ class CustomComponentReportTest extends TestCase->sequence(['name' => 'Asset 001'],['name' => 'Asset 002'],- )->create();+ )->create()->all();Component::factory()->create(['name' => 'Component A']);Component::factory()->checkedOutToAsset($assetA)->create(['name' => 'Component B']);diff --git a/tests/Support/CustomTestMacros.php b/tests/Support/CustomTestMacros.phpindex 4068d5e164..87b2f110c7 100644--- a/tests/Support/CustomTestMacros.php+++ b/tests/Support/CustomTestMacros.php@@ -213,7 +213,7 @@ trait CustomTestMacros$headers = collect($records->shift());- $combined = $records->map(fn($record) => $headers->combine($record));+ $combined = $records->map(fn ($record) => $headers->combine($record));Assert::assertTrue($combined->contains(function ($row) use ($pair) {@@ -232,6 +232,19 @@ trait CustomTestMacros});+ TestResponse::macro(+ 'assertRowCountInStreamedResponse',+ function (int $expectedCount) {+ Assert::assertCount(+ $expectedCount,+ collect(Reader::fromString($this->streamedContent())->getRecords()),+ "Response did not contain the expected number of rows: {$expectedCount}"+ );++ return $this;+ }+ );+TestResponse::macro('assertCsvHeader',function () {