function BreakpointDiscoveryTest::testThemeBreakpoints

Same name in other branches
  1. 9 core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php \Drupal\Tests\breakpoint\Kernel\BreakpointDiscoveryTest::testThemeBreakpoints()
  2. 8.9.x core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php \Drupal\Tests\breakpoint\Kernel\BreakpointDiscoveryTest::testThemeBreakpoints()
  3. 10 core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php \Drupal\Tests\breakpoint\Kernel\BreakpointDiscoveryTest::testThemeBreakpoints()

Tests the breakpoint group created for a theme.

File

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

Class

BreakpointDiscoveryTest
Tests discovery of breakpoints provided by themes and modules.

Namespace

Drupal\Tests\breakpoint\Kernel

Code

public function testThemeBreakpoints() : void {
    // 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->assertEquals($expected_breakpoint, $breakpoints[$id]->getPluginDefinition());
    }
    // Test that the order is as expected.
    $this->assertSame(array_keys($expected_breakpoints), array_keys($breakpoints));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.