3 namespace Drupal\Tests\block_content\Functional\Views;
6 * Tests the block_content integration into views.
10 class BlockContentIntegrationTest extends BlockContentTestBase {
13 * Views used by this test.
17 public static $testViews = ['test_block_content_view'];
20 * Tests basic block_content view with a block_content_type argument.
22 public function testBlockContentViewTypeArgument() {
23 // Create two content types with three block_contents each.
27 for ($i = 0; $i < 2; $i++) {
28 $type = $this->createBlockContentType();
31 for ($j = 0; $j < 5; $j++) {
32 // Ensure the right order of the block_contents.
33 $block_content = $this->createBlockContent(['type' => $type->id()]);
34 $block_contents[$type->id()][$block_content->id()] = $block_content;
35 $all_ids[] = $block_content->id();
39 $this->drupalGet('test-block_content-view');
40 $this->assertResponse(404);
42 $this->drupalGet('test-block_content-view/all');
43 $this->assertResponse(200);
44 $this->assertIds($all_ids);
45 /* @var \Drupal\block_content\Entity\BlockContentType[] $types*/
46 foreach ($types as $type) {
47 $this->drupalGet("test-block_content-view/{$type->id()}");
48 $this->assertIds(array_keys($block_contents[$type->id()]));
53 * Ensures that a list of block_contents appear on the page.
55 * @param array $expected_ids
56 * An array of block_content IDs.
58 protected function assertIds(array $expected_ids = []) {
59 $result = $this->xpath('//span[@class="field-content"]');
61 foreach ($result as $element) {
62 $ids[] = $element->getText();
64 $this->assertEqual($ids, $expected_ids);