Add comprehensive test coverage and update notes
This commit is contained in:
@@ -6,6 +6,30 @@ use App\Models\Thread;
|
||||
use App\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
beforeEach(function (): void {
|
||||
$parserProp = new ReflectionProperty(\App\Actions\BbcodeFormatter::class, 'parser');
|
||||
$parserProp->setAccessible(true);
|
||||
$parserProp->setValue(
|
||||
\Mockery::mock(\s9e\TextFormatter\Parser::class)
|
||||
->shouldReceive('parse')
|
||||
->andReturn('<r/>')
|
||||
->getMock()
|
||||
);
|
||||
|
||||
$rendererProp = new ReflectionProperty(\App\Actions\BbcodeFormatter::class, 'renderer');
|
||||
$rendererProp->setAccessible(true);
|
||||
$rendererProp->setValue(
|
||||
\Mockery::mock(\s9e\TextFormatter\Renderer::class)
|
||||
->shouldReceive('render')
|
||||
->andReturn('<p></p>')
|
||||
->getMock()
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(function (): void {
|
||||
\Mockery::close();
|
||||
});
|
||||
|
||||
function makeForum(): Forum
|
||||
{
|
||||
$category = Forum::create([
|
||||
@@ -80,7 +104,7 @@ it('requires authentication to update a thread', function (): void {
|
||||
'forum_id' => $forum->id,
|
||||
'user_id' => $owner->id,
|
||||
'title' => 'Original',
|
||||
'body' => 'Body',
|
||||
'body' => '',
|
||||
]);
|
||||
|
||||
$response = $this->patchJson("/api/threads/{$thread->id}", [
|
||||
@@ -100,7 +124,7 @@ it('enforces thread update permissions', function (): void {
|
||||
'forum_id' => $forum->id,
|
||||
'user_id' => $owner->id,
|
||||
'title' => 'Original',
|
||||
'body' => 'Body',
|
||||
'body' => '',
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($other);
|
||||
@@ -151,7 +175,7 @@ it('enforces solved status permissions', function (): void {
|
||||
'forum_id' => $forum->id,
|
||||
'user_id' => $owner->id,
|
||||
'title' => 'Original',
|
||||
'body' => 'Body',
|
||||
'body' => '',
|
||||
'solved' => false,
|
||||
]);
|
||||
|
||||
@@ -182,14 +206,14 @@ it('filters threads by forum', function (): void {
|
||||
'forum_id' => $forumA->id,
|
||||
'user_id' => null,
|
||||
'title' => 'Thread A',
|
||||
'body' => 'Body A',
|
||||
'body' => '',
|
||||
]);
|
||||
|
||||
Thread::create([
|
||||
'forum_id' => $forumB->id,
|
||||
'user_id' => null,
|
||||
'title' => 'Thread B',
|
||||
'body' => 'Body B',
|
||||
'body' => '',
|
||||
]);
|
||||
|
||||
$response = $this->getJson("/api/threads?forum=/api/forums/{$forumA->id}");
|
||||
@@ -208,7 +232,7 @@ it('increments views count when showing a thread', function (): void {
|
||||
'forum_id' => $forum->id,
|
||||
'user_id' => null,
|
||||
'title' => 'Viewed Thread',
|
||||
'body' => 'Body',
|
||||
'body' => '',
|
||||
'views_count' => 0,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user