Skip to content

A free open source IT asset/license management system

Add csv header helper

Marcus Moore5d88c27c49bf
diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
index 6c8ef64eb3..65bb54be76 100644
--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
@@ -93,7 +93,7 @@ class CustomComponentReportTest extends TestCase
'asset_serial' => '1',
])
->assertOk()
- ->assertHeader('content-type', 'text/csv; charset=utf-8')
+ ->assertCsvHeader()
->assertSeeTextInStreamedResponse([
trans('general.id'),
trans('general.company'),
@@ -135,7 +135,7 @@ class CustomComponentReportTest extends TestCase
// company and category intentionally omitted
])
->assertOk()
- ->assertHeader('content-type', 'text/csv; charset=utf-8')
+ ->assertCsvHeader()
->assertDontSeeTextInStreamedResponse([
trans('general.company'),
trans('general.category'),
@@ -164,7 +164,7 @@ class CustomComponentReportTest extends TestCase
],
])
->assertOk()
- ->assertHeader('content-type', 'text/csv; charset=utf-8')
+ ->assertCsvHeader()
->assertSeeTextInStreamedResponse('Component for Company A')
->assertDontSeeTextInStreamedResponse('Component for Company B');
}
@@ -193,7 +193,7 @@ class CustomComponentReportTest extends TestCase
$this->actingAs(User::factory()->canViewReports()->create())
->post(route('reports.custom.component.run'), $data)
->assertOk()
- ->assertHeader('content-type', 'text/csv; charset=utf-8')
+ ->assertCsvHeader()
->assertSeeTextInStreamedResponse('Category for Company A')
->assertDontSeeTextInStreamedResponse('Category for Company B');
}
diff --git a/tests/Support/CustomTestMacros.php b/tests/Support/CustomTestMacros.php
index 22045e7fac..f545310a69 100644
--- a/tests/Support/CustomTestMacros.php
+++ b/tests/Support/CustomTestMacros.php
@@ -187,5 +187,14 @@ trait CustomTestMacros
return $this;
}
);
+
+ TestResponse::macro(
+ 'assertCsvHeader',
+ function () {
+ $this->assertHeader('content-type', 'text/csv; charset=utf-8');
+
+ return $this;
+ }
+ );
}
}