diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php index b2e74db..700315c 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php @@ -109,7 +109,10 @@ class Breakpoint extends ConfigEntityBase implements BreakpointInterface { * {@inheritdoc} */ public function id() { - return $this->sourceType . '.' . $this->source . '.' . $this->name; + if (!isset($this->id)) { + $this->id = $this->sourceType . '.' . $this->source . '.' . $this->name; + } + return $this->id; } /** diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php index 1154dd7..1d0833d 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php @@ -111,7 +111,10 @@ public function save() { * {@inheritdoc} */ public function id() { - return $this->sourceType . '.' . $this->source . '.' . $this->name; + if (!isset($this->id)) { + $this->id = $this->sourceType . '.' . $this->source . '.' . $this->name; + } + return $this->id; } /** diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php index 85d0711..e132280 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php @@ -46,7 +46,7 @@ public function testConfigName() { $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid sourceType is entered.'); // Try an invalid source. - $breakpoint->id = ''; + $breakpoint = $breakpoint->createDuplicate(); $breakpoint->sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED; $breakpoint->source = 'custom*_module source'; @@ -60,7 +60,7 @@ public function testConfigName() { $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 = ''; + $breakpoint = $breakpoint->createDuplicate(); $breakpoint->source = 'custom_module'; $breakpoint->name = drupal_ucfirst($this->randomName()); @@ -74,7 +74,7 @@ public function testConfigName() { $this->assertTrue($exception, 'breakpoint_config_name: An exception is thrown when an invalid name is entered.'); // Try a valid breakpoint. - $breakpoint->id = ''; + $breakpoint = $breakpoint->createDuplicate(); $breakpoint->name = drupal_strtolower($this->randomName()); $breakpoint->mediaQuery = 'all'; diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php index 3751c81..7a563f6 100644 --- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php +++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php @@ -49,6 +49,7 @@ public function testConfigName() { $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'; @@ -63,6 +64,7 @@ public function testConfigName() { $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';