Initial commit
This commit is contained in:
62
tests/Feature/Catalog/EdiBandControllerTest.php
Normal file
62
tests/Feature/Catalog/EdiBandControllerTest.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Catalog;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EdiBandControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_index_returns_edi_bands(): void
|
||||
{
|
||||
$item = $this->createEdiBand();
|
||||
|
||||
$response = $this->getJson('/api/edi-bands');
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonFragment(['id' => $item->id]);
|
||||
}
|
||||
|
||||
public function test_show_returns_edi_band(): void
|
||||
{
|
||||
$item = $this->createEdiBand();
|
||||
|
||||
$response = $this->getJson("/api/edi-bands/{$item->id}");
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonFragment(['id' => $item->id]);
|
||||
}
|
||||
|
||||
public function test_admin_can_create_update_and_delete_edi_band(): void
|
||||
{
|
||||
$this->actingAsAdmin();
|
||||
|
||||
$createResponse = $this->postJson('/api/edi-bands', [
|
||||
'value' => 'EDI-144',
|
||||
]);
|
||||
|
||||
$createResponse->assertStatus(201);
|
||||
$itemId = $createResponse->json('id');
|
||||
|
||||
$updateResponse = $this->putJson("/api/edi-bands/{$itemId}", [
|
||||
'value' => 'EDI-432',
|
||||
]);
|
||||
|
||||
$updateResponse->assertStatus(200)
|
||||
->assertJsonFragment(['id' => $itemId]);
|
||||
|
||||
$this->deleteJson("/api/edi-bands/{$itemId}")
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
public function test_non_admin_cannot_create_edi_band(): void
|
||||
{
|
||||
$this->actingAsUser();
|
||||
|
||||
$this->postJson('/api/edi-bands', [
|
||||
'value' => 'EDI-144',
|
||||
])->assertStatus(403);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user