You are here

public function BreakpointMediaQueryTest::testInvalidMediaQueries in Breakpoints 8

Test invalid media queries.

File

lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php, line 71
Definition of Drupal\breakpoint\Tests\BreakpointMediaQueryTest.

Class

BreakpointMediaQueryTest
Tests for media queries in a breakpoint.

Namespace

Drupal\breakpoint\Tests

Code

public function testInvalidMediaQueries() {
  $media_queries = array(
    '',
    'not (orientation)',
    'only (orientation)',
    'all and not all',
    'screen and (width: 0xx)',
    'screen and (width: -8xx)',
    'screen and (width: -xx)',
    'screen and (width: xx)',
    'screen and (width: px)',
    'screen and (width: -8px)',
    'screen and (width: -0.8px)',
    'screen and (height: 0xx)',
    'screen and (height: -8xx)',
    'screen and (height: -xx)',
    'screen and (height: xx)',
    'screen and (height: px)',
    'screen and (height: -8px)',
    'screen and (height: -0.8px)',
    'screen and (device-width: 0xx)',
    'screen and (device-width: -8xx)',
    'screen and (device-width: -xx)',
    'screen and (device-width: xx)',
    'screen and (device-width: px)',
    'screen and (device-width: -8px)',
    'screen and (device-width: -0.8px)',
    'screen and (device-height: 0xx)',
    'screen and (device-height: -8xx)',
    'screen and (device-height: -xx)',
    'screen and (device-height: xx)',
    'screen and (device-height: px)',
    'screen and (device-height: -8px)',
    'screen and (device-height: -0.8px)',
    'screen and (min-orientation)',
    'screen and (max-orientation)',
    'screen and (min-orientation: landscape)',
    'screen and (max-orientation: landscape)',
    'screen and (orientation: bogus)',
    '(orientation: bogus)',
  );
  foreach ($media_queries as $media_query) {
    try {
      $this
        ->assertFalse(Breakpoint::isValidMediaQuery($media_query), $media_query . ' is not valid.');
    } catch (InvalidBreakpointMediaQueryException $e) {
      $this
        ->assertTrue(TRUE, $media_query . ' is not valid.');
    }
  }
}