Issue #1856272 by tim.plunkett: Speed up tests by only installing the views used by that tests.
parent
5221886921
commit
41ae1ead1a
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class BasicTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_simple_argument');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Basic query tests',
|
||||
|
@ -101,56 +108,8 @@ class BasicTest extends ViewUnitTestBase {
|
|||
* Tests simple argument.
|
||||
*/
|
||||
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
|
||||
$view = views_get_view('test_simple_argument');
|
||||
$view->setArguments(array(27));
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -171,7 +130,7 @@ class BasicTest extends ViewUnitTestBase {
|
|||
));
|
||||
|
||||
// Test "show all" if no argument is present.
|
||||
$view = $saved_view->cloneView();
|
||||
$view = views_get_view('test_simple_argument');
|
||||
$this->executeView($view);
|
||||
|
||||
// Build the expected result.
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Comment;
|
|||
*/
|
||||
class ArgumentUserUIDTest extends CommentTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_comment_user_uid');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Comment: User UID Argument',
|
||||
|
@ -21,7 +28,8 @@ class ArgumentUserUIDTest extends CommentTestBase {
|
|||
}
|
||||
|
||||
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(
|
||||
array(
|
||||
'nid' => $this->node_user_posted->nid,
|
||||
|
@ -30,8 +38,8 @@ class ArgumentUserUIDTest extends CommentTestBase {
|
|||
'nid' => $this->node_user_commented->nid,
|
||||
),
|
||||
);
|
||||
$this->column_map = array('nid' => 'nid');
|
||||
$this->assertIdenticalResultset($this->view, $result_set, $this->column_map);
|
||||
$column_map = array('nid' => 'nid');
|
||||
$this->assertIdenticalResultset($view, $result_set, $column_map);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,11 +42,4 @@ abstract class CommentTestBase extends ViewTestBase {
|
|||
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 @@ namespace Drupal\views\Tests\Comment;
|
|||
*/
|
||||
class FilterUserUIDTest extends CommentTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_comment_user_uid');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Comment: User UID Filter',
|
||||
|
@ -23,7 +30,9 @@ class FilterUserUIDTest extends CommentTestBase {
|
|||
}
|
||||
|
||||
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(
|
||||
'id' => 'uid_touch',
|
||||
|
@ -31,8 +40,8 @@ class FilterUserUIDTest extends CommentTestBase {
|
|||
'field' => 'uid_touch',
|
||||
'value' => array($this->loggedInUser->uid),
|
||||
);
|
||||
$this->view->addItem('default', 'filter', 'node', 'uid_touch', $options);
|
||||
$this->executeView($this->view, array($this->account->uid));
|
||||
$view->addItem('default', 'filter', 'node', 'uid_touch', $options);
|
||||
$this->executeView($view, array($this->account->uid));
|
||||
$result_set = array(
|
||||
array(
|
||||
'nid' => $this->node_user_posted->nid,
|
||||
|
@ -42,7 +51,7 @@ class FilterUserUIDTest extends CommentTestBase {
|
|||
),
|
||||
);
|
||||
$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 @@ use Drupal\views\Tests\ViewTestBase;
|
|||
*/
|
||||
class FieldEntityTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_field_get_entity');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Tests\Field;
|
||||
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
||||
/**
|
||||
* Tests the field_field handler.
|
||||
* @TODO
|
||||
|
@ -17,6 +19,13 @@ namespace Drupal\views\Tests\Field;
|
|||
*/
|
||||
class HandlerFieldFieldTest extends FieldTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_fieldapi');
|
||||
|
||||
public $nodes;
|
||||
|
||||
public static function getInfo() {
|
||||
|
@ -27,6 +36,9 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
@ -59,19 +71,21 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
|
||||
$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() {
|
||||
return $this->createViewFromConfig('test_view_fieldapi');
|
||||
protected function prepareView(ViewExecutable $view) {
|
||||
$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() {
|
||||
|
@ -81,7 +95,8 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
}
|
||||
|
||||
public function _testSimpleFieldRender() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view_fieldapi');
|
||||
$this->prepareView($view);
|
||||
$this->executeView($view);
|
||||
|
||||
// Tests that the rendered fields match the actual value of the fields.
|
||||
|
@ -99,7 +114,8 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
* Tests that fields with formatters runs as expected.
|
||||
*/
|
||||
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']]['settings'] = array(
|
||||
'trim_length' => 3,
|
||||
|
@ -115,11 +131,11 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
}
|
||||
|
||||
public function _testMultipleFieldRender() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view_fieldapi');
|
||||
$field_name = $this->fields[3]['field_name'];
|
||||
|
||||
// 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]['delta_limit'] = 3;
|
||||
$this->executeView($view);
|
||||
|
@ -141,7 +157,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
$view->destroy();
|
||||
|
||||
// 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]['delta_limit'] = 3;
|
||||
$view->displayHandlers['default']->options['fields'][$field_name]['delta_offset'] = 1;
|
||||
|
@ -160,7 +176,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
$view->destroy();
|
||||
|
||||
// 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]['group_rows'] = TRUE;
|
||||
$view->displayHandlers['default']->options['fields'][$field_name]['delta_limit'] = 3;
|
||||
|
@ -181,7 +197,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
$view->destroy();
|
||||
|
||||
// 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]['delta_limit'] = 0;
|
||||
$view->displayHandlers['default']->options['fields'][$field_name]['delta_first_last'] = TRUE;
|
||||
|
@ -199,7 +215,7 @@ class HandlerFieldFieldTest extends FieldTestBase {
|
|||
$view->destroy();
|
||||
|
||||
// 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_limit'] = 3;
|
||||
$view->displayHandlers['default']->options['fields'][$field_name]['group_rows'] = TRUE;
|
||||
|
|
|
@ -15,6 +15,13 @@ namespace Drupal\views\Tests\Handler;
|
|||
*/
|
||||
class AreaTest extends HandlerTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_example_area');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class AreaTextTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Area: Text',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class ArgumentNullTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Argument: Null',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Handler;
|
|||
*/
|
||||
class ArgumentStringTest extends HandlerTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_glossary');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Argument: String',
|
||||
|
@ -35,7 +42,7 @@ class ArgumentStringTest extends HandlerTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
$view = $this->createViewFromConfig('test_glossary');
|
||||
$view = views_get_view('test_glossary');
|
||||
$this->executeView($view);
|
||||
|
||||
$count_field = 'nid';
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldBooleanTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Boolean',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldCounterTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Counter',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldCustomTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Custom',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldDateTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Date',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldFileSizeTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: File size',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldUnitTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_field_tokens', 'test_field_output');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldUrlTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: URL',
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\Handler;
|
|||
*/
|
||||
class FieldWebTest extends HandlerTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_field_classes', 'test_field_output', 'test_click_sort');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FieldXssTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: XSS',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FilterCombineTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_job' => 'job',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Handler;
|
|||
*/
|
||||
class FilterDateTest extends HandlerTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter_date_between');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -41,14 +48,22 @@ class FilterDateTest extends HandlerTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs other test methods.
|
||||
*/
|
||||
protected function testDateFilter() {
|
||||
$this->_testOffset();
|
||||
$this->_testBetween();
|
||||
$this->_testUiValidation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the general offset functionality.
|
||||
*/
|
||||
function testOffset() {
|
||||
$saved_view = $this->createViewFromConfig('test_filter_date_between');
|
||||
protected function _testOffset() {
|
||||
$view = views_get_view('test_filter_date_between');
|
||||
|
||||
// Test offset for simple operator.
|
||||
$view = $this->getView($saved_view);
|
||||
$view->initHandlers();
|
||||
$view->filter['created']->operator = '>';
|
||||
$view->filter['created']->value['type'] = 'offset';
|
||||
|
@ -58,9 +73,9 @@ class FilterDateTest extends HandlerTestBase {
|
|||
array('nid' => $this->nodes[3]->nid),
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
||||
// Test offset for between operator.
|
||||
$view = $this->getView($saved_view);
|
||||
$view->initHandlers();
|
||||
$view->filter['created']->operator = 'between';
|
||||
$view->filter['created']->value['type'] = 'offset';
|
||||
|
@ -76,11 +91,10 @@ class FilterDateTest extends HandlerTestBase {
|
|||
/**
|
||||
* Tests the filter operator between/not between.
|
||||
*/
|
||||
function testBetween() {
|
||||
$saved_view = $this->createViewFromConfig('test_filter_date_between');
|
||||
protected function _testBetween() {
|
||||
$view = views_get_view('test_filter_date_between');
|
||||
|
||||
// Test between with min and max.
|
||||
$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');
|
||||
|
@ -90,9 +104,9 @@ class FilterDateTest extends HandlerTestBase {
|
|||
array('nid' => $this->nodes[1]->nid),
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
||||
// Test between with just max.
|
||||
$view = $this->getView($saved_view);
|
||||
$view->initHandlers();
|
||||
$view->filter['created']->operator = 'between';
|
||||
$view->filter['created']->value['max'] = format_date(250000, 'custom', 'Y-m-d H:s');
|
||||
|
@ -102,9 +116,9 @@ class FilterDateTest extends HandlerTestBase {
|
|||
array('nid' => $this->nodes[1]->nid),
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
||||
// Test not between with min and max.
|
||||
$view = $this->getView($saved_view);
|
||||
$view->initHandlers();
|
||||
$view->filter['created']->operator = 'not between';
|
||||
$view->filter['created']->value['min'] = format_date(150000, 'custom', 'Y-m-d H:s');
|
||||
|
@ -116,9 +130,9 @@ class FilterDateTest extends HandlerTestBase {
|
|||
array('nid' => $this->nodes[3]->nid),
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->map);
|
||||
$view->destroy();
|
||||
|
||||
// Test not between with just max.
|
||||
$view = $this->getView($saved_view);
|
||||
$view->initHandlers();
|
||||
$view->filter['created']->operator = 'not between';
|
||||
$view->filter['created']->value['max'] = format_date(150000, 'custom', 'Y-m-d H:s');
|
||||
|
@ -134,9 +148,8 @@ class FilterDateTest extends HandlerTestBase {
|
|||
/**
|
||||
* Make sure the validation callbacks works.
|
||||
*/
|
||||
function testUiValidation() {
|
||||
$view = $this->createViewFromConfig('test_filter_date_between');
|
||||
$view->save();
|
||||
protected function _testUiValidation() {
|
||||
$view = views_get_view('test_filter_date_between');
|
||||
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer views', 'administer site configuration')));
|
||||
menu_router_rebuild();
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FilterEqualityTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FilterInOperatorTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FilterNumericTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class FilterStringTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
protected $column_map = array(
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class HandlerAliasTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter', 'test_alias');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Handler alias tests',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Plugin\views\HandlerBase;
|
|||
*/
|
||||
class HandlerTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_view_handler_weight', 'test_handler_relationships', 'test_handler_test_access', 'test_filter_in_operator_ui');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -263,7 +270,8 @@ class HandlerTest extends ViewTestBase {
|
|||
* Tests the relationship method on the base class.
|
||||
*/
|
||||
public function testSetRelationship() {
|
||||
$view = $this->createViewFromConfig('test_handler_relationships');
|
||||
$view = views_get_view('test_handler_relationships');
|
||||
$view->setDisplay();
|
||||
// Setup a broken relationship.
|
||||
$view->addItem('default', 'relationship', $this->randomName(), $this->randomName(), array(), 'broken_relationship');
|
||||
// Setup a valid relationship.
|
||||
|
@ -301,7 +309,7 @@ class HandlerTest extends ViewTestBase {
|
|||
* @see Drupal\views\Plugin\views\HandlerBase::placeholder()
|
||||
*/
|
||||
public function testPlaceholder() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->initHandlers();
|
||||
$view->initQuery();
|
||||
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class RelationshipTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
/**
|
||||
* Maps between the key in the expected result and the query result.
|
||||
*
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class SortDateTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Sort: Date',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class SortRandomTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Sort: Random',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class SortTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Sort: Generic',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\Core\Language\Language;
|
|||
*/
|
||||
class ArgumentLanguageTest extends LanguageTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Argument: Language',
|
||||
|
@ -28,8 +35,9 @@ class ArgumentLanguageTest extends LanguageTestBase {
|
|||
* Tests the language argument.
|
||||
*/
|
||||
public function testArgument() {
|
||||
$view = views_get_view('test_view');
|
||||
foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
|
||||
$view = $this->getView();
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->overrideOption('arguments', array(
|
||||
'langcode' => array(
|
||||
'id' => 'langcode',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\Core\Language\Language;
|
|||
*/
|
||||
class FieldLanguageTest extends LanguageTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Language',
|
||||
|
@ -28,7 +35,8 @@ class FieldLanguageTest extends LanguageTestBase {
|
|||
* Tests the language field.
|
||||
*/
|
||||
public function testField() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->overrideOption('fields', array(
|
||||
'langcode' => array(
|
||||
'id' => 'langcode',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\Core\Language\Language;
|
|||
*/
|
||||
class FilterLanguageTest extends LanguageTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Filter: Language',
|
||||
|
@ -28,8 +35,9 @@ class FilterLanguageTest extends LanguageTestBase {
|
|||
* Tests the language filter.
|
||||
*/
|
||||
public function testFilter() {
|
||||
$view = views_get_view('test_view');
|
||||
foreach (array('en' => 'John', 'xx-lolspeak' => 'George') as $langcode => $name) {
|
||||
$view = $this->getView();
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->overrideOption('filters', array(
|
||||
'langcode' => array(
|
||||
'id' => 'langcode',
|
||||
|
|
|
@ -7,25 +7,18 @@
|
|||
|
||||
namespace Drupal\views\Tests\Language;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewUnitTestBase;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
||||
/**
|
||||
* Defines the base class for all Language handler tests.
|
||||
*/
|
||||
abstract class LanguageTestBase extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language');
|
||||
abstract class LanguageTestBase extends ViewUnitTestBase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
$this->enableModules(array('system', 'language'));
|
||||
|
||||
// Create another language beside English.
|
||||
$language = new Language(array('langcode' => 'xx-lolspeak', 'name' => 'Lolspeak'));
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class ModuleTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_status');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views Module tests',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Node;
|
|||
*/
|
||||
class FieldTypeTest extends NodeTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_field_type');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node: Node Type field',
|
||||
|
@ -31,17 +38,9 @@ class FieldTypeTest extends NodeTestBase {
|
|||
'node_type' => 'node_type',
|
||||
);
|
||||
|
||||
$view = $this->getView();
|
||||
$view->preview();
|
||||
$view = views_get_view('test_field_type');
|
||||
$this->executeView($view);
|
||||
$this->assertIdenticalResultset($view, $expected_result, $column_map, 'The correct node type was displayed.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_field_type');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Node;
|
|||
*/
|
||||
class FilterUidRevisionTest extends NodeTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter_node_uid_revision');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node: User has revision Filter',
|
||||
|
|
|
@ -13,6 +13,13 @@ use Drupal\views\Tests\ViewTestBase;
|
|||
*/
|
||||
class RevisionRelationships extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_node_revision_nid', 'test_node_revision_vid');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node: Revision integration',
|
||||
|
@ -37,7 +44,7 @@ class RevisionRelationships extends ViewTestBase {
|
|||
);
|
||||
|
||||
// Here should be two rows.
|
||||
$view_nid = $this->createViewFromConfig('test_node_revision_nid');
|
||||
$view_nid = views_get_view('test_node_revision_nid');
|
||||
$this->executeView($view_nid, array($node->nid));
|
||||
$resultset_nid = array(
|
||||
array(
|
||||
|
@ -54,7 +61,7 @@ class RevisionRelationships extends ViewTestBase {
|
|||
$this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map);
|
||||
|
||||
// There should be only one row with active revision 2.
|
||||
$view_vid = $this->createViewFromConfig('test_node_revision_vid');
|
||||
$view_vid = views_get_view('test_node_revision_vid');
|
||||
$this->executeView($view_vid, array($node->nid));
|
||||
$resultset_vid = array(
|
||||
array(
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\Node;
|
|||
*/
|
||||
class StatusExtraTest extends NodeTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_status_extra');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node: Status extra filter',
|
||||
|
|
|
@ -15,6 +15,13 @@ namespace Drupal\views\Tests\Plugin;
|
|||
*/
|
||||
class AccessTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_access_none', 'test_access_static', 'test_access_dynamic');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Access',
|
||||
|
@ -43,7 +50,8 @@ class AccessTest extends PluginTestBase {
|
|||
* Tests none access plugin.
|
||||
*/
|
||||
function testAccessNone() {
|
||||
$view = $this->createViewFromConfig('test_access_none');
|
||||
$view = views_get_view('test_access_none');
|
||||
$view->setDisplay();
|
||||
|
||||
$this->assertTrue($view->display_handler->access($this->admin_user), t('Admin-Account should be able to access the view everytime'));
|
||||
$this->assertTrue($view->display_handler->access($this->web_user));
|
||||
|
@ -60,7 +68,8 @@ class AccessTest extends PluginTestBase {
|
|||
* @see Drupal\views_test\Plugin\views\access\StaticTest
|
||||
*/
|
||||
function testStaticAccessPlugin() {
|
||||
$view = $this->createViewFromConfig('test_access_static');
|
||||
$view = views_get_view('test_access_static');
|
||||
$view->setDisplay();
|
||||
|
||||
$access_plugin = $view->display_handler->getPlugin('access');
|
||||
|
||||
|
@ -88,7 +97,8 @@ class AccessTest extends PluginTestBase {
|
|||
* @see Drupal\views_test\Plugin\views\access\DyamicTest
|
||||
*/
|
||||
function testDynamicAccessPlugin() {
|
||||
$view = $this->createViewFromConfig('test_access_dynamic');
|
||||
$view = views_get_view('test_access_dynamic');
|
||||
$view->setDisplay();
|
||||
$argument1 = $this->randomName();
|
||||
$argument2 = $this->randomName();
|
||||
state()->set('test_dynamic_access_argument1', $argument1);
|
||||
|
|
|
@ -15,6 +15,13 @@ use Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest as
|
|||
*/
|
||||
class ArgumentDefaultTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_argument_default_fixed', 'test_argument_default_current_user');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -22,13 +29,6 @@ class ArgumentDefaultTest extends PluginTestBase {
|
|||
*/
|
||||
public static $modules = array('views_ui');
|
||||
|
||||
/**
|
||||
* A random string used in the default views.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $random;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Argument default',
|
||||
|
@ -38,8 +38,6 @@ class ArgumentDefaultTest extends PluginTestBase {
|
|||
}
|
||||
|
||||
protected function setUp() {
|
||||
$this->random = $this->randomString();
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
@ -112,16 +110,18 @@ class ArgumentDefaultTest extends PluginTestBase {
|
|||
* Tests fixed default argument.
|
||||
*/
|
||||
function testArgumentDefaultFixed() {
|
||||
$view = $this->getView();
|
||||
$view->preExecute();
|
||||
$random = $this->randomName();
|
||||
$view = views_get_view('test_argument_default_fixed');
|
||||
$view->setDisplay();
|
||||
$options = $view->display_handler->getOption('arguments');
|
||||
$options['null']['default_argument_options']['argument'] = $random;
|
||||
$view->display_handler->overrideOption('arguments', $options);
|
||||
$view->initHandlers();
|
||||
|
||||
$this->assertEqual($view->argument['null']->get_default_argument(), $this->random, 'Fixed argument should be used by default.');
|
||||
$this->assertEqual($view->argument['null']->get_default_argument(), $random, 'Fixed argument should be used by default.');
|
||||
|
||||
// Make sure that a normal argument provided is used
|
||||
$view = $this->getView();
|
||||
|
||||
$random_string = $this->randomString();
|
||||
$random_string = $this->randomName();
|
||||
$view->executeDisplay('default', array($random_string));
|
||||
|
||||
$this->assertEqual($view->args[0], $random_string, 'Provided argument should be used.');
|
||||
|
@ -137,13 +137,4 @@ class ArgumentDefaultTest extends PluginTestBase {
|
|||
*/
|
||||
//function testArgumentDefaultNode() {}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
$view = $this->createViewFromConfig('test_argument_default_fixed');
|
||||
$view->displayHandlers['default']->display['display_options']['arguments']['null']['default_argument_options']['argument'] = $this->random;
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\ViewUnitTestBase;
|
|||
*/
|
||||
class ArgumentValidatorTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_argument_validate_php', 'test_view_argument_validate_numeric');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Argument validator',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\ViewExecutable;
|
|||
*/
|
||||
class CacheTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_cache');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Cache',
|
||||
|
@ -30,54 +37,6 @@ class CacheTest extends PluginTestBase {
|
|||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and return a basic view of the views_test_data table.
|
||||
*
|
||||
* @return Drupal\views\ViewExecutable
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
// Create the basic view.
|
||||
$view = $this->createViewFromConfig('test_view');
|
||||
$view->storage->addDisplay('default');
|
||||
$view->storage->set('base_table', 'views_test_data');
|
||||
|
||||
// Set up the fields we need.
|
||||
$display = $view->storage->newDisplay('default', 'Master', 'default');
|
||||
$display->overrideOption('fields', array(
|
||||
'id' => array(
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
// Set up the sort order.
|
||||
$display->overrideOption('sorts', array(
|
||||
'id' => array(
|
||||
'order' => 'ASC',
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests time based caching.
|
||||
*
|
||||
|
@ -85,7 +44,8 @@ class CacheTest extends PluginTestBase {
|
|||
*/
|
||||
function testTimeCaching() {
|
||||
// Create a basic result which just 2 results.
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
|
@ -107,7 +67,8 @@ class CacheTest extends PluginTestBase {
|
|||
drupal_write_record('views_test_data', $record);
|
||||
|
||||
// The Result should be the same as before, because of the caching.
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
|
@ -128,7 +89,8 @@ class CacheTest extends PluginTestBase {
|
|||
*/
|
||||
function testNoneCaching() {
|
||||
// Create a basic result which just 2 results.
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
'type' => 'none',
|
||||
'options' => array()
|
||||
|
@ -148,7 +110,8 @@ class CacheTest extends PluginTestBase {
|
|||
drupal_write_record('views_test_data', $record);
|
||||
|
||||
// The Result changes, because the view is not cached.
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
'type' => 'none',
|
||||
'options' => array()
|
||||
|
@ -166,7 +129,8 @@ class CacheTest extends PluginTestBase {
|
|||
// Create a view with output caching enabled.
|
||||
// Some hook_views_pre_render in views_test_data.module adds the test css/js file.
|
||||
// so they should be added to the css/js storage.
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
$view->storage->set('name', 'test_cache_header_storage');
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
'type' => 'time',
|
||||
|
@ -179,8 +143,9 @@ class CacheTest extends PluginTestBase {
|
|||
unset($view->pre_render_called);
|
||||
drupal_static_reset('drupal_add_css');
|
||||
drupal_static_reset('drupal_add_js');
|
||||
$view->destroy();
|
||||
|
||||
$view = $this->getView($view);
|
||||
$view->setDisplay();
|
||||
$view->preview();
|
||||
$css = drupal_add_css();
|
||||
$css_path = drupal_get_path('module', 'views_test_data') . '/views_cache.test.css';
|
||||
|
@ -199,13 +164,15 @@ class CacheTest extends PluginTestBase {
|
|||
drupal_add_css($system_css_path);
|
||||
$system_js_path = drupal_get_path('module', 'system') . '/system.cron.js';
|
||||
drupal_add_js($system_js_path);
|
||||
$view->destroy();
|
||||
|
||||
$view = $this->getView($view);
|
||||
$view->setDisplay();
|
||||
$view->preview();
|
||||
drupal_static_reset('drupal_add_css');
|
||||
drupal_static_reset('drupal_add_js');
|
||||
$view->destroy();
|
||||
|
||||
$view = $this->getView($view);
|
||||
$view->setDisplay();
|
||||
$view->preview();
|
||||
|
||||
$css = drupal_add_css();
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\Plugin\PluginTestBase;
|
|||
*/
|
||||
class DisplayExtenderTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display extender',
|
||||
|
@ -30,7 +37,6 @@ class DisplayExtenderTest extends PluginTestBase {
|
|||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test display extenders.
|
||||
*/
|
||||
|
@ -38,7 +44,7 @@ class DisplayExtenderTest extends PluginTestBase {
|
|||
config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
|
||||
$this->assertEqual(count(views_get_enabled_display_extenders()), 1, 'Make sure that there is only one enabled display extender.');
|
||||
|
||||
$view = $this->getBasicView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->initDisplay();
|
||||
|
||||
$this->assertEqual(count($view->display_handler->extender), 1, 'Make sure that only one extender is initialized.');
|
||||
|
@ -51,4 +57,5 @@ class DisplayExtenderTest extends PluginTestBase {
|
|||
$view->execute();
|
||||
$this->assertTrue($display_extender->testState['query'], 'Make sure the display extender was able to react on query.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\Plugin;
|
|||
*/
|
||||
class DisplayFeedTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_feed_display');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\Plugin\PluginTestBase;
|
|||
*/
|
||||
class DisplayPageTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_page_display');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display: Page plugin',
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views_test_data\Plugin\views\display\DisplayTest as DisplayTestPlugin
|
|||
*/
|
||||
class DisplayTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter_groups');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -111,7 +118,7 @@ class DisplayTest extends PluginTestBase {
|
|||
* Tests the overriding of filter_groups.
|
||||
*/
|
||||
public function testFilterGroupsOverriding() {
|
||||
$view = $this->createViewFromConfig('test_filter_groups');
|
||||
$view = views_get_view('test_filter_groups');
|
||||
$view->initDisplay();
|
||||
|
||||
// mark is as overridden, yes FALSE, means overridden.
|
||||
|
|
|
@ -14,6 +14,13 @@ use Drupal\views\Tests\UI\UITestBase;
|
|||
*/
|
||||
class ExposedFormTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_reset_button', 'test_exposed_admin_ui');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views_test_data\Plugin\views\filter\FilterTest as FilterPlugin;
|
|||
*/
|
||||
class FilterTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Plugin;
|
|||
*/
|
||||
class PagerTest extends PluginTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_store_pager_settings', 'test_pager_none', 'test_pager_some', 'test_pager_full', 'test_view_pager_full_zero_items_per_page');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -56,7 +63,7 @@ class PagerTest extends PluginTestBase {
|
|||
$this->assertText('Mini', 'Changed pager plugin, should change some text');
|
||||
|
||||
// Test behaviour described in http://drupal.org/node/652712#comment-2354400
|
||||
$view = $this->createViewFromConfig('test_store_pager_settings');
|
||||
$view = views_get_view('test_store_pager_settings');
|
||||
// Make it editable in the admin interface.
|
||||
$view->save();
|
||||
|
||||
|
@ -109,13 +116,13 @@ class PagerTest extends PluginTestBase {
|
|||
for ($i = 0; $i < 11; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_pager_none');
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(count($view->result), 11, 'Make sure that every item is returned in the result');
|
||||
|
||||
// Setup and test a offset.
|
||||
$view = $this->getView();
|
||||
|
||||
$view = views_get_view('test_pager_none');
|
||||
$view->setDisplay();
|
||||
$pager = array(
|
||||
'type' => 'none',
|
||||
'options' => array(
|
||||
|
@ -133,48 +140,35 @@ class PagerTest extends PluginTestBase {
|
|||
$this->assertEqual($view->pager->get_items_per_page(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_pager_none');
|
||||
}
|
||||
|
||||
public function testViewTotalRowsWithoutPager() {
|
||||
$this->createNodes(23);
|
||||
|
||||
$this->view->get_total_rows = TRUE;
|
||||
$this->executeView($this->view);
|
||||
|
||||
$this->assertEqual($this->view->total_rows, 23, "'total_rows' is calculated when pager type is 'none' and 'get_total_rows' is TRUE.");
|
||||
}
|
||||
|
||||
public function createNodes($count) {
|
||||
if ($count >= 0) {
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
for ($i = 0; $i < 23; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
|
||||
$view = views_get_view('test_pager_none');
|
||||
$view->get_total_rows = TRUE;
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual($view->total_rows, 23, "'total_rows' is calculated when pager type is 'none' and 'get_total_rows' is TRUE.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the some pager plugin.
|
||||
*/
|
||||
public function testLimit() {
|
||||
$saved_view = $this->createViewFromConfig('test_pager_some');
|
||||
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
$view = $saved_view->cloneView();
|
||||
|
||||
$view = views_get_view('test_pager_some');
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(count($view->result), 5, 'Make sure that only a certain count of items is returned');
|
||||
|
||||
// Setup and test a offset.
|
||||
$view = $this->getView($saved_view);
|
||||
|
||||
$view = views_get_view('test_pager_some');
|
||||
$view->setDisplay();
|
||||
$pager = array(
|
||||
'type' => 'none',
|
||||
'options' => array(
|
||||
|
@ -195,20 +189,19 @@ class PagerTest extends PluginTestBase {
|
|||
* Tests the normal pager.
|
||||
*/
|
||||
public function testNormalPager() {
|
||||
$saved_view = $this->createViewFromConfig('test_pager_full');
|
||||
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
$view = $saved_view->cloneView();
|
||||
|
||||
$view = views_get_view('test_pager_full');
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(count($view->result), 5, 'Make sure that only a certain count of items is returned');
|
||||
|
||||
// Setup and test a offset.
|
||||
$view = $this->getView($saved_view);
|
||||
|
||||
$view = views_get_view('test_pager_full');
|
||||
$view->setDisplay();
|
||||
$pager = array(
|
||||
'type' => 'full',
|
||||
'options' => array(
|
||||
|
@ -221,7 +214,7 @@ class PagerTest extends PluginTestBase {
|
|||
$this->assertEqual(count($view->result), 3, 'Make sure that only a certain count of items is returned');
|
||||
|
||||
// Test items per page = 0
|
||||
$view = $this->createViewFromConfig('test_view_pager_full_zero_items_per_page');
|
||||
$view = views_get_view('test_view_pager_full_zero_items_per_page');
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual(count($view->result), 11, 'All items are return');
|
||||
|
@ -230,8 +223,8 @@ class PagerTest extends PluginTestBase {
|
|||
|
||||
// Test items per page = 0.
|
||||
// Setup and test a offset.
|
||||
$view = $this->getView($saved_view);
|
||||
|
||||
$view = views_get_view('test_pager_full');
|
||||
$view->setDisplay();
|
||||
$pager = array(
|
||||
'type' => 'full',
|
||||
'options' => array(
|
||||
|
@ -255,7 +248,7 @@ class PagerTest extends PluginTestBase {
|
|||
for ($i = 0; $i < 11; $i++) {
|
||||
$this->drupalCreateNode();
|
||||
}
|
||||
$view = $this->createViewFromConfig('test_pager_full');
|
||||
$view = views_get_view('test_pager_full');
|
||||
$this->executeView($view);
|
||||
$view->use_ajax = TRUE; // force the value again here
|
||||
$view->pager = NULL;
|
||||
|
@ -267,7 +260,8 @@ class PagerTest extends PluginTestBase {
|
|||
* Test the api functions on the view object.
|
||||
*/
|
||||
function testPagerApi() {
|
||||
$view = $this->createViewFromConfig('test_pager_full');
|
||||
$view = views_get_view('test_pager_full');
|
||||
$view->setDisplay();
|
||||
// On the first round don't initialize the pager.
|
||||
|
||||
$this->assertEqual($view->getItemsPerPage(), NULL, 'If the pager is not initialized and no manual override there is no items per page.');
|
||||
|
|
|
@ -7,13 +7,20 @@
|
|||
|
||||
namespace Drupal\views\Tests\Plugin;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
use Drupal\views\Tests\ViewUnitTestBase;
|
||||
use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
|
||||
|
||||
/**
|
||||
* Tests query plugins.
|
||||
*/
|
||||
class QueryTest extends ViewTestBase {
|
||||
class QueryTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
|
@ -23,12 +30,6 @@ class QueryTest extends ViewTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['table']['base']['query_id'] = 'query_test';
|
||||
|
@ -48,13 +49,17 @@ class QueryTest extends ViewTestBase {
|
|||
* Tests the ViewExecutable::initQuery method.
|
||||
*/
|
||||
public function _testInitQuery() {
|
||||
$view = $this->getBasicView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->initQuery();
|
||||
$this->assertTrue($view->query instanceof QueryTestPlugin, 'Make sure the right query plugin got instantiated.');
|
||||
}
|
||||
|
||||
public function _testQueryExecute() {
|
||||
$view = $this->getBasicView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->initQuery();
|
||||
$view->query->setAllItems($this->dataSet());
|
||||
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Plugin;
|
|||
*/
|
||||
class StyleMappingTest extends StyleTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_style_mapping');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Style: Mapping',
|
||||
|
@ -33,8 +40,8 @@ class StyleMappingTest extends StyleTestBase {
|
|||
$view = views_get_view('test_style_mapping');
|
||||
$output = $this->mappedOutputHelper($view);
|
||||
$this->assertTrue(strpos($output, 'job') === FALSE, 'The job field is added to the view but not in the mapping.');
|
||||
$view->destroy();
|
||||
|
||||
$view = views_get_view('test_style_mapping');
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->options['style']['options']['mapping']['name_field'] = 'job';
|
||||
$output = $this->mappedOutputHelper($view);
|
||||
|
|
|
@ -18,6 +18,13 @@ use Drupal\views_test_data\Plugin\views\style\StyleTest as StyleTestPlugin;
|
|||
*/
|
||||
class StyleTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
/**
|
||||
* Stores the SimpleXML representation of the output.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Plugin;
|
|||
*/
|
||||
class StyleUnformattedTest extends StyleTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Style: Unformatted',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class QueryGroupByTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Groupby',
|
||||
|
@ -43,7 +50,7 @@ class QueryGroupByTest extends ViewTestBase {
|
|||
$this->drupalCreateNode($node_2);
|
||||
$this->drupalCreateNode($node_2);
|
||||
|
||||
$view = $this->createViewFromConfig('test_aggregate_count');
|
||||
$view = views_get_view('test_aggregate_count');
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
|
||||
|
@ -86,7 +93,8 @@ class QueryGroupByTest extends ViewTestBase {
|
|||
$this->drupalCreateNode($node_2);
|
||||
$this->drupalCreateNode($node_2);
|
||||
|
||||
$view = $this->createViewFromConfig('test_group_by_count');
|
||||
$view = views_get_view('test_group_by_count');
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->options['fields']['nid']['group_type'] = $group_by;
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -107,7 +115,6 @@ class QueryGroupByTest extends ViewTestBase {
|
|||
$this->GroupByTestHelper('sum', array(10, 18));
|
||||
}
|
||||
|
||||
|
||||
function testGroupByAverage() {
|
||||
$this->GroupByTestHelper('avg', array(2.5, 6));
|
||||
}
|
||||
|
@ -133,17 +140,11 @@ class QueryGroupByTest extends ViewTestBase {
|
|||
$this->drupalCreateNode($node_1);
|
||||
}
|
||||
|
||||
$this->executeView($this->view);
|
||||
$view = views_get_view('test_group_by_in_filters');
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertTrue(strpos($this->view->build_info['query'], 'GROUP BY'), t('Make sure that GROUP BY is in the query'));
|
||||
$this->assertTrue(strpos($this->view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_group_by_in_filters');
|
||||
$this->assertTrue(strpos($view->build_info['query'], 'GROUP BY'), 'Make sure that GROUP BY is in the query');
|
||||
$this->assertTrue(strpos($view->build_info['query'], 'HAVING'), 'Make sure that HAVING is in the query');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,19 +7,17 @@
|
|||
|
||||
namespace Drupal\views\Tests\Taxonomy;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
|
||||
/**
|
||||
* Tests the node_term_data relationship handler.
|
||||
*/
|
||||
class RelationshipNodeTermDataTest extends TaxonomyTestBase {
|
||||
|
||||
/**
|
||||
* The vocabulary for the test.
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var Drupal\taxonomy\Vocabulary
|
||||
* @var array
|
||||
*/
|
||||
protected $vocabulary;
|
||||
public static $testViews = array('test_taxonomy_node_term_data');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
|
@ -30,7 +28,8 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
|
|||
}
|
||||
|
||||
function testViewsHandlerRelationshipNodeTermData() {
|
||||
$this->executeView($this->view, array($this->term1->tid, $this->term2->tid));
|
||||
$view = views_get_view('test_taxonomy_node_term_data');
|
||||
$this->executeView($view, array($this->term1->tid, $this->term2->tid));
|
||||
$resultset = array(
|
||||
array(
|
||||
'nid' => $this->nodes[0]->nid,
|
||||
|
@ -40,14 +39,7 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
|
|||
),
|
||||
);
|
||||
$this->column_map = array('nid' => 'nid');
|
||||
$this->assertIdenticalResultset($this->view, $resultset, $this->column_map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_taxonomy_node_term_data');
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\Taxonomy;
|
|||
*/
|
||||
class RelationshipRepresentativeNode extends TaxonomyTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_groupwise_term');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Taxonomy: Representative Node Relationship',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class TokenReplaceTest extends ViewUnitTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_tokens');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'View core token replacement',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class DefaultViewsTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_status');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Default views functionality',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class DisplayExtenderUITest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display extender: UI',
|
||||
|
@ -26,7 +33,7 @@ class DisplayExtenderUITest extends UITestBase {
|
|||
public function testDisplayExtenderUI() {
|
||||
config('views.settings')->set('display_extenders', array('display_extender_test'))->save();
|
||||
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_view');
|
||||
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
|
||||
$display_option_url = 'admin/structure/views/nojs/display/test_view/default/test_extender_test_option';
|
||||
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class DisplayPath extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display Path: UI',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class DisplayTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display tests',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class GroupByTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_views_groupby_save');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Group By functionality',
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\ViewExecutable;
|
|||
*/
|
||||
class HandlerTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Handler test',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class PreviewTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_preview');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Preview functionality',
|
||||
|
|
|
@ -15,6 +15,13 @@ use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
|
|||
*/
|
||||
class QueryTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Query: UI',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class RedirectTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_redirect_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Redirect',
|
||||
|
@ -24,10 +31,11 @@ class RedirectTest extends UITestBase {
|
|||
* Tests the redirecting.
|
||||
*/
|
||||
public function testRedirect() {
|
||||
$view = $this->getBasicView();
|
||||
$view_name = 'test_view';
|
||||
$view = views_get_view($view_name);
|
||||
|
||||
$random_destination = $this->randomName();
|
||||
$edit_path = "admin/structure/views/view/{$view->storage->get('name')}/edit";
|
||||
$edit_path = "admin/structure/views/view/$view_name/edit";
|
||||
|
||||
$this->drupalPost($edit_path, array(), t('Save') , array('query' => array('destination' => $random_destination)));
|
||||
$this->assertUrl($random_destination, array(), 'Make sure the user got redirected to the expected page defined in the destination.');
|
||||
|
@ -35,12 +43,13 @@ class RedirectTest extends UITestBase {
|
|||
// Setup a view with a certain page display path. If you change the path
|
||||
// but have the old url in the destination the user should be redirected to
|
||||
// the new path.
|
||||
$view = views_get_view('test_redirect_view');
|
||||
$view_name = 'test_redirect_view';
|
||||
$view = views_get_view($view_name);
|
||||
$random_destination = $this->randomName();
|
||||
$new_path = $this->randomName();
|
||||
|
||||
$edit_path = "admin/structure/views/view/{$view->storage->get('name')}/edit";
|
||||
$path_edit_path = "admin/structure/views/nojs/display/{$view->storage->get('name')}/page_1/path";
|
||||
$edit_path = "admin/structure/views/view/$view_name/edit";
|
||||
$path_edit_path = "admin/structure/views/nojs/display/$view_name/page_1/path";
|
||||
|
||||
$this->drupalPost($path_edit_path, array('path' => $new_path), t('Apply'));
|
||||
$this->drupalPost($edit_path, array(), t('Save'), array('query' => array('destination' => 'test-redirect-view')));
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class RowUITest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Row: UI',
|
||||
|
@ -26,11 +33,12 @@ class RowUITest extends UITestBase {
|
|||
* Tests changing the row plugin and changing some options of a row.
|
||||
*/
|
||||
public function testRowUI() {
|
||||
$view = $this->getView();
|
||||
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
|
||||
$view_name = 'test_view';
|
||||
$view = views_get_view($view_name);
|
||||
$view_edit_url = "admin/structure/views/view/$view_name/edit";
|
||||
|
||||
$row_plugin_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/row";
|
||||
$row_options_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/row_options";
|
||||
$row_plugin_url = "admin/structure/views/nojs/display/$view_name/default/row";
|
||||
$row_options_url = "admin/structure/views/nojs/display/$view_name/default/row_options";
|
||||
|
||||
$this->drupalGet($row_plugin_url);
|
||||
$this->assertFieldByName('row', 'fields', 'The default row plugin selected in the UI should be fields.');
|
||||
|
@ -51,7 +59,7 @@ class RowUITest extends UITestBase {
|
|||
$this->drupalPost($view_edit_url, array(), t('Save'));
|
||||
$this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI');
|
||||
|
||||
$view = views_get_view($view->storage->get('name'));
|
||||
$view = views_get_view($view_name);
|
||||
$view->initDisplay();
|
||||
$row = $view->display_handler->getOption('row');
|
||||
$this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.');
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class StorageTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Storage properties',
|
||||
|
@ -26,9 +33,10 @@ class StorageTest extends UITestBase {
|
|||
* @see views_ui_edit_details_form
|
||||
*/
|
||||
public function testDetails() {
|
||||
$view = $this->getBasicView();
|
||||
$view_name = 'test_view';
|
||||
$view = views_get_view($view_name);
|
||||
|
||||
$path = "admin/structure/views/nojs/edit-details/{$view->storage->get('name')}";
|
||||
$path = "admin/structure/views/nojs/edit-details/$view_name";
|
||||
$edit = array(
|
||||
'human_name' => $this->randomName(),
|
||||
'tag' => $this->randomName(),
|
||||
|
@ -37,8 +45,8 @@ class StorageTest extends UITestBase {
|
|||
|
||||
$this->drupalPost($path, $edit, t('Apply'));
|
||||
$this->drupalPost(NULL, array(), t('Save'));
|
||||
$view = views_get_view($view->storage->get('name'));
|
||||
|
||||
$view = views_get_view($view_name);
|
||||
foreach (array('human_name', 'tag', 'description') as $property) {
|
||||
$this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property)));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\UI;
|
|||
*/
|
||||
class StyleUITest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Style: UI',
|
||||
|
@ -26,11 +33,12 @@ class StyleUITest extends UITestBase {
|
|||
* Tests changing the style plugin and changing some options of a style.
|
||||
*/
|
||||
public function testStyleUI() {
|
||||
$view = $this->getView();
|
||||
$view_edit_url = "admin/structure/views/view/{$view->storage->get('name')}/edit";
|
||||
$view_name = 'test_view';
|
||||
$view = views_get_view($view_name);
|
||||
$view_edit_url = "admin/structure/views/view/$view_name/edit";
|
||||
|
||||
$style_plugin_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/style";
|
||||
$style_options_url = "admin/structure/views/nojs/display/{$view->storage->get('name')}/default/style_options";
|
||||
$style_plugin_url = "admin/structure/views/nojs/display/$view_name/default/style";
|
||||
$style_options_url = "admin/structure/views/nojs/display/$view_name/default/style_options";
|
||||
|
||||
$this->drupalGet($style_plugin_url);
|
||||
$this->assertFieldByName('style', 'default', 'The default style plugin selected in the UI should be unformatted list.');
|
||||
|
@ -51,7 +59,7 @@ class StyleUITest extends UITestBase {
|
|||
$this->drupalPost($view_edit_url, array(), t('Save'));
|
||||
$this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
|
||||
|
||||
$view = views_get_view($view->storage->get('name'));
|
||||
$view = views_get_view($view_name);
|
||||
$view->initDisplay();
|
||||
$style = $view->display_handler->getOption('style');
|
||||
$this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.');
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\user\Plugin\views\access\Permission;
|
|||
*/
|
||||
class AccessPermissionTest extends AccessTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_access_perm');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Access permission',
|
||||
|
@ -24,12 +31,12 @@ class AccessPermissionTest extends AccessTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests perm access plugin.
|
||||
*/
|
||||
function testAccessPerm() {
|
||||
$view = $this->createViewFromConfig('test_access_perm');
|
||||
$view = views_get_view('test_access_perm');
|
||||
$view->setDisplay();
|
||||
|
||||
$access_plugin = $view->display_handler->getPlugin('access');
|
||||
$this->assertTrue($access_plugin instanceof Permission, 'Make sure the right class got instantiated.');
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\user\Plugin\views\access\Role;
|
|||
*/
|
||||
class AccessRoleTest extends AccessTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_access_role');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Access role',
|
||||
|
@ -28,7 +35,8 @@ class AccessRoleTest extends AccessTestBase {
|
|||
* Tests role access plugin.
|
||||
*/
|
||||
function testAccessRole() {
|
||||
$view = $this->createViewFromConfig('test_access_role');
|
||||
$view = views_get_view('test_access_role');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers['default']->options['access']['options']['role'] = array(
|
||||
$this->normalRole => $this->normalRole,
|
||||
|
@ -37,7 +45,6 @@ class AccessRoleTest extends AccessTestBase {
|
|||
$access_plugin = $view->display_handler->getPlugin('access');
|
||||
$this->assertTrue($access_plugin instanceof Role, 'Make sure the right class got instantiated.');
|
||||
|
||||
|
||||
$this->assertTrue($view->display_handler->access($this->adminUser), t('Admin-Account should be able to access the view everytime'));
|
||||
$this->assertFalse($view->display_handler->access($this->webUser));
|
||||
$this->assertTrue($view->display_handler->access($this->normalUser));
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\User;
|
|||
*/
|
||||
class ArgumentDefaultTest extends UserTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_plugin_argument_default_current_user');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Argument default',
|
||||
|
@ -31,20 +38,13 @@ class ArgumentDefaultTest extends UserTestBase {
|
|||
drupal_save_session(FALSE);
|
||||
$user = $account;
|
||||
|
||||
$this->view->preExecute();
|
||||
$this->view->initHandlers();
|
||||
$view = views_get_view('test_plugin_argument_default_current_user');
|
||||
$view->initHandlers();
|
||||
|
||||
$this->assertEqual($this->view->argument['null']->get_default_argument(), $account->uid, 'Uid of the current user is used.');
|
||||
$this->assertEqual($view->argument['null']->get_default_argument(), $account->uid, 'Uid of the current user is used.');
|
||||
// Switch back.
|
||||
$user = $admin;
|
||||
drupal_save_session(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_plugin_argument_default_current_user');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\User;
|
|||
*/
|
||||
class ArgumentValidateTest extends UserTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_argument_validate_user');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Argument validator',
|
||||
|
@ -76,7 +83,8 @@ class ArgumentValidateTest extends UserTestBase {
|
|||
}
|
||||
|
||||
function view_argument_validate_user($argtype) {
|
||||
$view = $this->createViewFromConfig('test_view_argument_validate_user');
|
||||
$view = views_get_view('test_view_argument_validate_user');
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers['default']->options['arguments']['null']['validate_options']['type'] = $argtype;
|
||||
$view->preExecute();
|
||||
$view->initHandlers();
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\User;
|
|||
*/
|
||||
class HandlerArgumentUserUidTest extends UserTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_user_uid_argument');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Uid Argument',
|
||||
|
|
|
@ -14,6 +14,13 @@ namespace Drupal\views\Tests\User;
|
|||
*/
|
||||
class HandlerFieldUserNameTest extends UserTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_views_handler_field_user_name');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Name Field',
|
||||
|
@ -22,8 +29,8 @@ class HandlerFieldUserNameTest extends UserTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
function testUserName() {
|
||||
$view = $this->getView();
|
||||
public function testUserName() {
|
||||
$view = views_get_view('test_views_handler_field_user_name');
|
||||
$this->executeView($view);
|
||||
|
||||
$view->row_index = 0;
|
||||
|
@ -53,11 +60,4 @@ class HandlerFieldUserNameTest extends UserTestBase {
|
|||
$this->assertIdentical($render, $anon_name , 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_views_handler_field_user_name');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\views\Tests\ViewTestBase;
|
|||
*/
|
||||
class HandlerFilterUserNameTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_user_name');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests\User;
|
|||
*/
|
||||
class RelationshipRepresentativeNode extends UserTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_groupwise_user');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'User: Representative Node Relationship',
|
||||
|
|
|
@ -12,6 +12,13 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class ViewElementTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
|
||||
/**
|
||||
* The raw render data array to use in tests.
|
||||
*
|
||||
|
@ -48,7 +55,8 @@ class ViewElementTest extends ViewTestBase {
|
|||
* Tests the rendered output and form output of a view element.
|
||||
*/
|
||||
public function testViewElement() {
|
||||
$view = $this->getBasicView();
|
||||
$view = views_get_view('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
// Set the content as our rendered array.
|
||||
$render = $this->render;
|
||||
|
|
|
@ -18,6 +18,13 @@ use Drupal\views\Plugin\views\display\Page;
|
|||
*/
|
||||
class ViewExecutableTest extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_destroy', 'test_executable_displays');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -63,13 +70,12 @@ class ViewExecutableTest extends ViewTestBase {
|
|||
* Tests the initDisplay() and initHandlers() methods.
|
||||
*/
|
||||
public function testInitMethods() {
|
||||
$view = $this->getBasicView();
|
||||
$view = views_get_view('test_destroy');
|
||||
$view->initDisplay();
|
||||
|
||||
$this->assertTrue($view->display_handler instanceof DefaultDisplay, 'Make sure a reference to the current display handler is set.');
|
||||
$this->assertTrue($view->displayHandlers['default'] instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
|
||||
|
||||
$view = $this->getBasicView();
|
||||
$view->destroy();
|
||||
$view->initHandlers();
|
||||
|
||||
|
@ -88,25 +94,18 @@ class ViewExecutableTest extends ViewTestBase {
|
|||
$this->assertTrue($view->displayHandlers['default'] instanceof DefaultDisplay, 'Make sure a display handler is created for each display.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides Drupal\views\Tests\ViewTestBase::getBasicView().
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the generation of the executable object.
|
||||
*/
|
||||
public function testConstructing() {
|
||||
$view = $this->getView();
|
||||
views_get_view('test_destroy');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the accessing of values on the object.
|
||||
*/
|
||||
public function testProperties() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_destroy');
|
||||
foreach ($this->executableProperties as $property) {
|
||||
$this->assertTrue(isset($view->{$property}));
|
||||
}
|
||||
|
@ -148,27 +147,18 @@ class ViewExecutableTest extends ViewTestBase {
|
|||
$view->setDisplay('page_2');
|
||||
$this->assertEqual($view->current_display, 'page_2', 'If setDisplay is called with a valid display id the appropriate display should be used.');
|
||||
$this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers['page_2']));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the deconstructor to be sure that every kind of heavy objects are removed.
|
||||
*/
|
||||
function testDestroy() {
|
||||
$view = $this->getView();
|
||||
$view = views_get_view('test_destroy');
|
||||
|
||||
$view->preview();
|
||||
$view->destroy();
|
||||
|
||||
$this->assertViewDestroy($view);
|
||||
|
||||
// Manipulate the display variable to test a previous bug.
|
||||
$view = $this->getView();
|
||||
$view->preview();
|
||||
|
||||
$view->destroy();
|
||||
$this->assertViewDestroy($view);
|
||||
}
|
||||
|
||||
function assertViewDestroy($view) {
|
||||
|
@ -216,11 +206,12 @@ class ViewExecutableTest extends ViewTestBase {
|
|||
// Test a view with multiple displays.
|
||||
// Validating a view shouldn't change the active display.
|
||||
// @todo Create an extra validation view.
|
||||
$this->view->setDisplay('page_1');
|
||||
$view = views_get_view('test_destroy');
|
||||
$view->setDisplay('page_1');
|
||||
|
||||
$this->view->validate();
|
||||
$view->validate();
|
||||
|
||||
$this->assertEqual('page_1', $this->view->current_display, "The display should be constant while validating");
|
||||
$this->assertEqual('page_1', $view->current_display, "The display should be constant while validating");
|
||||
|
||||
// @todo Write real tests for the validation.
|
||||
// In general the following things could be tested:
|
||||
|
|
|
@ -26,19 +26,12 @@ abstract class ViewTestBase extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views');
|
||||
|
||||
/**
|
||||
* The view to use for the test.
|
||||
*
|
||||
* @var Drupal\views\ViewExecutable
|
||||
*/
|
||||
protected $view;
|
||||
public static $modules = array('views', 'views_test_config');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->view = $this->getBasicView();
|
||||
ViewTestData::importTestViews(get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,9 +57,6 @@ abstract class ViewTestBase extends WebTestBase {
|
|||
}
|
||||
$query->execute();
|
||||
$this->checkPermissions(array(), TRUE);
|
||||
|
||||
// Reset the test view, in case it was dependent on the test data module.
|
||||
$this->view = $this->getBasicView();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,58 +244,4 @@ abstract class ViewTestBase extends WebTestBase {
|
|||
return ViewTestData::dataSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a basic view of the views_test_data table.
|
||||
*
|
||||
* @return Drupal\views\ViewExecutable
|
||||
* The built view object.
|
||||
*/
|
||||
protected function getBasicView() {
|
||||
return $this->createViewFromConfig('test_view');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new View instance by creating it directly from config data.
|
||||
*
|
||||
* @param string $view_name
|
||||
* The name of the test view to create.
|
||||
*
|
||||
* @return Drupal\views\ViewExecutable
|
||||
* A View instance.
|
||||
*/
|
||||
protected function createViewFromConfig($view_name) {
|
||||
if (!module_exists('views_test_config')) {
|
||||
module_enable(array('views_test_config'));
|
||||
}
|
||||
|
||||
$data = config("views.view.$view_name")->get();
|
||||
|
||||
$view = entity_create('view', $data);
|
||||
$view = $view->get('executable');
|
||||
$view->setDisplay();
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the view used in this test and sets the default display.
|
||||
*
|
||||
* @param Drupal\views\Plugin\Core\Entity\View $original_view
|
||||
* (optional) The view to clone. If not specified, the default view for the
|
||||
* test will be used.
|
||||
*
|
||||
* @return Drupal\views\ViewExecutable
|
||||
* A clone of the view.
|
||||
*/
|
||||
protected function getView($original_view = NULL) {
|
||||
if (isset($original_view)) {
|
||||
$view = $original_view->cloneView();
|
||||
}
|
||||
else {
|
||||
$view = $this->view->cloneView();
|
||||
}
|
||||
$view->setDisplay();
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Tests;
|
||||
|
||||
use Drupal\Core\Config\FileStorage;
|
||||
|
||||
/**
|
||||
* Provides tests view data and the base test schema with sample data records.
|
||||
*
|
||||
|
@ -17,6 +19,50 @@ namespace Drupal\views\Tests;
|
|||
*/
|
||||
class ViewTestData {
|
||||
|
||||
/**
|
||||
* Imports test views from config.
|
||||
*
|
||||
* @param string $class
|
||||
* The name of the test class.
|
||||
* @param array $modules
|
||||
* (optional) The module directories to look in for test views.
|
||||
* The views_test_config module will always be checked.
|
||||
*
|
||||
* @see config_install_default_config()
|
||||
*/
|
||||
public static function importTestViews($class, $modules = array()) {
|
||||
$modules[] = 'views_test_config';
|
||||
$views = array();
|
||||
while ($class) {
|
||||
if (property_exists($class, 'testViews')) {
|
||||
$views = array_merge($views, $class::$testViews);
|
||||
}
|
||||
$class = get_parent_class($class);
|
||||
}
|
||||
if (!empty($views)) {
|
||||
$target_storage = drupal_container()->get('config.storage');
|
||||
$config_changes = array(
|
||||
'delete' => array(),
|
||||
'create' => array(),
|
||||
'change' => array(),
|
||||
);
|
||||
foreach ($modules as $module) {
|
||||
$config_dir = drupal_get_path('module', $module) . '/test_views';
|
||||
$source_storage = new FileStorage($config_dir);
|
||||
foreach ($source_storage->listAll() as $config_name) {
|
||||
list(, , $id) = explode('.', $config_name);
|
||||
if (in_array($id, $views)) {
|
||||
$config_changes['create'][] = $config_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($config_changes['create'])) {
|
||||
$remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage);
|
||||
config_sync_changes($remaining_changes, $source_storage, $target_storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the schema definition.
|
||||
*/
|
||||
|
|
|
@ -41,8 +41,9 @@ abstract class ViewUnitTestBase extends DrupalUnitTestBase {
|
|||
$query->values($record);
|
||||
}
|
||||
$query->execute();
|
||||
}
|
||||
|
||||
ViewTestData::importTestViews(get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that a result set returned by a View matches expected values.
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
api_version: '3.0'
|
||||
base_table: views_test_data
|
||||
core: '8'
|
||||
description: ''
|
||||
disabled: '0'
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: '0'
|
||||
display_options:
|
||||
fields:
|
||||
id:
|
||||
id: id
|
||||
table: views_test_data
|
||||
field: id
|
||||
relationship: none
|
||||
name:
|
||||
id: name
|
||||
table: views_test_data
|
||||
field: name
|
||||
relationship: none
|
||||
age:
|
||||
id: age
|
||||
table: views_test_data
|
||||
field: age
|
||||
relationship: none
|
||||
defaults:
|
||||
fields: '0'
|
||||
sorts: '0'
|
||||
sorts:
|
||||
id:
|
||||
order: ASC
|
||||
id: id
|
||||
table: views_test_data
|
||||
field: id
|
||||
relationship: none
|
||||
human_name: ''
|
||||
name: test_cache
|
||||
tag: ''
|
||||
base_field: nid
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue