diff --git a/web/modules/custom/blog/tests/src/Kernel/PostTestBase.php b/web/modules/custom/blog/tests/src/Kernel/PostTestBase.php new file mode 100644 index 0000000..4bd6382 --- /dev/null +++ b/web/modules/custom/blog/tests/src/Kernel/PostTestBase.php @@ -0,0 +1,42 @@ +<?php + +namespace Drupal\Tests\opdavies_blog\Kernel; + +use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; +use Drupal\Tests\node\Traits\NodeCreationTrait; +use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait; + +abstract class PostTestBase extends EntityKernelTestBase { + + use NodeCreationTrait; + use TaxonomyTestTrait; + + public static $modules = [ + // Core. + 'node', + 'taxonomy', + 'link', + + // Contrib. + 'discoverable_entity_bundle_classes', + 'hook_event_dispatcher', + 'core_event_dispatcher', + + // Custom. + 'opdavies_blog_test', + 'opdavies_blog', + ]; + + protected function setUp() { + parent::setUp(); + + $this->installConfig([ + 'filter', + 'opdavies_blog_test', + ]); + + $this->installEntitySchema('taxonomy_vocabulary'); + $this->installEntitySchema('taxonomy_term'); + } + +} diff --git a/web/modules/custom/blog/tests/src/Kernel/ReorderBlogTagsTest.php b/web/modules/custom/blog/tests/src/Kernel/ReorderBlogTagsTest.php index 4343d3d..e1c449c 100644 --- a/web/modules/custom/blog/tests/src/Kernel/ReorderBlogTagsTest.php +++ b/web/modules/custom/blog/tests/src/Kernel/ReorderBlogTagsTest.php @@ -4,35 +4,13 @@ namespace Drupal\Tests\opdavies_blog\Kernel; -use Drupal\KernelTests\Core\Entity\EntityKernelTestBase; use Drupal\node\Entity\Node; use Drupal\opdavies_blog\Entity\Node\Post; use Drupal\taxonomy\Entity\Vocabulary; use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\VocabularyInterface; -use Drupal\Tests\node\Traits\NodeCreationTrait; -use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait; -final class ReorderBlogTagsTest extends EntityKernelTestBase { - - use NodeCreationTrait; - use TaxonomyTestTrait; - - public static $modules = [ - // Core. - 'node', - 'taxonomy', - 'link', - - // Contrib. - 'discoverable_entity_bundle_classes', - 'hook_event_dispatcher', - 'core_event_dispatcher', - - // Custom. - 'opdavies_blog', - 'opdavies_blog_test', - ]; +final class ReorderBlogTagsTest extends PostTestBase { /** @test */ public function it_reorders_tags_on_blog_posts_to_be_arranged_alphabetically(): void { @@ -59,18 +37,4 @@ final class ReorderBlogTagsTest extends EntityKernelTestBase { ); } - protected function setUp() { - parent::setUp(); - - $this->installConfig([ - 'filter', - 'opdavies_blog_test', - ]); - - $this->installSchema('node', ['node_access']); - - $this->installEntitySchema('taxonomy_vocabulary'); - $this->installEntitySchema('taxonomy_term'); - } - }