Commit 2a8e934c authored by damiankloip's avatar damiankloip Committed by tim.plunkett

Issue #1771944 by damiankloip, tim.plunkett, dawehner: Convert exported views...

Issue #1771944 by damiankloip, tim.plunkett, dawehner: Convert exported views in tests to config files.
parent 5b3959b2
......@@ -6,8 +6,6 @@
*/
use Drupal\Core\Database\Database;
use Drupal\views\View;
use Drupal\views\Plugin\views\join\JoinPluginBase;
use Drupal\views\Plugin\Type\ViewsPluginManager;
use Drupal\Component\Plugin\Exception\PluginException;
......
......@@ -38,16 +38,6 @@ function __construct(View $view = NULL) {
}
}
/**
* Gets the view which is analyzed by this analyzer.
*
* @return Drupal\views\View.
* The view to analyze.
*/
public function getView() {
return $this->view;
}
/**
* Sets the view which is analyzed by this analyzer.
*
......
......@@ -30,7 +30,7 @@ protected function setUp() {
* Tests a trivial result set.
*/
public function testSimpleResultSet() {
$view = $this->getBasicView();
$view = $this->getView();
// Execute the view.
$this->executeView($view);
......@@ -47,7 +47,7 @@ public function testSimpleResultSet() {
* Tests filtering of the result set.
*/
public function testSimpleFiltering() {
$view = $this->getBasicView();
$view = $this->getView();
// Add a filter.
$view->display['default']->handler->overrideOption('filters', array(
......@@ -105,7 +105,7 @@ public function testSimpleFiltering() {
* Tests simple argument.
*/
public function testSimpleArgument() {
$view = $this->getBasicView();
$view = $this->getView();
// Add a argument.
$view->display['default']->handler->overrideOption('arguments', array(
......@@ -174,7 +174,7 @@ public function testSimpleArgument() {
));
// Test "show all" if no argument is present.
$view = $saved_view;
$view = $saved_view->cloneView();
$this->executeView($view);
// Build the expected result.
......
......@@ -7,8 +7,6 @@
namespace Drupal\views\Tests\Comment;
use Drupal\views\View;
/**
* Tests the argument_comment_user_uid handler.
*/
......@@ -23,9 +21,7 @@ public static function getInfo() {
}
function testCommentUserUIDTest() {
$view = $this->view_comment_user_uid();
$this->executeView($view, array($this->account->uid));
$this->executeView($this->view, array($this->account->uid));
$result_set = array(
array(
'nid' => $this->node_user_posted->nid,
......@@ -35,7 +31,7 @@ function testCommentUserUIDTest() {
),
);
$this->column_map = array('nid' => 'nid');
$this->assertIdenticalResultset($view, $result_set, $this->column_map);
$this->assertIdenticalResultset($this->view, $result_set, $this->column_map);
}
}
......@@ -8,7 +8,6 @@
namespace Drupal\views\Tests\Comment;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views\View;
/**
* Tests the argument_comment_user_uid handler.
......@@ -43,42 +42,11 @@ function setUp() {
entity_create('comment', $comment)->save();
}
function view_comment_user_uid() {
$view = new View(array(), 'view');
$view->name = 'test_comment_user_uid';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test_comment_user_uid';
$view->core = 8;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->newDisplay('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Field: Content: nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
/* Contextual filter: Content: User posted or commented */
$handler->display->display_options['arguments']['uid_touch']['id'] = 'uid_touch';
$handler->display->display_options['arguments']['uid_touch']['table'] = 'node';
$handler->display->display_options['arguments']['uid_touch']['field'] = 'uid_touch';
$handler->display->display_options['arguments']['uid_touch']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['uid_touch']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['uid_touch']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['uid_touch']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['uid_touch']['summary_options']['items_per_page'] = '25';
return $view;
/**
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
*/
protected function getBasicView() {
return $this->createViewFromConfig('test_comment_user_uid');
}
}
......@@ -7,8 +7,6 @@
namespace Drupal\views\Tests\Comment;
use Drupal\views\View;
/**
* Tests the filter_comment_user_uid handler.
*
......@@ -24,14 +22,8 @@ public static function getInfo() {
);
}
/**
* Override the view from the argument test case to remove the argument and
* add filter with the uid as the value.
*/
function view_comment_user_uid() {
$view = parent::view_comment_user_uid();
// Remove the argument.
$view->setItem('default', 'argument', 'uid_touch', NULL);
function testCommentUserUIDTest() {
$this->view->setItem('default', 'argument', 'uid_touch', NULL);
$options = array(
'id' => 'uid_touch',
......@@ -39,15 +31,8 @@ function view_comment_user_uid() {
'field' => 'uid_touch',
'value' => array($this->loggedInUser->uid),
);
$view->addItem('default', 'filter', 'node', 'uid_touch', $options);
return $view;
}
function testCommentUserUIDTest() {
$view = $this->view_comment_user_uid();
$this->executeView($view, array($this->account->uid));
$this->view->addItem('default', 'filter', 'node', 'uid_touch', $options);
$this->executeView($this->view, array($this->account->uid));
$result_set = array(
array(
'nid' => $this->node_user_posted->nid,
......@@ -57,7 +42,7 @@ function testCommentUserUIDTest() {
),
);
$this->column_map = array('nid' => 'nid');
$this->assertIdenticalResultset($view, $result_set, $this->column_map);
$this->assertIdenticalResultset($this->view, $result_set, $this->column_map);
}
}
......@@ -7,8 +7,6 @@
namespace Drupal\views\Tests\Field;
use Drupal\views\View;
/**
* Tests the field_field handler.
* @TODO
......@@ -61,6 +59,19 @@ protected function setUp() {
$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().
*/
protected function getBasicView() {
return $this->createViewFromConfig('test_view_fieldapi');
}
public function testFieldRender() {
......@@ -70,7 +81,7 @@ public function testFieldRender() {
}
public function _testSimpleFieldRender() {
$view = $this->getFieldView();
$view = $this->getView();
$this->executeView($view);
// Tests that the rendered fields match the actual value of the fields.
......@@ -88,9 +99,9 @@ public function _testSimpleFieldRender() {
* Tests that fields with formatters runs as expected.
*/
public function _testFormatterSimpleFieldRender() {
$view = $this->getFieldView();
$view->display['default']->display_options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed';
$view->display['default']->display_options['fields'][$this->fields[0]['field_name']]['settings'] = array(
$view = $this->getView();
$view->display['default']->handler->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed';
$view->display['default']->handler->options['fields'][$this->fields[0]['field_name']]['settings'] = array(
'trim_length' => 3,
);
$this->executeView($view);
......@@ -104,11 +115,11 @@ public function _testFormatterSimpleFieldRender() {
}
public function _testMultipleFieldRender() {
$view = $this->getFieldView();
$view = $this->getView();
// Test delta limit.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$view->display['default']->handler->options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->handler->options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
......@@ -201,36 +212,4 @@ public function _testMultipleFieldRender() {
}
}
protected function getFieldView() {
$view = new View(array(), 'view');
$view->name = 'view_fieldapi';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'view_fieldapi';
$view->core = 8;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->newDisplay('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
foreach ($this->fields as $key => $field) {
$handler->display->display_options['fields'][$field['field_name']]['id'] = $field['field_name'];
$handler->display->display_options['fields'][$field['field_name']]['table'] = 'field_data_' . $field['field_name'];
$handler->display->display_options['fields'][$field['field_name']]['field'] = $field['field_name'];
}
return $view;
}
}
......@@ -29,7 +29,7 @@ protected function setUp() {
}
public function testAreaText() {
$view = $this->getBasicView();
$view = $this->getView();
// add a text header
$string = $this->randomName();
......
......@@ -35,7 +35,7 @@ function viewsData() {
public function testAreaText() {
// Test validation
$view = $this->getBasicView();
$view = $this->getView();
// Add a null argument.
$string = $this->randomString();
......@@ -60,7 +60,7 @@ public function testAreaText() {
$this->assertTrue($view->argument['null']->validateArgument(NULL), 'must_not_be returns TRUE, if there is no argument');
// Test execution.
$view = $this->getBasicView();
$view = $this->getView();
// Add a argument, which has null as handler.
$string = $this->randomString();
......
......@@ -7,8 +7,6 @@
namespace Drupal\views\Tests\Handler;
use Drupal\views\View;
/**
* Tests the core Drupal\views\Plugin\views\argument\String handler.
*/
......@@ -37,8 +35,7 @@ function testGlossary() {
}
}
$view = $this->viewGlossary();
$view->initDisplay();
$view = $this->createViewFromConfig('test_glossary');
$this->executeView($view);
$count_field = 'nid';
......@@ -55,49 +52,4 @@ function testGlossary() {
}
}
/**
* Provide a test view for testGlossary.
*
* @see testGlossary
* @return Drupal\views\View
*/
function viewGlossary() {
$view = new View(array(), 'view');
$view->name = 'test_glossary';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'test_glossary';
$view->core = 8;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->newDisplay('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
/* Contextual filter: Content: Title */
$handler->display->display_options['arguments']['title']['id'] = 'title';
$handler->display->display_options['arguments']['title']['table'] = 'node';
$handler->display->display_options['arguments']['title']['field'] = 'title';
$handler->display->display_options['arguments']['title']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['title']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['title']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['title']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['title']['glossary'] = TRUE;
$handler->display->display_options['arguments']['title']['limit'] = '1';
return $view;
}
}
......@@ -41,7 +41,7 @@ function viewsData() {
}
public function testFieldBoolean() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'age' => array(
......
......@@ -27,7 +27,7 @@ protected function setUp() {
}
function testSimple() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'counter' => array(
'id' => 'counter',
......@@ -49,7 +49,7 @@ function testSimple() {
$this->assertEqual(3, $view->style_plugin->rendered_fields[2]['counter']);
$view->destroy();
$view = $this->getBasicView();
$view = $this->getView();
$rand_start = rand(5, 10);
$view->display['default']->handler->overrideOption('fields', array(
'counter' => array(
......
......@@ -33,7 +33,7 @@ function viewsData() {
}
public function testFieldCustom() {
$view = $this->getBasicView();
$view = $this->getView();
// Alter the text of the field to a random string.
$random = $this->randomName();
......
......@@ -33,7 +33,7 @@ function viewsData() {
}
public function testFieldDate() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'created' => array(
......
......@@ -46,7 +46,7 @@ function viewsData() {
}
public function testFieldFileSize() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'age' => array(
......
......@@ -43,7 +43,7 @@ function testEmpty() {
* This tests alters the result to get easier and less coupled results.
*/
function _testHideIfEmpty() {
$view = $this->getBasicView();
$view = $this->getView();
$view->initDisplay();
$this->executeView($view);
......@@ -261,7 +261,7 @@ function _testHideIfEmpty() {
* Tests the usage of the empty text.
*/
function _testEmptyText() {
$view = $this->getBasicView();
$view = $this->getView();
$view->initDisplay();
$this->executeView($view);
......@@ -298,7 +298,7 @@ function _testEmptyText() {
* Tests views_handler_field::is_value_empty().
*/
function testIsValueEmpty() {
$view = $this->getBasicView();
$view = $this->getView();
$view->initDisplay();
$view->initHandlers();
$field = $view->field['name'];
......
......@@ -33,7 +33,7 @@ function viewsData() {
}
public function testFieldUrl() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'name' => array(
......@@ -50,8 +50,8 @@ public function testFieldUrl() {
$this->assertEqual('John', $view->field['name']->advanced_render($view->result[0]));
// Make the url a link.
$view->delete();
$view = $this->getBasicView();
$view->destroy();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'name' => array(
......
......@@ -47,7 +47,7 @@ function viewsData() {
}
public function testFieldXss() {
$view = $this->getBasicView();
$view = $this->getView();
$view->display['default']->handler->overrideOption('fields', array(
'name' => array(
......
......@@ -35,7 +35,6 @@ function setUp() {
protected function getBasicView() {
$view = parent::getBasicView();
$fields = $view->display['default']->handler->options['fields'];
$view->display['default']->display_options['fields']['job'] = array(
'id' => 'job',
'table' => 'views_test',
......@@ -46,7 +45,7 @@ protected function getBasicView() {
}
public function testFilterCombineContains() {
$view = $this->getBasicView();
$view = $this->getView();
// Change the filtering.
$view->display['default']->handler->overrideOption('filters', array(
......
......@@ -7,8 +7,6 @@
namespace Drupal\views\Tests\Handler;
use Drupal\views\View;
/**
* Tests the core Drupal\views\Plugin\views\filter\Date handler.
*/
......@@ -47,9 +45,10 @@ function setUp() {
* Test the general offset functionality.
*/
function testOffset() {
$view = $this->views_test_offset();
$saved_view = $this->createViewFromConfig('test_filter_date_between');
// Test offset for simple operator.
$view->setDisplay('default');
$view = $this->getView($saved_view);
$view->initHandlers();
$view->filter['created']->operator = '>';
$view->filter['created']->value['type'] = 'offset';
......@@ -59,10 +58,9 @@ function testOffset() {
array('nid' => $this->nodes[3]->nid),
);
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
// Test offset for between operator.
$view->setDisplay('default');
$view = $this->getView($saved_view);
$view->initHandlers();
$view->filter['created']->operator = 'between';
$view->filter['created']->value['type'] = 'offset';
......@@ -73,17 +71,16 @@ function testOffset() {
array('nid' => $this->nodes[3]->nid),
);
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
}
/**
* Tests the filter operator between/not between.
*/
function testBetween() {
$saved_view = $this->createViewFromConfig('test_filter_date_between');
// Test between with min and max.
$view = $this->views_test_between();
$view->setDisplay('default');
$view = $this->getView($saved_view);
$view->initHandlers();
$view->filter['created']->operator = 'between';
$view->filter['created']->value['min'] = format_date(150000, 'custom', 'Y-m-d H:s');
......@@ -93,11 +90,9 @@ function testBetween() {
array('nid' => $this->nodes[1]->nid),