public function BreakpointThemeTest::testThemeBreakpointGroupModule

Test the breakpoints defined by the custom group in the module.

File

drupal/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php, line 94
Definition of Drupal\breakpoint\Tests\BreakpointsThemeTest.

Class

BreakpointThemeTest
Test breakpoints provided by themes.

Namespace

Drupal\breakpoint\Tests

Code

public function testThemeBreakpointGroupModule() {

  // Call the import manually, since the testbot needs to enable the module
  // first, otherwise the theme isn't detected.
  _breakpoint_import_breakpoint_groups('breakpoint_theme_test', Breakpoint::SOURCE_TYPE_MODULE);

  // Verify the breakpoint group 'module_test' was created by
  // breakpoint_theme_test module.
  $breakpoint_group_obj = entity_create('breakpoint_group', array(
    'label' => 'Test Module',
    'name' => 'module_test',
    'sourceType' => Breakpoint::SOURCE_TYPE_MODULE,
    'source' => 'breakpoint_theme_test',
    'id' => Breakpoint::SOURCE_TYPE_MODULE . '.breakpoint_theme_test.module_test',
  ));
  $breakpoint_group_obj->breakpoints = array(
    'theme.breakpoint_test_theme.mobile' => array(),
    'theme.breakpoint_test_theme.narrow' => array(),
    'theme.breakpoint_test_theme.wide' => array(),
  );

  // Verify we can load this breakpoint defined by the theme.
  $this
    ->verifyBreakpointGroup($breakpoint_group_obj);

  // Disable the test theme and verify the breakpoint group still exists.
  theme_disable(array(
    'breakpoint_test_theme',
  ));
  $this
    ->assertTrue(entity_load('breakpoint_group', $breakpoint_group_obj
    ->id()), 'Breakpoint group still exists if theme is disabled.');

  // Disable the test module and verify the breakpoint group still exists.
  module_disable(array(
    'breakpoint_theme_test',
  ));
  $this
    ->assertTrue(entity_load('breakpoint_group', $breakpoint_group_obj
    ->id()), 'Breakpoint group still exists if module is disabled.');

  // Uninstall the test module and verify the breakpoint group is deleted.
  module_uninstall(array(
    'breakpoint_theme_test',
  ));
  $this
    ->assertFalse(entity_load('breakpoint_group', $breakpoint_group_obj
    ->id()), 'Breakpoint group is removed if module is uninstalled.');
}