Chris@0: setDisplay(); Chris@0: Chris@0: // Execute the view. Chris@0: $this->executeView($view); Chris@0: Chris@0: // Verify the result. Chris@0: $this->assertEqual(5, count($view->result), 'The number of returned rows match.'); Chris@0: $this->assertIdenticalResultset($view, $this->dataSet(), [ Chris@0: 'views_test_data_name' => 'name', Chris@0: 'views_test_data_age' => 'age', Chris@0: ]); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests filtering of the result set. Chris@0: */ Chris@0: public function testSimpleFiltering() { Chris@0: $view = Views::getView('test_view'); Chris@0: $view->setDisplay(); Chris@0: Chris@0: // Add a filter. Chris@0: $view->displayHandlers->get('default')->overrideOption('filters', [ Chris@0: 'age' => [ Chris@0: 'operator' => '<', Chris@0: 'value' => [ Chris@0: 'value' => '28', Chris@0: 'min' => '', Chris@0: 'max' => '', Chris@0: ], Chris@0: 'group' => '0', Chris@0: 'exposed' => FALSE, Chris@0: 'expose' => [ Chris@0: 'operator' => FALSE, Chris@0: 'label' => '', Chris@0: ], Chris@0: 'id' => 'age', Chris@0: 'table' => 'views_test_data', Chris@0: 'field' => 'age', Chris@0: 'relationship' => 'none', Chris@0: ], Chris@0: ]); Chris@0: Chris@0: // Execute the view. Chris@0: $this->executeView($view); Chris@0: Chris@0: // Build the expected result. Chris@0: $dataset = [ Chris@0: [ Chris@0: 'id' => 1, Chris@0: 'name' => 'John', Chris@0: 'age' => 25, Chris@0: ], Chris@0: [ Chris@0: 'id' => 2, Chris@0: 'name' => 'George', Chris@0: 'age' => 27, Chris@0: ], Chris@0: [ Chris@0: 'id' => 4, Chris@0: 'name' => 'Paul', Chris@0: 'age' => 26, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Verify the result. Chris@0: $this->assertEqual(3, count($view->result), 'The number of returned rows match.'); Chris@0: $this->assertIdenticalResultSet($view, $dataset, [ Chris@0: 'views_test_data_name' => 'name', Chris@0: 'views_test_data_age' => 'age', Chris@0: ]); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests simple argument. Chris@0: */ Chris@0: public function testSimpleArgument() { Chris@0: // Execute with a view Chris@0: $view = Views::getView('test_simple_argument'); Chris@0: $view->setArguments([27]); Chris@0: $this->executeView($view); Chris@0: Chris@0: // Build the expected result. Chris@0: $dataset = [ Chris@0: [ Chris@0: 'id' => 2, Chris@0: 'name' => 'George', Chris@0: 'age' => 27, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Verify the result. Chris@0: $this->assertEqual(1, count($view->result), 'The number of returned rows match.'); Chris@0: $this->assertIdenticalResultSet($view, $dataset, [ Chris@0: 'views_test_data_name' => 'name', Chris@0: 'views_test_data_age' => 'age', Chris@0: ]); Chris@0: Chris@0: // Test "show all" if no argument is present. Chris@0: $view = Views::getView('test_simple_argument'); Chris@0: $this->executeView($view); Chris@0: Chris@0: // Build the expected result. Chris@0: $dataset = $this->dataSet(); Chris@0: Chris@0: $this->assertEqual(5, count($view->result), 'The number of returned rows match.'); Chris@0: $this->assertIdenticalResultSet($view, $dataset, [ Chris@0: 'views_test_data_name' => 'name', Chris@0: 'views_test_data_age' => 'age', Chris@0: ]); Chris@0: } Chris@0: Chris@0: }