oliverdavies.uk/web/modules/custom/talks/tests/src/Kernel/TalksTestBase.php

68 lines
1.4 KiB
PHP
Raw Normal View History

<?php
namespace Drupal\Tests\opdavies_talks\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\opdavies_talks\Entity\Node\Talk;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\paragraphs\ParagraphInterface;
abstract class TalksTestBase extends EntityKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
// Core.
'node',
'file',
'datetime',
// Contrib.
'discoverable_entity_bundle_classes',
'entity_reference_revisions',
'paragraphs',
'hook_event_dispatcher',
'core_event_dispatcher',
// Custom.
'opdavies_talks',
'opdavies_talks_test',
];
protected $strictConfigSchema = FALSE;
2020-05-31 14:55:50 +01:00
protected function createEvent(array $overrides = []): ParagraphInterface {
/** @var \Drupal\paragraphs\ParagraphInterface $event */
2020-05-31 14:55:50 +01:00
$event = Paragraph::create(array_merge([
'type' => 'event',
2020-05-31 14:55:50 +01:00
], $overrides));
$event->save();
return $event;
}
protected function createTalk(array $overrides = []): Talk {
2020-05-31 14:55:50 +01:00
$talk = Node::create(array_merge([
'title' => 'Test Driven Drupal',
'type' => 'talk',
], $overrides));
$talk->save();
return $talk;
2020-05-31 14:55:50 +01:00
}
protected function setUp() {
parent::setUp();
$this->installEntitySchema('paragraph');
$this->installSchema('node', ['node_access']);
$this->installConfig(['opdavies_talks_test']);
}
}