You are here

public function EntityReferenceTest::setUp in GraphQL 8.4

Overrides GraphQLTestBase::setUp

File

tests/src/Kernel/DataProducer/EntityReferenceTest.php, line 27

Class

EntityReferenceTest
Data producers Field test class.

Namespace

Drupal\Tests\graphql\Kernel\DataProducer

Code

public function setUp() : void {
  parent::setUp();
  $this->entity = $this
    ->getMockBuilder(NodeInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->entity_interface = $this
    ->getMockBuilder(EntityInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->user = $this
    ->getMockBuilder(UserInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $content_type1 = NodeType::create([
    'type' => 'test1',
    'name' => 'ipsum1',
  ]);
  $content_type1
    ->save();
  $content_type2 = NodeType::create([
    'type' => 'test2',
    'name' => 'ipsum2',
  ]);
  $content_type2
    ->save();
  $this
    ->createEntityReferenceField('node', 'test1', 'field_test1_to_test2', 'test1 lable', 'node', 'default', [], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
  $this->referenced_node = Node::create([
    'title' => 'Dolor2',
    'type' => 'test2',
  ]);
  $this->referenced_node
    ->save();
  $this->referenced_node
    ->addTranslation('fr', [
    'title' => 'Dolor2 French',
  ])
    ->save();
  $this->node = Node::create([
    'title' => 'Dolor',
    'type' => 'test1',
    'field_test1_to_test2' => $this->referenced_node
      ->id(),
  ]);
  $this->node
    ->save();
}