A free open source IT asset/license management system
Move helper macros to CustomTestMacros
Marcus Mooree75f54cc1ced
diff --git a/tests/Feature/Reporting/CustomReportTest.php b/tests/Feature/Reporting/CustomReportTest.phpindex bce61a6f45..c2a45b63b9 100644--- a/tests/Feature/Reporting/CustomReportTest.php+++ b/tests/Feature/Reporting/CustomReportTest.php@@ -9,9 +9,7 @@ use App\Models\ReportTemplate;use App\Models\User;use Illuminate\Database\Eloquent\Collection;use Illuminate\Support\Facades\Crypt;-use Illuminate\Testing\TestResponse;use League\Csv\Reader;-use PHPUnit\Framework\Assert;use PHPUnit\Framework\Attributes\Group;use Tests\Concerns\TestsPermissionsRequirement;use Tests\TestCase;@@ -19,37 +17,6 @@ use Tests\TestCase;#[Group('custom-reporting')]class CustomReportTest extends TestCase implements TestsPermissionsRequirement{- protected function setUp(): void- {- parent::setUp();-- TestResponse::macro(- 'assertSeeTextInStreamedResponse',- function (string $needle) {- Assert::assertTrue(- collect(Reader::createFromString($this->streamedContent())->getRecords())- ->pluck(0)- ->contains($needle)- );-- return $this;- }- );-- TestResponse::macro(- 'assertDontSeeTextInStreamedResponse',- function (string $needle) {- Assert::assertFalse(- collect(Reader::createFromString($this->streamedContent())->getRecords())- ->pluck(0)- ->contains($needle)- );-- return $this;- }- );- }-public function test_requires_permission(){$this->actingAs(User::factory()->create())diff --git a/tests/Feature/Reporting/UnacceptedAssetReportTest.php b/tests/Feature/Reporting/UnacceptedAssetReportTest.phpindex 738e68e5ca..b16c6ecf62 100644--- a/tests/Feature/Reporting/UnacceptedAssetReportTest.php+++ b/tests/Feature/Reporting/UnacceptedAssetReportTest.php@@ -3,44 +3,10 @@namespace Tests\Feature\Reporting;use App\Models\User;-use Illuminate\Testing\TestResponse;-use League\Csv\Reader;-use PHPUnit\Framework\Assert;use Tests\TestCase;class UnacceptedAssetReportTest extends TestCase{- protected function setUp(): void- {- parent::setUp();-- TestResponse::macro(- 'assertSeeTextInStreamedResponse',- function (string $needle) {- Assert::assertTrue(- collect(Reader::createFromString($this->streamedContent())->getRecords())- ->pluck(0)- ->contains($needle)- );-- return $this;- }- );-- TestResponse::macro(- 'assertDontSeeTextInStreamedResponse',- function (string $needle) {- Assert::assertFalse(- collect(Reader::createFromString($this->streamedContent())->getRecords())- ->pluck(0)- ->contains($needle)- );-- return $this;- }- );- }-public function test_permission_required_to_view_unaccepted_asset_report(){$this->actingAs(User::factory()->create())diff --git a/tests/Support/CustomTestMacros.php b/tests/Support/CustomTestMacros.phpindex be9a527f4c..a214d077c5 100644--- a/tests/Support/CustomTestMacros.php+++ b/tests/Support/CustomTestMacros.php@@ -4,6 +4,7 @@ namespace Tests\Support;use Illuminate\Database\Eloquent\Model;use Illuminate\Testing\TestResponse;+use League\Csv\Reader;use PHPUnit\Framework\Assert;use RuntimeException;@@ -148,5 +149,31 @@ trait CustomTestMacrosreturn $this;});++ TestResponse::macro(+ 'assertSeeTextInStreamedResponse',+ function (string $needle) {+ Assert::assertTrue(+ collect(Reader::createFromString($this->streamedContent())->getRecords())+ ->pluck(0)+ ->contains($needle)+ );++ return $this;+ }+ );++ TestResponse::macro(+ 'assertDontSeeTextInStreamedResponse',+ function (string $needle) {+ Assert::assertFalse(+ collect(Reader::createFromString($this->streamedContent())->getRecords())+ ->pluck(0)+ ->contains($needle)+ );++ return $this;+ }+ );}}