From 048cd4512aa56202b546cd497e20efd0ead44794 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 4 Feb 2014 23:15:27 -0800 Subject: [PATCH] Issue #2181855 by Cottser: Don't let ViewTestBase hog the useful assertBlockAppears and assertNoBlockAppears methods. --- .../lib/Drupal/simpletest/WebTestBase.php | 36 +++++++++++++++++++ .../lib/Drupal/views/Tests/ViewTestBase.php | 36 ------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index d66d2a9f7ce..6b23a634aa4 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -18,6 +18,7 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\UserSession; use Drupal\Core\StreamWrapper\PublicStream; use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\block\Entity\Block; use Symfony\Component\HttpFoundation\Request; /** @@ -385,6 +386,41 @@ abstract class WebTestBase extends TestBase { return $block; } + /** + * Checks to see whether a block appears on the page. + * + * @param \Drupal\block\Entity\Block $block + * The block entity to find on the page. + */ + protected function assertBlockAppears(Block $block) { + $result = $this->findBlockInstance($block); + $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', array('@id' => $block->id()))); + } + + /** + * Checks to see whether a block does not appears on the page. + * + * @param \Drupal\block\Entity\Block $block + * The block entity to find on the page. + */ + protected function assertNoBlockAppears(Block $block) { + $result = $this->findBlockInstance($block); + $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', array('@id' => $block->id()))); + } + + /** + * Find a block instance on the page. + * + * @param \Drupal\block\Entity\Block $block + * The block entity to find on the page. + * + * @return array + * The result from the xpath query. + */ + protected function findBlockInstance(Block $block) { + return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $block->id())); + } + /** * Gets a list files that can be used in tests. * diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php index e77757e01ad..4ed9064f9e1 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php @@ -10,7 +10,6 @@ namespace Drupal\views\Tests; use Drupal\Core\Database\Query\SelectInterface; use Drupal\simpletest\WebTestBase; use Drupal\views\ViewExecutable; -use Drupal\block\Entity\Block; /** * Defines a base class for Views testing in the full web test environment. @@ -239,41 +238,6 @@ abstract class ViewTestBase extends WebTestBase { $this->verbose($verbose_message); } - /** - * Checks to see whether a block appears on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - */ - protected function assertBlockAppears(Block $block) { - $result = $this->findBlockInstance($block); - $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', array('@id' => $block->id()))); - } - - /** - * Checks to see whether a block does not appears on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - */ - protected function assertNoBlockAppears(Block $block) { - $result = $this->findBlockInstance($block); - $this->assertFalse(!empty($result), format_string('Ensure the block @id does not appear on the page', array('@id' => $block->id()))); - } - - /** - * Find a block instance on the page. - * - * @param \Drupal\block\Entity\Block $block - * The block entity to find on the page. - * - * @return array - * The result from the xpath query. - */ - protected function findBlockInstance(Block $block) { - return $this->xpath('//div[@id = :id]', array(':id' => 'block-' . $block->id())); - } - /** * Returns the schema definition. */