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

216 lines
8.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.');
$categories = \App\Models\Category::factory()->times(3)->create();
$types = \App\Models\Type::factory()->times(3)->create();
$resolutions = \App\Models\Resolution::factory()->times(3)->create();
$regions = \App\Models\Region::factory()->times(3)->create();
$distributors = \App\Models\Distributor::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('torrents.create'));
$response->assertOk();
$response->assertViewIs('torrent.create');
$response->assertViewHas('categories', $categories);
$response->assertViewHas('types', $types);
$response->assertViewHas('resolutions', $resolutions);
$response->assertViewHas('regions', $regions);
$response->assertViewHas('distributors', $distributors);
$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.');
$torrent = \App\Models\Torrent::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->delete(route('torrents.destroy', ['id' => $torrent->id]));
$response->assertOk();
$this->assertModelMissing($torrent);
// 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.');
$torrent = \App\Models\Torrent::factory()->create();
$user = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_unless(403)`...
$response = $this->actingAs($user)->delete(route('torrents.destroy', ['id' => $torrent->id]));
$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.');
$torrent = \App\Models\Torrent::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();
$regions = \App\Models\Region::factory()->times(3)->create();
$distributors = \App\Models\Distributor::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('torrents.edit', ['id' => $torrent->id]));
$response->assertOk();
$response->assertViewIs('torrent.edit');
$response->assertViewHas('categories', $categories);
$response->assertViewHas('types', $types);
$response->assertViewHas('resolutions', $resolutions);
$response->assertViewHas('regions', $regions);
$response->assertViewHas('distributors', $distributors);
$response->assertViewHas('keywords');
$response->assertViewHas('torrent', $torrent);
$response->assertViewHas('user', $user);
// TODO: perform additional assertions
});
test('edit 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.');
$torrent = \App\Models\Torrent::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();
$regions = \App\Models\Region::factory()->times(3)->create();
$distributors = \App\Models\Distributor::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_unless(403)`...
$response = $this->actingAs($user)->get(route('torrents.edit', ['id' => $torrent->id]));
$response->assertForbidden();
});
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('torrents.index'));
$response->assertOk();
$response->assertViewIs('torrent.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.');
$torrent = \App\Models\Torrent::factory()->create();
$tv = \App\Models\Tv::factory()->create();
$movie = \App\Models\Movie::factory()->create();
$featuredTorrent = \App\Models\FeaturedTorrent::factory()->create();
$history = \App\Models\History::factory()->create();
$audits = \App\Models\Audit::factory()->times(3)->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->get(route('torrents.show', ['id' => $torrent->id]));
$response->assertOk();
$response->assertViewIs('torrent.show');
$response->assertViewHas('torrent', $torrent);
$response->assertViewHas('user', $user);
$response->assertViewHas('personal_freeleech');
$response->assertViewHas('freeleech_token');
$response->assertViewHas('meta');
$response->assertViewHas('trailer');
$response->assertViewHas('platforms');
$response->assertViewHas('total_tips');
$response->assertViewHas('user_tips');
$response->assertViewHas('featured');
$response->assertViewHas('mediaInfo');
$response->assertViewHas('last_seed_activity');
$response->assertViewHas('playlists');
$response->assertViewHas('audits', $audits);
// TODO: perform additional assertions
});
test('store validates with a form request', function (): void {
$this->assertActionUsesFormRequest(
\App\Http\Controllers\TorrentController::class,
'store',
\App\Http\Requests\StoreTorrentRequest::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.');
$category = \App\Models\Category::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->post(route('torrents.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\TorrentController::class,
'update',
\App\Http\Requests\UpdateTorrentRequest::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.');
$torrent = \App\Models\Torrent::factory()->create();
$user = \App\Models\User::factory()->create();
$response = $this->actingAs($user)->patch(route('torrents.update', ['id' => $torrent->id]), [
// 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.');
$torrent = \App\Models\Torrent::factory()->create();
$user = \App\Models\User::factory()->create();
// TODO: perform additional setup to trigger `abort_unless(403)`...
$response = $this->actingAs($user)->patch(route('torrents.update', ['id' => $torrent->id]), [
// TODO: send request data
]);
$response->assertForbidden();
});
// test cases...