BlockContentIntegrationTest.php in Zircon Profile 8
File
core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php
View source
<?php
namespace Drupal\block_content\Tests\Views;
class BlockContentIntegrationTest extends BlockContentTestBase {
public static $testViews = array(
'test_block_content_view',
);
public function testBlockContentViewTypeArgument() {
$types = array();
$all_ids = array();
$block_contents = array();
for ($i = 0; $i < 2; $i++) {
$type = $this
->createBlockContentType();
$types[] = $type;
for ($j = 0; $j < 5; $j++) {
$block_content = $this
->createBlockContent(array(
'type' => $type
->id(),
));
$block_contents[$type
->id()][$block_content
->id()] = $block_content;
$all_ids[] = $block_content
->id();
}
}
$this
->drupalGet('test-block_content-view');
$this
->assertResponse(404);
$this
->drupalGet('test-block_content-view/all');
$this
->assertResponse(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 = array()) {
$result = $this
->xpath('//span[@class="field-content"]');
$ids = array();
foreach ($result as $element) {
$ids[] = (int) $element;
}
$this
->assertEqual($ids, $expected_ids);
}
}