diff --git a/modules/opd_presentations/tests/src/DrupalTestTraits/Entity/PresentationTest.php b/modules/opd_presentations/tests/src/DrupalTestTraits/Entity/PresentationTest.php index d4a563200..fa89fbffd 100644 --- a/modules/opd_presentations/tests/src/DrupalTestTraits/Entity/PresentationTest.php +++ b/modules/opd_presentations/tests/src/DrupalTestTraits/Entity/PresentationTest.php @@ -5,13 +5,13 @@ declare(strict_types=1); namespace Drupal\opd_presentations\DrupalTestTraits\Entity; use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\opd_presentations\Entity\Presentation; -use Drupal\paragraphs\Entity\Paragraph; -use Drupal\paragraphs\ParagraphInterface; +use Drupal\Tests\opd_presentations\Traits\PresentationCreationTrait; use weitzman\DrupalTestTraits\ExistingSiteBase; final class PresentationTest extends ExistingSiteBase { + use PresentationCreationTrait; + public function test_getting_past_events(): void { $presentation = $this->createPresentation( events: [ @@ -27,28 +27,4 @@ final class PresentationTest extends ExistingSiteBase { ); } - /** - * @param ParagraphInterface[] $events - */ - private function createPresentation(array $events): Presentation { - $presentation = $this->createNode([ - 'field_events' => $events, - 'type' => 'presentation', - ]); - - assert($presentation instanceof Presentation); - - return $presentation; - } - - /** - * @param array $values - */ - private function createEvent(array $values = []): ParagraphInterface { - return Paragraph::create(array_merge( - ['type' => 'event'], - $values, - )); - } - } diff --git a/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php b/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php new file mode 100644 index 000000000..8db6d43d0 --- /dev/null +++ b/modules/opd_presentations/tests/src/Traits/PresentationCreationTrait.php @@ -0,0 +1,41 @@ +createNode([ + 'field_events' => $events, + 'type' => 'presentation', + ]); + + assert($presentation instanceof Presentation); + + return $presentation; + } + + /** + * @param array $values + */ + private function createEvent(array $values = []): ParagraphInterface { + return Paragraph::create(array_merge( + ['type' => 'event'], + $values, + )); + } + +} +