Issue #1813832 by andypost, xjm, sun: Fixed Entity wrongly checks existence of ID in isNew() method.
parent
f711ad88d8
commit
453b2517f5
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue