BlockContentIntegrationTest.php in Drupal 10
File
core/modules/block_content/tests/src/Functional/Views/BlockContentIntegrationTest.php
View source
<?php
namespace Drupal\Tests\block_content\Functional\Views;
class BlockContentIntegrationTest extends BlockContentTestBase {
protected $defaultTheme = 'stark';
public static $testViews = [
'test_block_content_view',
];
public function testBlockContentViewTypeArgument() {
$types = [];
$all_ids = [];
$block_contents = [];
for ($i = 0; $i < 2; $i++) {
$type = $this
->createBlockContentType();
$types[] = $type;
for ($j = 0; $j < 5; $j++) {
$block_content = $this
->createBlockContent([
'type' => $type
->id(),
]);
$block_contents[$type
->id()][$block_content
->id()] = $block_content;
$all_ids[] = $block_content
->id();
}
}
$this
->drupalGet('test-block_content-view');
$this
->assertSession()
->statusCodeEquals(404);
$this
->drupalGet('test-block_content-view/all');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertIds($all_ids);
foreach ($types as $type) {
$this
->drupalGet("test-block_content-view/{$type->id()}");
$this
->assertIds(array_keys($block_contents[$type
->id()]));
}
}
protected function assertIds(array $expected_ids = []) : void {
$result = $this
->xpath('//span[@class="field-content"]');
$ids = [];
foreach ($result as $element) {
$ids[] = $element
->getText();
}
$this
->assertEquals($expected_ids, $ids);
}
}