public function BreakpointMediaQueryTest::testValidMediaQueries

Test valid media queries.

File

drupal/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php, line 29
Definition of Drupal\breakpoint\Tests\BreakpointMediaQueryTest.

Class

BreakpointMediaQueryTest
Tests for media queries in a breakpoint.

Namespace

Drupal\breakpoint\Tests

Code

public function testValidMediaQueries() {
  $media_queries = array(
    // Bartik breakpoints.
    '(min-width: 0px)',
    'all and (min-width: 560px) and (max-width:850px)',
    'all and (min-width: 851px)',
    // Seven breakpoints.
    '(min-width: 0em)',
    'screen and (min-width: 40em)',
    // Stark breakpoints.
    '(min-width: 0px)',
    'all and (min-width: 480px) and (max-width: 959px)',
    'all and (min-width: 960px)',
    // Other media queries.
    '(orientation)',
    'all and (orientation)',
    'not all and (orientation)',
    'only all and (orientation)',
    'screen and (width)',
    'screen and (width: 0)',
    'screen and (width: 0px)',
    'screen and (width: 0em)',
    'screen and (min-width: -0)',
    'screen and (max-width: 0)',
    'screen and (max-width: 0.3)',
    'screen and (min-width)',
    // Multiline and comments.
    'screen and /* this is a comment */ (min-width)',
    "screen\nand /* this is a comment */ (min-width)",
    "screen\n\nand /* this is\n a comment */ (min-width)",
    // Unrecognized features are allowed.
    'screen and (-webkit-min-device-pixel-ratio: 7)',
    'screen and (min-orientation: landscape)',
    'screen and (max-orientation: landscape)',
  );
  foreach ($media_queries as $media_query) {
    $this
      ->assertTrue(Breakpoint::isValidMediaQuery($media_query), $media_query . ' is valid.');
  }
}