Commit 221e6175 authored by gbyte.co's avatar gbyte.co

Issue #3079897 by idimopoulos, manuel.adan, gbyte.co, mjt772: entity_legal add...

Issue #3079897 by idimopoulos, manuel.adan, gbyte.co, mjt772: entity_legal add form breaks with simple_sitemap
parent 268ec89c
......@@ -408,7 +408,7 @@ class FormHelper {
$this->setEntityTypeId($entity_type_id);
$this->setBundleName($this->entityHelper->getEntityInstanceBundleName($form_entity));
// New menu link's id is '' instead of NULL, hence checking for empty.
$this->setInstanceId(!empty($form_entity->id()) ? $form_entity->id() : NULL);
$this->setInstanceId(!$form_entity->isNew() && !empty($form_entity->id()) ? $form_entity->id() : NULL);
break;
default:
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\simple_sitemap\Functional;
use Drupal\Core\Url;
use Drupal\node\Entity\Node;
/**
* Tests Simple XML Sitemap functional integration.
......@@ -376,6 +377,20 @@ class SimplesitemapTest extends SimplesitemapTestBase {
$this->assertTrue(empty($result));
}
/**
* Tests that a page does not break if an entity has its id set.
*/
public function testNewEntityWithIdSet() {
$new_node = Node::create([
'nid' => rand(5, 10),
'type' => 'page',
]);
// Assert that the form does not break if an entity has an id but is not
// saved.
// @see https://www.drupal.org/project/simple_sitemap/issues/3079897
\Drupal::service('entity.form_builder')->getForm($new_node);
}
/**
* Test indexing an atomic entity (here: a user)
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment