public function BasicTest::testSimpleArgument

Tests simple argument.

File

drupal/core/modules/views/lib/Drupal/views/Tests/BasicTest.php, line 110
Definition of Drupal\views\Tests\BasicTest.

Class

BasicTest
Basic test class for Views query builder tests.

Namespace

Drupal\views\Tests

Code

public function testSimpleArgument() {

  // Execute with a view
  $view = views_get_view('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), t('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_get_view('test_simple_argument');
  $this
    ->executeView($view);

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