You are here

public function BreakpointDiscoveryTest::testThemeBreakpoints in Zircon Profile 8

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

Test the breakpoint group created for a theme.

File

core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php, line 34
Contains \Drupal\breakpoint\Tests\BreakpointDiscoveryTest.

Class

BreakpointDiscoveryTest
Tests discovery of breakpoints provided by themes and modules.

Namespace

Drupal\breakpoint\Tests

Code

public function testThemeBreakpoints() {

  // Verify the breakpoint group for breakpoint_theme_test was created.
  $expected_breakpoints = array(
    'breakpoint_theme_test.mobile' => array(
      'label' => 'mobile',
      'mediaQuery' => '(min-width: 0px)',
      'weight' => 0,
      'multipliers' => array(
        '1x',
      ),
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.mobile',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ),
    'breakpoint_theme_test.narrow' => array(
      'label' => 'narrow',
      'mediaQuery' => '(min-width: 560px)',
      'weight' => 1,
      'multipliers' => array(
        '1x',
      ),
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.narrow',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ),
    'breakpoint_theme_test.wide' => array(
      'label' => 'wide',
      'mediaQuery' => '(min-width: 851px)',
      'weight' => 2,
      'multipliers' => array(
        '1x',
      ),
      'provider' => 'breakpoint_theme_test',
      'id' => 'breakpoint_theme_test.wide',
      'group' => 'breakpoint_theme_test',
      'class' => 'Drupal\\breakpoint\\Breakpoint',
    ),
    'breakpoint_theme_test.tv' => array(
      'label' => 'tv',
      'mediaQuery' => 'only screen and (min-width: 1220px)',
      'weight' => 3,
      'multipliers' => array(
        '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));
}