NodeIntegrationTest.php in Zircon Profile 8
File
core/modules/node/src/Tests/Views/NodeIntegrationTest.php
View source
<?php
namespace Drupal\node\Tests\Views;
class NodeIntegrationTest extends NodeTestBase {
public static $testViews = array(
'test_node_view',
);
public function testNodeViewTypeArgument() {
$types = array();
$all_nids = array();
for ($i = 0; $i < 2; $i++) {
$type = $this
->drupalCreateContentType([
'name' => '<em>' . $this
->randomMachineName() . '</em>',
]);
$types[] = $type;
for ($j = 0; $j < 5; $j++) {
$node = $this
->drupalCreateNode(array(
'type' => $type
->id(),
'created' => REQUEST_TIME - ($i * 5 + $j),
));
$nodes[$type
->id()][$node
->id()] = $node;
$all_nids[] = $node
->id();
}
}
$this
->drupalGet('test-node-view');
$this
->assertResponse(404);
$this
->drupalGet('test-node-view/all');
$this
->assertResponse(200);
$this
->assertNids($all_nids);
foreach ($types as $type) {
$this
->drupalGet("test-node-view/{$type->id()}");
$this
->assertEscaped($type
->label());
$this
->assertNids(array_keys($nodes[$type
->id()]));
}
}
protected function assertNids(array $expected_nids = array()) {
$result = $this
->xpath('//span[@class="field-content"]');
$nids = array();
foreach ($result as $element) {
$nids[] = (int) $element;
}
$this
->assertEqual($nids, $expected_nids);
}
}