You are here

public function NodeTypeTest::providerSource in Drupal 10

Same name in this branch
  1. 10 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d6/NodeTypeTest.php \Drupal\Tests\node\Kernel\Plugin\migrate\source\d6\NodeTypeTest::providerSource()
  2. 10 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php \Drupal\Tests\node\Kernel\Plugin\migrate\source\d7\NodeTypeTest::providerSource()
Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php \Drupal\Tests\node\Kernel\Plugin\migrate\source\d7\NodeTypeTest::providerSource()
  2. 9 core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php \Drupal\Tests\node\Kernel\Plugin\migrate\source\d7\NodeTypeTest::providerSource()

The data provider.

Return value

array Array of data sets to test, each of which is a numerically indexed array with the following elements:

  • An array of source data, which can be optionally processed and set up by subclasses.
  • An array of expected result rows.
  • (optional) The number of result rows the plugin under test is expected to return. If this is not a numeric value, the plugin will not be counted.
  • (optional) Array of configuration options for the plugin under test.

Overrides MigrateSourceTestBase::providerSource

See also

\Drupal\Tests\migrate\Kernel\MigrateSourceTestBase::testSource

File

core/modules/node/tests/src/Kernel/Plugin/migrate/source/d7/NodeTypeTest.php, line 24

Class

NodeTypeTest
Tests D7 node type source plugin.

Namespace

Drupal\Tests\node\Kernel\Plugin\migrate\source\d7

Code

public function providerSource() {
  $tests = [];

  // The source data.
  $tests[0]['source_data']['node_type'] = [
    [
      'type' => 'page',
      'name' => 'Page',
      'base' => 'node',
      'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
      'help' => '',
      'title_label' => 'Title',
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'disabled' => 0,
      'orig_type' => 'page',
    ],
    [
      'type' => 'story',
      'name' => 'Story',
      'base' => 'node',
      'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
      'help' => '',
      'title_label' => 'Title',
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'disabled' => 0,
      'orig_type' => 'story',
    ],
  ];
  $tests[0]['source_data']['variable'] = [
    [
      'name' => 'comment_anonymous_page',
      'value' => 'i:0;',
    ],
    [
      'name' => 'comment_anonymous_story',
      'value' => 'i:1;',
    ],
    [
      'name' => 'comment_default_mode_page',
      'value' => 'i:0;',
    ],
    [
      'name' => 'comment_default_mode_story',
      'value' => 'i:1;',
    ],
    [
      'name' => 'comment_default_per_page_page',
      'value' => 's:2:"10";',
    ],
    [
      'name' => 'comment_default_per_page_story',
      'value' => 's:2:"20";',
    ],
    [
      'name' => 'comment_form_location_page',
      'value' => 'i:0;',
    ],
    [
      'name' => 'comment_form_location_story',
      'value' => 'i:1;',
    ],
    [
      'name' => 'comment_page',
      'value' => 's:1:"0";',
    ],
    [
      'name' => 'comment_preview_page',
      'value' => 's:1:"0";',
    ],
    [
      'name' => 'comment_preview_story',
      'value' => 's:1:"1";',
    ],
    [
      'name' => 'comment_story',
      'value' => 's:1:"1";',
    ],
    [
      'name' => 'comment_subject_field_page',
      'value' => 'i:0;',
    ],
    [
      'name' => 'comment_subject_field_story',
      'value' => 'i:1;',
    ],
    [
      'name' => 'node_options_page',
      'value' => 'a:1:{i:0;s:6:"status";}',
    ],
    [
      'name' => 'node_options_story',
      'value' => 'a:1:{i:0;s:6:"status";}',
    ],
  ];
  $tests[0]['source_data']['field_config_instance'] = [
    [
      'entity_type' => 'node',
      'bundle' => 'page',
      'field_name' => 'body',
      'data' => 'a:1:{s:5:"label";s:4:"Body";}',
    ],
    [
      'entity_type' => 'node',
      'bundle' => 'story',
      'field_name' => 'body',
      'data' => 'a:1:{s:5:"label";s:4:"Body";}',
    ],
  ];
  $tests[0]['source_data']['system'] = [
    [
      'type' => 'module',
      'name' => 'comment',
      'status' => '1',
    ],
    [
      'type' => 'module',
      'name' => 'field',
      'status' => '1',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'type' => 'page',
      'name' => 'Page',
      'base' => 'node',
      'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
      'help' => '',
      'title_label' => 'Title',
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'disabled' => 0,
      'orig_type' => 'page',
      'options' => [
        'promote' => FALSE,
        'sticky' => FALSE,
        'status' => TRUE,
        'revision' => FALSE,
      ],
      'create_body' => TRUE,
      'body_label' => 'Body',
      'comment' => 0,
      'comment_default_mode' => 0,
      'comment_default_per_page' => '10',
      'comment_anonymous' => 0,
      'comment_subject_field' => 0,
      'comment_preview' => 0,
      'comment_form_location' => 0,
    ],
    [
      'type' => 'story',
      'name' => 'Story',
      'base' => 'node',
      'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
      'help' => '',
      'title_label' => 'Title',
      'custom' => 1,
      'modified' => 0,
      'locked' => 0,
      'disabled' => 0,
      'orig_type' => 'story',
      'options' => [
        'promote' => FALSE,
        'sticky' => FALSE,
        'status' => TRUE,
        'revision' => FALSE,
      ],
      'create_body' => TRUE,
      'body_label' => 'Body',
      'comment' => 1,
      'comment_default_mode' => 1,
      'comment_default_per_page' => '20',
      'comment_anonymous' => 1,
      'comment_subject_field' => 1,
      'comment_preview' => 1,
      'comment_form_location' => 1,
    ],
  ];
  return $tests;
}