Commit 4fe54558 authored by alexpott's avatar alexpott

Issue #2385227 by tibbsa: Clean-up entity_reference module test members -...

Issue #2385227 by tibbsa: Clean-up entity_reference module test members - ensure property definition and use of camelCase naming convention
parent 4bdc6840
......@@ -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();
......
......@@ -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 @@ protected function setUp() {
* 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 @@ public function testAutoCreate() {
// 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 @@ public function testAutoCreate() {
'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 @@ public function testAutoCreate() {
// 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);
......
......@@ -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 @@ protected function setUp() {
$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);
}
/**
......
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