41 lines
880 B
PHP
41 lines
880 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Drupal\Tests\opd_presentations\Traits;
|
|
|
|
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
|
use Drupal\opd_presentations\Entity\Presentation;
|
|
use Drupal\paragraphs\Entity\Paragraph;
|
|
use Drupal\paragraphs\ParagraphInterface;
|
|
|
|
trait PresentationCreationTrait {
|
|
|
|
use NodeCreationTrait;
|
|
|
|
/**
|
|
* @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<non-empty-string, mixed> $values
|
|
*/
|
|
private function createEvent(array $values = []): ParagraphInterface {
|
|
return Paragraph::create(array_merge(
|
|
['type' => 'event'],
|
|
$values,
|
|
));
|
|
}
|
|
|
|
}
|
|
|