Commit 9c2bfa8d authored by catch's avatar catch
Browse files

Issue #3203476 by mondrake, longwave, alexpott: Convert assertions involving...

Issue #3203476 by mondrake, longwave, alexpott: Convert assertions involving use of xpath on divs to WebAssert
parent 20205709
......@@ -272,8 +272,8 @@ public function testBlockThemeSelector() {
// Set the default theme and ensure the block is placed.
$theme_settings->set('default', $theme)->save();
$this->drupalGet('');
$elements = $this->xpath('//div[@id = :id]', [':id' => Html::getUniqueId('block-' . $block['id'])]);
$this->assertTrue(!empty($elements), 'The block was found.');
$block_id = Html::getUniqueId('block-' . $block['id']);
$this->assertSession()->elementExists('xpath', "//div[@id = '$block_id']");
}
}
......
......@@ -93,8 +93,7 @@ public function testBlockDemoUiPage() {
$this->drupalPlaceBlock('help_block', ['region' => 'help']);
$this->drupalGet('admin/structure/block');
$this->clickLink(t('Demonstrate block regions (@theme)', ['@theme' => 'Classy']));
$elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']);
$this->assertTrue(!empty($elements), 'Block demo regions are shown.');
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), "Highlighted")]');
// Ensure that other themes can use the block demo page.
\Drupal::service('theme_installer')->install(['test_theme']);
......@@ -201,16 +200,10 @@ public function testCandidateBlockList() {
* Tests the behavior of unsatisfied context-aware blocks.
*/
public function testContextAwareUnsatisfiedBlocks() {
$arguments = [
':category' => 'Block test',
':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/classy',
':text' => 'Test context-aware unsatisfied block',
];
$this->drupalGet('admin/structure/block');
$this->clickLink('Place block');
$elements = $this->xpath('//tr[.//td/div[text()=:text] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]', $arguments);
$this->assertTrue(empty($elements), 'The context-aware test block does not appear.');
// Verify that the context-aware test block does not appear.
$this->assertSession()->elementNotExists('xpath', '//tr[.//td/div[text()="Test context-aware unsatisfied block"] and .//td[text()="Block test"] and .//td//a[contains(@href, "admin/structure/block/add/test_context_aware_unsatisfied/classy")]]');
$definition = \Drupal::service('plugin.manager.block')->getDefinition('test_context_aware_unsatisfied');
$this->assertTrue(!empty($definition), 'The context-aware test block does not exist.');
......
......@@ -262,8 +262,7 @@ public function testBlockRendering() {
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']);
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual('Custom title', $result[0]->getText());
$this->assertSession()->elementTextEquals('xpath', '//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2', 'Custom title');
// Don't override the title anymore.
$plugin = $block->getPlugin();
......@@ -271,16 +270,14 @@ public function testBlockRendering() {
$block->save();
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertEqual('test_view_block', $result[0]->getText());
$this->assertSession()->elementTextEquals('xpath', '//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2', 'test_view_block');
// Hide the title.
$block->getPlugin()->setConfigurationValue('label_display', FALSE);
$block->save();
$this->drupalGet('');
$result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertTrue(empty($result), 'The title is not visible.');
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2');
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:system.site', 'config:views.view.test_view_block', 'http_response', 'rendered']));
}
......@@ -298,14 +295,14 @@ public function testBlockEmptyRendering() {
$block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']);
$this->drupalGet('');
$this->assertCount(1, $this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'));
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "block-views-blocktest-view-block-block-1")]', 1);
$display = &$view->getDisplay('block_1');
$display['display_options']['block_hide_empty'] = TRUE;
$view->save();
$this->drupalGet($url);
$this->assertCount(0, $this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'));
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "block-views-blocktest-view-block-block-1")]');
// Ensure that the view cacheability metadata is propagated even, for an
// empty block.
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered']));
......@@ -325,7 +322,7 @@ public function testBlockEmptyRendering() {
$view->save();
$this->drupalGet($url);
$this->assertCount(1, $this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'));
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "block-views-blocktest-view-block-block-1")]', 1);
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered']));
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
......@@ -343,7 +340,7 @@ public function testBlockEmptyRendering() {
$view->save();
$this->drupalGet($url);
$this->assertCount(0, $this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'));
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "block-views-blocktest-view-block-block-1")]');
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered']));
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
......@@ -360,7 +357,7 @@ public function testBlockEmptyRendering() {
$view->save();
$this->drupalGet($url);
$this->assertCount(1, $this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'));
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "block-views-blocktest-view-block-block-1")]', 1);
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block', 'http_response', 'rendered']));
$this->assertCacheContexts(['url.query_args:_wrapper_format']);
}
......
......@@ -41,18 +41,14 @@ public function testListing() {
$this->assertSession()->titleEquals('Custom block library | Drupal');
// Test for the table.
$element = $this->xpath('//div[@class="layout-content"]//table');
$this->assertNotEmpty($element, 'Configuration entity list table found.');
$this->assertSession()->elementExists('xpath', '//div[@class="layout-content"]//table');
// Test the table header.
$elements = $this->xpath('//div[@class="layout-content"]//table/thead/tr/th');
$this->assertCount(2, $elements, 'Correct number of table header cells found.');
// Test the table header, two cells should be present.
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/thead/tr/th', 2);
// Test the contents of each th cell.
$expected_items = [t('Block description'), t('Operations')];
foreach ($elements as $key => $element) {
$this->assertEqual($expected_items[$key], $element->getText());
}
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[1]', 'Block description');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[2]', 'Operations');
$label = 'Antelope';
$new_label = 'Albatross';
......@@ -71,12 +67,11 @@ public function testListing() {
$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');
$this->assertCount(2, $elements, 'Correct number of table row cells found.');
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td', 2);
// Check the contents of each row cell. The first cell contains the label,
// the second contains the machine name, and the third contains the
// operations list.
$this->assertSame($label, $elements[0]->getText());
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td[1]', $label);
// Edit the entity using the operations link.
$blocks = $this->container
......
......@@ -48,23 +48,16 @@ public function testListing() {
$this->assertSession()->fieldExists('type');
// Test for the table.
$element = $this->xpath('//div[@class="layout-content"]//table');
$this->assertNotEmpty($element, 'Views table found.');
$this->assertSession()->elementExists('xpath', '//div[@class="layout-content"]//table');
// Test the table header.
$elements = $this->xpath('//div[@class="layout-content"]//table/thead/tr/th');
$this->assertCount(4, $elements, 'Correct number of table header cells found.');
// Test the table header, four cells should be present.
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/thead/tr/th', 4);
// Test the contents of each th cell.
$expected_items = ['Block description', 'Block type', 'Updated Sort ascending', 'Operations'];
foreach ($elements as $key => $element) {
if ($element->find('xpath', 'a')) {
$this->assertSame($expected_items[$key], trim($element->find('xpath', 'a')->getText()));
}
else {
$this->assertSame($expected_items[$key], trim($element->getText()));
}
}
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[1]', 'Block description');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[2]', 'Block type');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[3]', 'Updated Sort ascending');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[4]', 'Operations');
$label = 'Antelope';
$new_label = 'Albatross';
......@@ -83,12 +76,11 @@ public function testListing() {
$this->assertSession()->elementTextContains('xpath', '//td/a', $label);
// Check the number of table row cells.
$elements = $this->xpath('//div[@class="layout-content"]//table/tbody/tr/td');
$this->assertCount(4, $elements, 'Correct number of table row cells found.');
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/tbody/tr/td', 4);
// Check the contents of each row cell. The first cell contains the label,
// the second contains the machine name, and the third contains the
// operations list.
$this->assertSame($label, $elements[0]->find('xpath', 'a')->getText());
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/tbody/tr/td/a', $label);
// Edit the entity using the operations link.
$blocks = $this->container
......
......@@ -168,29 +168,25 @@ public function testListUI() {
$this->assertSession()->titleEquals('Test configuration | Drupal');
// Test for the table.
$element = $this->xpath('//div[@class="layout-content"]//table');
$this->assertCount(1, $element, 'Configuration entity list table found.');
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table', 1);
// Test the table header.
$elements = $this->xpath('//div[@class="layout-content"]//table/thead/tr/th');
$this->assertCount(3, $elements, 'Correct number of table header cells found.');
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/thead/tr/th', 3);
// Test the contents of each th cell.
$expected_items = ['Label', 'Machine name', 'Operations'];
foreach ($elements as $key => $element) {
$this->assertSame($expected_items[$key], $element->getText());
}
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[1]', 'Label');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[2]', 'Machine name');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/thead/tr/th[3]', 'Operations');
// Check the number of table row cells.
$elements = $this->xpath('//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td');
$this->assertCount(3, $elements, 'Correct number of table row cells found.');
$this->assertSession()->elementsCount('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td', 3);
// Check the contents of each row cell. The first cell contains the label,
// the second contains the machine name, and the third contains the
// operations list.
$this->assertSame('Default', $elements[0]->getText());
$this->assertSame('dotted.default', $elements[1]->getText());
$this->assertNotEmpty($elements[2]->find('xpath', '//ul'), 'Operations list found.');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td[1]', 'Default');
$this->assertSession()->elementTextEquals('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td[2]', 'dotted.default');
$this->assertSession()->elementExists('xpath', '//div[@class="layout-content"]//table/tbody/tr[@class="odd"]/td[3]//ul');
// Add a new entity using the operations link.
$this->assertSession()->linkExists('Add test configuration');
......
......@@ -380,8 +380,8 @@ public function testSiteWideContact() {
$field_name . '[0][value]' => $this->randomMachineName(),
];
$this->submitForm($edit, 'Send message');
$result = $this->xpath('//div[@role=:role]', [':role' => 'contentinfo']);
$this->assertCount(0, $result, 'Messages not found.');
// Verify that messages are not found.
$this->assertSession()->elementNotExists('xpath', '//div[@role="contentinfo"]');
$this->assertSession()->addressEquals('user/' . $admin_user->id());
// Test preview and visibility of the message field and label. Submit the
......
......@@ -100,13 +100,10 @@ public function testContactLink() {
* Users which should have contact links.
*/
public function assertContactLinks(array $accounts, array $names) {
$result = $this->xpath('//div[contains(@class, "views-field-contact")]//a');
$this->assertSame(count($names), count($result));
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "views-field-contact")]//a', count($names));
foreach ($names as $name) {
$account = $accounts[$name];
$result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->toUrl('contact-form')->toString()]);
$this->assertGreaterThan(0, count($result));
$account_url = $accounts[$name]->toUrl('contact-form')->toString();
$this->assertSession()->elementExists('xpath', "//div[contains(@class, 'views-field-contact')]//a[contains(@href, '$account_url')]");
}
}
......
......@@ -122,8 +122,7 @@ public function testImageFieldSync() {
'settings[entity_test_mul][entity_test_mul][columns][field_test_et_ui_image][title]' => TRUE,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, 'Save configuration');
$errors = $this->xpath('//div[contains(@class, "messages--error")]');
$this->assertEmpty($errors, 'Settings correctly stored.');
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "messages--error")]');
$this->assertSession()->checkboxChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-alt');
$this->assertSession()->checkboxChecked('edit-settings-entity-test-mul-entity-test-mul-columns-field-test-et-ui-image-title');
$this->drupalLogin($this->translator);
......
......@@ -351,7 +351,7 @@ protected function doTestAuthoringInfo() {
'content_translation[created]' => '19/11/1978',
];
$this->drupalPostForm($entity->toUrl('edit-form'), $edit, $this->getFormSubmitAction($entity, $langcode));
$this->assertNotEmpty($this->xpath('//div[contains(@class, "error")]//ul'), 'Invalid values generate a list of form errors.');
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "error")]//ul');
$metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
$this->assertEqual($values[$langcode]['uid'], $metadata->getAuthor()->id(), 'Translation author correctly kept.');
$this->assertEqual($values[$langcode]['created'], $metadata->getCreatedTime(), 'Translation date correctly kept.');
......
......@@ -130,11 +130,8 @@ public function testBooleanFormatterSettings() {
// Test that the settings summary are present in the correct format.
$this->drupalGet('admin/structure/types/manage/' . $this->bundle . '/display');
$result = $this->xpath('//div[contains(@class, :class) and contains(text(), :text)]', [
':class' => 'field-plugin-summary',
':text' => (string) t('Display: @true_label / @false_label', ['@true_label' => $values[0], '@false_label' => $values[1]]),
]);
$this->assertCount(1, $result, "Boolean formatter settings summary exist.");
$this->assertSession()->elementExists('xpath', "//div[contains(@class, 'field-plugin-summary')]");
$this->assertSession()->elementTextEquals('xpath', "//div[contains(@class, 'field-plugin-summary')]", "Display: {$values[0]} / {$values[1]}");
}
}
......
......@@ -305,8 +305,7 @@ public function testFilterAdmin() {
$this->assertText('Basic page ' . $edit['title[0][value]'] . ' has been created.');
// Verify that the creation message contains a link to a node.
$view_link = $this->xpath('//div[contains(@class, "messages")]//a[contains(@href, :href)]', [':href' => 'node/']);
$this->assertNotEmpty($view_link, 'The message area contains a link to a node');
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "messages")]//a[contains(@href, "node/")]');
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertNotEmpty($node, 'Node found in database.');
......
......@@ -31,7 +31,8 @@ public function testWidgetElement() {
];
$this->createImageField($field_name, 'article', [], $field_settings, [], [], 'Image test on [site:name]');
$this->drupalGet('node/add/article');
$this->assertNotCount(0, $this->xpath('//div[contains(@class, "field--widget-image-image")]'), 'Image field widget found on add/node page', NULL);
// Verify that the image field widget is found on add/node page.
$this->assertSession()->elementExists('xpath', '//div[contains(@class, "field--widget-image-image")]');
// Verify that the image field widget limits accepted files.
$this->assertSession()->elementExists('xpath', '//input[contains(@accept, "image/*")]');
$this->assertNoText('Image test on [site:name]');
......
......@@ -33,10 +33,8 @@ public function testAJAXValidationMessage() {
$field->attachFile($this->container->get('file_system')->realpath($text_file->uri));
$this->assertSession()->waitForElement('css', '.messages--error');
$elements = $this->xpath('//div[contains(@class, :class)]', [
':class' => 'messages--error',
]);
$this->assertCount(1, $elements, 'Ajax validation messages are displayed once.');
// Verify that Ajax validation messages are displayed only once.
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "messages--error")]', 1);
}
/**
......
......@@ -223,20 +223,12 @@ public function testLanguageBlockWithDomain() {
$generator = $this->container->get('url_generator');
// Verify the English URL is correct
list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [
':id' => 'block-test-language-block',
':hreflang' => 'en',
]);
$english_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['en']]);
$this->assertEqual($english_link->getAttribute('href'), $english_url);
$this->assertSession()->elementAttributeContains('xpath', '//div[@id="block-test-language-block"]/ul/li/a[@hreflang="en"]', 'href', $english_url);
// Verify the Italian URL is correct
list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [
':id' => 'block-test-language-block',
':hreflang' => 'it',
]);
$italian_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['it']]);
$this->assertEqual($italian_link->getAttribute('href'), $italian_url);
$this->assertSession()->elementAttributeContains('xpath', '//div[@id="block-test-language-block"]/ul/li/a[@hreflang="it"]', 'href', $italian_url);
}
/**
......
......@@ -463,13 +463,11 @@ public function testUrlLanguageFallback() {
// Check that the language switcher active link matches the given browser
// language.
$args = [':id' => 'block-test-language-block', ':url' => Url::fromRoute('<front>')->toString() . $langcode_browser_fallback];
$fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args);
$this->assertSame($fields[0]->getText(), $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language');
$href = Url::fromRoute('<front>')->toString() . $langcode_browser_fallback;
$this->assertSession()->elementTextEquals('xpath', "//div[@id='block-test-language-block']//a[@class='language-link is-active' and starts-with(@href, '$href')]", $languages[$langcode_browser_fallback]->getName());
// Check that URLs are rewritten using the given browser language.
$fields = $this->xpath('//div[@class="site-name"]/a[@rel="home" and @href=:url]', $args);
$this->assertSame($fields[0]->getText(), 'Drupal', 'URLs are rewritten using the browser language.');
$this->assertSession()->elementTextEquals('xpath', "//div[@class='site-name']/a[@rel='home' and @href='$href']", 'Drupal');
}
/**
......
......@@ -19,20 +19,15 @@ public function assertButtons(array $buttons, $dropbutton = TRUE) {
// Verify that the number of buttons passed as parameters is
// available in the dropbutton widget.
if ($dropbutton) {
$i = 0;
$count = count($buttons);
// Assert there is no save button.
$this->assertSession()->buttonNotExists('Save');
// Dropbutton elements.
/** @var \Behat\Mink\Element\NodeElement[] $elements */
$elements = $this->xpath('//div[@class="dropbutton-wrapper"]//input[@type="submit"]');
$this->assertCount($count, $elements);
foreach ($elements as $element) {
$value = $element->getValue() ?: '';
$this->assertEqual($buttons[$i], $value);
$i++;
$this->assertSession()->elementsCount('xpath', '//div[@class="dropbutton-wrapper"]//input[@type="submit"]', $count);
for ($i = 0; $i++; $i < $count) {
$this->assertSession()->elementTextEquals('xpath', "(//div[@class='dropbutton-wrapper']//input[@type='submit'])[{$i + 1}]", $buttons[$i]);
}
}
else {
......
......@@ -119,7 +119,7 @@ public function testRecentNodeBlock() {
$this->assertText($node3->label());
// Check to make sure nodes are in the right order.
$this->assertNotEmpty($this->xpath('//div[@id="block-test-block"]//div[@class="item-list"]/ul/li[1]/div/span/a[text() = "' . $node3->label() . '"]'), 'Nodes were ordered correctly in block.');
$this->assertSession()->elementExists('xpath', '//div[@id="block-test-block"]//div[@class="item-list"]/ul/li[1]/div/span/a[text() = "' . $node3->label() . '"]');
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
......
......@@ -136,11 +136,7 @@ public function testMultilingualDisplaySettings() {
// Check if node body is showed.
$this->drupalGet('node/' . $node->id());
$body = $this->xpath('//article[contains(concat(" ", normalize-space(@class), " "), :node-class)]//div[contains(concat(" ", normalize-space(@class), " "), :content-class)]/descendant::p', [
':node-class' => ' node ',
':content-class' => 'node__content',
]);
$this->assertEqual($body[0]->getText(), $node->body->value, 'Node body found.');
$this->assertSession()->elementTextEquals('xpath', "//article[contains(concat(' ', normalize-space(@class), ' '), ' node ')]//div[contains(concat(' ', normalize-space(@class), ' '), 'node__content')]/descendant::p", $node->body->value);
}
}
......@@ -44,8 +44,7 @@ public function testPagePostInfo() {
// Check that the post information is displayed.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$elements = $this->xpath('//div[contains(@class, :class)]', [':class' => 'node__submitted']);
$this->assertCount(1, $elements, 'Post information is displayed.');
$this->assertSession()->elementsCount('xpath', '//div[contains(@class, "node__submitted")]', 1);
$node->delete();
// Set "Basic page" content type to display post information.
......@@ -59,9 +58,8 @@ public function testPagePostInfo() {
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, 'Save');
// Check that the post information is displayed.
$elements = $this->xpath('//div[contains(@class, :class)]', [':class' => 'node__submitted']);
$this->assertCount(0, $elements, 'Post information is not displayed.');
// Check that the post information is not displayed.
$this->assertSession()->elementNotExists('xpath', '//div[contains(@class, "node__submitted")]');
}
}
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