You are here

public function BasicTest::testSimpleArgument in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/BasicTest.php \Drupal\views\Tests\BasicTest::testSimpleArgument()

Tests simple argument.

File

core/modules/views/src/Tests/BasicTest.php, line 106
Contains \Drupal\views\Tests\BasicTest.

Class

BasicTest
A basic query test for Views.

Namespace

Drupal\views\Tests

Code

public function testSimpleArgument() {

  // Execute with a view
  $view = Views::getView('test_simple_argument');
  $view
    ->setArguments(array(
    27,
  ));
  $this
    ->executeView($view);

  // Build the expected result.
  $dataset = array(
    array(
      'id' => 2,
      'name' => 'George',
      'age' => 27,
    ),
  );

  // Verify the result.
  $this
    ->assertEqual(1, count($view->result), 'The number of returned rows match.');
  $this
    ->assertIdenticalResultSet($view, $dataset, array(
    'views_test_data_name' => 'name',
    'views_test_data_age' => 'age',
  ));

  // Test "show all" if no argument is present.
  $view = Views::getView('test_simple_argument');
  $this
    ->executeView($view);

  // Build the expected result.
  $dataset = $this
    ->dataSet();
  $this
    ->assertEqual(5, count($view->result), 'The number of returned rows match.');
  $this
    ->assertIdenticalResultSet($view, $dataset, array(
    'views_test_data_name' => 'name',
    'views_test_data_age' => 'age',
  ));
}