You are here

protected function LinkFieldTest::getEntitiesDataArray in Entity Share 8.2

Same name and namespace in other branches
  1. 8.3 modules/entity_share_client/tests/src/Functional/LinkFieldTest.php \Drupal\Tests\entity_share_client\Functional\LinkFieldTest::getEntitiesDataArray()

Helper function to get a mapping of the entities data.

Used to create the entities for the test and to test that it has been recreated properly.

Overrides EntityShareClientFunctionalTestBase::getEntitiesDataArray

File

modules/entity_share_client/tests/src/Functional/LinkFieldTest.php, line 71

Class

LinkFieldTest
Functional test class for link field.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

protected function getEntitiesDataArray() {
  return [
    'node' => [
      'en' => [
        // Used for internal linked.
        'es_test' => $this
          ->getCompleteNodeInfos([
          'status' => [
            'value' => NodeInterface::PUBLISHED,
            'checker_callback' => 'getValue',
          ],
        ]),
        // Link: external.
        'es_test_link_external' => $this
          ->getCompleteNodeInfos([
          'field_es_test_link' => [
            'value' => [
              [
                'uri' => $this->faker->url,
                'title' => $this->faker
                  ->text(255),
              ],
            ],
            'checker_callback' => 'getFilteredStructureValues',
          ],
        ]),
        // Link: external without text.
        'es_test_link_external_without_text' => $this
          ->getCompleteNodeInfos([
          'field_es_test_link' => [
            'value' => [
              [
                'uri' => $this->faker->url,
              ],
            ],
            'checker_callback' => 'getFilteredStructureValues',
          ],
        ]),
        // Link: external with options.
        'es_test_link_external_with_options' => $this
          ->getCompleteNodeInfos([
          'field_es_test_link' => [
            'value' => [
              [
                'uri' => $this->faker->url,
                'title' => $this->faker
                  ->text(255),
                'options' => [
                  'attributes' => [
                    'class' => [
                      $this->faker
                        ->text(20),
                      $this->faker
                        ->text(20),
                      $this->faker
                        ->text(20),
                    ],
                  ],
                ],
              ],
            ],
            'checker_callback' => 'getFilteredStructureValues',
          ],
        ]),
        // Link: internal.
        'es_test_link_internal' => $this
          ->getCompleteNodeInfos([
          'field_es_test_link' => [
            'value_callback' => function () {
              return [
                [
                  'uri' => 'entity:node/' . $this
                    ->getEntityId('node', 'es_test'),
                ],
              ];
            },
            'checker_callback' => 'getExpectedInternalLinkValue',
          ],
        ]),
      ],
    ],
  ];
}