You are here

public function BreakpointsThemeTestCase::testThemeBreakpoints in Breakpoints 7

Test the breakpoints provided by a theme.

File

./breakpoints.test, line 746
Tests for breakpoints.module

Class

BreakpointsThemeTestCase
Test breakpoints provided by themes.

Code

public function testThemeBreakpoints() {

  // Verify the breakpoint group for breakpoints_test_theme was created.
  $breakpoint_group = new stdClass();
  $breakpoint_group->disabled = FALSE;

  /* Edit this to true to make a default breakpoint_group disabled initially */
  $breakpoint_group->api_version = 1;
  $breakpoint_group->machine_name = 'breakpoints_test_theme';
  $breakpoint_group->name = 'Breakpoints test theme';
  $breakpoint_group->breakpoints = array(
    'breakpoints.theme.breakpoints_test_theme.mobile',
    'breakpoints.theme.breakpoints_test_theme.narrow',
    'breakpoints.theme.breakpoints_test_theme.wide',
    'breakpoints.theme.breakpoints_test_theme.tv',
  );
  $breakpoint_group->type = 'theme';
  $breakpoint_group->overridden = 0;
  $this
    ->verifyBreakpointGroup($breakpoint_group, FALSE);

  // Override the breakpoints.
  $this
    ->drupalGet('admin/config/media/breakpoints/groups/' . $breakpoint_group->machine_name);
  $this
    ->drupalPost(NULL, array(), t('Override theme breakpoints'));

  // Clear CTools cache, since drupalGet and drupalPost are different requests than the request
  // this test is running in, the group object is still in the static cache, so we need to clear
  // it manually.
  ctools_export_load_object_reset('breakpoint_group');

  // Verify the group is overridden.
  $breakpoint_group->breakpoints = array(
    'custom.breakpoints_test_theme.mobile',
    'custom.breakpoints_test_theme.narrow',
    'custom.breakpoints_test_theme.wide',
    'custom.breakpoints_test_theme.tv',
  );
  $breakpoint_group->overridden = 1;
  $this
    ->verifyBreakpointGroup($breakpoint_group, FALSE);

  // Verify there is no override button for this group anymore.
  $this
    ->drupalGet('admin/config/media/breakpoints/groups/' . $breakpoint_group->machine_name);
  $this
    ->assertNoFieldById('edit-override');
}