mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-24 05:29:26 -05:00
update: test suite
This commit is contained in:
@@ -1,44 +1,47 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
namespace Tests\Feature\Http\Controllers;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use App\Models\Article;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\GroupsTableSeeder;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @see \App\Http\Controllers\ArticleController
|
||||
*/
|
||||
final class ArticleControllerTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function index_returns_an_ok_response(): void
|
||||
{
|
||||
$this->seed(GroupsTableSeeder::class);
|
||||
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();
|
||||
$articles = Article::factory()->times(3)->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response = $this->actingAs($user)->get(route('articles.index'));
|
||||
$response = $this->actingAs($user)->get(route('articles.index'));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertViewIs('article.index');
|
||||
$response->assertViewHas('articles');
|
||||
}
|
||||
$response->assertOk();
|
||||
$response->assertViewIs('article.index');
|
||||
$response->assertViewHas('articles', $articles);
|
||||
|
||||
#[Test]
|
||||
public function show_returns_an_ok_response(): void
|
||||
{
|
||||
$this->seed(GroupsTableSeeder::class);
|
||||
// TODO: perform additional assertions
|
||||
});
|
||||
|
||||
$article = Article::factory()->create();
|
||||
$user = User::factory()->create();
|
||||
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.');
|
||||
|
||||
$response = $this->actingAs($user)->get(route('articles.show', ['article' => $article]));
|
||||
$article = Article::factory()->create();
|
||||
$user = User::factory()->create();
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertViewIs('article.show');
|
||||
$response->assertViewHas('article');
|
||||
}
|
||||
}
|
||||
$response = $this->actingAs($user)->get(route('articles.show', [$article]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertViewIs('article.show');
|
||||
$response->assertViewHas('article', $article);
|
||||
|
||||
// TODO: perform additional assertions
|
||||
});
|
||||
|
||||
// test cases...
|
||||
|
||||
Reference in New Issue
Block a user