update: tests

This commit is contained in:
HDVinnie
2023-08-16 16:01:18 -04:00
parent 428c0cd070
commit f2010af491
40 changed files with 36 additions and 118 deletions
@@ -1,23 +0,0 @@
<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
/**
* @see \App\Console\Commands\AutoGraveyard
*/
it('runs successfully', function (): void {
$this->artisan('auto:graveyard')
->assertExitCode(0)
->run();
// TODO: perform additional assertions to ensure the command behaved as expected
});
@@ -32,6 +32,4 @@ test('show returns an ok response', function (): void {
$response->assertOk();
$response->assertViewIs('mediahub.person.show');
$response->assertViewHas('person', $person);
$response->assertViewHas('movieCategoryIds');
$response->assertViewHas('tvCategoryIds');
});
@@ -12,50 +12,44 @@
*/
use App\Models\User;
use Database\Seeders\GroupsTableSeeder;
use Database\Seeders\UsersTableSeeder;
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.');
$this->seed(UsersTableSeeder::class);
$this->seed(GroupsTableSeeder::class);
$user = User::factory()->create();
$authUser = User::factory()->create();
$userToFollow = User::factory()->create();
$response = $this->actingAs($authUser)->delete(route('users.followers.destroy', [$user]));
$response = $this->actingAs($user)->delete(route('users.followers.destroy', ['user' => $userToFollow]));
$response->assertRedirect(route('users.show', ['user' => $userToFollow]))
->assertSessionHas('success', sprintf('You are no longer following %s', $userToFollow->username));
$response->assertOk();
$this->assertModelMissing($user);
// TODO: perform additional assertions
$this->assertDatabaseMissing('follows', [
'user_id' => $user->id,
'target_id' => $userToFollow->id,
]);
});
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 = User::factory()->create();
$authUser = User::factory()->create();
$response = $this->actingAs($authUser)->get(route('users.followers.index', [$user]));
$response->assertOk();
$response->assertViewIs('user.follower.index');
$response->assertViewHas('followers');
$response->assertViewHas('user', $user);
// TODO: perform additional assertions
});
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.');
$this->seed(UsersTableSeeder::class);
$this->seed(GroupsTableSeeder::class);
$user = User::factory()->create();
$authUser = User::factory()->create();
$userToFollow = User::factory()->create();
$response = $this->actingAs($authUser)->post(route('users.followers.store', [$user]), [
// TODO: send request data
]);
$response->assertOk();
// TODO: perform additional assertions
$response = $this->actingAs($user)->post(route('users.followers.store', ['user' => $userToFollow]));
$response->assertRedirect(route('users.show', ['user' => $userToFollow]))
->assertSessionHas('success', sprintf('You are now following %s', $userToFollow->username));
});
// test cases...
-52
View File
@@ -1,52 +0,0 @@
<?php
namespace Tests\Old;
use App\Models\User;
use Database\Seeders\GroupsTableSeeder;
use Database\Seeders\UsersTableSeeder;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
/**
* @see \App\Http\Controllers\FollowController
*/
final class FollowControllerTest extends TestCase
{
#[Test]
public function destroy_returns_an_ok_response(): void
{
$this->seed(UsersTableSeeder::class);
$this->seed(GroupsTableSeeder::class);
$user = User::factory()->create();
$userToFollow = User::factory()->create();
$response = $this->actingAs($user)->delete(route('users.followers.destroy', ['user' => $userToFollow]));
$response->assertRedirect(route('users.show', ['user' => $userToFollow]))
->assertSessionHas('success', sprintf('You are no longer following %s', $userToFollow->username));
$this->assertDatabaseMissing('follows', [
'user_id' => $user->id,
'target_id' => $userToFollow->id,
]);
}
#[Test]
public function store_returns_an_ok_response(): void
{
$this->seed(UsersTableSeeder::class);
$this->seed(GroupsTableSeeder::class);
$user = User::factory()->create();
$userToFollow = User::factory()->create();
$response = $this->actingAs($user)->post(route('users.followers.store', ['user' => $userToFollow]));
$response->assertRedirect(route('users.show', ['user' => $userToFollow]))
->assertSessionHas('success', sprintf('You are now following %s', $userToFollow->username));
}
}
@@ -1,22 +1,23 @@
<?php
namespace Tests\Unit\Console\Commands;
use Tests\TestCase;
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
/**
* @see \App\Console\Commands\AutoRewardResurrection
*/
class AutoRewardResurrectionTest extends TestCase
{
/**
* @test
*/
public function it_runs_successfully(): void
{
$this->artisan('auto:reward_resurrection')
->expectsOutput('Automated Reward Resurrections Command Complete')
->assertExitCode(0)
->run();
}
}
it('runs successfully', function (): void {
$this->artisan('auto:reward_resurrection')
->assertExitCode(0)
->run();
// TODO: perform additional assertions to ensure the command behaved as expected
});