mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-15 18:14:09 -08:00
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace Tests\Feature\Consumables\Ui;
|
||
|
|
||
|
use App\Models\License;
|
||
|
use App\Models\Depreciation;
|
||
|
use App\Models\User;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
class LicenseViewTest extends TestCase
|
||
|
{
|
||
|
public function testPermissionRequiredToViewLicense()
|
||
|
{
|
||
|
$license = License::factory()->create();
|
||
|
$this->actingAs(User::factory()->create())
|
||
|
->get(route('licenses.show', $license))
|
||
|
->assertForbidden();
|
||
|
}
|
||
|
|
||
|
|
||
|
public function testLicenseWithNoPurchaseDateDoesNotTriggerDepreciation()
|
||
|
{
|
||
|
$depreciation = Depreciation::factory()->create(['months' => 12]);
|
||
|
$license = License::factory()->create(['depreciation_id' => $depreciation->id, 'purchase_date' => null]);
|
||
|
$this->actingAs(User::factory()->superuser()->create())
|
||
|
->get(route('licenses.show', $license))
|
||
|
->assertOk();
|
||
|
}
|
||
|
|
||
|
public function testLicenseWithPurchaseDateDepreciatesCorrectly()
|
||
|
{
|
||
|
$depreciation = Depreciation::factory()->create(['months' => 12]);
|
||
|
$license = License::factory()->create(['depreciation_id' => $depreciation->id, 'purchase_date' => '2020-01-01']);
|
||
|
$this->actingAs(User::factory()->superuser()->create())
|
||
|
->get(route('licenses.show', $license))
|
||
|
->assertOk()
|
||
|
->assertSee([
|
||
|
'2021-01-01'
|
||
|
], false);
|
||
|
}
|
||
|
}
|