Skip to content

A free open source IT asset/license management system

Improve macro

Marcus Moore55e46b2d15c0
diff --git a/tests/Feature/Reporting/CustomReportTest.php b/tests/Feature/Reporting/CustomReportTest.php
index c2a45b63b9..a895723176 100644
--- a/tests/Feature/Reporting/CustomReportTest.php
+++ b/tests/Feature/Reporting/CustomReportTest.php
@@ -88,30 +88,26 @@ class CustomReportTest extends TestCase implements TestsPermissionsRequirement
$this->actingAs($superUser)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
- ->assertSeeTextInStreamedResponse('Asset A')
- ->assertSeeTextInStreamedResponse('Asset B');
+ ->assertSeeTextInStreamedResponse(['Asset A', 'Asset B']);
$this->actingAs($userInCompanyA)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
- ->assertSeeTextInStreamedResponse('Asset A')
- ->assertSeeTextInStreamedResponse('Asset B');
+ ->assertSeeTextInStreamedResponse(['Asset A', 'Asset B']);
$this->actingAs($userInCompanyB)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
- ->assertSeeTextInStreamedResponse('Asset A')
- ->assertSeeTextInStreamedResponse('Asset B');
+ ->assertSeeTextInStreamedResponse(['Asset A', 'Asset B']);
$this->settings->enableMultipleFullCompanySupport();
$this->actingAs($superUser)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
- ->assertSeeTextInStreamedResponse('Asset A')
- ->assertSeeTextInStreamedResponse('Asset B');
+ ->assertSeeTextInStreamedResponse(['Asset A', 'Asset B']);
$this->actingAs($userInCompanyA)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
->assertSeeTextInStreamedResponse('Asset A')
- ->assertDontSeeTextInStreamedResponse('Asset B');
+ ->assertDontSeeTextInStreamedResponse(['Asset B']);
$this->actingAs($userInCompanyB)
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
diff --git a/tests/Support/CustomTestMacros.php b/tests/Support/CustomTestMacros.php
index 0b2c00f816..22045e7fac 100644
--- a/tests/Support/CustomTestMacros.php
+++ b/tests/Support/CustomTestMacros.php
@@ -152,12 +152,18 @@ trait CustomTestMacros
TestResponse::macro(
'assertSeeTextInStreamedResponse',
- function (string $needle) {
- Assert::assertTrue(
- collect(Reader::createFromString($this->streamedContent())->getRecords())
- ->flatten()
- ->contains($needle)
- );
+ function (array|string $needles): self {
+ if (! is_array($needles)) {
+ $needles = [$needles];
+ }
+
+ $records = collect(Reader::createFromString($this->streamedContent())->getRecords())->flatten();
+
+ foreach ($needles as $needle) {
+ Assert::assertTrue(
+ $records->contains($needle)
+ );
+ }
return $this;
}
@@ -165,12 +171,18 @@ trait CustomTestMacros
TestResponse::macro(
'assertDontSeeTextInStreamedResponse',
- function (string $needle) {
- Assert::assertFalse(
- collect(Reader::createFromString($this->streamedContent())->getRecords())
- ->flatten()
- ->contains($needle)
- );
+ function (array|string $needles): self {
+ if (! is_array($needles)) {
+ $needles = [$needles];
+ }
+
+ $records = collect(Reader::createFromString($this->streamedContent())->getRecords())->flatten();
+
+ foreach ($needles as $needle) {
+ Assert::assertFalse(
+ $records->contains($needle)
+ );
+ }
return $this;
}