mirror of
https://github.com/snipe/snipe-it.git
synced 2025-10-30 03:42:35 +00:00
Renamed test
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
a5e37519f5
commit
c570f656bf
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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',
|
||||
@ -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))
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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()
|
||||
{
|
||||
17
tests/Feature/Maintenances/Ui/ShowMaintenanceTest.php
Normal file
17
tests/Feature/Maintenances/Ui/ShowMaintenanceTest.php
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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';
|
||||
Loading…
x
Reference in New Issue
Block a user