Commit 4fe54558 authored by Alex Pott's avatar Alex Pott
Browse files

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
Loading
Loading
Loading
Loading
+8 −0
Changes for core/modules/entity_reference/src/Tests/EntityReferenceAdminTest.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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();

+21 −7
Changes for core/modules/entity_reference/src/Tests/EntityReferenceAutoCreateTest.php: 21 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -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);
+9 −2
Changes for core/modules/entity_reference/src/Tests/EntityReferenceFieldDefaultValueTest.php: 9 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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);
  }

  /**