diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php index 4d623784228a..a89606c32faf 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php @@ -27,6 +27,14 @@ class EntityReferenceAdminTest extends WebTestBase { */ public static $modules = array('node', 'field_ui', 'entity_reference', 'path', 'taxonomy'); + + /** + * The name of the content type created for testing purposes. + * + * @var string + */ + protected $type; + protected function setUp() { parent::setUp(); diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php index ac3ebf8b230d..ea4d37fe8bcb 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php @@ -20,15 +20,29 @@ class EntityReferenceAutoCreateTest extends WebTestBase { public static $modules = array('entity_reference', 'node'); + /** + * The name of a content type that will reference $referencedType. + * + * @var string + */ + protected $referencingType; + + /** + * The name of a content type that will be referenced by $referencingType. + * + * @var string + */ + protected $referencedType; + protected function setUp() { parent::setUp(); // Create "referencing" and "referenced" node types. $referencing = $this->drupalCreateContentType(); - $this->referencing_type = $referencing->type; + $this->referencingType = $referencing->type; $referenced = $this->drupalCreateContentType(); - $this->referenced_type = $referenced->type; + $this->referencedType = $referenced->type; entity_create('field_storage_config', array( 'field_name' => 'test_field', @@ -75,10 +89,10 @@ class EntityReferenceAutoCreateTest extends WebTestBase { * entity. */ public function testAutoCreate() { - $user1 = $this->drupalCreateUser(array('access content', "create $this->referencing_type content")); + $user1 = $this->drupalCreateUser(array('access content', "create $this->referencingType content")); $this->drupalLogin($user1); - $this->drupalGet('node/add/' . $this->referencing_type); + $this->drupalGet('node/add/' . $this->referencingType); $this->assertFieldByXPath('//input[@id="edit-test-field-0-target-id" and contains(@class, "form-autocomplete")]', NULL, 'The autocomplete input element appears.'); $new_title = $this->randomMachineName(); @@ -86,7 +100,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase { // Assert referenced node does not exist. $base_query = \Drupal::entityQuery('node'); $base_query - ->condition('type', $this->referenced_type) + ->condition('type', $this->referencedType) ->condition('title', $new_title); $query = clone $base_query; @@ -97,7 +111,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase { 'title[0][value]' => $this->randomMachineName(), 'test_field[0][target_id]' => $new_title, ); - $this->drupalPostForm("node/add/$this->referencing_type", $edit, 'Save'); + $this->drupalPostForm("node/add/$this->referencingType", $edit, 'Save'); // Assert referenced node was created. $query = clone $base_query; @@ -108,7 +122,7 @@ class EntityReferenceAutoCreateTest extends WebTestBase { // Assert the referenced node is associated with referencing node. $result = \Drupal::entityQuery('node') - ->condition('type', $this->referencing_type) + ->condition('type', $this->referencingType) ->execute(); $referencing_nid = key($result); diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php index aacc4b5395f5..3ccc84269b43 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php @@ -26,6 +26,13 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase { */ public static $modules = array('entity_reference', 'field_ui', 'node'); + /** + * A user with permission to administer content types, node fields, etc. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + protected function setUp() { parent::setUp(); @@ -34,8 +41,8 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase { $this->drupalCreateContentType(array('type' => 'referenced_content')); // Create admin user. - $this->admin_user = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('access content', 'administer content types', 'administer node fields', 'administer node form display', 'bypass node access')); + $this->drupalLogin($this->adminUser); } /**