public function NodeIntegrationTest::testNodeViewTypeArgument

Tests basic node view with a node type argument.

File

drupal/core/modules/node/lib/Drupal/node/Tests/Views/NodeIntegrationTest.php, line 30
Contains \Drupal\node\Tests\Views\NodeIntegrationTest.

Class

NodeIntegrationTest

Namespace

Drupal\node\Tests\Views

Code

public function testNodeViewTypeArgument() {

  // Create two content types with three nodes each.
  $types = array();
  $all_nids = array();
  for ($i = 0; $i < 2; $i++) {
    $type = $this
      ->drupalCreateContentType();
    $types[] = $type;
    for ($j = 0; $j < 5; $j++) {

      // Ensure the right order of the nodes.
      $node = $this
        ->drupalCreateNode(array(
        'type' => $type->type,
        'created' => REQUEST_TIME - ($i * 5 + $j),
      ));
      $nodes[$type->type][$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->type}");
    $this
      ->assertNids(array_keys($nodes[$type->type]));
  }
}