diff -u b/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module --- b/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -35,6 +35,8 @@ * Implements hook_enable(). * * Import breakpoints from all enabled themes. + * + * @todo: This should be removed if https://drupal.org/node/1813100 is resolved. */ function breakpoint_enable() { // Import breakpoints from themes. @@ -53,6 +55,8 @@ * An array of theme names. * * @see _breakpoint_theme_enabled() + * + * @todo: This should be removed if https://drupal.org/node/1813100 is resolved. */ function breakpoint_themes_enabled($theme_list) { _breakpoint_theme_enabled($theme_list); @@ -65,6 +69,8 @@ * An array of theme names. * * @see _breakpoint_delete_breakpoints() + * + * @todo: This should be removed if https://drupal.org/node/1813100 is resolved. */ function breakpoint_themes_disabled($theme_list) { _breakpoint_delete_breakpoints($theme_list, Breakpoint::SOURCE_TYPE_THEME); @@ -77,7 +83,9 @@ * An array of the modules that were enabled. * * @see _breakpoint_modules_enabled() - */ + * + * @todo: This should be removed if https://drupal.org/node/1813100 is resolved. +*/ function breakpoint_modules_enabled($modules) { _breakpoint_modules_enabled($modules); } @@ -89,6 +97,8 @@ * An array of the modules that were uninstalled. * * @see _breakpoint_delete_breakpoints() + * + * @todo: This should be removed if https://drupal.org/node/1813100 is resolved. */ function breakpoint_modules_uninstalled($modules) { _breakpoint_delete_breakpoints($modules, Breakpoint::SOURCE_TYPE_MODULE); @@ -366,7 +376,7 @@ * @return array * An array containing breakpoint group labels indexed by their ids. */ -function breakpoint_group_labels() { +function breakpoint_group_select_options() { $options = array(); $breakpoint_groups = entity_load_multiple('breakpoint_group'); foreach ($breakpoint_groups as $breakpoint_group) { @@ -382,13 +392,13 @@ * @return array * An array containing breakpoints indexed by their ids. */ -function breakpoint_labels() { +function breakpoint_select_options() { $options = array(); $breakpoints = entity_load_multiple('breakpoint'); foreach ($breakpoints as $breakpoint) { $options[$breakpoint->id()] = $breakpoint->label() . ' (' . $breakpoint->source . ' - ' . $breakpoint->sourceType . ') [' . $breakpoint->mediaQuery . ']'; } - + asort($options); return $options; } @@ -405,6 +415,9 @@ * Either Breakpoint::SOURCE_TYPE_THEME or Breakpoint::SOURCE_TYPE_MODULE. * * @return Drupal\breakpoint\BreakpointGroup + * + * @see _breakpoint_import_media_queries() + * @see _breakpoint_import_breakpoint_groups() */ function _breakpoint_group_create_or_load($name, $label, $source, $source_type) { // Try loading the breakpoint group. diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Breakpoint.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Breakpoint.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Breakpoint.php @@ -32,7 +32,7 @@ /** * Denotes that a breakpoint or breakpoint group is defined by the user. */ - const SOURCE_TYPE_CUSTOM = 'custom'; + const SOURCE_TYPE_USER_DEFINED = 'custom'; /** * The breakpoint ID (config name). @@ -83,9 +83,9 @@ * Allowed values: * Breakpoint::SOURCE_TYPE_THEME * Breakpoint::SOURCE_TYPE_MODULE - * Breakpoint::SOURCE_TYPE_CUSTOM + * Breakpoint::SOURCE_TYPE_USER_DEFINED */ - public $sourceType = Breakpoint::SOURCE_TYPE_CUSTOM; + public $sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED; /** * The breakpoint weight. @@ -134,19 +134,6 @@ } /** - * Duplicates a breakpoint. - * - * The new breakpoint inherits the media query. - * - * @return Drupal\breakpoint\Breakpoint - */ - public function duplicate() { - return entity_create('breakpoint', array( - 'mediaQuery' => $this->mediaQuery, - )); - } - - /** * Checks if the breakpoint is valid. * * @throws Drupal\breakpoint\InvalidBreakpointSourceTypeException @@ -159,7 +146,7 @@ public function isValid() { // Check for illegal values in breakpoint source type. if (!in_array($this->sourceType, array( - Breakpoint::SOURCE_TYPE_CUSTOM, + Breakpoint::SOURCE_TYPE_USER_DEFINED, Breakpoint::SOURCE_TYPE_MODULE, Breakpoint::SOURCE_TYPE_THEME) )) { @@ -191,6 +178,8 @@ * @see https://github.com/adobe/webkit/blob/master/Source/WebCore/css/ */ public static function isValidMediaQuery($media_query) { + // Array describing all known media features and the expected value type or + // an array containing the allowed values. $media_features = array( 'width' => 'length', 'min-width' => 'length', 'max-width' => 'length', 'height' => 'length', 'min-height' => 'length', 'max-height' => 'length', @@ -213,7 +202,7 @@ // Remove comments /* ... */. $media_query = preg_replace('/\/\*[\s\S]*?\*\//', '', $media_query); - // Check mediaQuery_list: S* [mediaQuery [ ',' S* mediaQuery ]* ]? + // Check media list. $parts = explode(',', $media_query); foreach ($parts as $part) { // Split on ' and ' @@ -221,15 +210,15 @@ $media_type_found = FALSE; foreach ($query_parts as $query_part) { $matches = array(); - // Check expression: '(' S* media_feature S* [ ':' S* expr ]? ')' S* + // Try to match: '(media_feature: value)' and variants. if (preg_match('/^\(([\w\-]+)(:\s?([\w\-\.]+))?\)/', trim($query_part), $matches)) { - // Single expression. + // Single expression like '(color)'. if (isset($matches[1]) && !isset($matches[2])) { if (!array_key_exists($matches[1], $media_features)) { throw new InvalidBreakpointMediaQueryException('Invalid media feature detected.'); } } - // Full expression. + // Full expression like '(min-width: 20em)'. elseif (isset($matches[3]) && !isset($matches[4])) { $value = trim($matches[3]); if (!array_key_exists($matches[1], $media_features)) { @@ -249,6 +238,7 @@ switch ($media_features[$matches[1]]) { case 'length': $length_matches = array(); + // Check for a valid number and an allowed unit. if (preg_match('/^(\-)?(\d+(?:\.\d+)?)?((?:|em|ex|px|cm|mm|in|pt|pc|deg|rad|grad|ms|s|hz|khz|dpi|dpcm))$/i', trim($value), $length_matches)) { // Only -0 is allowed. if ($length_matches[1] === '-' && $length_matches[2] !== '0') { @@ -268,14 +258,14 @@ } } - // Check [ONLY | NOT]? S* media_type + // Check for screen, only screen, not screen and variants. elseif (preg_match('/^((?:only|not)?\s?)([\w\-]+)$/i', trim($query_part), $matches)) { if ($media_type_found) { throw new InvalidBreakpointMediaQueryException('Only one media type is allowed.'); } $media_type_found = TRUE; } - // Check illegal [ONLY | NOT]? S* media_type + // Check for (scan), (only scan), (not scan) and variants. elseif (preg_match('/^((?:only|not)\s?)\(([\w\-]+)\)$/i', trim($query_part), $matches)) { throw new InvalidBreakpointMediaQueryException('Invalid media query detected.'); } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/BreakpointGroup.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/BreakpointGroup.php @@ -69,11 +69,11 @@ * Allowed values: * Breakpoint::SOURCE_TYPE_THEME * Breakpoint::SOURCE_TYPE_MODULE - * Breakpoint::SOURCE_TYPE_CUSTOM + * Breakpoint::SOURCE_TYPE_USER_DEFINED * * @see Drupal\breakpoint\Breakpoint */ - public $sourceType = Breakpoint::SOURCE_TYPE_CUSTOM; + public $sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED; /** * Overrides Drupal\config\ConfigEntityBase::__construct(). @@ -112,7 +112,7 @@ public function isValid() { // Check for illegal values in breakpoint group source type. if (!in_array($this->sourceType, array( - Breakpoint::SOURCE_TYPE_CUSTOM, + Breakpoint::SOURCE_TYPE_USER_DEFINED, Breakpoint::SOURCE_TYPE_MODULE, Breakpoint::SOURCE_TYPE_THEME) )) { @@ -132,20 +132,6 @@ } /** - * Duplicates a breakpoint group. - * - * The new breakpoint group inherits the breakpoints. - * - * @return Drupal\breakpoint\BreakpointGroup - */ - public function duplicate() { - return entity_create('breakpoint_group', array( - 'breakpoints' => array_keys($this->breakpoints), - 'name' => 'clone_of_' . $this->name, - )); - } - - /** * Adds a breakpoint using a name and a media query. * * @param string $name @@ -176,7 +162,7 @@ * * The breakpoint name is either the machine_name or the id of a breakpoint. * - * @param type $breakpoints + * @param array $breakpoints * Array containing breakpoints keyed by their id. */ public function addBreakpoints($breakpoints) { diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php @@ -17,9 +17,6 @@ */ class BreakpointAPITest extends BreakpointTestBase { - /** - * Drupal\simpletest\WebTestBase\getInfo(). - */ public static function getInfo() { return array( 'name' => 'Breakpoint general API functions', @@ -46,11 +43,11 @@ catch (InvalidBreakpointSourceTypeException $e) { $exception = TRUE; } - $this->assertTrue($exception, t('breakpoint_config_name: An exception is thrown when an invalid sourceType is entered.')); + $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid sourceType is entered.'); // Try an invalid source. $breakpoint->id = ''; - $breakpoint->sourceType = Breakpoint::SOURCE_TYPE_CUSTOM; + $breakpoint->sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED; $breakpoint->source = 'custom*_module source'; $exception = FALSE; @@ -60,7 +57,7 @@ catch (InvalidBreakpointSourceException $e) { $exception = TRUE; } - $this->assertTrue($exception, t('breakpoint_config_name: An exception is thrown when an invalid source is entered.')); + $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->id = ''; @@ -74,7 +71,7 @@ catch (InvalidBreakpointNameException $e) { $exception = TRUE; } - $this->assertTrue($exception, t('breakpoint_config_name: An exception is thrown when an invalid name is entered.')); + $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid name is entered.'); // Try a valid breakpoint. $breakpoint->id = ''; @@ -89,6 +86,6 @@ $exception = TRUE; } - $this->assertFalse($exception, t('breakpoint_config_name: No exception is thrown when a valid breakpoint is passed.')); - $this->assertEqual($breakpoint->id(), Breakpoint::SOURCE_TYPE_CUSTOM . '.custom_module.' . $breakpoint->name, t('breakpoint_config_name: A id is set when a valid breakpoint is passed.')); + $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.'); } } reverted: --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCrudTest.php +++ /dev/null @@ -1,57 +0,0 @@ - 'Breakpoint CRUD operations', - 'description' => 'Test creation, loading, updating, deleting of breakpoints.', - 'group' => 'Breakpoint', - ); - } - - /** - * Test CRUD operations for breakpoints. - */ - public function testBreakpointCrud() { - // Add a breakpoint with minimum data only. - $breakpoint = entity_create('breakpoint', array( - 'label' => drupal_strtolower($this->randomName()), - 'mediaQuery' => '(min-width: 600px)', - )); - $breakpoint->save(); - - $this->verifyBreakpoint($breakpoint); - - // Test breakpoint_load_all - $all_breakpoints = entity_load_multiple('breakpoint'); - $config_name = $breakpoint->id(); - $this->assertTrue(isset($all_breakpoints[$config_name]), t('breakpoint_load_all: 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->assertFalse(breakpoint_load($config_name), t('breakpoint_load: Loading a deleted breakpoint returns false.'), t('Breakpoints API')); - } -} diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php @@ -18,9 +18,6 @@ */ class BreakpointGroupAPITest extends BreakpointGroupTestBase { - /** - * Drupal\simpletest\WebTestBase\getInfo(). - */ public static function getInfo() { return array( 'name' => 'Breakpoint group general API functions', @@ -49,11 +46,11 @@ catch (InvalidBreakpointSourceTypeException $e) { $exception = TRUE; } - $this->assertTrue($exception, t('An exception is thrown when an invalid sourceType is entered.')); + $this->assertTrue($exception, 'An exception is thrown when an invalid sourceType is entered.'); // Try an invalid source. $breakpoint_group->name = ''; - $breakpoint_group->sourceType = Breakpoint::SOURCE_TYPE_CUSTOM; + $breakpoint_group->sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED; $breakpoint_group->source = 'custom*_module source'; $exception = FALSE; @@ -63,7 +60,7 @@ catch (InvalidBreakpointSourceException $e) { $exception = TRUE; } - $this->assertTrue($exception, t('An exception is thrown when an invalid source is entered.')); + $this->assertTrue($exception, 'An exception is thrown when an invalid source is entered.'); // Try a valid breakpoint_group. $breakpoint_group->name = 'test'; @@ -77,5 +74,5 @@ $exception = TRUE; } - $this->assertFalse($exception, t('No exception is thrown when a valid data is passed.')); + $this->assertFalse($exception, 'No exception is thrown when a valid data is passed.'); } } reverted: --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupCrudTest.php +++ /dev/null @@ -1,72 +0,0 @@ - 'Breakpoint group CRUD operations', - 'description' => 'Test creation, loading, updating, deleting of breakpoint groups.', - 'group' => 'Breakpoint', - ); - } - - /** - * 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->randomName()), - 'weight' => $i, - 'mediaQuery' => "(min-width: {$width}px)", - )); - $breakpoint->save(); - $breakpoints[$breakpoint->id()] = $breakpoint; - } - // Add a breakpoint group with minimum data only. - $label = $this->randomName(); - - $group = entity_create('breakpoint_group', array( - 'label' => $label, - 'name' => drupal_strtolower($label), - )); - $group->save(); - $this->verifyBreakpointGroup($group); - - // Update the breakpoint group. - $group->breakpoints = array_keys($breakpoints); - $group->save(); - $this->verifyBreakpointGroup($group); - - // Duplicate the breakpoint group. - $new_set = entity_create('breakpoint_group', array( - 'breakpoints' => $group->breakpoints, - 'name' => 'clone_of_' . $group->name, - )); - $duplicated_set = $group->duplicate(); - $this->verifyBreakpointGroup($duplicated_set, $new_set); - - // Delete the breakpoint group. - $group->delete(); - $this->assertFalse(entity_load('breakpoint_group', $group->id()), t('breakpoint_group_load: Loading a deleted breakpoint group returns false.'), t('Breakpoints API')); - } -} diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupTestBase.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupTestBase.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupTestBase.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupTestBase.php @@ -21,9 +21,6 @@ */ public static $modules = array('breakpoint'); - /** - * Drupal\simpletest\WebTestBase\setUp(). - */ public function setUp() { parent::setUp(); } @@ -39,7 +36,6 @@ 'breakpoints', 'sourceType', ); - $assert_set = t('Breakpoints API'); // Verify breakpoint_group_load(). $compare_set = is_null($compare_set) ? entity_load('breakpoint_group', $group->id()) : $compare_set; @@ -50,7 +46,7 @@ '%property' => $property, ); if (is_array($compare_set->{$property})) { - $this->assertEqual(array_keys($compare_set->{$property}), array_keys($group->{$property}), t('breakpoint_group_load: Proper %property for breakpoint group %group.', $t_args), $assert_set); + $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( @@ -59,7 +55,7 @@ '%property1' => $compare_set->{$property}, '%property2' => $group->{$property}, ); - $this->assertEqual($compare_set->{$property}, $group->{$property}, t('breakpoint_group_load: Proper %property: %property1 == %property2 for breakpoint group %group.', $t_args), $assert_set); + $this->assertEqual($compare_set->{$property}, $group->{$property}, format_string('breakpoint_group_load: Proper %property: %property1 == %property2 for breakpoint group %group.', $t_args), 'Breakpoint API'); } } } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointMediaQueryTest.php @@ -15,9 +15,6 @@ */ class BreakpointMediaQueryTest extends UnitTestBase { - /** - * Drupal\simpletest\WebTestBase\getInfo(). - */ public static function getInfo() { return array( 'name' => 'Breakpoint media query tests', @@ -42,6 +39,7 @@ '(min-width: 0px)', 'all and (min-width: 480px) and (max-width: 959px)', 'all and (min-width: 960px)', + // Other media queries. '(orientation)', 'all and (orientation)', 'not all and (orientation)', @@ -118,7 +116,7 @@ $this->assertFalse(Breakpoint::isValidMediaQuery($media_query), $media_query . ' is not valid.'); } catch (InvalidBreakpointMediaQueryException $e) { - $this->assertTrue(TRUE, $media_query . ' is not valid.'); + $this->assertTrue(TRUE, format_string('%media_query is not valid.', array('%media_query' => $media_query))); } } } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointTestBase.php @@ -21,9 +21,6 @@ */ public static $modules = array('breakpoint'); - /** - * Drupal\simpletest\WebTestBase\setUp(). - */ public function setUp() { parent::setUp(); } @@ -40,7 +37,6 @@ 'weight', 'multipliers', ); - $assert_group = t('Breakpoints API'); // Verify breakpoint_load(). $compare_breakpoint = is_null($compare_breakpoint) ? breakpoint_load($breakpoint->id()) : $compare_breakpoint; @@ -49,7 +45,7 @@ '%breakpoint' => $breakpoint->label(), '%property' => $property, ); - $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, t('breakpoint_load: Proper %property for breakpoint %breakpoint.', $t_args), $assert_group); + $this->assertEqual($compare_breakpoint->{$property}, $breakpoint->{$property}, format_string('breakpoint_load: Proper %property for breakpoint %breakpoint.', $t_args), 'Breakpoint API'); } } } diff -u b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php --- b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointThemeTest.php @@ -22,9 +22,6 @@ */ public static $modules = array('breakpoint_theme_test'); - /** - * Drupal\simpletest\WebTestBase\getInfo(). - */ public static function getInfo() { return array( 'name' => 'Breakpoint theme functionality', @@ -33,9 +30,6 @@ ); } - /** - * Drupal\simpletest\WebTestBase\setUp(). - */ public function setUp() { parent::setUp(); theme_enable(array('breakpoint_test_theme')); @@ -65,7 +59,7 @@ // Disable the test theme and verify the breakpoint group is deleted. theme_disable(array('breakpoint_test_theme')); - $this->assertFalse(entity_load('breakpoint_group', $breakpoint_group_obj->id()), t('breakpoint_group_load: Loading a deleted breakpoint group returns false.'), t('Breakpoints API')); + $this->assertFalse(entity_load('breakpoint_group', $breakpoint_group_obj->id()), 'breakpoint_group_load: Loading a deleted breakpoint group returns false.', 'Breakpoint API'); } /** @@ -74,7 +68,7 @@ public function testThemeBreakpointGroup() { // Verify the breakpoint group 'test' was created by breakpoint_test_theme. $breakpoint_group_obj = entity_create('breakpoint_group', array( - 'label' => 'Test', + 'label' => 'Test Theme', 'name' => 'test', 'sourceType' => Breakpoint::SOURCE_TYPE_THEME, 'source' => 'breakpoint_test_theme', @@ -91,7 +85,7 @@ // Disable the test theme and verify the breakpoint group is deleted. theme_disable(array('breakpoint_test_theme')); - $this->assertFalse(entity_load('breakpoint_group', $breakpoint_group_obj->id()), t('breakpoint_group_load: Loading a deleted breakpoint group returns false.'), t('Breakpoints API')); + $this->assertFalse(entity_load('breakpoint_group', $breakpoint_group_obj->id()), 'breakpoint_group_load: Loading a deleted breakpoint group returns false.', 'Breakpoint API'); } /** diff -u b/core/modules/breakpoint/tests/themes/breakpoint_test_theme/config/breakpoint_test_theme.breakpoint_groups.yml b/core/modules/breakpoint/tests/themes/breakpoint_test_theme/config/breakpoint_test_theme.breakpoint_groups.yml --- b/core/modules/breakpoint/tests/themes/breakpoint_test_theme/config/breakpoint_test_theme.breakpoint_groups.yml +++ b/core/modules/breakpoint/tests/themes/breakpoint_test_theme/config/breakpoint_test_theme.breakpoint_groups.yml @@ -1,5 +1,5 @@ test: - label: Test + label: Test Theme breakpoints: - mobile - narrow only in patch2: unchanged: --- /dev/null +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php @@ -0,0 +1,54 @@ + 'Breakpoint CRUD operations', + 'description' => 'Test creation, loading, updating, deleting of breakpoints.', + 'group' => 'Breakpoint', + ); + } + + /** + * Test CRUD operations for breakpoints. + */ + public function testBreakpointCRUD() { + // Add a breakpoint with minimum data only. + $breakpoint = entity_create('breakpoint', array( + 'label' => drupal_strtolower($this->randomName()), + 'mediaQuery' => '(min-width: 600px)', + )); + $breakpoint->save(); + + $this->verifyBreakpoint($breakpoint); + + // Test breakpoint_load_all + $all_breakpoints = entity_load_multiple('breakpoint'); + $config_name = $breakpoint->id(); + $this->assertTrue(isset($all_breakpoints[$config_name]), 'breakpoint_load_all: 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->assertFalse(breakpoint_load($config_name), 'breakpoint_load: Loading a deleted breakpoint returns false.', 'Breakpoints API'); + } +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupCRUDTest.php @@ -0,0 +1,61 @@ + 'Breakpoint group CRUD operations', + 'description' => 'Test creation, loading, updating, deleting of breakpoint groups.', + 'group' => 'Breakpoint', + ); + } + + /** + * 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->randomName()), + 'weight' => $i, + 'mediaQuery' => "(min-width: {$width}px)", + )); + $breakpoint->save(); + $breakpoints[$breakpoint->id()] = $breakpoint; + } + // Add a breakpoint group with minimum data only. + $label = $this->randomName(); + + $group = entity_create('breakpoint_group', array( + 'label' => $label, + 'name' => drupal_strtolower($label), + )); + $group->save(); + $this->verifyBreakpointGroup($group); + + // Update the breakpoint group. + $group->breakpoints = array_keys($breakpoints); + $group->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'); + } +}