Commit d8f4b270 authored by catch's avatar catch
Browse files

Issue #3139429 by mondrake, rahulrasgon, mohrerao, siddhant.bhosale, paulocs,...

Issue #3139429 by mondrake, rahulrasgon, mohrerao, siddhant.bhosale, paulocs, longwave, jungle, cburschka, munish.kumar: Replace usages of AssertLegacyTrait::assert(No)FieldByXPath, that is deprecated

(cherry picked from commit 652efc72)
parent d8348473
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public function testHtml() {

    // Ensure that a block's ID is converted to an HTML valid ID, and that
    // block-specific attributes are added to the same DOM element.
    $this->assertFieldByXPath('//div[@id="block-test-html-block" and @data-custom-attribute="foo"]', NULL, 'HTML ID and attributes for test block are valid and on the same DOM element.');
    $this->assertSession()->elementExists('xpath', '//div[@id="block-test-html-block" and @data-custom-attribute="foo"]');

    // Ensure expected markup for a menu block.
    $elements = $this->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', [':nav-class' => 'block-menu', ':ul-class' => 'menu']);
+2 −2
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ public function testBlock() {
    // Check for <div id="block-my-block-instance-name"> if the machine name
    // is my_block_instance_name.
    $xpath = $this->assertSession()->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]);
    $this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.');
    $this->assertSession()->elementNotExists('xpath', $xpath);

    // Test deleting the block from the edit form.
    $this->drupalGet('admin/structure/block/manage/' . $block['id']);
@@ -352,7 +352,7 @@ public function moveBlockToRegion(array $block, $region) {
      ':region-class' => 'region region-' . Html::getClass($region),
      ':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])),
    ]);
    $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', ['%region_name' => Html::getClass($region)]));
    $this->assertSession()->elementExists('xpath', $xpath);
  }

  /**
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public function testContextAwareBlocks() {
    // Tests that conditions with missing context are not displayed.
    $this->drupalGet('admin/structure/block/manage/testcontextawareblock');
    $this->assertNoRaw('No existing type');
    $this->assertNoFieldByXPath('//*[@name="visibility[condition_test_no_existing_type][negate]"]');
    $this->assertSession()->elementNotExists('xpath', '//*[@name="visibility[condition_test_no_existing_type][negate]"]');
  }

  /**
+3 −3
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public function testBlockContentCreation() {
    ]));

    // Check that the view mode setting is hidden because only one exists.
    $this->assertNoFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting hidden because only one exists');
    $this->assertSession()->fieldNotExists('settings[view_mode]');

    // Check that the block exists in the database.
    $blocks = \Drupal::entityTypeManager()
@@ -140,7 +140,7 @@ public function testBlockContentCreationMultipleViewModes() {

    // Check that the view mode setting is shown because more than one exists.
    $this->drupalGet('admin/structure/block/manage/testblock');
    $this->assertFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting shown because multiple exist');
    $this->assertSession()->fieldExists('settings[view_mode]');

    // Change the view mode.
    $view_mode['region'] = 'content';
@@ -149,7 +149,7 @@ public function testBlockContentCreationMultipleViewModes() {

    // Go to the configure page and verify the view mode has changed.
    $this->drupalGet('admin/structure/block/manage/testblock');
    $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]', 'test_view_mode', 'View mode changed to Test View Mode');
    $this->assertSession()->fieldValueEquals('settings[view_mode]', 'test_view_mode');

    // Check that the block exists in the database.
    $blocks = \Drupal::entityTypeManager()
+3 −3
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public function testListing() {

    // Confirm that once the user returns to the listing, the text of the label
    // (versus elsewhere on the page).
    $this->assertFieldByXpath('//td', $label, 'Label found for added block.');
    $this->assertSession()->elementTextContains('xpath', '//td', $label);

    // Check the number of table row cells.
    $elements = $this->xpath('//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td');
@@ -98,7 +98,7 @@ public function testListing() {

    // Confirm that once the user returns to the listing, the text of the label
    // (versus elsewhere on the page).
    $this->assertFieldByXpath('//td', $new_label, 'Label found for updated custom block.');
    $this->assertSession()->elementTextContains('xpath', '//td', $new_label);

    // Delete the added entity using the operations link.
    $this->assertSession()->linkByHrefExists('block/' . $block->id() . '/delete');
@@ -110,7 +110,7 @@ public function testListing() {

    // Verify that the text of the label and machine name does not appear in
    // the list (though it may appear elsewhere on the page).
    $this->assertNoFieldByXpath('//td', $new_label, 'No label found for deleted custom block.');
    $this->assertSession()->elementTextNotContains('xpath', '//td', $new_label);

    // Confirm that the empty text is displayed.
    $this->assertText(t('There are no custom blocks yet.'));
Loading