You are here

public function GatherContentUploadTestBase::getSimpleNode in GatherContent 8.5

Returns the Node for the simple ProcessPane test.

Return value

\Drupal\node\Entity\Node Node object.

1 call to GatherContentUploadTestBase::getSimpleNode()
GatherContentUploadTest::testProcessGroups in gathercontent_upload/tests/src/Kernel/GatherContentUploadTest.php
Tests the field manipulation.

File

gathercontent_upload/tests/src/Kernel/GatherContentUploadTestBase.php, line 90

Class

GatherContentUploadTestBase
Class GatherContentUploadTestBase.

Namespace

Drupal\Tests\gathercontent_upload\Kernel

Code

public function getSimpleNode() {
  $image = File::create([
    'uri' => 'public://example1.png',
  ]);
  $image
    ->save();
  $paragraph_1 = Paragraph::create([
    'type' => 'para',
    'field_text' => 'Test paragraph field',
    'field_image' => [
      [
        'target_id' => $image
          ->id(),
      ],
    ],
  ]);
  $paragraph_1
    ->save();
  $paragraph_2 = Paragraph::create([
    'type' => 'para_2',
    'field_text' => 'Test paragraph 2 field',
  ]);
  $paragraph_2
    ->save();
  $term_1 = Term::create([
    'vid' => 'tags',
    'name' => 'First choice',
    'gathercontent_option_ids' => 'ad10caf0-239b-473f-b106-6f615a35f574',
  ]);
  $term_1
    ->save();
  $term_2 = Term::create([
    'vid' => 'tags',
    'name' => 'Choice1',
    'gathercontent_option_ids' => 'd009aae5-a91d-4a57-bc00-e8888b738c8d',
  ]);
  $term_2
    ->save();
  return Node::create([
    'title' => 'Test node',
    'type' => 'page',
    'body' => 'Test body',
    'field_guidodo' => 'Test guide',
    'field_image' => [
      [
        'target_id' => $image
          ->id(),
      ],
    ],
    'field_radio' => [
      [
        'target_id' => $term_1
          ->id(),
      ],
    ],
    'field_tags_alt' => [
      [
        'target_id' => $term_2
          ->id(),
      ],
    ],
    'field_para' => [
      [
        'target_id' => $paragraph_1
          ->id(),
        'target_revision_id' => $paragraph_1
          ->getRevisionId(),
      ],
      [
        'target_id' => $paragraph_2
          ->id(),
        'target_revision_id' => $paragraph_2
          ->getRevisionId(),
      ],
    ],
  ]);
}