Files
UNIT3D/tests/Feature/Http/Controllers/RequestControllerTest.php
2023-07-11 18:27:15 +00:00

175 lines
6.4 KiB
PHP

<?php
uses(RefreshDatabase::class);
test('create returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$category = \App\Models\Category::factory()->create();
$categories = \App\Models\Category::factory()->times(3)->create();
$types = \App\Models\Type::factory()->times(3)->create();
$resolutions = \App\Models\Resolution::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('requests.create'));
$response->assertOk();
$response->assertViewIs('requests.create');
$response->assertViewHas('categories', $categories);
$response->assertViewHas('types', $types);
$response->assertViewHas('resolutions', $resolutions);
$response->assertViewHas('user', $user);
$response->assertViewHas('category_id');
$response->assertViewHas('title');
$response->assertViewHas('imdb');
$response->assertViewHas('tmdb');
$response->assertViewHas('mal');
$response->assertViewHas('tvdb');
$response->assertViewHas('igdb');
// TODO: perform additional assertions
});
test('destroy returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->delete(route('requests.destroy', [$torrentRequest]));
$response->assertOk();
$this->assertModelMissing($torrentRequest);
// TODO: perform additional assertions
});
test('destroy aborts with a 403', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$user = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_unless(403)`...
$response = $this->actingAs($user)->delete(route('requests.destroy', [$torrentRequest]));
$response->assertForbidden();
});
test('edit returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$categories = \App\Models\Category::factory()->times(3)->create();
$types = \App\Models\Type::factory()->times(3)->create();
$resolutions = \App\Models\Resolution::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('requests.edit', [$torrentRequest]));
$response->assertOk();
$response->assertViewIs('requests.edit');
$response->assertViewHas('categories', $categories);
$response->assertViewHas('types', $types);
$response->assertViewHas('resolutions', $resolutions);
$response->assertViewHas('user', $user);
$response->assertViewHas('torrentRequest', $torrentRequest);
// TODO: perform additional assertions
});
test('index returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('requests.index'));
$response->assertOk();
$response->assertViewIs('requests.index');
// TODO: perform additional assertions
});
test('show returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$tv = \App\Models\Tv::factory()->create();
$movie = \App\Models\Movie::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('requests.show', [$torrentRequest]));
$response->assertOk();
$response->assertViewIs('requests.show');
$response->assertViewHas('torrentRequest', $torrentRequest);
$response->assertViewHas('user', $user);
$response->assertViewHas('meta');
// TODO: perform additional assertions
});
test('store validates with a form request', function (): void {
$this->assertActionUsesFormRequest(
\App\Http\Controllers\RequestController::class,
'store',
\App\Http\Requests\StoreTorrentRequestRequest::class
);
});
test('store returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->post(route('requests.store'), [
// TODO: send request data
]);
$response->assertOk();
// TODO: perform additional assertions
});
test('update validates with a form request', function (): void {
$this->assertActionUsesFormRequest(
\App\Http\Controllers\RequestController::class,
'update',
\App\Http\Requests\UpdateTorrentRequestRequest::class
);
});
test('update returns an ok response', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->patch(route('requests.update', [$torrentRequest]), [
// TODO: send request data
]);
$response->assertOk();
// TODO: perform additional assertions
});
test('update aborts with a 403', function (): void {
$this->markTestIncomplete('This test case was generated by Shift. When you are ready, remove this line and complete this test case.');
$torrentRequest = \App\Models\TorrentRequest::factory()->create();
$user = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_unless(403)`...
$response = $this->actingAs($user)->patch(route('requests.update', [$torrentRequest]), [
// TODO: send request data
]);
$response->assertForbidden();
});
// test cases...