A free open source IT asset/license management system
Mooooar tests
snipe0656d9b59340
diff --git a/tests/Feature/Importing/Api/ImportComponentsTest.php b/tests/Feature/Importing/Api/ImportComponentsTest.phpindex 7cc6f79a7e..b2673bc051 100644--- a/tests/Feature/Importing/Api/ImportComponentsTest.php+++ b/tests/Feature/Importing/Api/ImportComponentsTest.php@@ -351,6 +351,25 @@ class ImportComponentsTest extends ImportDataTestCase implements TestsPermission$this->assertTrue((bool) $component->requestable);}+ #[Test]+ public function import_persists_the_archived_flag_from_csv(): void+ {+ $this->actingAsForApi(User::factory()->superuser()->create());++ $importFileBuilder = ImportFileBuilder::new(['archived' => 'TRUE']);+ $row = $importFileBuilder->firstRow();+ $import = Import::factory()->component()->create([+ 'file_path' => $importFileBuilder->saveToImportsDirectory(),+ ]);++ $this->importFileResponse(['import' => $import->id])->assertOk();++ $component = Component::query()+ ->where('name', $row['itemName'])+ ->sole();+ $this->assertTrue((bool) $component->archived);+ }+#[Test]public function update_mode_logs_component_update_in_actionlog(): void{diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.phpindex b199468f87..f4bc8dcd00 100644--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php@@ -618,6 +618,53 @@ class CustomComponentReportTest extends TestCase->assertSeeTextInStreamedResponse('Deleted Component');}+ public function test_archived_component_is_included_by_default()+ {+ Component::factory()->archived()->create(['name' => 'Archived Component']);+ Component::factory()->create(['name' => 'Live Component']);++ $this->sendRequest([+ 'component_name' => '1',+ ])+ ->assertOk()+ ->assertCsvHeader()+ ->assertSeeTextInStreamedResponse('Live Component')+ ->assertSeeTextInStreamedResponse('Archived Component');+ }++ public function test_exclude_archived_filters_out_archived_components()+ {+ Component::factory()->archived()->create(['name' => 'Archived Component']);+ Component::factory()->create(['name' => 'Live Component']);++ $this->sendRequest([+ 'component_name' => '1',+ 'exclude_archived' => '1',+ ])+ ->assertOk()+ ->assertCsvHeader()+ ->assertSeeTextInStreamedResponse('Live Component')+ ->assertDontSeeTextInStreamedResponse('Archived Component');+ }++ public function test_archived_output_column_renders_yes_and_no()+ {+ Component::factory()->archived()->create(['name' => 'Archived Row']);+ Component::factory()->create(['name' => 'Live Row']);++ $response = $this->sendRequest([+ 'component_name' => '1',+ 'archived' => '1',+ ])+ ->assertOk()+ ->assertCsvHeader();++ $body = $response->streamedContent();+ $this->assertStringContainsString('Archived', $body);+ $this->assertStringContainsString(trans('general.yes'), $body);+ $this->assertStringContainsString(trans('general.no'), $body);+ }+public function test_does_not_included_assignments_by_default(){[$assetA, $assetB] = Asset::factory()diff --git a/tests/Support/Importing/ComponentsImportFileBuilder.php b/tests/Support/Importing/ComponentsImportFileBuilder.phpindex 49968668ef..d519e4d3f2 100644--- a/tests/Support/Importing/ComponentsImportFileBuilder.php+++ b/tests/Support/Importing/ComponentsImportFileBuilder.php@@ -44,6 +44,7 @@ class ComponentsImportFileBuilder extends FileBuilder'quantity' => 'Quantity','serialNumber' => 'Serial number','requestable' => 'Requestable',+ 'archived' => 'Archived',];}@@ -67,6 +68,7 @@ class ComponentsImportFileBuilder extends FileBuilder'quantity' => rand(1, 100_000),'serialNumber' => 'SN:COM:'.Str::random(),'requestable' => '',+ 'archived' => '',];}}