Skip to content

Commit

Permalink
test: add reusable traits
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Dec 17, 2024
1 parent dbed6a1 commit bda07b1
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/integration/ExtensionDepsTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace FoF\FollowTags\tests\integration;

trait ExtensionDepsTrait
{
public function extensionDeps(): void
{
$this->extension('flarum-tags');
$this->extension('fof-extend');
$this->extension('fof-follow-tags');
}
}
24 changes: 24 additions & 0 deletions tests/integration/NotificationsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace FoF\FollowTags\tests\integration;

use Flarum\Testing\integration\TestCase;
use FoF\FollowTags\tests\integration\ExtensionDepsTrait;
use FoF\FollowTags\tests\integration\TagsDefinitionTrait;

class NotificationsTest extends TestCase
{
use ExtensionDepsTrait;
use TagsDefinitionTrait;

public function setUp(): void
{
parent::setUp();

$this->extensionDeps();

$this->prepareDatabase([
'tags' => $this->tags(),
]);
}
}
15 changes: 15 additions & 0 deletions tests/integration/TagsDefinitionTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace FoF\FollowTags\tests\integration;

trait TagsDefinitionTrait
{
public function tags(): array
{
return [
['id' => 1, 'name' => 'General', 'slug' => 'general', 'position' => 0, 'parent_id' => null],
['id' => 2, 'name' => 'Testing', 'slug' => 'testing', 'position' => 1, 'parent_id' => null],
['id' => 3, 'name' => 'Archive', 'slug' => 'archive', 'position' => 2, 'parent_id' => null, 'is_restricted' => true],
];
}
}

0 comments on commit bda07b1

Please sign in to comment.