Unverified Commit c114930c authored by alexpott's avatar alexpott
Browse files

Issue #3139440 by jungle, Hardik_Patel_12, siddhant.bhosale, sharma.amitt16,...

Issue #3139440 by jungle, Hardik_Patel_12, siddhant.bhosale, sharma.amitt16, durgeshs: Replace usages of deprecated AssertLegacyTrait::buildXPathQuery()
parent f142dd7d
......@@ -223,7 +223,7 @@ public function testBlock() {
$this->assertNoText(t($block['settings[label]']));
// Check for <div id="block-my-block-instance-name"> if the machine name
// is my_block_instance_name.
$xpath = $this->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]);
$xpath = $this->assertSession()->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]);
$this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.');
// Test deleting the block from the edit form.
......@@ -349,7 +349,7 @@ public function moveBlockToRegion(array $block, $region) {
$this->assertText(t($block['settings[label]']), 'Block successfully being displayed on the page.');
// Confirm that the custom block was found at the proper region.
$xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', [
$xpath = $this->assertSession()->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', [
':region-class' => 'region region-' . Html::getClass($region),
':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])),
]);
......
......@@ -390,7 +390,7 @@ protected function createEntityReferenceField($target_type, $bundles = []) {
* An array of expected options.
*/
protected function assertFieldSelectOptions($name, array $expected_options) {
$xpath = $this->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$xpath = $this->assertSession()->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
......
......@@ -250,7 +250,7 @@ public function testFieldAdminHandler() {
* An array of expected options.
*/
protected function assertFieldSelectOptions($name, array $expected_options) {
$xpath = $this->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$xpath = $this->assertSession()->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
......
......@@ -293,7 +293,7 @@ public function assertNodeViewTextHelper(EntityInterface $node, $view_mode, $tex
* An array of expected options.
*/
protected function assertFieldSelectOptions($name, array $expected_options) {
$xpath = $this->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$xpath = $this->assertSession()->buildXPathQuery('//select[@name=:name]', [':name' => $name]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
......
......@@ -205,7 +205,7 @@ public function testForum() {
$forum_arg = [':forum' => 'forum-list-' . $this->forum['tid']];
// Topics cell contains number of topics and number of unread topics.
$xpath = $this->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__topics"]', $forum_arg);
$xpath = $this->assertSession()->buildXPathQuery('//tr[@id=:forum]//td[@class="forum__topics"]', $forum_arg);
$topics = $this->xpath($xpath);
$topics = trim($topics[0]->getText());
// The extracted text contains the number of topics (6) and new posts
......
......@@ -36,7 +36,7 @@ protected function assertMenuActiveTrail($tree, $last_active) {
':href' => Url::fromUri('base:' . $link_path)->toString(),
':title' => $link_title,
];
$xpath .= $this->buildXPathQuery($part_xpath, $part_args);
$xpath .= $this->assertSession()->buildXPathQuery($part_xpath, $part_args);
$i++;
}
$elements = $this->xpath($xpath);
......
......@@ -188,7 +188,7 @@ protected function parseContent($content) {
*/
protected function xpathContent($content, $xpath, array $arguments = []) {
if ($elements = $this->parseContent($content)) {
$xpath = $this->buildXPathQuery($xpath, $arguments);
$xpath = $this->assertSession()->buildXPathQuery($xpath, $arguments);
$result = $elements->xpath($xpath);
// Some combinations of PHP / libxml versions return an empty array
// instead of the documented FALSE. Forcefully convert any falsish values
......
......@@ -231,12 +231,14 @@ public function testExposedBlock() {
$this->assertNoText($view->getTitle(), 'Block title was not displayed.');
// Test there is an exposed form in a block.
$xpath = $this->buildXPathQuery('//div[@id=:id]/form/@id', [':id' => Html::getUniqueId('block-' . $block->id())]);
$xpath = $this->assertSession()->buildXPathQuery('//div[@id=:id]/form/@id', [':id' => Html::getUniqueId('block-' . $block->id())]);
$result = $this->xpath($xpath);
$this->assertCount(1, $result);
// Test there is not an exposed form in the view page content area.
$xpath = $this->buildXPathQuery('//div[@class="view-content"]/form/@id', [':id' => Html::getUniqueId('block-' . $block->id())]);
$xpath = $this->assertSession()->buildXPathQuery('//div[@class="view-content"]/form/@id', [
':id' => Html::getUniqueId('block-' . $block->id()),
]);
$this->assertNoFieldByXpath($xpath, $this->getExpectedExposedFormId($view), 'No exposed form found in views content region.');
// Test there is only one views exposed form on the page.
......
......@@ -914,7 +914,7 @@ protected function buildXPathQuery($xpath, array $args = []) {
protected function constructFieldXpath($attribute, $value) {
@trigger_error('AssertLegacyTrait::constructFieldXpath() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
$xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]';
return $this->buildXPathQuery($xpath, [':value' => $value]);
return $this->assertSession()->buildXPathQuery($xpath, [':value' => $value]);
}
/**
......
......@@ -295,6 +295,16 @@ public function testGetRawContent() {
$this->assertSame($this->getSession()->getPage()->getContent(), $this->getRawContent());
}
/**
* Tests legacy buildXPathQuery().
*
* @group legacy
* @expectedDeprecation AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738
*/
public function testBuildXPathQuery() {
$this->buildXPathQuery('\\html');
}
/**
* Tests legacy field asserts which use xpath directly.
*/
......
......@@ -197,7 +197,6 @@ public static function getSkippedDeprecations() {
'AssertLegacyTrait::assertEscaped() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->assertEscaped() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNoEscaped() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->assertNoEscaped() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertPattern() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseMatches() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::constructFieldXpath() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead. See https://www.drupal.org/node/3129738',
];
}
......
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