You are here

public function EntityFieldValueTest::nodeValuesProvider in GraphQL 8.3

Data provider for testRawValues.

Return value

array

File

modules/graphql_core/tests/src/Kernel/Entity/EntityFieldValueTest.php, line 260

Class

EntityFieldValueTest
Test basic entity fields.

Namespace

Drupal\Tests\graphql_core\Kernel\Entity

Code

public function nodeValuesProvider() {
  $fieldValues = [
    'body' => [
      'value' => 'test',
      'summary' => 'test summary',
    ],
    'field_text' => [
      'a',
      'b',
      'c',
    ],
    'field_boolean' => [
      TRUE,
      FALSE,
    ],
    'field_link' => [
      [
        'title' => 'Internal link',
        'uri' => 'internal:/node/1',
        'options' => [
          'attributes' => [
            '_target' => 'blank',
          ],
        ],
      ],
      [
        'title' => 'External link',
        'uri' => 'http://drupal.org',
        'options' => [
          'attributes' => [
            '_target' => 'blank',
          ],
        ],
      ],
    ],
    'field_integer' => [
      10,
      -5,
    ],
    'field_float' => [
      3.14145,
      -8.800000000000001,
    ],
    'field_decimal' => [
      10.5,
      -17.22,
    ],
    'field_datetime' => [
      '2017-01-01',
      '1900-01-01',
    ],
    'field_timestamp' => [
      0,
      300,
    ],
    'field_email' => [
      'test@test.com',
    ],
    'field_string' => [
      'test',
      '123',
    ],
    'field_reference' => [
      [
        'target_id' => 1,
      ],
    ],
    'field_file' => [
      [
        'target_id' => 1,
        'display' => 0,
        'description' => 'description test 1',
      ],
      [
        'target_id' => 2,
        'display' => 1,
        'description' => 'description test 2',
      ],
    ],
    'field_image' => [
      [
        'target_id' => 1,
        'alt' => 'alt test 1',
        'title' => 'title test 1',
        'width' => 100,
        'height' => 50,
      ],
      [
        'target_id' => 2,
        'alt' => 'alt test 2',
        'title' => 'title test 2',
        'width' => 200,
        'height' => 100,
      ],
    ],
  ];
  $expected = [
    'nid' => 1,
    'vid' => 1,
    'langcode' => [
      'value' => 'en',
    ],
    'type' => [
      'targetId' => 'test',
    ],
    'uid' => [
      'targetId' => 0,
      'entity' => [
        'name' => '',
      ],
    ],
    'title' => 'Test',
    'status' => TRUE,
    'promote' => TRUE,
    'sticky' => FALSE,
    'revisionTranslationAffected' => TRUE,
    'body' => [
      'value' => 'test',
      'summary' => 'test summary',
      'summaryProcessed' => "<p>test summary</p>\n",
      'processed' => "<p>test</p>\n",
      'format' => null,
    ],
    'fieldText' => [
      [
        'value' => 'a',
      ],
      [
        'value' => 'b',
      ],
      [
        'value' => 'c',
      ],
    ],
    'fieldBoolean' => [
      TRUE,
      FALSE,
    ],
    'fieldLink' => [
      [
        'title' => 'Internal link',
        'uri' => 'internal:/node/1',
        'target' => 'blank',
        'url' => [
          'internal' => '/node/1',
        ],
      ],
      [
        'title' => 'External link',
        'uri' => 'http://drupal.org',
        'target' => 'blank',
        'url' => [
          'external' => 'http://drupal.org',
        ],
      ],
    ],
    'fieldInteger' => [
      10,
      -5,
    ],
    'fieldFloat' => [
      3.14145,
      -8.800000000000001,
    ],
    'fieldDecimal' => [
      10.5,
      -17.22,
    ],
    'fieldDatetime' => [
      [
        'value' => '2017-01-01',
      ],
      [
        'value' => '1900-01-01',
      ],
    ],
    'fieldTimestamp' => [
      0,
      300,
    ],
    'fieldEmail' => [
      'test@test.com',
    ],
    'fieldString' => [
      'test',
      '123',
    ],
    'fieldReference' => [
      [
        'targetId' => 1,
        'entity' => [
          'title' => 'Test',
          'fieldReference' => [
            [
              'targetId' => 1,
              'entity' => [
                'title' => 'Test',
              ],
            ],
          ],
        ],
      ],
    ],
    'fieldFile' => [
      [
        'targetId' => 1,
        'display' => FALSE,
        'description' => 'description test 1',
        'entity' => [],
      ],
      [
        'targetId' => 2,
        'display' => TRUE,
        'description' => 'description test 2',
        'entity' => [],
      ],
    ],
    'fieldImage' => [
      [
        'targetId' => 1,
        'alt' => 'alt test 1',
        'title' => 'title test 1',
        'width' => 100,
        'height' => 50,
        'entity' => [],
      ],
      [
        'targetId' => 2,
        'alt' => 'alt test 2',
        'title' => 'title test 2',
        'width' => 200,
        'height' => 100,
        'entity' => [],
      ],
    ],
  ];
  return [
    [
      $fieldValues,
      $expected,
    ],
  ];
}