public function RouteEntityTest::setUp in GraphQL 8.4
Overrides GraphQLTestBase::setUp
File
- tests/
src/ Kernel/ DataProducer/ Routing/ RouteEntityTest.php, line 21
Class
- RouteEntityTest
- Test class for the RouteEntity data producer.
Namespace
Drupal\Tests\graphql\Kernel\DataProducer\RoutingCode
public function setUp() : void {
parent::setUp();
$content_type = NodeType::create([
'type' => 'event',
'name' => 'Event',
'translatable' => TRUE,
'display_submitted' => FALSE,
]);
$content_type
->save();
// Published node and published translations.
$this->published_node = Node::create([
'title' => 'Test Event',
'type' => 'event',
'status' => NodeInterface::PUBLISHED,
]);
$this->published_node
->save();
$this->translation_fr_published = $this->published_node
->addTranslation('fr', [
'title' => 'Test Event FR',
]);
$this->translation_fr_published
->save();
$this->translation_de_published = $this->published_node
->addTranslation('de', [
'title' => 'Test Event DE',
]);
$this->translation_de_published
->save();
// Unpublished node and unpublished translations.
$this->unpublished_node = Node::create([
'title' => 'Test Unpublished Event',
'type' => 'event',
'status' => NodeInterface::NOT_PUBLISHED,
]);
$this->unpublished_node
->save();
$this->translation_fr_unpublished = $this->unpublished_node
->addTranslation('fr', [
'title' => 'Test Unpublished Event FR',
]);
$this->translation_fr_unpublished->status = NodeInterface::NOT_PUBLISHED;
$this->translation_fr_unpublished
->save();
$this->translation_de_unpublished = $this->unpublished_node
->addTranslation('de', [
'title' => 'Test Unpublished Event DE',
]);
$this->translation_de_unpublished->status = NodeInterface::NOT_PUBLISHED;
$this->translation_de_unpublished
->save();
// Unpublished node to published translations.
$this->unpublished_to_published_node = Node::create([
'title' => 'Test Unpublished to Published Event',
'type' => 'event',
'status' => NodeInterface::NOT_PUBLISHED,
]);
$this->unpublished_to_published_node
->save();
$this->translation_fr_unpublished_to_published = $this->unpublished_to_published_node
->addTranslation('fr', [
'title' => 'Test Unpublished to Published Event FR',
]);
$this->translation_fr_unpublished_to_published->status = NodeInterface::PUBLISHED;
$this->translation_fr_unpublished_to_published
->save();
$this->translation_de_unpublished_to_published = $this->unpublished_to_published_node
->addTranslation('de', [
'title' => 'Test Unpublished to Published Event DE',
]);
$this->translation_de_unpublished_to_published->status = NodeInterface::PUBLISHED;
$this->translation_de_unpublished_to_published
->save();
// Published node to unpublished translations.
$this->published_to_unpublished_node = Node::create([
'title' => 'Test Published to Unpublished Event',
'type' => 'event',
'status' => NodeInterface::PUBLISHED,
]);
$this->published_to_unpublished_node
->save();
$this->translation_fr_published_to_unpublished = $this->published_to_unpublished_node
->addTranslation('fr', [
'title' => 'Test Published to Unpublished Event FR',
]);
$this->translation_fr_published_to_unpublished->status = NodeInterface::NOT_PUBLISHED;
$this->translation_fr_published_to_unpublished
->save();
$this->translation_de_published_to_unpublished = $this->published_to_unpublished_node
->addTranslation('de', [
'title' => 'Test Published to Unpublished Event DE',
]);
$this->translation_de_published_to_unpublished->status = NodeInterface::NOT_PUBLISHED;
$this->translation_de_published_to_unpublished
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'event', TRUE);
}