Skip to content

Commit

Permalink
chore: continue what's left
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Apr 28, 2024
1 parent 1ca5614 commit be4c4dd
Show file tree
Hide file tree
Showing 32 changed files with 110 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@

use Carbon\Carbon;
use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\Post;
use Flarum\User\User;

trait InteractsWithUnapprovedContent
{
protected function prepareUnapprovedDatabaseContent()
{
$this->prepareDatabase([
'users' => [
User::class => [
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
$this->normalUser(),
['id' => 3, 'username' => 'acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
Expand Down Expand Up @@ -47,7 +49,7 @@ protected function prepareUnapprovedDatabaseContent()
['id' => 10, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 0, 'is_approved' => 1, 'number' => 4],
['id' => 11, 'discussion_id' => 7, 'user_id' => 4, 'type' => 'comment', 'content' => '<t><p>Text</p></t>', 'is_private' => 1, 'is_approved' => 0, 'number' => 5],
],
'groups' => [
Group::class => [
['id' => 4, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0]
],
'group_user' => [
Expand Down
3 changes: 2 additions & 1 deletion extensions/flags/tests/integration/api/flags/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class ListTest extends TestCase
Expand All @@ -30,7 +31,7 @@ protected function setUp(): void
$this->extension('flarum-flags');

$this->prepareDatabase([
'users' => [
User::class => [
$this->normalUser(),
[
'id' => 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class ListWithTagsTest extends TestCase
Expand All @@ -31,13 +33,13 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => [
Tag::class => [
['id' => 1, 'name' => 'Unrestricted', 'slug' => '1', 'position' => 0, 'parent_id' => null],
['id' => 2, 'name' => 'Mods can view discussions', 'slug' => '2', 'position' => 0, 'parent_id' => null, 'is_restricted' => true],
['id' => 3, 'name' => 'Mods can view flags', 'slug' => '3', 'position' => 0, 'parent_id' => null, 'is_restricted' => true],
['id' => 4, 'name' => 'Mods can view discussions and flags', 'slug' => '4', 'position' => 0, 'parent_id' => null, 'is_restricted' => true],
],
'users' => [
User::class => [
$this->normalUser(),
[
'id' => 3,
Expand Down
6 changes: 4 additions & 2 deletions extensions/likes/tests/integration/api/LikePostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

use Carbon\Carbon;
use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Psr\Http\Message\ResponseInterface;

class LikePostTest extends TestCase
Expand All @@ -28,7 +30,7 @@ protected function setUp(): void
$this->extension('flarum-likes');

$this->prepareDatabase([
'users' => [
User::class => [
['id' => 1, 'username' => 'Muralf', 'email' => 'muralf@machine.local', 'is_email_confirmed' => 1],
$this->normalUser(),
['id' => 3, 'username' => 'Acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
Expand All @@ -42,7 +44,7 @@ protected function setUp(): void
['id' => 5, 'number' => 3, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 3, 'type' => 'discussionRenamed', 'content' => '<t><p>something</p></t>'],
['id' => 6, 'number' => 4, 'discussion_id' => 1, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>something</p></t>'],
],
'groups' => [
Group::class => [
['id' => 5, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0],
['id' => 6, 'name_singular' => 'Acme1', 'name_plural' => 'Acme1', 'is_hidden' => 0]
],
Expand Down
3 changes: 2 additions & 1 deletion extensions/likes/tests/integration/api/ListPostsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class ListPostsTest extends TestCase
Expand All @@ -38,7 +39,7 @@ protected function setUp(): void
Post::class => [
['id' => 101, 'discussion_id' => 100, 'created_at' => Carbon::now(), 'user_id' => 1, 'type' => 'comment', 'content' => '<t><p>text</p></t>'],
],
'users' => [
User::class => [
$this->normalUser(),
['id' => 102, 'username' => 'user102', 'email' => '102@machine.local', 'is_email_confirmed' => 1],
['id' => 103, 'username' => 'user103', 'email' => '103@machine.local', 'is_email_confirmed' => 1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function setUp(): void
['group_id' => Group::MEMBER_ID, 'permission' => 'postWithoutThrottle'],
['group_id' => 9, 'permission' => 'mentionGroups'],
],
'groups' => [
Group::class => [
['id' => 9, 'name_singular' => 'HasPermissionToMentionGroups', 'name_plural' => 'test'],
['id' => 10, 'name_singular' => 'Hidden', 'name_plural' => 'Ninjas', 'icon' => 'fas fa-wrench', 'color' => '#000', 'is_hidden' => 1],
['id' => 11, 'name_singular' => 'Fresh Name', 'name_plural' => 'Fresh Name', 'color' => '#ccc', 'icon' => 'fas fa-users', 'is_hidden' => 0]
Expand Down
3 changes: 2 additions & 1 deletion extensions/mentions/tests/integration/api/ListPostsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Flarum\Post\Post;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class ListPostsTest extends TestCase
Expand Down Expand Up @@ -45,7 +46,7 @@ protected function setUp(): void
['post_id' => 3, 'mentions_user_id' => 1],
['post_id' => 4, 'mentions_user_id' => 2]
],
'users' => [
User::class => [
$this->normalUser(),
]
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function setUp(): void
$this->extension('flarum-mentions');

$this->prepareDatabase([
'users' => [
User::class => [
['id' => 3, 'username' => 'potato', 'email' => 'potato@machine.local', 'is_email_confirmed' => 1],
['id' => 4, 'username' => 'toby', 'email' => 'toby@machine.local', 'is_email_confirmed' => 1],
['id' => 5, 'username' => 'bad_user', 'email' => 'bad_user@machine.local', 'is_email_confirmed' => 1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Flarum\Group\Group;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
Expand Down Expand Up @@ -42,7 +43,7 @@ protected function setUp(): void
['id' => 8, 'number' => 6, 'discussion_id' => 2, 'created_at' => Carbon::now(), 'user_id' => 4, 'type' => 'comment', 'content' => '<r><TAGMENTION id="2020" slug="i_am_a_deleted_tag" tagname="i_am_a_deleted_tag">#i_am_a_deleted_tag</TAGMENTION></r>'],
['id' => 10, 'number' => 11, 'discussion_id' => 2, 'created_at' => Carbon::now(), 'user_id' => 4, 'type' => 'comment', 'content' => '<r><TAGMENTION id="5" slug="laravel">#laravel</TAGMENTION></r>'],
],
'tags' => [
Tag::class => [
['id' => 1, 'name' => 'Test', 'slug' => 'test', 'is_restricted' => 0],
['id' => 2, 'name' => 'Flarum', 'slug' => 'flarum', 'is_restricted' => 0],
['id' => 3, 'name' => 'Support', 'slug' => 'support', 'is_restricted' => 0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected function setUp(): void

$this->extension('flarum-nicknames');
$this->prepareDatabase([
'users' => [
User::class => [
$this->normalUser(),
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Carbon\Carbon;
use Flarum\Discussion\Discussion;
use Flarum\Tags\Tag;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
Expand Down Expand Up @@ -42,7 +43,7 @@ protected function setUp(): void
['discussion_id' => 1, 'user_id' => 3, 'last_read_post_number' => 1],
['discussion_id' => 3, 'user_id' => 3, 'last_read_post_number' => 1],
],
'tags' => [
Tag::class => [
['id' => 1, 'slug' => 'general', 'position' => 0, 'parent_id' => null]
],
'discussion_tag' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Flarum\Suspend\Tests\integration\api\users;

use Carbon\Carbon;
use Flarum\Group\Group;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
Expand All @@ -31,7 +32,7 @@ protected function setUp(): void
$this->normalUser(),
['id' => 3, 'username' => 'acme', 'email' => 'acme@machine.local', 'is_email_confirmed' => 1],
],
'groups' => [
Group::class => [
['id' => 5, 'name_singular' => 'Acme', 'name_plural' => 'Acme', 'is_hidden' => 0]
],
'group_user' => [
Expand Down
2 changes: 2 additions & 0 deletions extensions/tags/src/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Flarum\User\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
Expand Down Expand Up @@ -51,6 +52,7 @@
class Tag extends AbstractModel
{
use ScopeVisibilityTrait;
use HasFactory;

protected $table = 'tags';

Expand Down
32 changes: 32 additions & 0 deletions extensions/tags/src/TagFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Flarum\Tags;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;

class TagFactory extends Factory
{
public function definition(): array
{
return [
'name' => $this->faker->word,
'slug' => $this->faker->slug,
'description' => $this->faker->sentence,
'color' => $this->faker->hexColor,
'background_path' => null,
'background_mode' => null,
'position' => 0,
'parent_id' => null,
'default_sort' => null,
'is_restricted' => false,
'is_hidden' => false,
'discussion_count' => 0,
'last_posted_at' => null,
'last_posted_discussion_id' => null,
'last_posted_user_id' => null,
'icon' => null,
'created_at' => Carbon::now(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
namespace Flarum\Tags\Tests\integration\api\discussions;

use Flarum\Group\Group;
use Flarum\Tags\Tag;
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;

class CreateTest extends TestCase
{
Expand All @@ -29,8 +31,8 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => $this->tags(),
'users' => [
Tag::class => $this->tags(),
User::class => [
$this->normalUser(),
],
'group_permission' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
namespace Flarum\Tags\Tests\integration\api\discussions;

use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
Expand All @@ -32,7 +34,7 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => $this->tags(),
Tag::class => $this->tags(),
User::class => [
$this->normalUser(),
[
Expand All @@ -43,7 +45,7 @@ protected function setUp(): void
'is_email_confirmed' => 1,
]
],
'groups' => [
Group::class => [
['id' => 100, 'name_singular' => 'acme', 'name_plural' => 'acme']
],
'group_user' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
Expand All @@ -33,7 +34,7 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => $this->tags(),
Tag::class => $this->tags(),
User::class => [
$this->normalUser(),
],
Expand Down
6 changes: 4 additions & 2 deletions extensions/tags/tests/integration/api/posts/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
namespace Flarum\Tags\Tests\integration\api\posts;

use Flarum\Discussion\Discussion;
use Flarum\Group\Group;
use Flarum\Post\Post;
use Flarum\Tags\Tag;
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
Expand All @@ -31,7 +33,7 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => $this->tags(),
Tag::class => $this->tags(),
User::class => [
$this->normalUser(),
[
Expand All @@ -42,7 +44,7 @@ protected function setUp(): void
'is_email_confirmed' => 1,
]
],
'groups' => [
Group::class => [
['id' => 100, 'name_singular' => 'acme', 'name_plural' => 'acme']
],
'group_user' => [
Expand Down
3 changes: 2 additions & 1 deletion extensions/tags/tests/integration/api/tags/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Flarum\Tags\Tag;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class CreateTest extends TestCase
Expand All @@ -28,7 +29,7 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'users' => [
User::class => [
$this->normalUser(),
],
]);
Expand Down
6 changes: 4 additions & 2 deletions extensions/tags/tests/integration/api/tags/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
namespace Flarum\Tags\Tests\integration\api\tags;

use Flarum\Group\Group;
use Flarum\Tags\Tag;
use Flarum\Tags\Tests\integration\RetrievesRepresentativeTags;
use Flarum\Testing\integration\RetrievesAuthorizedUsers;
use Flarum\Testing\integration\TestCase;
use Flarum\User\User;
use Illuminate\Support\Arr;

class ListTest extends TestCase
Expand All @@ -30,8 +32,8 @@ protected function setUp(): void
$this->extension('flarum-tags');

$this->prepareDatabase([
'tags' => $this->tags(),
'users' => [
Tag::class => $this->tags(),
User::class => [
$this->normalUser(),
],
'group_permission' => [
Expand Down
Loading

0 comments on commit be4c4dd

Please sign in to comment.