Skip to content

A free open source IT asset/license management system

Renamed test

snipec570f656bf33
diff --git a/tests/Feature/AssetMaintenances/Ui/ShowAssetMaintenanceTest.php b/tests/Feature/AssetMaintenances/Ui/ShowAssetMaintenanceTest.php
deleted file mode 100644
index da9ef8fa40..0000000000
--- a/tests/Feature/AssetMaintenances/Ui/ShowAssetMaintenanceTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Tests\Feature\AssetMaintenances\Ui;
-
-use App\Models\AssetMaintenance;
-use App\Models\User;
-use Tests\TestCase;
-
-class ShowAssetMaintenanceTest extends TestCase
-{
- public function testPageRenders()
- {
- $this->actingAs(User::factory()->superuser()->create())
- ->get(route('maintenances.show', AssetMaintenance::factory()->create()->id))
- ->assertOk();
- }
-}
diff --git a/tests/Feature/AssetMaintenances/Api/CreateAssetMaintenanceTest.php b/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
similarity index 77%
rename from tests/Feature/AssetMaintenances/Api/CreateAssetMaintenanceTest.php
rename to tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
index 509ecf6102..f2872e9e41 100644
--- a/tests/Feature/AssetMaintenances/Api/CreateAssetMaintenanceTest.php
+++ b/tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
@@ -1,9 +1,9 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Api;
+namespace Tests\Feature\Maintenances\Api;
use App\Models\Asset;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use App\Models\Category;
use App\Models\Supplier;
use App\Models\User;
@@ -12,17 +12,17 @@ use Illuminate\Support\Facades\Storage;
use Illuminate\Testing\Fluent\AssertableJson;
use Tests\TestCase;
-class CreateAssetMaintenanceTest extends TestCase
+class CreateMaintenanceTest extends TestCase
{
- public function testRequiresPermissionToCreateAssetMaintenance()
+ public function testRequiresPermissionToCreateMaintenance()
{
$this->actingAsForApi(User::factory()->create())
->postJson(route('api.maintenances.store'))
->assertForbidden();
}
- public function testCanCreateAssetMaintenance()
+ public function testCanCreateMaintenance()
{
Storage::fake('public');
@@ -33,7 +33,7 @@ class CreateAssetMaintenanceTest extends TestCase
$response = $this->actingAsForApi($actor)
->postJson(route('api.maintenances.store'), [
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
@@ -48,16 +48,16 @@ class CreateAssetMaintenanceTest extends TestCase
->assertStatus(200);
// Since we rename the file in the ImageUploadRequest, we have to fetch the record from the database
- $assetMaintenance = AssetMaintenance::where('title', 'Test Maintenance')->first();
+ $assetMaintenance = Maintenance::where('title', 'Test Maintenance')->first();
// Assert file was stored...
- Storage::disk('public')->assertExists(app('asset_maintenances_path').$assetMaintenance->image);
+ Storage::disk('public')->assertExists(app('maintenances_path').$assetMaintenance->image);
$this->assertDatabaseHas('asset_maintenances', [
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'is_warranty' => 1,
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
diff --git a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php b/tests/Feature/Maintenances/Api/DeleteMaintenancesTest.php
similarity index 78%
rename from tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php
rename to tests/Feature/Maintenances/Api/DeleteMaintenancesTest.php
index 8a0189bc5b..b8f34e3c63 100644
--- a/tests/Feature/AssetMaintenances/Api/DeleteAssetMaintenancesTest.php
+++ b/tests/Feature/Maintenances/Api/DeleteMaintenancesTest.php
@@ -1,19 +1,19 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Api;
+namespace Tests\Feature\Maintenances\Api;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use App\Models\Company;
use App\Models\User;
use Tests\Concerns\TestsFullMultipleCompaniesSupport;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
-class DeleteAssetMaintenancesTest extends TestCase implements TestsFullMultipleCompaniesSupport, TestsPermissionsRequirement
+class DeleteMaintenancesTest extends TestCase implements TestsFullMultipleCompaniesSupport, TestsPermissionsRequirement
{
public function testRequiresPermission()
{
- $assetMaintenance = AssetMaintenance::factory()->create();
+ $assetMaintenance = Maintenance::factory()->create();
$this->actingAsForApi(User::factory()->create())
->deleteJson(route('api.maintenances.destroy', $assetMaintenance))
@@ -26,9 +26,9 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsFullMultipleC
{
[$companyA, $companyB] = Company::factory()->count(2)->create();
- $assetMaintenanceA = AssetMaintenance::factory()->create();
- $assetMaintenanceB = AssetMaintenance::factory()->create();
- $assetMaintenanceC = AssetMaintenance::factory()->create();
+ $assetMaintenanceA = Maintenance::factory()->create();
+ $assetMaintenanceB = Maintenance::factory()->create();
+ $assetMaintenanceC = Maintenance::factory()->create();
$assetMaintenanceA->asset->update(['company_id' => $companyA->id]);
$assetMaintenanceB->asset->update(['company_id' => $companyB->id]);
@@ -57,9 +57,9 @@ class DeleteAssetMaintenancesTest extends TestCase implements TestsFullMultipleC
$this->assertSoftDeleted($assetMaintenanceC);
}
- public function testCanDeleteAssetMaintenance()
+ public function testCanDeleteMaintenance()
{
- $assetMaintenance = AssetMaintenance::factory()->create();
+ $assetMaintenance = Maintenance::factory()->create();
$this->actingAsForApi(User::factory()->editAssets()->create())
->deleteJson(route('api.maintenances.destroy', $assetMaintenance))
diff --git a/tests/Feature/AssetMaintenances/Api/EditAssetMaintenanceTest.php b/tests/Feature/Maintenances/Api/EditMaintenanceTest.php
similarity index 75%
rename from tests/Feature/AssetMaintenances/Api/EditAssetMaintenanceTest.php
rename to tests/Feature/Maintenances/Api/EditMaintenanceTest.php
index e6c84f3088..4aec56efa7 100644
--- a/tests/Feature/AssetMaintenances/Api/EditAssetMaintenanceTest.php
+++ b/tests/Feature/Maintenances/Api/EditMaintenanceTest.php
@@ -1,37 +1,37 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Api;
+namespace Tests\Feature\Maintenances\Api;
use App\Models\Asset;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
-class EditAssetMaintenanceTest extends TestCase
+class EditMaintenanceTest extends TestCase
{
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('maintenances.update', AssetMaintenance::factory()->create()->id))
+ ->get(route('maintenances.update', Maintenance::factory()->create()->id))
->assertOk();
}
- public function testCanEditAssetMaintenance()
+ public function testCanEditMaintenance()
{
Storage::fake('public');
$actor = User::factory()->superuser()->create();
$asset = Asset::factory()->create();
$supplier = Supplier::factory()->create();
- $maintenance = AssetMaintenance::factory()->create();
+ $maintenance = Maintenance::factory()->create();
$response = $this->actingAs($actor)
->followingRedirects()
->patch(route('maintenances.update', $maintenance), [
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
'start_date' => '2021-01-01',
@@ -46,13 +46,13 @@ class EditAssetMaintenanceTest extends TestCase
$maintenance->refresh();
// Assert file was stored...
- Storage::disk('public')->assertExists(app('asset_maintenances_path').$maintenance->image);
+ Storage::disk('public')->assertExists(app('maintenances_path').$maintenance->image);
$this->assertDatabaseHas('asset_maintenances', [
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'is_warranty' => 1,
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
diff --git a/tests/Feature/AssetMaintenances/Ui/CreateAssetMaintenanceTest.php b/tests/Feature/Maintenances/Ui/CreateMaintenanceTest.php
similarity index 79%
rename from tests/Feature/AssetMaintenances/Ui/CreateAssetMaintenanceTest.php
rename to tests/Feature/Maintenances/Ui/CreateMaintenanceTest.php
index 5ccf70eddb..03f618ac8c 100644
--- a/tests/Feature/AssetMaintenances/Ui/CreateAssetMaintenanceTest.php
+++ b/tests/Feature/Maintenances/Ui/CreateMaintenanceTest.php
@@ -1,16 +1,16 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Ui;
+namespace Tests\Feature\Maintenances\Ui;
use App\Models\Asset;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
-class CreateAssetMaintenanceTest extends TestCase
+class CreateMaintenanceTest extends TestCase
{
public function testPageRenders()
{
@@ -20,7 +20,7 @@ class CreateAssetMaintenanceTest extends TestCase
}
- public function testCanCreateAssetMaintenance()
+ public function testCanCreateMaintenance()
{
Storage::fake('public');
$actor = User::factory()->superuser()->create();
@@ -31,7 +31,7 @@ class CreateAssetMaintenanceTest extends TestCase
$this->actingAs($actor)
->followingRedirects()
->post(route('maintenances.store'), [
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'selected_assets' => [$asset->id],
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
@@ -45,17 +45,17 @@ class CreateAssetMaintenanceTest extends TestCase
->assertOk();
// Since we rename the file in the ImageUploadRequest, we have to fetch the record from the database
- $assetMaintenance = AssetMaintenance::where('title', 'Test Maintenance')->first();
+ $assetMaintenance = Maintenance::where('title', 'Test Maintenance')->first();
// Assert file was stored...
- Storage::disk('public')->assertExists(app('asset_maintenances_path').$assetMaintenance->image);
+ Storage::disk('public')->assertExists(app('maintenances_path').$assetMaintenance->image);
$this->assertDatabaseHas('asset_maintenances', [
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'is_warranty' => 1,
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
diff --git a/tests/Feature/AssetMaintenances/Ui/EditAssetMaintenanceTest.php b/tests/Feature/Maintenances/Ui/EditMaintenanceTest.php
similarity index 72%
rename from tests/Feature/AssetMaintenances/Ui/EditAssetMaintenanceTest.php
rename to tests/Feature/Maintenances/Ui/EditMaintenanceTest.php
index e898cc4990..9b18ad629b 100644
--- a/tests/Feature/AssetMaintenances/Ui/EditAssetMaintenanceTest.php
+++ b/tests/Feature/Maintenances/Ui/EditMaintenanceTest.php
@@ -1,35 +1,35 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Ui;
+namespace Tests\Feature\Maintenances\Ui;
use App\Models\Asset;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use App\Models\Supplier;
use App\Models\User;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
-class EditAssetMaintenanceTest extends TestCase
+class EditMaintenanceTest extends TestCase
{
public function testPageRenders()
{
$this->actingAs(User::factory()->superuser()->create())
- ->get(route('maintenances.edit', AssetMaintenance::factory()->create()->id))
+ ->get(route('maintenances.edit', Maintenance::factory()->create()->id))
->assertOk();
}
- public function testCanUpdateAssetMaintenance()
+ public function testCanUpdateMaintenance()
{
$actor = User::factory()->superuser()->create();
$asset = Asset::factory()->create();
- $assetMaintenance = AssetMaintenance::factory()->create(['asset_id' => $asset]);
+ $assetMaintenance = Maintenance::factory()->create(['asset_id' => $asset]);
$supplier = Supplier::factory()->create();
$this->actingAs($actor)
->followingRedirects()
->put(route('maintenances.update', $assetMaintenance), [
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
@@ -43,16 +43,16 @@ class EditAssetMaintenanceTest extends TestCase
->assertOk();
// Since we rename the file in the ImageUploadRequest, we have to fetch the record from the database
- $assetMaintenance = AssetMaintenance::where('title', 'Test Maintenance')->first();
+ $assetMaintenance = Maintenance::where('title', 'Test Maintenance')->first();
// Assert file was stored...
- Storage::disk('public')->assertExists(app('asset_maintenances_path').$assetMaintenance->image);
+ Storage::disk('public')->assertExists(app('maintenances_path').$assetMaintenance->image);
$this->assertDatabaseHas('asset_maintenances', [
'asset_id' => $asset->id,
'supplier_id' => $supplier->id,
'asset_maintenance_type' => 'Maintenance',
- 'title' => 'Test Maintenance',
+ 'name' => 'Test Maintenance',
'is_warranty' => 1,
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
diff --git a/tests/Feature/AssetMaintenances/Ui/AssetMaintenanceIndexTest.php b/tests/Feature/Maintenances/Ui/MaintenanceIndexTest.php
similarity index 71%
rename from tests/Feature/AssetMaintenances/Ui/AssetMaintenanceIndexTest.php
rename to tests/Feature/Maintenances/Ui/MaintenanceIndexTest.php
index 4f87690008..b6e3793e5e 100644
--- a/tests/Feature/AssetMaintenances/Ui/AssetMaintenanceIndexTest.php
+++ b/tests/Feature/Maintenances/Ui/MaintenanceIndexTest.php
@@ -1,11 +1,11 @@
<?php
-namespace Tests\Feature\AssetMaintenances\Ui;
+namespace Tests\Feature\Maintenances\Ui;
use App\Models\User;
use Tests\TestCase;
-class AssetMaintenanceIndexTest extends TestCase
+class MaintenanceIndexTest extends TestCase
{
public function testPageRenders()
{
diff --git a/tests/Feature/Maintenances/Ui/ShowMaintenanceTest.php b/tests/Feature/Maintenances/Ui/ShowMaintenanceTest.php
new file mode 100644
index 0000000000..fb366d1d54
--- /dev/null
+++ b/tests/Feature/Maintenances/Ui/ShowMaintenanceTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Tests\Feature\Maintenances\Ui;
+
+use App\Models\Maintenance;
+use App\Models\User;
+use Tests\TestCase;
+
+class ShowMaintenanceTest extends TestCase
+{
+ public function testPageRenders()
+ {
+ $this->actingAs(User::factory()->superuser()->create())
+ ->get(route('maintenances.show', Maintenance::factory()->create()->id))
+ ->assertOk();
+ }
+}
diff --git a/tests/Unit/AssetMaintenanceTest.php b/tests/Unit/MaintenanceTest.php
similarity index 82%
rename from tests/Unit/AssetMaintenanceTest.php
rename to tests/Unit/MaintenanceTest.php
index 46a0efdd7c..e0faf4a03f 100644
--- a/tests/Unit/AssetMaintenanceTest.php
+++ b/tests/Unit/MaintenanceTest.php
@@ -1,14 +1,14 @@
<?php
namespace Tests\Unit;
-use App\Models\AssetMaintenance;
+use App\Models\Maintenance;
use Tests\TestCase;
-class AssetMaintenanceTest extends TestCase
+class MaintenanceTest extends TestCase
{
public function testZerosOutWarrantyIfBlank()
{
- $c = new AssetMaintenance;
+ $c = new Maintenance;
$c->is_warranty = '';
$this->assertTrue($c->is_warranty === 0);
$c->is_warranty = '4';
@@ -17,7 +17,7 @@ class AssetMaintenanceTest extends TestCase
public function testSetsCostsAppropriately()
{
- $c = new AssetMaintenance();
+ $c = new Maintenance();
$c->cost = '0.00';
$this->assertTrue($c->cost === null);
$c->cost = '9.54';
@@ -28,7 +28,7 @@ class AssetMaintenanceTest extends TestCase
public function testNullsOutNotesIfBlank()
{
- $c = new AssetMaintenance;
+ $c = new Maintenance;
$c->notes = '';
$this->assertTrue($c->notes === null);
$c->notes = 'This is a long note';
@@ -37,7 +37,7 @@ class AssetMaintenanceTest extends TestCase
public function testNullsOutCompletionDateIfBlankOrInvalid()
{
- $c = new AssetMaintenance;
+ $c = new Maintenance;
$c->completion_date = '';
$this->assertTrue($c->completion_date === null);
$c->completion_date = '0000-00-00';