Commit 41ae1ead authored by catch's avatar catch

Issue #1856272 by tim.plunkett: Speed up tests by only installing the views used by that tests.

parent 52218869
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
*/ */
class BasicTest extends ViewUnitTestBase { class BasicTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view', 'test_simple_argument');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Basic query tests', 'name' => 'Basic query tests',
...@@ -101,56 +108,8 @@ public function testSimpleFiltering() { ...@@ -101,56 +108,8 @@ public function testSimpleFiltering() {
* Tests simple argument. * Tests simple argument.
*/ */
public function testSimpleArgument() { public function testSimpleArgument() {
$view = views_get_view('test_view');
$view->setDisplay();
// Add a argument.
$view->displayHandlers['default']->overrideOption('arguments', array(
'age' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'breadcrumb' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate' => array(
'type' => 'none',
'fail' => 'not found',
),
'break_phrase' => 0,
'not' => 0,
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'page' => 0,
'story' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
)
));
$saved_view = clone $view;
// Execute with a view // Execute with a view
$view = views_get_view('test_simple_argument');
$view->setArguments(array(27)); $view->setArguments(array(27));
$this->executeView($view); $this->executeView($view);
...@@ -171,7 +130,7 @@ public function testSimpleArgument() { ...@@ -171,7 +130,7 @@ public function testSimpleArgument() {
)); ));
// Test "show all" if no argument is present. // Test "show all" if no argument is present.
$view = $saved_view->cloneView(); $view = views_get_view('test_simple_argument');
$this->executeView($view); $this->executeView($view);
// Build the expected result. // Build the expected result.
......
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
*/ */
class ArgumentUserUIDTest extends CommentTestBase { class ArgumentUserUIDTest extends CommentTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_comment_user_uid');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Comment: User UID Argument', 'name' => 'Comment: User UID Argument',
...@@ -21,7 +28,8 @@ public static function getInfo() { ...@@ -21,7 +28,8 @@ public static function getInfo() {
} }
function testCommentUserUIDTest() { function testCommentUserUIDTest() {
$this->executeView($this->view, array($this->account->uid)); $view = views_get_view('test_comment_user_uid');
$this->executeView($view, array($this->account->uid));
$result_set = array( $result_set = array(
array( array(
'nid' => $this->node_user_posted->nid, 'nid' => $this->node_user_posted->nid,
...@@ -30,8 +38,8 @@ function testCommentUserUIDTest() { ...@@ -30,8 +38,8 @@ function testCommentUserUIDTest() {
'nid' => $this->node_user_commented->nid, 'nid' => $this->node_user_commented->nid,
), ),
); );
$this->column_map = array('nid' => 'nid'); $column_map = array('nid' => 'nid');
$this->assertIdenticalResultset($this->view, $result_set, $this->column_map); $this->assertIdenticalResultset($view, $result_set, $column_map);
} }
} }
...@@ -42,11 +42,4 @@ function setUp() { ...@@ -42,11 +42,4 @@ function setUp() {
entity_create('comment', $comment)->save(); entity_create('comment', $comment)->save();
} }
/**
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
*/
protected function getBasicView() {
return $this->createViewFromConfig('test_comment_user_uid');
}
} }
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class FilterUserUIDTest extends CommentTestBase { class FilterUserUIDTest extends CommentTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_comment_user_uid');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Comment: User UID Filter', 'name' => 'Comment: User UID Filter',
...@@ -23,7 +30,9 @@ public static function getInfo() { ...@@ -23,7 +30,9 @@ public static function getInfo() {
} }
function testCommentUserUIDTest() { function testCommentUserUIDTest() {
$this->view->setItem('default', 'argument', 'uid_touch', NULL); $view = views_get_view('test_comment_user_uid');
$view->setDisplay();
$view->setItem('default', 'argument', 'uid_touch', NULL);
$options = array( $options = array(
'id' => 'uid_touch', 'id' => 'uid_touch',
...@@ -31,8 +40,8 @@ function testCommentUserUIDTest() { ...@@ -31,8 +40,8 @@ function testCommentUserUIDTest() {
'field' => 'uid_touch', 'field' => 'uid_touch',
'value' => array($this->loggedInUser->uid), 'value' => array($this->loggedInUser->uid),
); );
$this->view->addItem('default', 'filter', 'node', 'uid_touch', $options); $view->addItem('default', 'filter', 'node', 'uid_touch', $options);
$this->executeView($this->view, array($this->account->uid)); $this->executeView($view, array($this->account->uid));
$result_set = array( $result_set = array(
array( array(
'nid' => $this->node_user_posted->nid, 'nid' => $this->node_user_posted->nid,
...@@ -42,7 +51,7 @@ function testCommentUserUIDTest() { ...@@ -42,7 +51,7 @@ function testCommentUserUIDTest() {
), ),
); );
$this->column_map = array('nid' => 'nid'); $this->column_map = array('nid' => 'nid');
$this->assertIdenticalResultset($this->view, $result_set, $this->column_map); $this->assertIdenticalResultset($view, $result_set, $this->column_map);
} }
} }
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
*/ */
class FieldEntityTest extends ViewTestBase { class FieldEntityTest extends ViewTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_field_get_entity');
/** /**
* Modules to enable. * Modules to enable.
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\views\Tests\Field; namespace Drupal\views\Tests\Field;
use Drupal\views\ViewExecutable;
/** /**
* Tests the field_field handler. * Tests the field_field handler.
* @TODO * @TODO
...@@ -17,6 +19,13 @@ ...@@ -17,6 +19,13 @@
*/ */
class HandlerFieldFieldTest extends FieldTestBase { class HandlerFieldFieldTest extends FieldTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view_fieldapi');
public $nodes; public $nodes;
public static function getInfo() { public static function getInfo() {
...@@ -27,6 +36,9 @@ public static function getInfo() { ...@@ -27,6 +36,9 @@ public static function getInfo() {
); );
} }
/**
* @todo.
*/
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
...@@ -59,19 +71,21 @@ protected function setUp() { ...@@ -59,19 +71,21 @@ protected function setUp() {
$this->nodes[$i] = $this->drupalCreateNode($edit); $this->nodes[$i] = $this->drupalCreateNode($edit);
} }
foreach ($this->fields as $key => $field) {
$this->view->display_handler->display['display_options']['fields'][$field['field_name']]['id'] = $field['field_name'];
$this->view->display_handler->display['display_options']['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name'];
$this->view->display_handler->display['display_options']['fields'][$field['field_name']]['field'] = $field['field_name'];
}
} }
/** /**
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView(). * Sets up the testing view with random field data.
*
* @param \Drupal\views\ViewExecutable $view
* The view to add field data to.
*/ */
protected function getBasicView() { protected function prepareView(ViewExecutable $view) {
return $this->createViewFromConfig('test_view_fieldapi'); $view->initDisplay();
foreach ($this->fields as $key => $field) {
$view->display_handler->options['fields'][$field['field_name']]['id'] = $field['field_name'];
$view->display_handler->options['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name'];
$view->display_handler->options['fields'][$field['field_name']]['field'] = $field['field_name'];
}
} }
public function testFieldRender() { public function testFieldRender() {
...@@ -81,7 +95,8 @@ public function testFieldRender() { ...@@ -81,7 +95,8 @@ public function testFieldRender() {
} }
public function _testSimpleFieldRender() { public function _testSimpleFieldRender() {
$view = $this->getView(); $view = views_get_view('test_view_fieldapi');
$this->prepareView($view);
$this->executeView($view); $this->executeView($view);
// Tests that the rendered fields match the actual value of the fields. // Tests that the rendered fields match the actual value of the fields.
...@@ -99,7 +114,8 @@ public function _testSimpleFieldRender() { ...@@ -99,7 +114,8 @@ public function _testSimpleFieldRender() {
* Tests that fields with formatters runs as expected. * Tests that fields with formatters runs as expected.
*/ */
public function _testFormatterSimpleFieldRender() { public function _testFormatterSimpleFieldRender() {
$view = $this->getView(); $view = views_get_view('test_view_fieldapi');
$this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed'; $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed';
$view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['settings'] = array( $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['settings'] = array(
'trim_length' => 3, 'trim_length' => 3,
...@@ -115,11 +131,11 @@ public function _testFormatterSimpleFieldRender() { ...@@ -115,11 +131,11 @@ public function _testFormatterSimpleFieldRender() {
} }
public function _testMultipleFieldRender() { public function _testMultipleFieldRender() {
$view = $this->getView(); $view = views_get_view('test_view_fieldapi');
$field_name = $this->fields[3]['field_name']; $field_name = $this->fields[3]['field_name'];
// Test delta limit. // Test delta limit.
$view->initDisplay(); $this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3; $view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3;
$this->executeView($view); $this->executeView($view);
...@@ -141,7 +157,7 @@ public function _testMultipleFieldRender() { ...@@ -141,7 +157,7 @@ public function _testMultipleFieldRender() {
$view->destroy(); $view->destroy();
// Test delta limit + offset // Test delta limit + offset
$view->initDisplay(); $this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3; $view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_offset'] = 1; $view->displayHandlers['default']->options['fields'][$field_name]['delta_offset'] = 1;
...@@ -160,7 +176,7 @@ public function _testMultipleFieldRender() { ...@@ -160,7 +176,7 @@ public function _testMultipleFieldRender() {
$view->destroy(); $view->destroy();
// Test delta limit + reverse. // Test delta limit + reverse.
$view->initDisplay(); $this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$field_name]['delta_offset'] = 0; $view->displayHandlers['default']->options['fields'][$field_name]['delta_offset'] = 0;
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3; $view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3;
...@@ -181,7 +197,7 @@ public function _testMultipleFieldRender() { ...@@ -181,7 +197,7 @@ public function _testMultipleFieldRender() {
$view->destroy(); $view->destroy();
// Test delta first last. // Test delta first last.
$view->initDisplay(); $this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 0; $view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 0;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_first_last'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['delta_first_last'] = TRUE;
...@@ -199,7 +215,7 @@ public function _testMultipleFieldRender() { ...@@ -199,7 +215,7 @@ public function _testMultipleFieldRender() {
$view->destroy(); $view->destroy();
// Test delta limit + custom seperator. // Test delta limit + custom seperator.
$view->initDisplay(); $this->prepareView($view);
$view->displayHandlers['default']->options['fields'][$field_name]['delta_first_last'] = FALSE; $view->displayHandlers['default']->options['fields'][$field_name]['delta_first_last'] = FALSE;
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3; $view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3;
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE; $view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
......
...@@ -15,6 +15,13 @@ ...@@ -15,6 +15,13 @@
*/ */
class AreaTest extends HandlerTestBase { class AreaTest extends HandlerTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_example_area');
/** /**
* Modules to enable. * Modules to enable.
* *
......
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
*/ */
class AreaTextTest extends ViewUnitTestBase { class AreaTextTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Area: Text', 'name' => 'Area: Text',
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class ArgumentNullTest extends ViewUnitTestBase { class ArgumentNullTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Argument: Null', 'name' => 'Argument: Null',
......
...@@ -12,6 +12,13 @@ ...@@ -12,6 +12,13 @@
*/ */
class ArgumentStringTest extends HandlerTestBase { class ArgumentStringTest extends HandlerTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_glossary');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Argument: String', 'name' => 'Argument: String',
...@@ -35,7 +42,7 @@ function testGlossary() { ...@@ -35,7 +42,7 @@ function testGlossary() {
} }
} }
$view = $this->createViewFromConfig('test_glossary'); $view = views_get_view('test_glossary');
$this->executeView($view); $this->executeView($view);
$count_field = 'nid'; $count_field = 'nid';
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class FieldBooleanTest extends ViewUnitTestBase { class FieldBooleanTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field: Boolean', 'name' => 'Field: Boolean',
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class FieldCounterTest extends ViewUnitTestBase { class FieldCounterTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field: Counter', 'name' => 'Field: Counter',
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class FieldCustomTest extends ViewUnitTestBase { class FieldCustomTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field: Custom', 'name' => 'Field: Custom',
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
*/ */
class FieldDateTest extends ViewUnitTestBase { class FieldDateTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field: Date', 'name' => 'Field: Date',
......
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
*/ */
class FieldFileSizeTest extends ViewUnitTestBase { class FieldFileSizeTest extends ViewUnitTestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_view');
public static function getInfo() { public static function getInfo() {
return array( return array(
'name' => 'Field: File size', 'name' => 'Field: File size',
......
...@@ -16,6 +16,13 @@ ...@@ -16,6 +16,13 @@
*/ */
class FieldUnitTest extends ViewUnitTestBase { class FieldUnitTest extends ViewUnitTestBase {