You are here

public function BreakpointMediaQueryTest::testValidMediaQueries in Breakpoints 8

Test valid media queries.

File

lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php, line 32
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)',
    '(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)",
  );
  foreach ($media_queries as $media_query) {
    $this
      ->assertTrue(Breakpoint::isValidMediaQuery($media_query), $media_query . ' is valid.');
  }
}