drupalCreateContentType(['name' => '' . $this->randomMachineName() . '']); $types[] = $type; for ($j = 0; $j < 5; $j++) { // Ensure the right order of the nodes. $node = $this->drupalCreateNode(['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()])); } } /** * Ensures that a list of nodes appear on the page. * * @param array $expected_nids * An array of node IDs. */ protected function assertNids(array $expected_nids = []) { $result = $this->xpath('//span[@class="field-content"]'); $nids = []; foreach ($result as $element) { $nids[] = (int) $element->getText(); } $this->assertEqual($nids, $expected_nids); } }