You are here

public function ResponsiveImageStylesTest::providerSource in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/responsive_image/tests/src/Kernel/Plugin/migrate/source/d7/ResponsiveImageStylesTest.php \Drupal\Tests\responsive_image\Kernel\Plugin\migrate\source\d7\ResponsiveImageStylesTest::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/responsive_image/tests/src/Kernel/Plugin/migrate/source/d7/ResponsiveImageStylesTest.php, line 26

Class

ResponsiveImageStylesTest
Tests D7 responsive image styles source plugin.

Namespace

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

Code

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

  // The source data.
  $tests[0]['source_data']['picture_mapping'] = [
    [
      'label' => 'Narrow',
      'machine_name' => 'narrow',
      'breakpoint_group' => 'responsive_image',
      'mapping' => 'a:2:{s:38:"breakpoints.theme.my_theme_id.computer";a:3:{s:12:"multiplier_1";a:2:{s:12:"mapping_type";s:11:"image_style";s:11:"image_style";s:20:"custom_image_style_1";}s:12:"multiplier_2";a:3:{s:12:"mapping_type";s:5:"sizes";s:5:"sizes";i:2;s:18:"sizes_image_styles";a:2:{i:0;s:20:"custom_image_style_1";i:1;s:20:"custom_image_style_2";}}s:12:"multiplier_3";a:1:{s:12:"mapping_type";s:5:"_none";}}s:42:"breakpoints.theme.my_theme_id.computer_two";a:1:{s:12:"multiplier_2";a:3:{s:12:"mapping_type";s:5:"sizes";s:5:"sizes";i:2;s:18:"sizes_image_styles";a:2:{i:0;s:20:"custom_image_style_1";i:1;s:20:"custom_image_style_2";}}}}',
    ],
  ];

  // The expected results.
  $tests[0]['expected_data'] = [
    [
      'label' => 'Narrow',
      'machine_name' => 'narrow',
      'breakpoint_group' => 'responsive_image',
      'mapping' => [
        'breakpoints.theme.my_theme_id.computer' => [
          'multiplier_1' => [
            'mapping_type' => 'image_style',
            'image_style' => 'custom_image_style_1',
          ],
          'multiplier_2' => [
            'mapping_type' => 'sizes',
            'sizes' => 2,
            'sizes_image_styles' => [
              0 => 'custom_image_style_1',
              1 => 'custom_image_style_2',
            ],
          ],
          'multiplier_3' => [
            'mapping_type' => '_none',
          ],
        ],
        'breakpoints.theme.my_theme_id.computer_two' => [
          'multiplier_2' => [
            'mapping_type' => 'sizes',
            'sizes' => 2,
            'sizes_image_styles' => [
              0 => 'custom_image_style_1',
              1 => 'custom_image_style_2',
            ],
          ],
        ],
      ],
    ],
  ];
  return $tests;
}