summaryrefslogtreecommitdiffstats
path: root/core/modules/breakpoint/src/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/breakpoint/src/Tests')
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointAPITest.php88
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointCRUDTest.php50
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php207
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointGroupAPITest.php75
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointGroupCRUDTest.php54
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointGroupTestBase.php64
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointTestBase.php51
-rw-r--r--core/modules/breakpoint/src/Tests/BreakpointThemeTest.php74
8 files changed, 207 insertions, 456 deletions
diff --git a/core/modules/breakpoint/src/Tests/BreakpointAPITest.php b/core/modules/breakpoint/src/Tests/BreakpointAPITest.php
deleted file mode 100644
index abfb430..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointAPITest.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointAPITest.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\breakpoint\Tests\BreakpointsTestBase;
-use Drupal\breakpoint\Entity\Breakpoint;
-use Drupal\breakpoint\InvalidBreakpointNameException;
-use Drupal\breakpoint\InvalidBreakpointSourceException;
-use Drupal\breakpoint\InvalidBreakpointSourceTypeException;
-use Drupal\Component\Utility\Unicode;
-
-/**
- * Tests general API functions of the breakpoint module.
- *
- * @group breakpoint
- */
-class BreakpointAPITest extends BreakpointTestBase {
-
- /**
- * Test Breakpoint::buildConfigName().
- */
- public function testConfigName() {
- // Try an invalid sourceType.
- $label = $this->randomMachineName();
- $breakpoint = entity_create('breakpoint', array(
- 'label' => $label,
- 'name' => Unicode::strtolower($label),
- 'source' => 'custom_module',
- 'sourceType' => 'oops',
- ));
-
- $exception = FALSE;
- try {
- $breakpoint->save();
- }
- catch (InvalidBreakpointSourceTypeException $e) {
- $exception = TRUE;
- }
- $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid sourceType is entered.');
-
- // Try an invalid source.
- $breakpoint = $breakpoint->createDuplicate();
- $breakpoint->sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED;
- $breakpoint->source = 'custom*_module source';
-
- $exception = FALSE;
- try {
- $breakpoint->save();
- }
- catch (InvalidBreakpointSourceException $e) {
- $exception = TRUE;
- }
- $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid source is entered.');
-
- // Try an invalid name (make sure there is at least once capital letter).
- $breakpoint = $breakpoint->createDuplicate();
- $breakpoint->source = 'custom_module';
- $breakpoint->name = drupal_ucfirst($this->randomMachineName());
-
- $exception = FALSE;
- try {
- $breakpoint->save();
- }
- catch (InvalidBreakpointNameException $e) {
- $exception = TRUE;
- }
- $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid name is entered.');
-
- // Try a valid breakpoint.
- $breakpoint = $breakpoint->createDuplicate();
- $breakpoint->name = drupal_strtolower($this->randomMachineName());
- $breakpoint->mediaQuery = 'all';
-
- $exception = FALSE;
- try {
- $breakpoint->save();
- }
- catch (\Exception $e) {
- $exception = TRUE;
- }
- $this->assertFalse($exception, 'breakpoint_config_name: No exception is thrown when a valid breakpoint is passed.');
- $this->assertEqual($breakpoint->id(), Breakpoint::SOURCE_TYPE_USER_DEFINED . '.custom_module.' . $breakpoint->name, 'breakpoint_config_name: A id is set when a valid breakpoint is passed.');
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointCRUDTest.php b/core/modules/breakpoint/src/Tests/BreakpointCRUDTest.php
deleted file mode 100644
index 5b46d3d..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointCRUDTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointCRUDTest.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\breakpoint\Tests\BreakpointTestBase;
-use Drupal\breakpoint\Entity\Breakpoint;
-
-/**
- * Tests creation, loading, updating, deleting of breakpoints.
- *
- * @group breakpoint
- */
-class BreakpointCRUDTest extends BreakpointTestBase {
-
- /**
- * Test CRUD operations for breakpoints.
- */
- public function testBreakpointCRUD() {
- // Add a breakpoint with minimum data only.
- $label = $this->randomMachineName();
- $breakpoint = entity_create('breakpoint', array(
- 'label' => $label,
- 'mediaQuery' => '(min-width: 600px)',
- 'name' => drupal_strtolower($label),
- ));
- $breakpoint->save();
-
- $this->verifyBreakpoint($breakpoint);
-
- // Test BreakPoint::loadMultiple().
- $all_breakpoints = Breakpoint::loadMultiple();
- $config_name = $breakpoint->id();
- $this->assertTrue(isset($all_breakpoints[$config_name]), 'New breakpoint is present when loading all breakpoints.');
- $this->verifyBreakpoint($breakpoint, $all_breakpoints[$config_name]);
-
- // Update the breakpoint.
- $breakpoint->weight = 1;
- $breakpoint->multipliers['2x'] = '2x';
- $breakpoint->save();
- $this->verifyBreakpoint($breakpoint);
-
- // Delete the breakpoint.
- $breakpoint->delete();
- $this->assertNull(Breakpoint::load($config_name), 'Loading a deleted breakpoint returns null.', 'Breakpoints API');
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php
new file mode 100644
index 0000000..515359b
--- /dev/null
+++ b/core/modules/breakpoint/src/Tests/BreakpointDiscoveryTest.php
@@ -0,0 +1,207 @@
+<?php
+/**
+ * @file
+ * Definition of Drupal\breakpoint\Tests\BreakpointDiscoveryTest.
+ */
+
+namespace Drupal\breakpoint\Tests;
+
+use Drupal\simpletest\KernelTestBase;
+
+/**
+ * Tests discovery of breakpoints provided by themes and modules.
+ *
+ * @group breakpoint
+ */
+class BreakpointDiscoveryTest extends KernelTestBase {
+
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = array('breakpoint', 'breakpoint_module_test');
+
+ protected function setUp() {
+ parent::setUp();
+ \Drupal::service('theme_handler')->enable(array('breakpoint_theme_test'));
+ }
+
+ /**
+ * Test the breakpoint group created for a theme.
+ */
+ public function testThemeBreakpoints() {
+ // Verify the breakpoint group for breakpoint_theme_test was created.
+ $expected_breakpoints = array(
+ 'breakpoint_theme_test.mobile' => array(
+ 'label' => 'mobile',
+ 'mediaQuery' => '(min-width: 0px)',
+ 'weight' => 0,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.mobile',
+ 'group' => 'breakpoint_theme_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_theme_test.narrow' => array(
+ 'label' => 'narrow',
+ 'mediaQuery' => '(min-width: 560px)',
+ 'weight' => 1,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.narrow',
+ 'group' => 'breakpoint_theme_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_theme_test.wide' => array(
+ 'label' => 'wide',
+ 'mediaQuery' => '(min-width: 851px)',
+ 'weight' => 2,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.wide',
+ 'group' => 'breakpoint_theme_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_theme_test.tv' => array(
+ 'label' => 'tv',
+ 'mediaQuery' => 'only screen and (min-width: 3456px)',
+ 'weight' => 3,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.tv',
+ 'group' => 'breakpoint_theme_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ );
+
+ $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test');
+ foreach ($expected_breakpoints as $id => $expected_breakpoint) {
+ $this->assertEqual($expected_breakpoint, $breakpoints[$id]->getPluginDefinition());
+ }
+
+ // Test that the order is as expected.
+ $this->assertIdentical(array_keys($expected_breakpoints), array_keys($breakpoints));
+ }
+
+ /**
+ * Test the custom breakpoint group provided by a theme and a module.
+ */
+ public function testCustomBreakpointGroups () {
+ // Verify the breakpoint group for breakpoint_theme_test.group2 was created.
+ $expected_breakpoints = array(
+ 'breakpoint_theme_test.group2.narrow' => array(
+ 'label' => 'narrow',
+ 'mediaQuery' => '(min-width: 560px)',
+ 'weight' => 1,
+ 'multipliers' => array(
+ '1x',
+ '2x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.group2.narrow',
+ 'group' => 'breakpoint_theme_test.group2',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_theme_test.group2.wide' => array(
+ 'label' => 'wide',
+ 'mediaQuery' => '(min-width: 851px)',
+ 'weight' => 2,
+ 'multipliers' => array(
+ '1x',
+ '2x',
+ ),
+ 'provider' => 'breakpoint_theme_test',
+ 'id' => 'breakpoint_theme_test.group2.wide',
+ 'group' => 'breakpoint_theme_test.group2',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => array(
+ 'label' => 'tv',
+ 'mediaQuery' => '(min-width: 6000px)',
+ 'weight' => 3,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_module_test',
+ 'id' => 'breakpoint_module_test.breakpoint_theme_test.group2.tv',
+ 'group' => 'breakpoint_theme_test.group2',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ );
+
+ $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test.group2');
+ foreach ($expected_breakpoints as $id => $expected_breakpoint) {
+ $this->assertEqual($expected_breakpoint, $breakpoints[$id]->getPluginDefinition());
+ }
+ }
+
+ /**
+ * Test the breakpoint group created for a module.
+ */
+ public function testModuleBreakpoints() {
+ $expected_breakpoints = array(
+ 'breakpoint_module_test.mobile' => array(
+ 'label' => 'mobile',
+ 'mediaQuery' => '(min-width: 0px)',
+ 'weight' => 0,
+ 'multipliers' => array(
+ '1x',
+ ),
+ 'provider' => 'breakpoint_module_test',
+ 'id' => 'breakpoint_module_test.mobile',
+ 'group' => 'breakpoint_module_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ 'breakpoint_module_test.standard' => array(
+ 'label' => 'standard',
+ 'mediaQuery' => '(min-width: 560px)',
+ 'weight' => 1,
+ 'multipliers' => array(
+ '1x',
+ '2x',
+ ),
+ 'provider' => 'breakpoint_module_test',
+ 'id' => 'breakpoint_module_test.standard',
+ 'group' => 'breakpoint_module_test',
+ 'class' => 'Drupal\\breakpoint\\Breakpoint',
+ ),
+ );
+
+ $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_module_test');
+ foreach ($expected_breakpoints as $id => $expected_breakpoint) {
+ $this->assertEqual($expected_breakpoint, $breakpoints[$id]->getPluginDefinition());
+ }
+ }
+
+ /**
+ * Test the collection of breakpoint groups.
+ */
+ public function testBreakpointGroups() {
+ $expected = array(
+ 'bartik' => 'Bartik',
+ 'breakpoint_module_test' => 'Breakpoint test module',
+ 'breakpoint_theme_test' => 'Breakpoint test theme',
+ 'breakpoint_theme_test.group2' => 'breakpoint_theme_test.group2',
+ );
+ $breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups();
+ // Ensure the order is as expected. Should be sorted by label.
+ $this->assertIdentical($expected, $breakpoint_groups);
+
+ $expected = array(
+ 'breakpoint_theme_test' => 'theme',
+ 'breakpoint_module_test' => 'module',
+ );
+ $breakpoint_group_providers = \Drupal::service('breakpoint.manager')->getGroupProviders('breakpoint_theme_test.group2');
+ $this->assertEqual($expected, $breakpoint_group_providers);
+ }
+
+}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointGroupAPITest.php b/core/modules/breakpoint/src/Tests/BreakpointGroupAPITest.php
deleted file mode 100644
index f8a0191..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointGroupAPITest.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointGroupAPITest.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\breakpoint\Tests\BreakpointsTestBase;
-use Drupal\breakpoint\Entity\BreakpointGroup;
-use Drupal\breakpoint\Entity\Breakpoint;
-use Drupal\breakpoint\InvalidBreakpointNameException;
-use Drupal\breakpoint\InvalidBreakpointSourceException;
-use Drupal\breakpoint\InvalidBreakpointSourceTypeException;
-use Drupal\Component\Utility\Unicode;
-
-/**
- * Tests general API functions of the breakpoint module.
- *
- * @group breakpoint
- */
-class BreakpointGroupAPITest extends BreakpointGroupTestBase {
-
- /**
- * Test Breakpoint::buildConfigName().
- */
- public function testConfigName() {
- // Try an invalid sourceType.
- $label = $this->randomMachineName();
- $breakpoint_group = entity_create('breakpoint_group', array(
- 'label' => $label,
- 'name' => drupal_strtolower($label),
- 'source' => 'custom_module',
- 'sourceType' => 'oops',
- ));
-
- $exception = FALSE;
- try {
- $breakpoint_group->save();
- }
- catch (InvalidBreakpointSourceTypeException $e) {
- $exception = TRUE;
- }
- $this->assertTrue($exception, 'An exception is thrown when an invalid sourceType is entered.');
-
- // Try an invalid source.
- $breakpoint_group = $breakpoint_group->createDuplicate();
- $breakpoint_group->name = '';
- $breakpoint_group->sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED;
- $breakpoint_group->source = 'custom*_module source';
-
- $exception = FALSE;
- try {
- $breakpoint_group->save();
- }
- catch (InvalidBreakpointSourceException $e) {
- $exception = TRUE;
- }
- $this->assertTrue($exception, 'An exception is thrown when an invalid source is entered.');
-
- // Try a valid breakpoint_group.
- $breakpoint_group = $breakpoint_group->createDuplicate();
- $breakpoint_group->name = 'test';
- $breakpoint_group->source = 'custom_module_source';
-
- $exception = FALSE;
- try {
- $breakpoint_group->save();
- }
- catch (\Exception $e) {
- $exception = TRUE;
- }
- $this->assertFalse($exception, 'No exception is thrown when a valid data is passed.');
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointGroupCRUDTest.php b/core/modules/breakpoint/src/Tests/BreakpointGroupCRUDTest.php
deleted file mode 100644
index aa949de..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointGroupCRUDTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointGroupCRUDTest.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\breakpoint\Tests\BreakpointGroupTestBase;
-use Drupal\breakpoint\Entity\BreakpointGroup;
-use Drupal\breakpoint\Entity\Breakpoint;
-
-/**
- * Tests creation, loading, updating, deleting of breakpoint groups.
- *
- * @group breakpoint
- */
-class BreakpointGroupCRUDTest extends BreakpointGroupTestBase {
-
- /**
- * Test CRUD operations for breakpoint groups.
- */
- public function testBreakpointGroupCRUD() {
- // Add breakpoints.
- $breakpoints = array();
- for ($i = 0; $i <= 3; $i++) {
- $width = ($i + 1) * 200;
- $breakpoint = entity_create('breakpoint', array(
- 'name' => drupal_strtolower($this->randomMachineName()),
- 'weight' => $i,
- 'mediaQuery' => "(min-width: {$width}px)",
- ));
- $breakpoint->save();
- $breakpoints[$breakpoint->id()] = $breakpoint;
- }
- // Add a breakpoint group with minimum data only.
- $label = $this->randomMachineName();
-
- $group = entity_create('breakpoint_group', array(
- 'label' => $label,
- 'name' => drupal_strtolower($label),
- ));
- $group->save();
- $this->verifyBreakpointGroup($group);
-
- // Update the breakpoint group.
- $group->addBreakpoints($breakpoints)->save();
- $this->verifyBreakpointGroup($group);
-
- // Delete the breakpoint group.
- $group->delete();
- $this->assertFalse(entity_load('breakpoint_group', $group->id()), 'breakpoint_group_load: Loading a deleted breakpoint group returns false.', 'Breakpoints API');
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointGroupTestBase.php b/core/modules/breakpoint/src/Tests/BreakpointGroupTestBase.php
deleted file mode 100644
index 8dd8868..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointGroupTestBase.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointGroupTestBase.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\simpletest\WebTestBase;
-use Drupal\breakpoint\Entity\BreakpointGroup;
-
-/**
- * Base class for Breakpoint group tests.
- */
-abstract class BreakpointGroupTestBase extends WebTestBase {
-
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = array('breakpoint');
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Verify that a breakpoint is properly stored.
- */
- public function verifyBreakpointGroup(BreakpointGroup $group, BreakpointGroup $compare_set = NULL) {
- $properties = array(
- 'label',
- 'id',
- 'name',
- 'sourceType',
- );
-
- // Verify breakpoint_group_load().
- $compare_set = is_null($compare_set) ? entity_load('breakpoint_group', $group->id()) : $compare_set;
-
- foreach ($properties as $property) {
- $t_args = array(
- '%group' => $group->label(),
- '%property' => $property,
- );
- if (is_array($compare_set->{$property})) {
- $this->assertEqual(array_keys($compare_set->{$property}), array_keys($group->{$property}), format_string('breakpoint_group_load: Proper %property for breakpoint group %group.', $t_args), 'Breakpoint API');
- }
- else {
- $t_args = array(
- '%group' => $group->label(),
- '%property' => $property,
- '%property1' => $compare_set->{$property},
- '%property2' => $group->{$property},
- );
- $this->assertEqual($compare_set->{$property}, $group->{$property}, format_string('breakpoint_group_load: Proper %property: %property1 == %property2 for breakpoint group %group.', $t_args), 'Breakpoint API');
- }
- }
-
- // Ensure that the breakpoint group has the expected breakpoints.
- $this->assertEqual(array_keys($compare_set->getBreakpoints()), array_keys($group->getBreakpoints()));
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointTestBase.php b/core/modules/breakpoint/src/Tests/BreakpointTestBase.php
deleted file mode 100644
index c820689..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointTestBase.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointTestBase.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\simpletest\WebTestBase;
-use Drupal\breakpoint\Entity\Breakpoint;
-
-/**
- * Base class for Breakpoint tests.
- */
-abstract class BreakpointTestBase extends WebTestBase {
-
- /**
- * Modules to enable.
- *
- * @var array
- */
- public static $modules = array('breakpoint');
-
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Verify that a breakpoint is properly stored.
- */
- public function verifyBreakpoint(Breakpoint $breakpoint, Breakpoint $compare_breakpoint = NULL) {
- $properties = array(
- 'label',
- 'mediaQuery',
- 'source',
- 'sourceType',
- 'weight',
- 'multipliers',
- );
-
- // Verify Breakpoint::load().
- $compare_breakpoint = is_null($compare_breakpoint) ? Breakpoint::load($breakpoint->id()) : $compare_breakpoint;
- foreach ($properties as $property) {
- $t_args = array(
- '%breakpoint' => $breakpoint->label(),
- '%property' => $property,
- );
- $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API');
- }
- }
-}
diff --git a/core/modules/breakpoint/src/Tests/BreakpointThemeTest.php b/core/modules/breakpoint/src/Tests/BreakpointThemeTest.php
deleted file mode 100644
index 233ae72..0000000
--- a/core/modules/breakpoint/src/Tests/BreakpointThemeTest.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/**
- * @file
- * Definition of Drupal\breakpoint\Tests\BreakpointsThemeTest.
- */
-
-namespace Drupal\breakpoint\Tests;
-
-use Drupal\breakpoint\Tests\BreakpointGroupTestBase;
-use Drupal\breakpoint\Entity\BreakpointGroup;
-use Drupal\breakpoint\Entity\Breakpoint;
-
-/**
- * Thoroughly test the breakpoints provided by a theme.
- *
- * @group breakpoint
- */
-class BreakpointThemeTest extends BreakpointGroupTestBase {
-
- protected function setUp() {
- parent::setUp();
- theme_enable(array('breakpoint_test_theme'));
- }
-
- /**
- * Test the breakpoints provided by a theme.
- */
- 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',
- 'name' => 'breakpoint_test_theme',
- 'source' => 'breakpoint_test_theme',
- 'sourceType' => Breakpoint::SOURCE_TYPE_THEME,
- 'id' => Breakpoint::SOURCE_TYPE_THEME . '.breakpoint_test_theme.breakpoint_test_theme',
- ));
- $breakpoint_group_obj->addBreakpoints(entity_load_multiple('breakpoint',
- array(
- 'theme.breakpoint_test_theme.mobile',
- 'theme.breakpoint_test_theme.narrow',
- 'theme.breakpoint_test_theme.wide',
- 'theme.breakpoint_test_theme.tv',
- )
- ));
-
- // Verify we can load this breakpoint defined by the theme.
- $this->verifyBreakpointGroup($breakpoint_group_obj);
- }
-
- /**
- * Test the breakpoints defined by the custom group.
- */
- public function testThemeBreakpointGroup() {
- // Verify the breakpoint group 'test' was created by breakpoint_test_theme.
- $breakpoint_group_obj = entity_create('breakpoint_group', array(
- 'label' => 'Test Theme',
- 'name' => 'test',
- 'sourceType' => Breakpoint::SOURCE_TYPE_THEME,
- 'source' => 'breakpoint_test_theme',
- 'id' => Breakpoint::SOURCE_TYPE_THEME . '.breakpoint_test_theme.test',
- ));
- $breakpoint_group_obj->addBreakpoints(entity_load_multiple('breakpoint',
- array(
- 'theme.breakpoint_test_theme.mobile',
- 'theme.breakpoint_test_theme.narrow',
- 'theme.breakpoint_test_theme.wide',
- )
- ));
-
- // Verify we can load this breakpoint defined by the theme.
- $this->verifyBreakpointGroup($breakpoint_group_obj);
- }
-
-}