Skip to content

Commit

Permalink
update: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HDVinnie committed Aug 16, 2023
1 parent 428c0cd commit f2010af
Show file tree
Hide file tree
Showing 40 changed files with 36 additions and 118 deletions.
23 changes: 0 additions & 23 deletions tests/Feature/Console/Commands/AutoGraveyardTest.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,4 @@
$response->assertOk();
$response->assertViewIs('mediahub.person.show');
$response->assertViewHas('person', $person);
$response->assertViewHas('movieCategoryIds');
$response->assertViewHas('tvCategoryIds');
});
42 changes: 18 additions & 24 deletions tests/Feature/Http/Controllers/User/FollowControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 0 additions & 52 deletions tests/Old/FollowControllerTest.php

This file was deleted.

35 changes: 18 additions & 17 deletions tests/Unit/Console/Commands/AutoRewardResurrectionTest.php
Original file line number Diff line number Diff line change
@@ -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
});
File renamed without changes.
File renamed without changes.

0 comments on commit f2010af

Please sign in to comment.