diff -u b/core/modules/block/tests/src/Functional/BlockTestBase.php b/core/modules/block/src/Tests/BlockTestBase.php --- b/core/modules/block/tests/src/Functional/BlockTestBase.php +++ b/core/modules/block/src/Tests/BlockTestBase.php @@ -1,14 +1,21 @@ $id, 'ids[1]' => $cached_id]; - $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-page']]); + $url = 'contextual/render?_format=json,destination=test-page'; + $this->getSession()->getDriver()->getClient()->request('POST', $url, $post); $this->assertResponse(200); - $json = Json::decode($response); + $json = Json::decode($this->getSession()->getPage()->getContent()); $this->assertIdentical($json[$id], ''); $this->assertIdentical($json[$cached_id], ''); } - /** - * 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', ['@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', ['@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]', [':id' => 'block-' . $block->id()]); - } - } only in patch2: unchanged: --- /dev/null +++ b/core/modules/block/tests/src/Functional/AssertBlockAppearsTrait.php @@ -0,0 +1,49 @@ +findBlockInstance($block); + $this->assertTrue(!empty($result), format_string('Ensure the block @id appears on the page', ['@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', ['@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]', [':id' => 'block-' . $block->id()]); + } + +} \ No newline at end of file