mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Add more tests for Asset Model index and store methods
This commit is contained in:
parent
08bd39dbba
commit
672aabf4ac
23
tests/Feature/AssetModels/Ui/AssetModelIndexTest.php
Normal file
23
tests/Feature/AssetModels/Ui/AssetModelIndexTest.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\AssetModels\Ui;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetModelIndexTest extends TestCase
|
||||
{
|
||||
public function testPermissionRequiredToViewAssetModelList()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->get(route('models.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testUserCanListAssetModels()
|
||||
{
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->get(route('models.index'))
|
||||
->assertOk();
|
||||
}
|
||||
}
|
35
tests/Feature/AssetModels/Ui/AssetModelStoreTest.php
Normal file
35
tests/Feature/AssetModels/Ui/AssetModelStoreTest.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\AssetModels\Ui;
|
||||
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetModelStoreTest extends TestCase
|
||||
{
|
||||
public function testPermissionRequiredToStoreAssetModel()
|
||||
{
|
||||
$this->actingAs(User::factory()->create())
|
||||
->post(route('models.store'), [
|
||||
'name' => 'Test Model',
|
||||
'category_id' => Category::factory()->create()->id
|
||||
])
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
public function testUserCanCreateAssetModels()
|
||||
{
|
||||
$this->assertFalse(AssetModel::where('name', 'Test Model')->exists());
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('models.store'), [
|
||||
'name' => 'Test Model',
|
||||
'category_id' => Category::factory()->create()->id
|
||||
])
|
||||
->assertRedirect(route('models.index'));
|
||||
|
||||
$this->assertTrue(AssetModel::where('name', 'Test Model')->exists());
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\AssetModels\Ui;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Company;
|
||||
use App\Models\CustomField;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\Supplier;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AssetModelsTest extends TestCase
|
||||
{
|
||||
public function testUserCanListAssetModels()
|
||||
{
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->get(route('models.index'))
|
||||
->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
public function testUserCanCreateAssetModels()
|
||||
{
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('models.index'), [
|
||||
'name' => 'Test Model',
|
||||
'category_id' => Category::factory()->create()->id
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('models.index'));
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue