public function BreakpointThemeTest::testThemeBreakpoints in Breakpoints 8
Test the breakpoints provided by a theme.
File
- lib/
Drupal/ breakpoint/ Tests/ BreakpointThemeTest.php, line 47 - Definition of Drupal\breakpoint\Tests\BreakpointsThemeTest.
Class
- BreakpointThemeTest
- Test breakpoints provided by themes.
Namespace
Drupal\breakpoint\TestsCode
public function testThemeBreakpoints() {
// Verify the breakpoint group for breakpoint_test_theme was created.
$breakpoint_group_obj = entity_create('breakpoint_group', array(
'label' => 'Breakpoint test theme',
'id' => 'breakpoint_test_theme',
'sourceType' => Breakpoint::SOURCE_TYPE_THEME,
'overridden' => FALSE,
));
$breakpoint_group_obj->breakpoints = array(
'theme.breakpoint_test_theme.mobile' => array(),
'theme.breakpoint_test_theme.narrow' => array(),
'theme.breakpoint_test_theme.wide' => array(),
'theme.breakpoint_test_theme.tv' => array(),
);
// Verify we can load this breakpoint defined by the theme.
$this
->verifyBreakpointGroup($breakpoint_group_obj);
// Override the breakpoints.
$overridden_set = clone $breakpoint_group_obj;
$breakpoint_group = entity_load('breakpoint_group', 'breakpoint_test_theme');
$breakpoint_group = $breakpoint_group
->override();
$overridden_set->overridden = 1;
$this
->verifyBreakpointGroup($overridden_set);
// Verify the breakpoints in this breakpoint group are overridden.
foreach (array_keys($breakpoint_group_obj->breakpoints) as $breakpoint_id) {
$breakpoint = entity_load('breakpoint', $breakpoint_id);
$this
->assertTrue($breakpoint->overridden, t('Breakpoint @breakpoint should be overridden', array(
'@breakpoint' => $breakpoint
->label(),
)), t('Breakpoint API'));
}
// Revert the breakpoint group.
$breakpoint_group = entity_load('breakpoint_group', 'breakpoint_test_theme');
$breakpoint_group = $breakpoint_group
->revert();
// Verify the breakpoint group has its original values again when loaded.
$this
->verifyBreakpointGroup($breakpoint_group_obj);
// Verify the breakpoints in this breakpoint group are no longer overridden.
foreach (array_keys($breakpoint_group_obj->breakpoints) as $breakpoint_id) {
$breakpoint = entity_load('breakpoint', $breakpoint_id);
$this
->assertFalse($breakpoint->overridden, t('Breakpoint @breakpoint should not be overridden', array(
'@breakpoint' => $breakpoint
->label(),
)), t('Breakpoint API'));
}
// Disable the test theme and verify the breakpoint group is deleted.
theme_disable(array(
'breakpoint_test_theme',
));
$this
->assertFalse(entity_load('breakpoint_group', 'breakpoint_test_theme'), t('breakpoint_group_load: Loading a deleted breakpoint group returns false.'), t('Breakpoints API'));
}