Unverified Commit d471b0c3 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3247694 by danflanagan8, mglaman: User tests should not rely on Classy

parent 3e14e0bb
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -21,14 +21,14 @@ class UserAccountLinksTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->drupalPlaceBlock('system_menu_block:account');
    $this->drupalPlaceBlock('system_menu_block:account', ['id' => 'user_account_links_test_system_menu_block_account']);
    // Make test-page default.
    $this->config('system.site')->set('page.front', '/test-page')->save();
  }
@@ -46,15 +46,15 @@ public function testSecondaryMenu() {

    // For a logged-in user, expect the secondary menu to have links for "My
    // account" and "Log out".
    $this->assertSession()->elementsCount('xpath', '//ul[@class="menu"]/li/a[contains(@href, "user") and text()="My account"]', 1);
    $this->assertSession()->elementsCount('xpath', '//ul[@class="menu"]/li/a[contains(@href, "user/logout") and text()="Log out"]', 1);
    $this->assertSession()->elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]', 1);
    $this->assertSession()->elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user/logout") and text()="Log out"]', 1);

    // Log out and get the homepage.
    $this->drupalLogout();
    $this->drupalGet('<front>');

    // For a logged-out user, expect the secondary menu to have a "Log in" link.
    $this->assertSession()->elementsCount('xpath', '//ul[@class="menu"]/li/a[contains(@href, "user/login") and text()="Log in"]', 1);
    $this->assertSession()->elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user/login") and text()="Log in"]', 1);
  }

  /**
@@ -69,7 +69,7 @@ public function testDisabledAccountLink() {

    // Verify that the 'My account' link exists before we check for its
    // disappearance.
    $this->assertSession()->elementsCount('xpath', '//ul[@class="menu"]/li/a[contains(@href, "user") and text()="My account"]', 1);
    $this->assertSession()->elementsCount('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]', 1);

    // Verify that the 'My account' link is enabled. Do not assume the value of
    // auto-increment is 1. Use XPath to obtain input element id and name using
@@ -87,7 +87,7 @@ public function testDisabledAccountLink() {
    $this->drupalGet('<front>');

    // Verify that the 'My account' link does not appear when disabled.
    $this->assertSession()->elementNotExists('xpath', '//ul[@class="menu"]/li/a[contains(@href, "user") and text()="My account"]');
    $this->assertSession()->elementNotExists('xpath', '//nav[@id="block-user-account-links-test-system-menu-block-account"]/ul/li/a[contains(@href, "user") and text()="My account"]');
  }

  /**
+2 −2
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ class UserAdminListingTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * Tests the listing.
@@ -73,7 +73,7 @@ public function testUserListing() {
      $account_columns = $account->findAll('css', 'td');
      $name = $account_columns[0]->find('css', 'a')->getText();
      $roles = [];
      $account_roles = $account_columns[2]->findAll('css', 'td div ul li');
      $account_roles = $account_columns[2]->findAll('css', 'td ul li');
      if (!empty($account_roles)) {
        foreach ($account_roles as $element) {
          $roles[] = $element->getText();
+4 −4
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ class UserBlocksTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * A user with the 'administer blocks' permission.
@@ -37,7 +37,7 @@ protected function setUp(): void {

    $this->adminUser = $this->drupalCreateUser(['administer blocks']);
    $this->drupalLogin($this->adminUser);
    $this->drupalPlaceBlock('user_login_block');
    $this->drupalPlaceBlock('user_login_block', ['id' => 'user_blocks_test_user_login_block']);
    $this->drupalLogout($this->adminUser);
  }

@@ -56,10 +56,10 @@ public function testUserLoginBlockVisibility() {
    foreach ($paths as $path => $expected_visibility) {
      $this->drupalGet($path);
      if ($expected_visibility) {
        $this->assertSession()->elementExists('xpath', '//div[contains(@class,"block-user-login-block") and @role="form"]');
        $this->assertSession()->elementExists('xpath', '//div[@id="block-user-blocks-test-user-login-block" and @role="form"]');
      }
      else {
        $this->assertSession()->elementNotExists('xpath', '//div[contains(@class,"block-user-login-block") and @role="form"]');
        $this->assertSession()->elementNotExists('xpath', '//div[@id="block-user-blocks-test-user-login-block" and @role="form"]');
      }
    }
  }
+3 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ class UserPictureTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * A regular user.
@@ -121,7 +121,7 @@ public function testPictureOnNodeComment() {

    // Verify that the image is displayed on the node page.
    $this->drupalGet('node/' . $node->id());
    $elements = $this->cssSelect('.node__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
    $elements = $this->cssSelect('article[role="article"] > footer img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
    $this->assertCount(1, $elements, 'User picture with alt text found on node page.');

    // Enable user pictures on comments, instead of nodes.
@@ -135,7 +135,7 @@ public function testPictureOnNodeComment() {
    ];
    $this->drupalGet('comment/reply/node/' . $node->id() . '/comment');
    $this->submitForm($edit, 'Save');
    $elements = $this->cssSelect('.comment__meta .field--name-user-picture img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
    $elements = $this->cssSelect('#comment-1 img[alt="' . $alt_text . '"][src="' . $image_url . '"]');
    $this->assertCount(1, $elements, 'User picture with alt text found on the comment.');

    // Disable user pictures on comments and nodes.
+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ class UserRoleAdminTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'classy';
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
@@ -41,7 +41,7 @@ protected function setUp(): void {
      'administer permissions',
      'administer users',
    ]);
    $this->drupalPlaceBlock('local_tasks_block');
    $this->drupalPlaceBlock('local_tasks_block', ['id' => 'test_role_admin_test_local_tasks_block']);
  }

  /**
@@ -52,7 +52,7 @@ public function testRoleAdministration() {
    $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
    // Test presence of tab.
    $this->drupalGet('admin/people/permissions');
    $this->assertSession()->elementsCount('xpath', '//ul[@class="tabs primary" and //a[contains(., "Roles")]]', 1);
    $this->assertSession()->elementsCount('xpath', '//div[@id="block-test-role-admin-test-local-tasks-block"]/ul/li/a[contains(., "Roles")]', 1);

    // Test adding a role. (In doing so, we use a role name that happens to
    // correspond to an integer, to test that the role administration pages
Loading