Issue #1813832 by andypost: Fixed Allow use '0' as id for entity.

8.0.x
Dries 2012-10-16 14:23:44 -04:00
parent d3edf50190
commit f8673ac410
3 changed files with 8 additions and 3 deletions

View File

@ -51,7 +51,8 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
* since each configuration entity is unique.
*/
final public function isNew() {
return !$this->id();
$id = $this->id();
return !isset($id);
}
/**

View File

@ -91,7 +91,8 @@ class Entity implements IteratorAggregate, EntityInterface {
* Implements EntityInterface::isNew().
*/
public function isNew() {
return !empty($this->enforceIsNew) || !$this->id();
$id = $this->id();
return !empty($this->enforceIsNew) || !isset($id);
}
/**

View File

@ -78,13 +78,16 @@ class ConfigEntityTest extends WebTestBase {
// Rename the configuration entity's ID/machine name.
$this->assertLinkByHref('admin/structure/config_test/manage/' . $id);
$edit = array(
'id' => strtolower($this->randomName()),
'id' => '0',
'label' => $label3,
);
$this->drupalPost('admin/structure/config_test/manage/' . $id, $edit, 'Save');
$this->assertResponse(200);
$this->assertNoText($label1);
$this->assertText($label3);
$this->drupalPost('admin/structure/config_test/manage/0/delete', array(), 'Delete');
$this->assertResponse(200);
$this->assertNoText($label3);
}
}