Extract a Date class for event dates
This commit is contained in:
parent
c2dd8a1a07
commit
c2cd2164f5
3 changed files with 27 additions and 5 deletions
|
@ -7,6 +7,7 @@ namespace Drupal\Tests\opd_presentations\Traits;
|
|||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\ctools\Testing\EntityCreationTrait;
|
||||
use Drupal\opd_presentations\Date;
|
||||
use Drupal\opd_presentations\Event;
|
||||
use Drupal\opd_presentations\Presentation;
|
||||
|
||||
|
@ -29,11 +30,11 @@ trait PresentationCreationTrait {
|
|||
return $presentation;
|
||||
}
|
||||
|
||||
private function createEvent(string $eventName, string $eventDate): Event {
|
||||
private function createEvent(string $eventName, Date $eventDate): Event {
|
||||
$event = $this->createEntity(
|
||||
entity_type: 'paragraph',
|
||||
values: [
|
||||
'field_date' => (new DrupalDateTime($eventDate))->getTimestamp(),
|
||||
'field_date' => $eventDate->toTimestamp(),
|
||||
'field_event_name' => $eventName,
|
||||
'type' => Event::PARAGRAPH_TYPE,
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue