You are here

public function BreakpointDiscoveryTest::testThemeBreakpoints in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php \Drupal\Tests\breakpoint\Kernel\BreakpointDiscoveryTest::testThemeBreakpoints()

Test the breakpoint group created for a theme.

File

core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php, line 29

Class

BreakpointDiscoveryTest
Tests discovery of breakpoints provided by themes and modules.

Namespace

Drupal\Tests\breakpoint\Kernel

Code

public function testThemeBreakpoints() {

  // Verify the breakpoint group for breakpoint_theme_test was created.
  $expected_breakpoints = [
    'breakpoint_theme_test.mobile' => [
      'label' => 'mobile',
      'mediaQuery' => '(min-width: 0px)',
      'weight' => 0,
      'multipliers' => [
        '1x',
      ],
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.mobile',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ],
    'breakpoint_theme_test.narrow' => [
      'label' => 'narrow',
      'mediaQuery' => '(min-width: 560px)',
      'weight' => 1,
      'multipliers' => [
        '1x',
      ],
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.narrow',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ],
    'breakpoint_theme_test.wide' => [
      'label' => 'wide',
      'mediaQuery' => '(min-width: 851px)',
      'weight' => 2,
      'multipliers' => [
        '1x',
      ],
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.wide',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ],
    'breakpoint_theme_test.tv' => [
      'label' => 'tv',
      'mediaQuery' => 'only screen and (min-width: 1220px)',
      'weight' => 3,
      'multipliers' => [
        '1x',
      ],
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.tv',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ],
  ];
  $breakpoints = \Drupal::service('breakpoint.manager')
    ->getBreakpointsByGroup('breakpoint_theme_test');
  foreach ($expected_breakpoints as $id => $expected_breakpoint) {
    $this
      ->assertEqual($expected_breakpoint, $breakpoints[$id]
      ->getPluginDefinition());
  }

  // Test that the order is as expected.
  $this
    ->assertIdentical(array_keys($expected_breakpoints), array_keys($breakpoints));
}