12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Tests\Feature\API;
- use App\Models\Library;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Illuminate\Support\Facades\Auth;
- use Tests\Feature\TestCase;
- class LibraryTest extends TestCase
- {
- public function test_create_library(): void
- {
- $form = Library::factory()->make();
- $form->whitelist = [
- Auth::id(),
- ];
- $response = $this->post(route('library.store'), $form->toArray());
- $response->assertStatus(201);
- }
- public function test_library_update(): void
- {
- $library = Library::factory()->create();
- $form = Library::factory()->make();
- $response = $this->put(route('library.update', ['library' => $library->id]), $form->toArray());
- $response->assertStatus(204);
- $newAsset = Library::find($library->id);
- $this->assertEquals($form->name, $newAsset->name);
- }
- public function test_library_show(): void
- {
- $library = Library::factory()->create();
- $response = $this->get(route('library.show', ['library' => $library->id]));
- $response->assertStatus(200)
- ->assertJsonStructure([
- 'data' => [
- 'id',
- 'name',
- 'asset_id',
- 'project_id',
- 'acl',
- 'whitelist'
- ]
- ]);
- }
- }
|