public function DataCollectorTest::testBlocksDataCollector in Devel 4.x
Same name and namespace in other branches
- 8.3 webprofiler/tests/src/Functional/DataCollectorTest.php \Drupal\Tests\webprofiler\Functional\DataCollectorTest::testBlocksDataCollector()
Tests the Blocks data collector.
File
- webprofiler/
tests/ src/ Functional/ DataCollectorTest.php, line 48
Class
- DataCollectorTest
- Tests the DataCollector functions of webprofiler.
Namespace
Drupal\Tests\webprofiler\FunctionalCode
public function testBlocksDataCollector() {
// This test was added to ensure we do not have any regression faults such
// as happened with the blocksDataCollector.
// @see https://www.drupal.org/project/devel/issues/3106747
$this
->drupalPlaceBlock('page_title_block', [
'id' => 'page-title',
]);
$this
->drupalPlaceBlock('local_tasks_block', [
'id' => 'local-tasks',
]);
$this
->drupalLogin($this->rootUser);
// What is the right way to collect the block data? The blocks are being
// placed OK above but the following does not work (obviously).
// $data has a 'blocks' key and that array has 'loaded' and 'rendered' keys
// but the values are empty.
$request = Request::create('', 'GET');
$response = Response::create();
$this->blocksDataCollector
->collect($request, $response);
$data = $this->blocksDataCollector
->getData();
$this
->assertCount(1, $data);
}