diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php index 012dc03bc5..967dfb630b 100644 --- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\field\Functional\EntityReference; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\entity_test\Entity\EntityTestNoBundle; use Drupal\field\Entity\FieldConfig; use Drupal\Tests\BrowserTestBase; use Drupal\Tests\field\Traits\EntityReferenceTestTrait; @@ -230,11 +229,18 @@ public function testMultipleTargetBundles() { * Tests if an entity reference field have no bundles. */ public function testNoBundles() { + $account = $this->drupalCreateUser([ + 'access content', + "create $this->referencingType content", + 'administer entity_test content', + ]); + $this->drupalLogin($account); + $field_name = mb_strtolower($this->randomMachineName()); $handler_settings = [ 'auto_create' => TRUE, ]; - $this->createEntityReferenceField('node', $this->referencingType, $field_name, $this->randomString(), 'entity_test_no_bundle', 'default', $handler_settings); + $this->createEntityReferenceField('node', $this->referencingType, $field_name, $this->randomString(), 'entity_test_no_bundle_with_label', 'default', $handler_settings); entity_get_form_display('node', $this->referencingType, 'default') ->setComponent($field_name, ['type' => 'entity_reference_autocomplete']) ->save(); @@ -249,7 +255,7 @@ public function testNoBundles() { $this->drupalPostForm('node/add/' . $this->referencingType, $edit, 'Save'); // Assert referenced entity was created. - $result = \Drupal::entityQuery('entity_test_no_bundle') + $result = \Drupal::entityQuery('entity_test_no_bundle_with_label') ->condition('name', $name) ->execute(); $this->assertTrue($result, 'Referenced entity was created.'); diff --git a/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestNoBundleWithLabel.php b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestNoBundleWithLabel.php new file mode 100644 index 0000000000..84771f8495 --- /dev/null +++ b/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestNoBundleWithLabel.php @@ -0,0 +1,28 @@ +