Issue #1813832 by andypost, xjm, sun: Fixed Entity wrongly checks existence of ID in isNew() method.

8.0.x
webchick 2012-10-23 19:56:52 -07:00
parent f711ad88d8
commit 453b2517f5
3 changed files with 15 additions and 2 deletions

View File

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

View File

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

View File

@ -85,6 +85,19 @@ class ConfigEntityTest extends WebTestBase {
$this->assertResponse(200); $this->assertResponse(200);
$this->assertNoText($label1); $this->assertNoText($label1);
$this->assertText($label3); $this->assertText($label3);
// Create a configuration entity with '0' machine name.
$edit = array(
'id' => '0',
'label' => '0',
);
$this->drupalPost('admin/structure/config_test/add', $edit, 'Save');
$this->assertResponse(200);
$message_insert = format_string('%label configuration has been created.', array('%label' => $edit['id']));
$this->assertRaw($message_insert);
$this->drupalPost('admin/structure/config_test/manage/0/delete', array(), 'Delete');
$this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted');
} }
} }