updated contrib modules
This commit is contained in:
29
sites/all/modules/views/tests/README.txt
Normal file
29
sites/all/modules/views/tests/README.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
Views Tests
|
||||
```````````
|
||||
All of the tests may be executed with the following command:
|
||||
|
||||
$ scripts/run-tests.sh --color --url http://example.com/ --php `which php` --concurrency 4 --verbose --directory 'sites/all/modules/contrib/views/tests' 2> /dev/null
|
||||
|
||||
Explanation:
|
||||
--color
|
||||
Colorizes the output. Optional.
|
||||
--url http://example.com/
|
||||
The name of the Drupal 7 hostname used locally for running tests, e.g.
|
||||
"http://drupal7.dev". Required.
|
||||
--php `which php`
|
||||
Tells the test runner the path to the PHP binary. Only necessary if the test
|
||||
runner is unable to find the path automatically or to use an alternative
|
||||
PHP binary. Optional.
|
||||
--cuncurrency 4
|
||||
Run multiple test processes simultaneously. Four appears to be a good
|
||||
balance between melting the computer and improving performance. Optional.
|
||||
--verbose
|
||||
Display results for all of the assertion statements after the summary
|
||||
details. Optional.
|
||||
--directory 'sites/all/modules/contrib/views/tests'
|
||||
Run all of the commands in the following directory. The path is relative to
|
||||
the Drupal installation's root directory. This will run all of Views' tests
|
||||
in one go, rather than either repeating the names of test groups or running
|
||||
multiple commands. Optional.
|
||||
2> /dev/null
|
||||
Outputs all error messages to /dev/null, i.e. hides them. Optional.
|
@@ -20,10 +20,10 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
||||
/**
|
||||
* Post comment.
|
||||
*
|
||||
* @param $node
|
||||
* @param object $node
|
||||
* Node to post comment on.
|
||||
* @param $comment
|
||||
* Comment to save
|
||||
* @param array $comment
|
||||
* Comment to save.
|
||||
*/
|
||||
function postComment($node, $comment = array()) {
|
||||
$comment += array(
|
||||
@@ -38,8 +38,8 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Add two users, create a node with the user1 as author and another node with user2 as author.
|
||||
// For the second node add a comment from user1.
|
||||
// Add two users, create a node with the user1 as author and another node
|
||||
// with user2 as author. For the second node add a comment from user1.
|
||||
$this->account = $this->drupalCreateUser();
|
||||
$this->account2 = $this->drupalCreateUser();
|
||||
$this->drupalLogin($this->account);
|
||||
@@ -51,7 +51,6 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
||||
function testCommentUserUidTest() {
|
||||
$view = $this->view_comment_user_uid();
|
||||
|
||||
|
||||
$this->executeView($view, array($this->account->uid));
|
||||
$resultset = array(
|
||||
array(
|
||||
@@ -67,7 +66,7 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
function view_comment_user_uid() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_comment_user_uid';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
@@ -103,4 +102,5 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,4 +38,5 @@ class viewsHandlerFilterCommentUserUidTest extends viewsHandlerArgumentCommentUs
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,33 +6,40 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
* - Test on a generic entity not on a node.
|
||||
* @todo Test on a generic entity not on a node.
|
||||
*
|
||||
* What has to be tested:
|
||||
* - Take sure that every wanted field is added to the according entity type.
|
||||
* - Take sure the joins are done correct.
|
||||
* - Use basic fields and take sure that the full wanted object is build.
|
||||
* - Use relationships between different entity types, for example node and the node author(user).
|
||||
* - Take sure that every wanted field is added to the according entity type.
|
||||
* - Take sure the joins are done correct.
|
||||
* - Use basic fields and take sure that the full wanted object is build.
|
||||
* - Use relationships between different entity types, for example node and
|
||||
* the node author(user).
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides some helper methods for testing fieldapi integration into views.
|
||||
*/
|
||||
class ViewsFieldApiTestHelper extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
* Stores the field definitions used by the test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $fields;
|
||||
|
||||
/**
|
||||
* Stores the instances of the fields. They have
|
||||
* the same keys as the fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $instances;
|
||||
|
||||
protected function CreateUser($extra_edit = array()) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function createUser($extra_edit = array()) {
|
||||
$permissions = array('access comments', 'access content', 'post comments', 'skip comment approval');
|
||||
// Create a role with the given permission set.
|
||||
if (!($rid = $this->drupalCreateRole($permissions))) {
|
||||
@@ -92,6 +99,7 @@ class ViewsFieldApiTestHelper extends ViewsSqlTest {
|
||||
drupal_static_reset('_views_fetch_data_recursion_protected');
|
||||
drupal_static_reset('_views_fetch_data_fully_loaded');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +124,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
|
||||
$langcode = LANGUAGE_NONE;
|
||||
|
||||
|
||||
$field_names = $this->setUpFields();
|
||||
|
||||
// The first one will be attached to nodes only.
|
||||
@@ -152,7 +159,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
// Now create some example nodes/users for the view result.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$edit = array(
|
||||
// @TODO Write a helper method to create such values.
|
||||
// @todo Write a helper method to create such values.
|
||||
'field_name_0' => array($langcode => array((array('value' => $this->randomName())))),
|
||||
'field_name_2' => array($langcode => array((array('value' => $this->randomName())))),
|
||||
);
|
||||
@@ -164,7 +171,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
'field_name_1' => array($langcode => array((array('value' => $this->randomName())))),
|
||||
'field_name_2' => array($langcode => array((array('value' => $this->randomName())))),
|
||||
);
|
||||
$this->users[] = $this->CreateUser($edit);
|
||||
$this->users[] = $this->createUser($edit);
|
||||
}
|
||||
|
||||
// Reset views data cache.
|
||||
@@ -178,7 +185,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
*/
|
||||
function testViewsData() {
|
||||
$data = views_fetch_data();
|
||||
|
||||
|
||||
// Check the table and the joins of the first field.
|
||||
// Attached to node only.
|
||||
$field = $this->fields[0];
|
||||
@@ -210,7 +217,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
);
|
||||
$this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_revision']);
|
||||
|
||||
|
||||
// Check the table and the joins of the second field.
|
||||
// Attached to both node and user.
|
||||
$field_2 = $this->fields[2];
|
||||
@@ -230,7 +236,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
'extra' => array(
|
||||
array('field' => 'entity_type', 'value' => 'node'),
|
||||
array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
|
||||
)
|
||||
),
|
||||
);
|
||||
$this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['node']);
|
||||
$expected_join = array(
|
||||
@@ -239,7 +245,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
'extra' => array(
|
||||
array('field' => 'entity_type', 'value' => 'node'),
|
||||
array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
|
||||
)
|
||||
),
|
||||
);
|
||||
$this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_revision']);
|
||||
$expected_join = array(
|
||||
@@ -248,32 +254,25 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper {
|
||||
'extra' => array(
|
||||
array('field' => 'entity_type', 'value' => 'user'),
|
||||
array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE),
|
||||
)
|
||||
),
|
||||
);
|
||||
$this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['users']);
|
||||
|
||||
// Check the fields
|
||||
// @todo
|
||||
|
||||
// Check the arguments
|
||||
// @todo
|
||||
|
||||
// Check the sort criterias
|
||||
// @todo
|
||||
|
||||
// Check the relationships
|
||||
// @todo
|
||||
|
||||
// @todo Check the fields.
|
||||
// @todo Check the arguments.
|
||||
// @todo Check the sort criterias.
|
||||
// @todo Check the relationships.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the field_field handler.
|
||||
* @TODO
|
||||
* Check a entity-type with bundles
|
||||
* Check a entity-type without bundles
|
||||
* Check locale:disabled, locale:enabled and locale:enabled with another language
|
||||
* Check revisions
|
||||
*
|
||||
* @todo Check a entity-type with bundles.
|
||||
* @todo Check a entity-type without bundles.
|
||||
* @todo Check locale:disabled, locale:enabled and locale:enabled with another language.
|
||||
* @todo Check revisions.
|
||||
*/
|
||||
class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
public $nodes;
|
||||
@@ -282,7 +281,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
return array(
|
||||
'name' => 'Fieldapi: Field handler',
|
||||
'description' => 'Tests the field itself of the fieldapi integration',
|
||||
'group' => 'Views Modules'
|
||||
'group' => 'Views Modules',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -353,7 +352,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
$this->executeView($view);
|
||||
|
||||
// Take sure that the formatter works as expected.
|
||||
// @TODO: actually there should be a specific formatter.
|
||||
// @todo actually there should be a specific formatter.
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$rendered_field = $view->style_plugin->get_field($i, $this->fields[0]['field_name']);
|
||||
$this->assertEqual(strlen($rendered_field), 3);
|
||||
@@ -384,7 +383,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
|
||||
$view->destroy();
|
||||
|
||||
// Test delta limit + offset
|
||||
// Test delta limit + offset.
|
||||
$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']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1;
|
||||
@@ -459,7 +458,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
}
|
||||
|
||||
protected function getFieldView() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'view_fieldapi';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
@@ -491,4 +490,3 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class ViewsHandlerAreaTextTest extends ViewsSqlTest {
|
||||
public function testAreaText() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// add a text header
|
||||
// add a text header.
|
||||
$string = $this->randomName();
|
||||
$view->display['default']->handler->override_option('header', array(
|
||||
'area' => array(
|
||||
|
@@ -25,7 +25,7 @@ class ViewsHandlerArgumentNullTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
public function testAreaText() {
|
||||
// Test validation
|
||||
// Test validation.
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Add a null argument.
|
||||
|
@@ -53,6 +53,7 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest {
|
||||
* Provide a test view for testGlossary.
|
||||
*
|
||||
* @see testGlossary
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
function viewGlossary() {
|
||||
@@ -93,4 +94,5 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -6,11 +6,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests the generic field handler
|
||||
* Tests the generic field handler.
|
||||
*
|
||||
* @see views_handler_field
|
||||
*/
|
||||
class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field',
|
||||
@@ -19,6 +23,9 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->column_map = array(
|
||||
@@ -26,17 +33,12 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
function testEmpty() {
|
||||
$this->_testHideIfEmpty();
|
||||
$this->_testEmptyText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the hide if empty functionality.
|
||||
*
|
||||
* This tests alters the result to get easier and less coupled results.
|
||||
*/
|
||||
function _testHideIfEmpty() {
|
||||
public function testHideIfEmpty() {
|
||||
$view = $this->getBasicView();
|
||||
$view->init_display();
|
||||
$this->executeView($view);
|
||||
@@ -139,7 +141,8 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
$render = $view->field['name']->advanced_render($view->result[0]);
|
||||
$this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "0" should not be treated as empty.');
|
||||
|
||||
// Test when results are rewritten to an empty string and non-zero empty results are hidden.
|
||||
// Test when results are rewritten to an empty string and non-zero empty
|
||||
// results are hidden.
|
||||
$view->field['name']->options['hide_alter_empty'] = TRUE;
|
||||
$view->field['name']->options['hide_empty'] = TRUE;
|
||||
$view->field['name']->options['empty_zero'] = FALSE;
|
||||
@@ -254,7 +257,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
/**
|
||||
* Tests the usage of the empty text.
|
||||
*/
|
||||
function _testEmptyText() {
|
||||
public function testEmptyText() {
|
||||
$view = $this->getBasicView();
|
||||
$view->init_display();
|
||||
$this->executeView($view);
|
||||
@@ -291,7 +294,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest {
|
||||
/**
|
||||
* Tests views_handler_field::is_value_empty().
|
||||
*/
|
||||
function testIsValueEmpty() {
|
||||
public function testIsValueEmpty() {
|
||||
$view = $this->getBasicView();
|
||||
$view->init_display();
|
||||
$view->init_handlers();
|
||||
|
@@ -18,7 +18,7 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
function dataSet() {
|
||||
// Use default dataset but remove the age from john and paul
|
||||
// Use default dataset but remove the age from john and paul.
|
||||
$data = parent::dataSet();
|
||||
$data[0]['age'] = 0;
|
||||
$data[3]['age'] = 0;
|
||||
@@ -105,4 +105,5 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest {
|
||||
$this->assertNotEqual($values['false'], $view->field['age']->advanced_render($view->result[0]));
|
||||
$this->assertNotEqual($values['true'], $view->field['age']->advanced_render($view->result[1]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest {
|
||||
'table' => 'views',
|
||||
'field' => 'counter',
|
||||
'relationship' => 'none',
|
||||
'counter_start' => $rand_start
|
||||
'counter_start' => $rand_start,
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -64,7 +64,8 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest {
|
||||
$this->assertEqual(2 + $rand_start, $view->style_plugin->rendered_fields[2]['counter']);
|
||||
}
|
||||
|
||||
// @TODO: Write tests for pager.
|
||||
// @todo Write tests for pager.
|
||||
function testPager() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,4 +44,5 @@ class ViewsHandlerFieldCustomTest extends ViewsSqlTest {
|
||||
|
||||
$this->assertEqual($random, $view->style_plugin->get_field(0, 'name'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Tests the core views_handler_field_date handler.
|
||||
*/
|
||||
class ViewsHandlerFieldDateTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field: Date',
|
||||
@@ -17,12 +21,18 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test']['created']['field']['handler'] = 'views_handler_field_date';
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testFieldDate() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
@@ -32,7 +42,8 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
|
||||
'table' => 'views_test',
|
||||
'field' => 'created',
|
||||
'relationship' => 'none',
|
||||
// c is iso 8601 date format @see http://php.net/manual/en/function.date.php
|
||||
// c is iso 8601 date format.
|
||||
// @see http://php.net/manual/en/function.date.php
|
||||
'custom_date_format' => 'c',
|
||||
'second_date_format' => 'custom',
|
||||
'second_date_format_custom' => 'c',
|
||||
@@ -62,13 +73,17 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
|
||||
$intervals = array(
|
||||
'raw time ago' => format_interval(REQUEST_TIME - $time, 2),
|
||||
'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))),
|
||||
// TODO write tests for them
|
||||
// 'raw time span' => format_interval(REQUEST_TIME - $time, 2),
|
||||
// 'time span' => t('%time hence', array('%time' => format_interval(REQUEST_TIME - $time, 2))),
|
||||
// @todo write tests for them
|
||||
// 'raw time span' => format_interval(REQUEST_TIME - $time, 2),
|
||||
// 'time span' => t('%time hence',
|
||||
// array('%time' => format_interval(REQUEST_TIME - $time, 2))),
|
||||
);
|
||||
$this->assertRenderedDatesEqual($view, $intervals);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
|
||||
foreach ($map as $date_format => $expected_result) {
|
||||
$check_result_number = 0;
|
||||
@@ -114,4 +129,5 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -63,4 +63,5 @@ class ViewsHandlerFileExtensionTest extends ViewsSqlTest {
|
||||
$this->assertEqual($view->field['name']->advanced_render($view->result[2]), 'tar.gz');
|
||||
$this->assertEqual($view->field['name']->advanced_render($view->result[3]), '');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -61,4 +61,5 @@ class ViewsHandlerTestFileSize extends ViewsSqlTest {
|
||||
$this->assertEqual($view->field['age']->advanced_render($view->result[2]), 1000);
|
||||
$this->assertEqual($view->field['age']->advanced_render($view->result[3]), 10000);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -42,4 +42,5 @@ class ViewsHandlerFieldMath extends ViewsSqlTest {
|
||||
|
||||
$this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -57,4 +57,5 @@ class ViewsHandlerFieldUrlTest extends ViewsSqlTest {
|
||||
|
||||
$this->assertEqual(l('John', 'John'), $view->field['name']->advanced_render($view->result[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class ViewsHandlerTestXss extends ViewsSqlTest {
|
||||
$map = array(
|
||||
'John' => 'John',
|
||||
"Foo\xC0barbaz" => '',
|
||||
'Fooÿñ' => 'Fooÿñ'
|
||||
'Fooÿñ' => 'Fooÿñ',
|
||||
);
|
||||
|
||||
return $map;
|
||||
@@ -57,4 +57,5 @@ class ViewsHandlerTestXss extends ViewsSqlTest {
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -102,4 +102,5 @@ class ViewsHandlerFilterCombineTest extends ViewsSqlTest {
|
||||
unset($schema['views_test']['fields']['job']['not null']);
|
||||
return $schema;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -168,7 +168,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
|
||||
$view = $this->views_test_between();
|
||||
$view->save();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
menu_rebuild();
|
||||
$this->drupalGet('admin/structure/views/view/test_filter_date_between/edit');
|
||||
@@ -182,7 +182,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
function views_test_between() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_filter_date_between';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -218,4 +218,5 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
|
||||
$view = $this->views_test_between();
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
|
||||
function testEqual() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -59,7 +59,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: =, Value: Ringo
|
||||
// Filter: Name, Operator: =, Value: Ringo.
|
||||
$filters['name']['group_info']['default_group'] = 1;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -76,7 +76,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
|
||||
function testNotEqual() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -110,7 +110,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: !=, Value: Ringo
|
||||
// Filter: Name, Operator: !=, Value: Ringo.
|
||||
$filters['name']['group_info']['default_group'] = 2;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
@@ -38,7 +38,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
public function testFilterNumericSimple() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
@@ -82,7 +82,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
public function testFilterNumericBetween() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
@@ -114,11 +114,11 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
|
||||
// test not between
|
||||
// test not between.
|
||||
$view->delete();
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
@@ -160,7 +160,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
@@ -188,7 +187,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
@@ -211,7 +209,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
public function testFilterNumericEmpty() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
@@ -223,14 +221,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
));
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
);
|
||||
$resultset = array();
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
|
||||
$view->delete();
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'age' => array(
|
||||
'id' => 'age',
|
||||
@@ -243,7 +240,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
array(
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
@@ -272,15 +269,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Age, Operator: empty, Value:
|
||||
// Filter: Age, Operator: empty, Value.
|
||||
$filters['age']['group_info']['default_group'] = 4;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
);
|
||||
$resultset = array();
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
|
||||
@@ -288,15 +283,14 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Age, Operator: empty, Value:
|
||||
// Filter: Age, Operator: empty, Value.
|
||||
$filters['age']['group_info']['default_group'] = 5;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
array(
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
@@ -320,6 +314,38 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest {
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the limit operators functionality.
|
||||
*/
|
||||
public function testFilterNumericExposedLimitOperators() {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicView();
|
||||
|
||||
$available_operators = array('<', '>', 'between');
|
||||
|
||||
$filters['age']['expose'] += array(
|
||||
'limit_operators' => TRUE,
|
||||
'available_operators' => drupal_map_assoc($available_operators),
|
||||
);
|
||||
|
||||
$view->display['default']->handler->override_option('filters', $filters);
|
||||
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$form = array();
|
||||
$form_state = array();
|
||||
$view->filter['age']->operator_form($form, $form_state);
|
||||
|
||||
$operator = $form['operator'];
|
||||
|
||||
$this->assertTrue(in_array($operator['#default_value'], $available_operators), 'Default value operator found in list of available operators.');
|
||||
|
||||
foreach ($available_operators as $available_operator) {
|
||||
$this->assertTrue($operator['#options'][$available_operator], format_string('@operator found in options', array('@operator' => $available_operator)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function testAllowEmpty() {
|
||||
$view = $this->getBasicView();
|
||||
|
@@ -75,7 +75,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringEqual() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -100,7 +100,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: =, Value: Ringo
|
||||
// Filter: Name, Operator: =, Value: Ringo.
|
||||
$filters['name']['group_info']['default_group'] = 1;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -119,7 +119,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringNotEqual() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -153,7 +153,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: !=, Value: Ringo
|
||||
// Filter: Name, Operator: !=, Value: Ringo.
|
||||
$filters['name']['group_info']['default_group'] = '2';
|
||||
|
||||
$view->set_display('page_1');
|
||||
@@ -182,7 +182,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringContains() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -208,7 +208,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: contains, Value: ing
|
||||
// Filter: Name, Operator: contains, Value: ing.
|
||||
$filters['name']['group_info']['default_group'] = '3';
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -228,7 +228,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringWord() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -254,7 +254,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -277,10 +277,10 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
|
||||
|
||||
function testFilterStringGroupedExposedWord() {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: contains, Value: ing
|
||||
// Filter: Name, Operator: contains, Value: ing.
|
||||
$filters['name']['group_info']['default_group'] = '3';
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -299,7 +299,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Description, Operator: contains, Value: actor
|
||||
// Filter: Description, Operator: contains, Value: actor.
|
||||
$filters['description']['group_info']['default_group'] = '1';
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -319,7 +319,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringStarts() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -344,7 +344,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: starts, Value: George
|
||||
// Filter: Name, Operator: starts, Value: George.
|
||||
$filters['description']['group_info']['default_group'] = 2;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -362,7 +362,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringNotStarts() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -385,7 +385,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
@@ -394,7 +394,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Name, Operator: not_starts, Value: George
|
||||
// Filter: Name, Operator: not_starts, Value: George.
|
||||
$filters['description']['group_info']['default_group'] = 3;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -411,7 +411,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
@@ -419,7 +419,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringEnds() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -447,7 +447,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Descriptino, Operator: ends, Value: Beatles
|
||||
// Filter: Descriptino, Operator: ends, Value: Beatles.
|
||||
$filters['description']['group_info']['default_group'] = 4;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -468,7 +468,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringNotEnds() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -488,7 +488,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
@@ -497,7 +497,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Description, Operator: not_ends, Value: Beatles
|
||||
// Filter: Description, Operator: not_ends, Value: Beatles.
|
||||
$filters['description']['group_info']['default_group'] = 5;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -511,7 +511,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringNot() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -539,7 +539,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
}
|
||||
@@ -549,7 +549,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Description, Operator: not (does not contains), Value: Beatles
|
||||
// Filter: Description, Operator: not (does not contains), Value: Beatles.
|
||||
$filters['description']['group_info']['default_group'] = 6;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
@@ -563,7 +563,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
array(
|
||||
'name' => 'Paul',
|
||||
),
|
||||
// There is no Meredith returned because his description is empty
|
||||
// There is no Meredith returned because his description is empty.
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
||||
|
||||
@@ -572,7 +572,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringShorter() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -620,7 +620,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringLonger() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
@@ -663,7 +663,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
function testFilterStringEmpty() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the filtering
|
||||
// Change the filtering.
|
||||
$view->display['default']->handler->override_option('filters', array(
|
||||
'description' => array(
|
||||
'id' => 'description',
|
||||
@@ -687,7 +687,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = $this->getBasicPageView();
|
||||
|
||||
// Filter: Description, Operator: empty, Value:
|
||||
// Filter: Description, Operator: empty, Value.
|
||||
$filters['description']['group_info']['default_group'] = 7;
|
||||
$view->set_display('page_1');
|
||||
$view->display['page_1']->handler->override_option('filters', $filters);
|
||||
|
1099
sites/all/modules/views/tests/handlers/views_handler_manytoone.test
Normal file
1099
sites/all/modules/views/tests/handlers/views_handler_manytoone.test
Normal file
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
|
||||
public function testNumericOrdering() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the ordering
|
||||
// Change the ordering.
|
||||
$view->display['default']->handler->override_option('sorts', array(
|
||||
'age' => array(
|
||||
'order' => 'ASC',
|
||||
@@ -46,7 +46,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
|
||||
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Reverse the ordering
|
||||
// Reverse the ordering.
|
||||
$view->display['default']->handler->override_option('sorts', array(
|
||||
'age' => array(
|
||||
'order' => 'DESC',
|
||||
@@ -74,7 +74,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
|
||||
public function testStringOrdering() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Change the ordering
|
||||
// Change the ordering.
|
||||
$view->display['default']->handler->override_option('sorts', array(
|
||||
'name' => array(
|
||||
'order' => 'ASC',
|
||||
@@ -97,7 +97,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
|
||||
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// Reverse the ordering
|
||||
// Reverse the ordering.
|
||||
$view->display['default']->handler->override_option('sorts', array(
|
||||
'name' => array(
|
||||
'order' => 'DESC',
|
||||
@@ -118,4 +118,5 @@ class ViewsHandlerSortTest extends ViewsSqlTest {
|
||||
'views_test_age' => 'age',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,61 +21,66 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
$expected = array();
|
||||
if (!$reverse) {
|
||||
switch ($granularity) {
|
||||
case 'second':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
case 'minute':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
case 'hour':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
case 'day':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
case 'month':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
case 'year':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case 'second':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($granularity) {
|
||||
@@ -88,6 +93,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
array('name' => 'John'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'minute':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
@@ -95,8 +101,9 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'John'),
|
||||
);
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
@@ -106,6 +113,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
array('name' => 'John'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
@@ -115,6 +123,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
@@ -124,6 +133,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
@@ -163,7 +173,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
),
|
||||
));
|
||||
|
||||
// Change the ordering
|
||||
// Change the ordering.
|
||||
$view->display['default']->handler->override_option('sorts', array(
|
||||
'created' => array(
|
||||
'id' => 'created',
|
||||
@@ -195,4 +205,5 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Tests for core views_handler_sort_random handler.
|
||||
*/
|
||||
class ViewsHandlerSortRandomTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Sort: random',
|
||||
@@ -77,7 +81,8 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest {
|
||||
'views_test_age' => 'views_test_name',
|
||||
));
|
||||
|
||||
// Execute a second random view, we expect the result set to be different again.
|
||||
// Execute a second random view, we expect the result set to be different
|
||||
// again.
|
||||
$view_random_2 = $this->getBasicRandomView();
|
||||
$this->executeView($view_random_2);
|
||||
$this->assertEqual(count($this->dataSet()), count($view_random_2->result), t('The number of returned rows match.'));
|
||||
@@ -86,4 +91,5 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest {
|
||||
'views_test_age' => 'views_test_name',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains ViewsHandlerTest.
|
||||
* Definition of ViewsHandlerTest.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ class ViewsHandlerTest extends ViewsSqlTest {
|
||||
public function testHandlerAccess() {
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// add a test area
|
||||
// add a test area.
|
||||
$view->display['default']->handler->override_option('header', array(
|
||||
'test_access' => array(
|
||||
'id' => 'test_access',
|
||||
@@ -61,7 +61,7 @@ class ViewsHandlerTest extends ViewsSqlTest {
|
||||
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// add a test area
|
||||
// add a test area.
|
||||
$view->display['default']->handler->override_option('header', array(
|
||||
'test_access' => array(
|
||||
'id' => 'test_access',
|
||||
|
@@ -174,4 +174,5 @@ class ViewsNodeRevisionRelationsTestCase extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,9 @@
|
||||
*/
|
||||
class ViewsPluginDisplayTestCase extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Display plugin',
|
||||
@@ -35,6 +38,7 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest {
|
||||
* Returns a test view for testFilterGroupsOverriding.
|
||||
*
|
||||
* @see testFilterGroupsOverriding
|
||||
*
|
||||
* @return view
|
||||
*/
|
||||
function viewFilterGroupsOverriding() {
|
||||
@@ -80,7 +84,9 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Based on a bug some filter_groups landed in the overridden display, even the filters weren't overridden.
|
||||
* Based on a bug some filter_groups landed in the overridden display.
|
||||
*
|
||||
* Even the filters weren't overridden.
|
||||
* This caused multiple issues.
|
||||
* Take sure that the value from the default display are used.
|
||||
*
|
||||
@@ -191,4 +197,5 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -78,6 +78,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$expected = array();
|
||||
$expected['Job: Singer'] = array();
|
||||
$expected['Job: Singer']['group'] = 'Job: Singer';
|
||||
$expected['Job: Singer']['level'] = '0';
|
||||
$expected['Job: Singer']['rows'][0] = new StdClass();
|
||||
$expected['Job: Singer']['rows'][0]->views_test_name = 'John';
|
||||
$expected['Job: Singer']['rows'][0]->views_test_job = 'Singer';
|
||||
@@ -88,6 +89,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$expected['Job: Singer']['rows'][1]->views_test_id = '2';
|
||||
$expected['Job: Drummer'] = array();
|
||||
$expected['Job: Drummer']['group'] = 'Job: Drummer';
|
||||
$expected['Job: Drummer']['level'] = '0';
|
||||
$expected['Job: Drummer']['rows'][2] = new StdClass();
|
||||
$expected['Job: Drummer']['rows'][2]->views_test_name = 'Ringo';
|
||||
$expected['Job: Drummer']['rows'][2]->views_test_job = 'Drummer';
|
||||
@@ -161,8 +163,10 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$expected = array();
|
||||
$expected['Job: Singer'] = array();
|
||||
$expected['Job: Singer']['group'] = 'Job: Singer';
|
||||
$expected['Job: Singer']['level'] = 0;
|
||||
$expected['Job: Singer']['rows']['Age: 25'] = array();
|
||||
$expected['Job: Singer']['rows']['Age: 25']['group'] = 'Age: 25';
|
||||
$expected['Job: Singer']['rows']['Age: 25']['level'] = 1;
|
||||
$expected['Job: Singer']['rows']['Age: 25']['rows'][0] = new StdClass();
|
||||
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_name = 'John';
|
||||
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_job = 'Singer';
|
||||
@@ -170,6 +174,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$expected['Job: Singer']['rows']['Age: 25']['rows'][0]->views_test_id = '1';
|
||||
$expected['Job: Singer']['rows']['Age: 27'] = array();
|
||||
$expected['Job: Singer']['rows']['Age: 27']['group'] = 'Age: 27';
|
||||
$expected['Job: Singer']['rows']['Age: 27']['level'] = 1;
|
||||
$expected['Job: Singer']['rows']['Age: 27']['rows'][1] = new StdClass();
|
||||
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_name = 'George';
|
||||
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_job = 'Singer';
|
||||
@@ -177,15 +182,16 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_id = '2';
|
||||
$expected['Job: Drummer'] = array();
|
||||
$expected['Job: Drummer']['group'] = 'Job: Drummer';
|
||||
$expected['Job: Drummer']['level'] = 0;
|
||||
$expected['Job: Drummer']['rows']['Age: 28'] = array();
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['group'] = 'Age: 28';
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['level'] = 1;
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2] = new StdClass();
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_name = 'Ringo';
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_job = 'Drummer';
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_age = '28';
|
||||
$expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_id = '3';
|
||||
|
||||
|
||||
// Alter the results to support the stripped case.
|
||||
if ($stripped) {
|
||||
|
||||
@@ -206,7 +212,6 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$view->style_plugin->options['grouping'][1] = array('field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE);
|
||||
}
|
||||
|
||||
|
||||
// The newer api passes the value of the grouping as well.
|
||||
$sets_new_rendered = $view->style_plugin->render_grouping($view->result, $view->style_plugin->options['grouping'], TRUE);
|
||||
|
||||
@@ -261,4 +266,5 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,6 +17,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
*/
|
||||
var $nodes;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Jump menu',
|
||||
@@ -25,7 +28,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->nodes = array();
|
||||
@@ -37,7 +42,6 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
$this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests jump menues with more then one same path but maybe differnet titles.
|
||||
*/
|
||||
@@ -46,7 +50,8 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
$view->set_display();
|
||||
$view->init_handlers();
|
||||
|
||||
// Setup a [path] which would leed to "duplicate" paths, but still the shouldn't be used for grouping.
|
||||
// Setup a [path] which would leed to "duplicate" paths, but still the
|
||||
// shouldn't be used for grouping.
|
||||
$view->field['nothing']->options['alter']['text'] = '[path]';
|
||||
$view->preview();
|
||||
$form = $view->style_plugin->render($view->result);
|
||||
@@ -65,8 +70,11 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function getJumpMenuView() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_jump_menu';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
@@ -148,4 +156,5 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ class ViewsPluginStyleMappingTest extends ViewsPluginStyleTestBase {
|
||||
|
||||
protected function viewsPlugins() {
|
||||
return array(
|
||||
'style' => array(
|
||||
'style' => array(
|
||||
'test_mapping' => array(
|
||||
'title' => t('Field mapping'),
|
||||
'help' => t('Maps specific fields to specific purposes.'),
|
||||
|
@@ -42,7 +42,7 @@ class ViewsPluginStyleUnformattedTestCase extends ViewsPluginStyleTestBase {
|
||||
if ($count == 1) {
|
||||
$this->assertTrue(strpos($class, "views-row-first") !== FALSE, 'Take sure that the first class is set right.');
|
||||
}
|
||||
else if ($count == $count_result) {
|
||||
elseif ($count == $count_result) {
|
||||
$this->assertTrue(strpos($class, "views-row-last") !== FALSE, 'Take sure that the last class is set right.');
|
||||
|
||||
}
|
||||
|
@@ -34,9 +34,8 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
//$web_user = $this->drupalCreateUser(array('create article content'));
|
||||
//$this->drupalLogin($web_user);
|
||||
|
||||
// $web_user = $this->drupalCreateUser(array('create article content'));
|
||||
// $this->drupalLogin($web_user);
|
||||
$vocabulary = taxonomy_vocabulary_machine_name_load('tags');
|
||||
$this->term_1 = $this->createTerm($vocabulary);
|
||||
$this->term_2 = $this->createTerm($vocabulary);
|
||||
@@ -119,4 +118,5 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,22 +2,25 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains views_test_area_access
|
||||
* Definition of views_test_area_access.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A test access plugin.
|
||||
*/
|
||||
class views_test_area_access extends views_handler_area {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function access() {
|
||||
public function access() {
|
||||
return $this->options['custom_access'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['custom_access'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
|
@@ -9,18 +9,29 @@
|
||||
* Tests a dynamic access plugin.
|
||||
*/
|
||||
class views_test_plugin_access_test_dynamic extends views_plugin_access {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['access'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function access($account) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($account) {
|
||||
return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == variable_get('test_dynamic_access_argument1', NULL) && isset($this->view->args[1]) && $this->view->args[1] == variable_get('test_dynamic_access_argument2', NULL);
|
||||
}
|
||||
|
||||
function get_access_callback() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_access_callback() {
|
||||
return array('views_test_test_dynamic_access_callback', array(!empty($options['access']), 1, 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,18 +9,29 @@
|
||||
* Tests a static access plugin.
|
||||
*/
|
||||
class views_test_plugin_access_test_static extends views_plugin_access {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['access'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function access($account) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($account) {
|
||||
return !empty($this->options['access']);
|
||||
}
|
||||
|
||||
function get_access_callback() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_access_callback() {
|
||||
return array('views_test_test_static_access_callback', array(!empty($options['access'])));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
class views_test_plugin_style_test_mapping extends views_plugin_style_mapping {
|
||||
|
||||
/**
|
||||
* Overrides views_plugin_style_mapping::define_mapping().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function define_mapping() {
|
||||
return array(
|
||||
@@ -49,4 +49,5 @@ class views_test_plugin_style_test_mapping extends views_plugin_style_mapping {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -43,17 +43,33 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest {
|
||||
$anon_name = variable_get('anonymous', t('Anonymous'));
|
||||
$view->result[0]->users_name = '';
|
||||
$render = $view->field['name']->advanced_render($view->result[0]);
|
||||
$this->assertIdentical($render, $anon_name , 'For user0 it should use the default anonymous name by default.');
|
||||
$this->assertIdentical($render, $anon_name, 'For user0 it should use the default anonymous name by default.');
|
||||
|
||||
$view->field['name']->options['overwrite_anonymous'] = TRUE;
|
||||
$anon_name = $view->field['name']->options['anonymous_text'] = $this->randomName();
|
||||
$render = $view->field['name']->advanced_render($view->result[0]);
|
||||
$this->assertIdentical($render, $anon_name , 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
|
||||
|
||||
$this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that deselecting 'link_to_user' and 'format_username' works.
|
||||
*/
|
||||
public function testOptions() {
|
||||
$view = $this->view_raw_user_name();
|
||||
$view->init_display();
|
||||
$this->executeView($view);
|
||||
|
||||
$view->row_index = 0;
|
||||
|
||||
$username = $view->result[0]->users_name = 'test';
|
||||
$view->result[0]->uid = 1;
|
||||
$render = $view->field['name']->advanced_render($view->result[0]);
|
||||
$this->assertTrue(strpos($render, $username) !== FALSE, 'If link to user is checked the username should be part of the output.');
|
||||
}
|
||||
|
||||
function view_user_name() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_views_handler_field_user_name';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
@@ -93,4 +109,47 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
function view_raw_user_name() {
|
||||
$view = new view;
|
||||
$view->name = 'test_views_handler_field_user_name';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'users';
|
||||
$view->human_name = 'test_views_handler_field_user_name';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['access']['type'] = 'none';
|
||||
$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'] = 'fields';
|
||||
/* Field: User: Name */
|
||||
$handler->display->display_options['fields']['name']['id'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['table'] = 'users';
|
||||
$handler->display->display_options['fields']['name']['field'] = 'name';
|
||||
$handler->display->display_options['fields']['name']['label'] = '';
|
||||
$handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['word_boundary'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['ellipsis'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['name']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['name']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['name']['empty_zero'] = 0;
|
||||
$handler->display->display_options['fields']['name']['link_to_user'] = 0;
|
||||
$handler->display->display_options['fields']['name']['format_username'] = 0;
|
||||
$handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
|
||||
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
@@ -9,9 +9,20 @@
|
||||
* Tests basic user module integration into views.
|
||||
*/
|
||||
class ViewsUserTestCase extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
var $users = array();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
var $nodes = array();
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Tests basic user integration',
|
||||
@@ -20,7 +31,9 @@ class ViewsUserTestCase extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
@@ -31,7 +44,7 @@ class ViewsUserTestCase extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a view which has no explicit relationship to the author and check the result.
|
||||
* Add a view which has no explicit relationship to the author.
|
||||
*
|
||||
* @todo: Remove the following comment once the relationship is required.
|
||||
* One day a view will require the relationship so it should still work
|
||||
@@ -51,8 +64,11 @@ class ViewsUserTestCase extends ViewsSqlTest {
|
||||
$this->assertIdenticalResultset($view, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function test_view_user_relationship() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_user_relationship';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
@@ -140,4 +156,5 @@ class ViewsUserTestCase extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Tests views user argument default plugin.
|
||||
*/
|
||||
class ViewsUserArgumentDefault extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Tests user argument default plugin',
|
||||
@@ -17,11 +21,15 @@ class ViewsUserArgumentDefault extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function test_plugin_argument_default_current_user() {
|
||||
// Create a user to test.
|
||||
$account = $this->drupalCreateUser();
|
||||
|
||||
// Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser.
|
||||
// Switch the user, we have to check the global user too, because
|
||||
// drupalLogin is only for the simpletest browser.
|
||||
$this->drupalLogin($account);
|
||||
global $user;
|
||||
$admin = $user;
|
||||
@@ -40,8 +48,11 @@ class ViewsUserArgumentDefault extends ViewsSqlTest {
|
||||
drupal_save_session(TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function view_plugin_argument_default_current_user() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_plugin_argument_default_current_user';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -87,4 +98,5 @@ class ViewsUserArgumentDefault extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ class ViewsUserArgumentValidate extends ViewsSqlTest {
|
||||
|
||||
function testArgumentValidateUserUid() {
|
||||
$account = $this->account;
|
||||
// test 'uid' case
|
||||
// test 'uid' case.
|
||||
$view = $this->view_argument_validate_user('uid');
|
||||
$view->set_display('default');
|
||||
$view->pre_execute();
|
||||
@@ -36,13 +36,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest {
|
||||
$this->assertFalse($view->argument['null']->validate_arg($account->name));
|
||||
// Reset safed argument validation.
|
||||
$view->argument['null']->argument_validated = NULL;
|
||||
// Fail for a valid numeric, but for a user that doesn't exist
|
||||
// Fail for a valid numeric, but for a user that doesn't exist.
|
||||
$this->assertFalse($view->argument['null']->validate_arg(32));
|
||||
}
|
||||
|
||||
function testArgumentValidateUserName() {
|
||||
$account = $this->account;
|
||||
// test 'name' case
|
||||
// test 'name' case.
|
||||
$view = $this->view_argument_validate_user('name');
|
||||
$view->set_display('default');
|
||||
$view->pre_execute();
|
||||
@@ -54,13 +54,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest {
|
||||
$this->assertFalse($view->argument['null']->validate_arg($account->uid));
|
||||
// Reset safed argument validation.
|
||||
$view->argument['null']->argument_validated = NULL;
|
||||
// Fail for a valid string, but for a user that doesn't exist
|
||||
// Fail for a valid string, but for a user that doesn't exist.
|
||||
$this->assertFalse($view->argument['null']->validate_arg($this->randomName()));
|
||||
}
|
||||
|
||||
function testArgumentValidateUserEither() {
|
||||
$account = $this->account;
|
||||
// test 'either' case
|
||||
// test 'either' case.
|
||||
$view = $this->view_argument_validate_user('either');
|
||||
$view->set_display('default');
|
||||
$view->pre_execute();
|
||||
@@ -72,16 +72,16 @@ class ViewsUserArgumentValidate extends ViewsSqlTest {
|
||||
$this->assertTrue($view->argument['null']->validate_arg($account->uid));
|
||||
// Reset safed argument validation.
|
||||
$view->argument['null']->argument_validated = NULL;
|
||||
// Fail for a valid string, but for a user that doesn't exist
|
||||
// Fail for a valid string, but for a user that doesn't exist.
|
||||
$this->assertFalse($view->argument['null']->validate_arg($this->randomName()));
|
||||
// Reset safed argument validation.
|
||||
$view->argument['null']->argument_validated = NULL;
|
||||
// Fail for a valid uid, but for a user that doesn't exist
|
||||
// Fail for a valid uid, but for a user that doesn't exist.
|
||||
$this->assertFalse($view->argument['null']->validate_arg(32));
|
||||
}
|
||||
|
||||
function view_argument_validate_user($argtype) {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'view_argument_validate_user';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
|
@@ -17,6 +17,9 @@ class ViewsAccessTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
@@ -20,7 +20,7 @@ class ViewsAnalyzeTest extends ViewsSqlTest {
|
||||
public function setUp() {
|
||||
parent::setUp('views_ui');
|
||||
module_enable(array('views_ui'));
|
||||
// @TODO Figure out why it's required to clear the cache here.
|
||||
// @todo Figure out why it's required to clear the cache here.
|
||||
views_module_include('views_default', TRUE);
|
||||
views_get_all_views(TRUE);
|
||||
menu_rebuild();
|
||||
@@ -48,4 +48,5 @@ class ViewsAnalyzeTest extends ViewsSqlTest {
|
||||
// This redirects the user back to the main views edit page.
|
||||
$this->drupalPost(NULL, array(), t('Ok'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest {
|
||||
return array(
|
||||
'name' => 'Argument_default',
|
||||
'description' => 'Tests pluggable argument_default for views.',
|
||||
'group' => 'Views Plugins'
|
||||
'group' => 'Views Plugins',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest {
|
||||
|
||||
$view->destroy();
|
||||
|
||||
// Make sure that a normal argument provided is used
|
||||
// Make sure that a normal argument provided is used.
|
||||
$view = $this->view_argument_default_fixed();
|
||||
|
||||
$view->set_display('default');
|
||||
@@ -87,7 +87,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
function view_argument_default_fixed() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_argument_default_fixed';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -134,4 +134,5 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -40,10 +40,27 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest {
|
||||
$this->assertTrue($view->argument['null']->validate_arg(12));
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure argument validation works properly.
|
||||
*/
|
||||
function testArgumentValidatePhpFailure() {
|
||||
$view = $this->view_test_argument_validate_php_failure();
|
||||
$view->save();
|
||||
$this->drupalGet('test-php-failure');
|
||||
|
||||
// This should return a 403, indicating that the arguments validation fails.
|
||||
$this->assertResponse(403);
|
||||
|
||||
$this->drupalGet('test-php-failure-feed');
|
||||
|
||||
// This should return a 403, indicating that the arguments validation fails.
|
||||
$this->assertResponse(403);
|
||||
}
|
||||
|
||||
function view_test_argument_validate_php($string) {
|
||||
$code = 'return $argument == \''. $string .'\';';
|
||||
$view = new view;
|
||||
$view->name = 'view_argument_validate_numeric';
|
||||
$code = 'return $argument == \'' . $string . '\';';
|
||||
$view = new view();
|
||||
$view->name = 'view_argument_validate_php';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
$view->view_php = '';
|
||||
@@ -74,7 +91,7 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
function view_argument_validate_numeric() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'view_argument_validate_numeric';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -103,4 +120,69 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return view $view
|
||||
* The required view object.
|
||||
*/
|
||||
function view_test_argument_validate_php_failure() {
|
||||
$view = new view();
|
||||
$view->name = 'view_argument_validate_php_failure';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = '';
|
||||
$view->core = 0;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['access']['type'] = 'none';
|
||||
$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'] = 'none';
|
||||
$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'] = '';
|
||||
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
|
||||
/* Contextual filter: Global: Null */
|
||||
$handler->display->display_options['arguments']['null']['id'] = 'null';
|
||||
$handler->display->display_options['arguments']['null']['table'] = 'views';
|
||||
$handler->display->display_options['arguments']['null']['field'] = 'null';
|
||||
$handler->display->display_options['arguments']['null']['default_action'] = 'default';
|
||||
$handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed';
|
||||
$handler->display->display_options['arguments']['null']['default_argument_options']['argument'] = 'No filter';
|
||||
$handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0';
|
||||
$handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25';
|
||||
$handler->display->display_options['arguments']['null']['specify_validation'] = TRUE;
|
||||
$handler->display->display_options['arguments']['null']['validate']['type'] = 'php';
|
||||
$handler->display->display_options['arguments']['null']['validate_options']['code'] = 'return FALSE;';
|
||||
$handler->display->display_options['arguments']['null']['validate']['fail'] = 'access denied';
|
||||
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||
$handler->display->display_options['path'] = 'test-php-failure';
|
||||
|
||||
/* Display: Feed */
|
||||
$handler = $view->new_display('feed', 'Feed', 'feed_1');
|
||||
$handler->display->display_options['path'] = 'test-php-failure-feed';
|
||||
$handler->display->display_options['pager']['type'] = 'none';
|
||||
$handler->display->display_options['pager']['options']['offset'] = '0';
|
||||
$handler->display->display_options['style_plugin'] = 'rss';
|
||||
$handler->display->display_options['row_plugin'] = 'node_rss';
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,18 +2,20 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of ViewsBasicTest.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic test class for Views query builder tests.
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class ViewsBasicTest extends ViewsSqlTest {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Basic query test',
|
||||
'description' => 'A basic query test for Views.',
|
||||
'group' => 'Views'
|
||||
'group' => 'Views',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -137,12 +139,12 @@ class ViewsBasicTest extends ViewsSqlTest {
|
||||
'validate_argument_transform' => 0,
|
||||
'validate_user_restrict_roles' => 0,
|
||||
'validate_argument_php' => '',
|
||||
)
|
||||
),
|
||||
));
|
||||
|
||||
$saved_view = clone $view;
|
||||
|
||||
// Execute with a view
|
||||
// Execute with a view.
|
||||
$view->set_arguments(array(27));
|
||||
$this->executeView($view);
|
||||
|
||||
@@ -175,4 +177,5 @@ class ViewsBasicTest extends ViewsSqlTest {
|
||||
'views_test_age' => 'age',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,11 +11,15 @@
|
||||
* @see views_plugin_cache
|
||||
*/
|
||||
class ViewsCacheTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Cache',
|
||||
'description' => 'Tests pluggable caching for views.',
|
||||
'group' => 'Views Plugins'
|
||||
'group' => 'Views Plugins',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,9 +157,9 @@ class ViewsCacheTest extends ViewsSqlTest {
|
||||
* Tests css/js storage and restoring mechanism.
|
||||
*/
|
||||
function testHeaderStorage() {
|
||||
// Create a view with output caching enabled.
|
||||
// Some hook_views_pre_render in views_test.module adds the test css/js file.
|
||||
// so they should be added to the css/js storage.
|
||||
// Create a view with output caching enabled. Some hook_views_pre_render in
|
||||
// views_test.module adds the test css/js file, so they should be added to
|
||||
// the css/js storage.
|
||||
$view = $this->getBasicView();
|
||||
$view->init_display();
|
||||
$view->name = 'test_cache_header_storage';
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* Just a placeholder file for the test.
|
||||
*
|
||||
* @see ViewsCacheTest::testHeaderStorage
|
||||
*/
|
||||
|
277
sites/all/modules/views/tests/views_clone.test
Normal file
277
sites/all/modules/views/tests/views_clone.test
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests cloning a view.
|
||||
*/
|
||||
class ViewsCloneTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
* Provide the test's meta information.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Test cloning a view',
|
||||
'description' => 'Tests clone_view method of views class',
|
||||
'group' => 'Views',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new term with random properties in vocabulary $vocabulary.
|
||||
*/
|
||||
protected function createTerm($vocabulary) {
|
||||
$term = new stdClass();
|
||||
$term->name = $this->randomName();
|
||||
$term->description = $this->randomName();
|
||||
// Use the first available text format.
|
||||
$term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField();
|
||||
$term->vid = $vocabulary->vid;
|
||||
taxonomy_term_save($term);
|
||||
return $term;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$vocabulary = taxonomy_vocabulary_machine_name_load('tags');
|
||||
$this->term = $this->createTerm($vocabulary);
|
||||
|
||||
$node = array();
|
||||
$node['type'] = 'article';
|
||||
$node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->term->tid;
|
||||
$this->node = $this->drupalCreateNode($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test cloning a view.
|
||||
*/
|
||||
public function testClone() {
|
||||
// Prepare view to be cloned.
|
||||
$view = $this->getTestCloneView();
|
||||
$view->set_arguments(array(
|
||||
0 => $this->node->nid,
|
||||
));
|
||||
$view->set_exposed_input(array(
|
||||
'field_tags_tid' => $this->term->tid,
|
||||
));
|
||||
|
||||
// Execute view to be cloned.
|
||||
$result = $view->execute();
|
||||
|
||||
// To make sure that we are properly testing removal of all properties, we
|
||||
// first need to assert that they are actually present in the original view.
|
||||
$keys = array(
|
||||
'current_display',
|
||||
'display_handler',
|
||||
'field',
|
||||
'argument',
|
||||
'filter',
|
||||
'sort',
|
||||
'relationship',
|
||||
'header',
|
||||
'footer',
|
||||
'empty',
|
||||
'query',
|
||||
'inited',
|
||||
'style_plugin',
|
||||
'plugin_name',
|
||||
'exposed_data',
|
||||
'exposed_input',
|
||||
'exposed_widgets',
|
||||
'many_to_one_aliases',
|
||||
'many_to_one_tables',
|
||||
'feed_icon',
|
||||
);
|
||||
foreach ($keys as $key) {
|
||||
$this->assertTrue(isset($view->{$key}), $key . 'is set in original view.');
|
||||
}
|
||||
$this->assertTrue($view->built, 'Assert original view built.');
|
||||
$this->assertTrue($view->executed, 'Assert original view executed.');
|
||||
$this->assertNotEqual($view->build_info, array(), 'Assert original view has build_info.');
|
||||
$this->assertNotEqual($view->attachment_before, '', 'Assert original view has attachment_before.');
|
||||
$this->assertNotEqual($view->attachment_after, '', 'Assert original view has attachment_after.');
|
||||
$this->assertNotEqual($view->result, array(), 'Assert original view has result.');
|
||||
|
||||
// Clone view.
|
||||
$clone = $view->clone_view();
|
||||
|
||||
// Assert that all relevant properties have been removed or reset.
|
||||
$keys = array(
|
||||
'current_display',
|
||||
'display_handler',
|
||||
'field',
|
||||
'argument',
|
||||
'filter',
|
||||
'sort',
|
||||
'relationship',
|
||||
'header',
|
||||
'footer',
|
||||
'empty',
|
||||
'query',
|
||||
'inited',
|
||||
'style_plugin',
|
||||
'plugin_name',
|
||||
'exposed_data',
|
||||
'exposed_input',
|
||||
'exposed_widgets',
|
||||
'many_to_one_aliases',
|
||||
'many_to_one_tables',
|
||||
'feed_icon',
|
||||
);
|
||||
foreach ($keys as $key) {
|
||||
$this->assertFalse(isset($clone->{$key}), $key . ' has been removed in cloned view.');
|
||||
}
|
||||
foreach ($clone->display as $id => $display) {
|
||||
$this->assertFalse(isset($clone->display[$id]->handler), 'Make sure all display handlers have been destroyed.');
|
||||
}
|
||||
$this->assertFalse($clone->built, 'Assert cloned view not built.');
|
||||
$this->assertFalse($clone->executed, 'Assert cloned view not executed.');
|
||||
$this->assertEqual($clone->build_info, array(), 'Assert cloned view has empty build_info.');
|
||||
$this->assertEqual($clone->attachment_before, '', 'Assert cloned view has empty attachment_before.');
|
||||
$this->assertEqual($clone->attachment_after, '', 'Assert cloned view has empty attachment_after.');
|
||||
$this->assertEqual($clone->result, array(), 'Assert cloned view has empty result.');
|
||||
|
||||
// Execute cloned view.
|
||||
$clone->execute();
|
||||
|
||||
// Assert result sets are equal.
|
||||
$this->assertEqual($view->result, $clone->result, 'Result sets of cloned view and original view match.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate test_clone view.
|
||||
*/
|
||||
protected function getTestCloneView() {
|
||||
$view = new view();
|
||||
$view->name = 'test_clone';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'test_clone';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'test_clone';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$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['pager']['options']['items_per_page'] = '10';
|
||||
$handler->display->display_options['style_plugin'] = 'default';
|
||||
$handler->display->display_options['row_plugin'] = 'node';
|
||||
/* Header: Global: Text area */
|
||||
$handler->display->display_options['header']['area']['id'] = 'area';
|
||||
$handler->display->display_options['header']['area']['table'] = 'views';
|
||||
$handler->display->display_options['header']['area']['field'] = 'area';
|
||||
$handler->display->display_options['header']['area']['label'] = 'Header';
|
||||
$handler->display->display_options['header']['area']['content'] = 'Header';
|
||||
$handler->display->display_options['header']['area']['format'] = 'filtered_html';
|
||||
/* Footer: Global: Text area */
|
||||
$handler->display->display_options['footer']['area']['id'] = 'area';
|
||||
$handler->display->display_options['footer']['area']['table'] = 'views';
|
||||
$handler->display->display_options['footer']['area']['field'] = 'area';
|
||||
$handler->display->display_options['footer']['area']['label'] = 'Footer';
|
||||
$handler->display->display_options['footer']['area']['content'] = 'Footer';
|
||||
$handler->display->display_options['footer']['area']['format'] = 'filtered_html';
|
||||
/* No results behavior: Global: Text area */
|
||||
$handler->display->display_options['empty']['area']['id'] = 'area';
|
||||
$handler->display->display_options['empty']['area']['table'] = 'views';
|
||||
$handler->display->display_options['empty']['area']['field'] = 'area';
|
||||
$handler->display->display_options['empty']['area']['label'] = 'Empty';
|
||||
$handler->display->display_options['empty']['area']['empty'] = TRUE;
|
||||
$handler->display->display_options['empty']['area']['content'] = 'Empty';
|
||||
$handler->display->display_options['empty']['area']['format'] = 'filtered_html';
|
||||
/* Relationship: Comment: Last Comment */
|
||||
$handler->display->display_options['relationships']['cid']['id'] = 'cid';
|
||||
$handler->display->display_options['relationships']['cid']['table'] = 'node_comment_statistics';
|
||||
$handler->display->display_options['relationships']['cid']['field'] = 'cid';
|
||||
/* 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'] = '';
|
||||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
|
||||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
|
||||
/* Sort criterion: Content: Post date */
|
||||
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
||||
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
||||
/* Contextual filter: Content: Nid */
|
||||
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
|
||||
$handler->display->display_options['arguments']['nid']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
|
||||
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
|
||||
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
|
||||
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
|
||||
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 'All';
|
||||
$handler->display->display_options['filters']['status']['group'] = 1;
|
||||
$handler->display->display_options['filters']['status']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator_id'] = '';
|
||||
$handler->display->display_options['filters']['status']['expose']['label'] = 'Published';
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op';
|
||||
$handler->display->display_options['filters']['status']['expose']['identifier'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['expose']['remember_roles'] = array(
|
||||
2 => '2',
|
||||
);
|
||||
/* Filter criterion: Content: Tags (field_tags) */
|
||||
$handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['exposed'] = TRUE;
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array(
|
||||
2 => '2',
|
||||
);
|
||||
$handler->display->display_options['filters']['field_tags_tid']['reduce_duplicates'] = TRUE;
|
||||
$handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page');
|
||||
$handler->display->display_options['path'] = 'test-clone';
|
||||
/* Display: attachment_before */
|
||||
$handler = $view->new_display('attachment', 'attachment_before', 'attachment_1');
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['displays'] = array(
|
||||
'default' => 'default',
|
||||
'page' => 'page',
|
||||
);
|
||||
$handler->display->display_options['inherit_exposed_filters'] = TRUE;
|
||||
/* Display: attachment_after */
|
||||
$handler = $view->new_display('attachment', 'attachment_after', 'attachment_2');
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['displays'] = array(
|
||||
'default' => 'default',
|
||||
'page' => 'page',
|
||||
);
|
||||
$handler->display->display_options['attachment_position'] = 'after';
|
||||
$handler->display->display_options['inherit_exposed_filters'] = TRUE;
|
||||
/* Display: Feed */
|
||||
$handler = $view->new_display('feed', 'Feed', 'feed_1');
|
||||
$handler->display->display_options['pager']['type'] = 'some';
|
||||
$handler->display->display_options['style_plugin'] = 'rss';
|
||||
$handler->display->display_options['row_plugin'] = 'node_rss';
|
||||
$handler->display->display_options['path'] = 'test_clone/rss';
|
||||
$handler->display->display_options['displays'] = array(
|
||||
'default' => 'default',
|
||||
'page' => 'page',
|
||||
);
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
@@ -9,6 +9,10 @@
|
||||
* Tests exposed forms.
|
||||
*/
|
||||
class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Exposed forms',
|
||||
@@ -17,10 +21,13 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp('views_ui');
|
||||
module_enable(array('views_ui'));
|
||||
// @TODO Figure out why it's required to clear the cache here.
|
||||
// @todo Figure out why it's required to clear the cache here.
|
||||
views_module_include('views_default', TRUE);
|
||||
views_get_all_views(TRUE);
|
||||
menu_rebuild();
|
||||
@@ -75,7 +82,8 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$this->drupalGet('test_exposed_remember');
|
||||
$this->assertFieldByName('type', 'page');
|
||||
|
||||
// Request the page with an unrelated GET argument, filter should still be set.
|
||||
// Request the page with an unrelated GET argument, filter should still be
|
||||
// set.
|
||||
$this->drupalGet('test_exposed_remember', array('query' => array('argument' => 'value')));
|
||||
$this->assertFieldByName('type', 'page');
|
||||
|
||||
@@ -101,8 +109,8 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
// Be sure that the button is called exposed.
|
||||
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter'));
|
||||
|
||||
// The first time the filter UI is displayed, the operator and the
|
||||
// value forms should be shown.
|
||||
// The first time the filter UI is displayed, the operator and the value
|
||||
// forms should be shown.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
|
||||
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
|
||||
@@ -112,10 +120,10 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
|
||||
// Check the label of the expose button.
|
||||
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
|
||||
// Check the label of the grouped exposed button
|
||||
// Check the label of the grouped exposed button.
|
||||
$this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters'));
|
||||
|
||||
// After Expose the filter, Operator and Value should be still here
|
||||
// After Expose the filter, Operator and Value should be still here.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
|
||||
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
|
||||
@@ -141,18 +149,18 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
|
||||
$this->drupalPost(NULL, array(), t('Grouped filters'));
|
||||
|
||||
// After click on 'Grouped Filters' standard operator and value should not be displayed
|
||||
// After click on 'Grouped Filters' standard operator and value should not
|
||||
// be displayed.
|
||||
$this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists');
|
||||
$this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists');
|
||||
$this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
|
||||
$this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
|
||||
|
||||
|
||||
// Check that after click on 'Grouped Filters', a new button is shown to
|
||||
// add more items to the list.
|
||||
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
|
||||
|
||||
// Create a grouped filter
|
||||
// Create a grouped filter.
|
||||
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
|
||||
$edit = array();
|
||||
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
|
||||
@@ -166,13 +174,13 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$edit["options[group_info][group_items][3][value][page]"] = TRUE;
|
||||
$this->drupalPost(NULL, $edit, t('Apply'));
|
||||
|
||||
// Validate that all the titles are defined for each group
|
||||
// Validate that all the titles are defined for each group.
|
||||
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
|
||||
$edit = array();
|
||||
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
|
||||
$edit["options[group_info][group_items][1][value][article]"] = TRUE;
|
||||
|
||||
// This should trigger an error
|
||||
// This should trigger an error.
|
||||
$edit["options[group_info][group_items][2][title]"] = '';
|
||||
$edit["options[group_info][group_items][2][value][page]"] = TRUE;
|
||||
|
||||
@@ -182,11 +190,11 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$this->drupalPost(NULL, $edit, t('Apply'));
|
||||
$this->assertRaw(t('The title is required if value for this item is defined.'), t('Group items should have a title'));
|
||||
|
||||
// Un-Expose the filter
|
||||
// Un-Expose the filter.
|
||||
$this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type');
|
||||
$this->drupalPost(NULL, array(), t('Hide filter'));
|
||||
|
||||
// After Un-Expose the filter, Operator and Value should be shown again
|
||||
// After Un-Expose the filter, Operator and Value should be shown again.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists after hide filter');
|
||||
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter');
|
||||
@@ -199,4 +207,5 @@ class ViewsExposedFormTest extends ViewsSqlTest {
|
||||
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
|
||||
$this->assertFieldById('edit-options-expose-label', '', t('Make sure a label field is shown'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest {
|
||||
);
|
||||
foreach ($nodes_per_char as $char => $count) {
|
||||
$setting = array(
|
||||
'type' => $type->type
|
||||
'type' => $type->type,
|
||||
);
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$node = $setting;
|
||||
@@ -46,7 +46,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest {
|
||||
}
|
||||
}
|
||||
|
||||
// Execute glossary view
|
||||
// Execute glossary view.
|
||||
$view = views_get_view('glossary');
|
||||
$view->set_display('attachment');
|
||||
$view->execute_display('attachment');
|
||||
@@ -57,4 +57,5 @@ class ViewsGlossaryTestCase extends ViewsSqlTest {
|
||||
$this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,20 +2,103 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests aggregate functionality of Views.
|
||||
* Definitions of ViewsQueryGroupByTest and ViewsUiGroupbyTestCase.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests aggregate functionality of views, for example count.
|
||||
*/
|
||||
class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
* Test meta data.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Groupby',
|
||||
'description' => 'Tests aggregate functionality of views, for example count.',
|
||||
'group' => 'Views',
|
||||
);
|
||||
}
|
||||
|
||||
// tests ambiguous group by column error (postgresql)
|
||||
public function testAggregateAmbiguity() {
|
||||
// Create 4 nodes of type1
|
||||
$type1 = $this->drupalCreateContentType();
|
||||
|
||||
$node_1 = array(
|
||||
'type' => $type1->type,
|
||||
);
|
||||
$this->drupalCreateNode($node_1);
|
||||
$this->drupalCreateNode($node_1);
|
||||
$this->drupalCreateNode($node_1);
|
||||
$this->drupalCreateNode($node_1);
|
||||
|
||||
$view = $this->viewsAggregateAmbiguityView();
|
||||
$output = $view->execute_display();
|
||||
|
||||
$this->assertEqual(count($view->result), 1, 'Make sure there are no ambiguity problems with the group by operation.');
|
||||
}
|
||||
|
||||
public function viewsAggregateAmbiguityView() {
|
||||
$view = new view();
|
||||
$view->name = 'aggregate_ambiguity';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = '';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$handler->display->display_options['group_by'] = TRUE;
|
||||
$handler->display->display_options['access']['type'] = 'none';
|
||||
$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: COUNT(Content revision: Nid) */
|
||||
$handler->display->display_options['fields']['nid']['id'] = 'nid';
|
||||
$handler->display->display_options['fields']['nid']['table'] = 'node_revision';
|
||||
$handler->display->display_options['fields']['nid']['field'] = 'nid';
|
||||
$handler->display->display_options['fields']['nid']['group_type'] = 'count';
|
||||
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
|
||||
/* Field: Content: Nid */
|
||||
$handler->display->display_options['fields']['nid_1']['id'] = 'nid_1';
|
||||
$handler->display->display_options['fields']['nid_1']['table'] = 'node';
|
||||
$handler->display->display_options['fields']['nid_1']['field'] = 'nid';
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['make_link'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['word_boundary'] = 1;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['ellipsis'] = 1;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['strip_tags'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['alter']['html'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['hide_empty'] = 0;
|
||||
$handler->display->display_options['fields']['nid_1']['empty_zero'] = 0;
|
||||
/* Contextual filter: Content: Type */
|
||||
$handler->display->display_options['arguments']['type']['id'] = 'type';
|
||||
$handler->display->display_options['arguments']['type']['table'] = 'node';
|
||||
$handler->display->display_options['arguments']['type']['field'] = 'type';
|
||||
$handler->display->display_options['arguments']['type']['default_action'] = 'summary';
|
||||
$handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed';
|
||||
$handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary';
|
||||
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +131,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
|
||||
$types = array();
|
||||
foreach ($view->result as $item) {
|
||||
// num_records is a alias for nid.
|
||||
// 'num_records' is a alias for nid.
|
||||
$types[$item->node_type] = $item->num_records;
|
||||
}
|
||||
|
||||
@@ -56,9 +139,15 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
$this->assertEqual($types[$type2->type], 3);
|
||||
}
|
||||
|
||||
//public function testAggregateSum() {
|
||||
//}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public function testAggregateSum() {
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsAggregateCountView() {
|
||||
$view = new view;
|
||||
$view->name = 'aggregate_count';
|
||||
@@ -103,7 +192,6 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
$handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed';
|
||||
$handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary';
|
||||
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
@@ -144,7 +232,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
// There's no need for a function in order to have aggregation.
|
||||
if (empty($group_by)) {
|
||||
$types = array($type1->type, $type2->type);
|
||||
$results = array_map(function ($item) { return $item->node_type; }, $view->result);
|
||||
$results = array_map(function ($item) {
|
||||
return $item->node_type;
|
||||
}, $view->result);
|
||||
sort($types);
|
||||
sort($results);
|
||||
$this->assertIdentical($results, $types);
|
||||
@@ -160,6 +250,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
$this->assertEqual($results[$type2->type], $values[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsGroupByViewHelper($group_by = NULL) {
|
||||
$view = new view;
|
||||
$view->name = 'group_by_count';
|
||||
@@ -219,31 +312,51 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupByCount() {
|
||||
$this->GroupByTestHelper('count', array(4, 3));
|
||||
}
|
||||
|
||||
function testGroupBySum() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupBySum() {
|
||||
$this->GroupByTestHelper('sum', array(10, 18));
|
||||
}
|
||||
|
||||
|
||||
function testGroupByAverage() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupByAverage() {
|
||||
$this->GroupByTestHelper('avg', array(2.5, 6));
|
||||
}
|
||||
|
||||
function testGroupByMin() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupByMin() {
|
||||
$this->GroupByTestHelper('min', array(1, 5));
|
||||
}
|
||||
|
||||
function testGroupByMax() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function testGroupByMax() {
|
||||
$this->GroupByTestHelper('max', array(4, 7));
|
||||
}
|
||||
|
||||
function testGroupByNone() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupByNone() {
|
||||
$this->GroupByTestHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testGroupByCountOnlyFilters() {
|
||||
// Check if GROUP BY and HAVING are included when a view
|
||||
// Doesn't display SUM, COUNT, MAX... functions in SELECT statment
|
||||
@@ -264,6 +377,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
$this->assertTrue(strpos($view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query'));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsGroupByCountViewOnlyFilters() {
|
||||
$view = new view;
|
||||
$view->name = 'group_by_in_filters';
|
||||
@@ -308,12 +424,17 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests UI of aggregate functionality..
|
||||
* Tests UI of aggregate functionality.
|
||||
*/
|
||||
class viewsUiGroupbyTestCase extends DrupalWebTestCase {
|
||||
class ViewsUiGroupbyTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function setUp() {
|
||||
// Enable views_ui.
|
||||
parent::setUp('views_ui', 'views_test');
|
||||
@@ -323,6 +444,9 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase {
|
||||
$this->drupalLogin($views_admin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test meta data.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Groupby UI',
|
||||
@@ -349,4 +473,5 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase {
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by');
|
||||
}
|
||||
|
||||
}
|
||||
|
161
sites/all/modules/views/tests/views_handler_filter.test
Normal file
161
sites/all/modules/views/tests/views_handler_filter.test
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of ViewsHandlerFilterTest.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests filter handler.
|
||||
*/
|
||||
class ViewsHandlerFilterTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Handler filter test',
|
||||
'description' => 'test filter handler definitions',
|
||||
'group' => 'Views',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
// The Views and Views UI modules will be enabled with this.
|
||||
parent::setUp();
|
||||
|
||||
// Assign vocabulary 'tag' to user entity.
|
||||
$field_definition = field_read_field('field_tags');
|
||||
$instance_definition = array(
|
||||
'field_name' => $field_definition['field_name'],
|
||||
'entity_type' => 'user',
|
||||
'bundle' => 'user',
|
||||
'widget' => array(
|
||||
'type' => 'taxonomy_autocomplete',
|
||||
),
|
||||
'display' => array(
|
||||
'default' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
'teaser' => array(
|
||||
'type' => 'taxonomy_term_reference_link',
|
||||
'weight' => 10,
|
||||
),
|
||||
),
|
||||
);
|
||||
field_create_instance($instance_definition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests "is all of" of filter operation.
|
||||
*/
|
||||
function testFilterInOperatorUi() {
|
||||
$term = $this->drupalCreateTerm(1);
|
||||
|
||||
$node1 = $this->drupalCreateNode(array('type' => 'article','field_tags_tid' => $term->tid, 'created' => REQUEST_TIME));
|
||||
$node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1));
|
||||
$user2 = $this->drupalCreateUser(array('access content'));
|
||||
// $this->drupalLogin($this->drupalCreateUser(array('administer users'));
|
||||
$this->drupalLogin($this->drupalCreateUser(array('administer users', 'access administration pages', 'administer site configuration', 'administer nodes', 'bypass node access')));
|
||||
|
||||
$this->drupalGet('node/1/edit');
|
||||
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name;
|
||||
$this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
|
||||
|
||||
$edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name;
|
||||
$this->drupalPost('user/' . $user2->uid . '/edit', $edit, t('Save'));
|
||||
|
||||
$result[] = array('nid' => $node1->nid);
|
||||
$view = $this->get_sample_view();
|
||||
$this->executeView($view);
|
||||
$this->assertIdenticalResultset($view, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample view.
|
||||
*
|
||||
* @return \view
|
||||
*/
|
||||
protected function get_sample_view() {
|
||||
$view = new view();
|
||||
$view->name = 'article';
|
||||
$view->description = '';
|
||||
$view->tag = 'default';
|
||||
$view->base_table = 'node';
|
||||
$view->human_name = 'Article';
|
||||
$view->core = 7;
|
||||
$view->api_version = '3.0';
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
$handler = $view->new_display('default', 'Master', 'default');
|
||||
$handler->display->display_options['title'] = 'Article';
|
||||
$handler->display->display_options['use_more_always'] = FALSE;
|
||||
$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['pager']['options']['items_per_page'] = '10';
|
||||
$handler->display->display_options['style_plugin'] = 'table';
|
||||
$handler->display->display_options['style_options']['columns'] = array(
|
||||
'title' => 'title',
|
||||
);
|
||||
$handler->display->display_options['style_options']['default'] = '-1';
|
||||
$handler->display->display_options['style_options']['info'] = array(
|
||||
'title' => array(
|
||||
'sortable' => 0,
|
||||
'default_sort_order' => 'asc',
|
||||
'align' => '',
|
||||
'separator' => '',
|
||||
'empty_column' => 0,
|
||||
),
|
||||
);
|
||||
/* 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';
|
||||
$handler->display->display_options['fields']['nid']['label'] = '';
|
||||
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
|
||||
/* Sort criterion: Content: Post date */
|
||||
$handler->display->display_options['sorts']['created']['id'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['table'] = 'node';
|
||||
$handler->display->display_options['sorts']['created']['field'] = 'created';
|
||||
$handler->display->display_options['sorts']['created']['order'] = 'DESC';
|
||||
/* Filter criterion: Content: Published */
|
||||
$handler->display->display_options['filters']['status']['id'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['table'] = 'node';
|
||||
$handler->display->display_options['filters']['status']['field'] = 'status';
|
||||
$handler->display->display_options['filters']['status']['value'] = 1;
|
||||
$handler->display->display_options['filters']['status']['group'] = 1;
|
||||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
|
||||
/* Filter criterion: Field: Tags (field_tags) */
|
||||
$handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['operator'] = 'and';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['value'] = array(
|
||||
0 => '1',
|
||||
);
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid';
|
||||
$handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array(
|
||||
2 => '2',
|
||||
);
|
||||
$handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
|
||||
|
||||
/* Display: Page */
|
||||
$handler = $view->new_display('page', 'Page', 'page');
|
||||
$handler->display->display_options['path'] = 'article';
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
@@ -48,13 +48,13 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
$empty_stdclass->value = array();
|
||||
|
||||
$null = NULL;
|
||||
// check defaults
|
||||
// check defaults.
|
||||
$this->assertEqual($empty_stdclass, views_break_phrase_string('', $null));
|
||||
|
||||
$handler = views_get_handler('node', 'title', 'argument');
|
||||
$this->assertEqual($handler, views_break_phrase_string('', $handler));
|
||||
|
||||
// test ors
|
||||
// test ors.
|
||||
$handler = views_break_phrase_string('word1 word2+word');
|
||||
$this->assertEqualValue(array('word1', 'word2', 'word'), $handler);
|
||||
$this->assertEqual('or', $handler->operator);
|
||||
@@ -88,7 +88,7 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
$this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler);
|
||||
$this->assertEqual('and', $handler->operator);
|
||||
|
||||
// test a single word
|
||||
// test a single word.
|
||||
$handler = views_break_phrase_string('word');
|
||||
$this->assertEqualValue(array('word'), $handler);
|
||||
$this->assertEqual('and', $handler->operator);
|
||||
@@ -103,7 +103,7 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
$empty_stdclass->value = array();
|
||||
|
||||
$null = NULL;
|
||||
// check defaults
|
||||
// check defaults.
|
||||
$this->assertEqual($empty_stdclass, views_break_phrase('', $null));
|
||||
|
||||
$handler = views_get_handler('node', 'title', 'argument');
|
||||
@@ -113,7 +113,7 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
$n1 = rand(0, 100);
|
||||
$n2 = rand(0, 100);
|
||||
$n3 = rand(0, 100);
|
||||
// test ors
|
||||
// test ors.
|
||||
$this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1 $n2+$n3", $handler));
|
||||
$this->assertEqual('or', $handler->operator);
|
||||
$this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1+$n2+$n3", $handler));
|
||||
@@ -133,7 +133,7 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
/**
|
||||
* Check to see if two values are equal.
|
||||
*
|
||||
* @param $first
|
||||
* @param string $first
|
||||
* The first value to check.
|
||||
* @param views_handler $handler
|
||||
* @param string $message
|
||||
@@ -147,4 +147,5 @@ class ViewsHandlersTest extends ViewsSqlTest {
|
||||
protected function assertEqualValue($first, $handler, $message = '', $group = 'Other') {
|
||||
return $this->assert($first == $handler->value, $message ? $message : t('First value is equal to second value'), $group);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ class ViewsModuleTest extends ViewsSqlTest {
|
||||
'khoảng cách từ đại lí đến',
|
||||
'của hãng bao gồm ba dòng',
|
||||
'сд асд асд ас',
|
||||
'асд асд асд ас'
|
||||
'асд асд асд ас',
|
||||
);
|
||||
// Just test maxlength without word boundry.
|
||||
$alter = array(
|
||||
@@ -91,7 +91,8 @@ class ViewsModuleTest extends ViewsSqlTest {
|
||||
*/
|
||||
function testModuleTemplates() {
|
||||
$views_status = variable_get('views_defaults', array());
|
||||
$views_status['frontpage'] = FALSE; // false is enabled
|
||||
$views_status['frontpage'] = FALSE;
|
||||
// false is enabled.
|
||||
variable_set('views_defaults', $views_status);
|
||||
|
||||
$existing = array();
|
||||
@@ -127,7 +128,6 @@ class ViewsModuleTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
// Test the automatic conversion feature.
|
||||
|
||||
// Test the automatic table renaming.
|
||||
$handler = views_get_handler('views_test_previous', 'id', 'field');
|
||||
$this->assertInstanceHandler($handler, 'views_test', 'id', 'field');
|
||||
@@ -194,7 +194,6 @@ class ViewsModuleTest extends ViewsSqlTest {
|
||||
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
|
||||
$this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
|
||||
|
||||
|
||||
// Test if the cache consistency is ensured. There was an issue where
|
||||
// calling _views_fetch_data() first with a table would prevent the function
|
||||
// from properly rebuilt a missing the general cache entry.
|
||||
@@ -238,4 +237,5 @@ class ViewsModuleTest extends ViewsSqlTest {
|
||||
drupal_static_reset('_views_fetch_data_recursion_protected');
|
||||
drupal_static_reset('_views_fetch_data_fully_loaded');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Tests the pluggable pager system.
|
||||
*/
|
||||
class ViewsPagerTest extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Pager',
|
||||
@@ -17,6 +21,9 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp('views', 'views_ui', 'views_test');
|
||||
}
|
||||
@@ -29,11 +36,10 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
public function testStorePagerSettings() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration'));
|
||||
$this->drupalLogin($admin_user);
|
||||
// Test behaviour described in http://drupal.org/node/652712#comment-2354918.
|
||||
|
||||
// Test behaviour described in
|
||||
// http://drupal.org/node/652712#comment-2354918.
|
||||
$this->drupalGet('admin/structure/views/view/frontpage/edit');
|
||||
|
||||
|
||||
$edit = array(
|
||||
'pager_options[items_per_page]' => 20,
|
||||
);
|
||||
@@ -70,8 +76,8 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
|
||||
$this->assertText('20 items');
|
||||
|
||||
// add new display and test the settings again, by override it.
|
||||
$edit = array( );
|
||||
// Add new display and test the settings again, by override it.
|
||||
$edit = array();
|
||||
// Add a display and override the pager settings.
|
||||
$this->drupalPost('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page'));
|
||||
$edit = array(
|
||||
@@ -91,11 +97,13 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
);
|
||||
$this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply'));
|
||||
$this->assertText('20 items');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsStorePagerSettings() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_store_pager_settings';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -120,8 +128,8 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
* Tests the none-pager-query.
|
||||
*/
|
||||
public function testNoLimit() {
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
// 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();
|
||||
}
|
||||
@@ -153,15 +161,18 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$this->assertEqual($view->query->pager->get_items_per_page(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsPagerNoLimit() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_pager_none';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
$view->view_php = '';
|
||||
$view->base_table = 'node';
|
||||
$view->is_cacheable = FALSE;
|
||||
$view->api_version =3;
|
||||
$view->api_version = 3;
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
|
||||
/* Display: Master */
|
||||
@@ -175,6 +186,9 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testViewTotalRowsWithoutPager() {
|
||||
$this->createNodes(23);
|
||||
|
||||
@@ -186,6 +200,9 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$this->assertEqual($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++) {
|
||||
@@ -198,8 +215,8 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
* Tests the some pager plugin.
|
||||
*/
|
||||
public function testLimit() {
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
// 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();
|
||||
}
|
||||
@@ -229,8 +246,11 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$this->assertFalse($view->query->pager->use_count_query());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsPagerLimit() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_pager_some';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -257,8 +277,8 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
* Tests the normal pager.
|
||||
*/
|
||||
public function testNormalPager() {
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
// 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();
|
||||
}
|
||||
@@ -290,8 +310,7 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
|
||||
$this->assertEqual(count($view->result), 11, 'All items are return');
|
||||
|
||||
// TODO test number of pages.
|
||||
|
||||
// @todo test number of pages.
|
||||
// Test items per page = 0.
|
||||
$view->destroy();
|
||||
|
||||
@@ -313,8 +332,11 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$this->assertEqual(count($view->result), 11);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewPagerFullZeroItemsPerPage() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'view_pager_full_zero_items_per_page';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -353,8 +375,11 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsPagerFull() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_pager_full';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -379,8 +404,11 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsPagerFullFields() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_pager_full';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -421,22 +449,24 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
* Tests the minipager.
|
||||
*/
|
||||
public function testMiniPager() {
|
||||
// the functionality is the same as the normal pager, so i don't know what to test here.
|
||||
// The functionality is the same as the normal pager, so i don't know what
|
||||
// to test here.
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests rendering with NULL pager.
|
||||
*/
|
||||
public function testRenderNullPager() {
|
||||
// Create 11 nodes and make sure that everyone is returned.
|
||||
// We create 11 nodes, because the default pager plugin had 10 items per page.
|
||||
// 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 = $this->viewsPagerFullFields();
|
||||
$view->set_display('default');
|
||||
$this->executeView($view);
|
||||
$view->use_ajax = TRUE; // force the value again here
|
||||
$view->use_ajax = TRUE;
|
||||
// force the value again here.
|
||||
$view->query->pager = NULL;
|
||||
$output = $view->render();
|
||||
$this->assertEqual(preg_match('/<ul class="pager">/', $output), 0, t('The pager is not rendered.'));
|
||||
@@ -448,7 +478,6 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
function testPagerApi() {
|
||||
$view = $this->viewsPagerFull();
|
||||
// On the first round don't initialize the pager.
|
||||
|
||||
$this->assertEqual($view->get_items_per_page(), NULL, 'If the pager is not initialized and no manual override there is no items per page.');
|
||||
$rand_number = rand(1, 5);
|
||||
$view->set_items_per_page($rand_number);
|
||||
@@ -491,6 +520,6 @@ class ViewsPagerTest extends ViewsSqlTest {
|
||||
$rand_number = rand(6, 11);
|
||||
$view->query->pager->set_current_page($rand_number);
|
||||
$this->assertEqual($view->get_current_page(), $rand_number, 'Make sure get_current_page uses the settings of set_current_page.');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,15 +9,17 @@
|
||||
* A stump localisation plugin which has static variables to cache the input.
|
||||
*/
|
||||
class views_plugin_localization_test extends views_plugin_localization {
|
||||
|
||||
/**
|
||||
* Store the strings which was translated.
|
||||
*/
|
||||
var $translated_strings;
|
||||
public $translated_strings;
|
||||
|
||||
/**
|
||||
* Return the string and take sure that the test can find out whether the
|
||||
* string got translated.
|
||||
*/
|
||||
function translate_string($string, $keys = array(), $format = '') {
|
||||
public function translate_string($string, $keys = array(), $format = '') {
|
||||
$this->translated_strings[] = $string;
|
||||
return $string . "-translated";
|
||||
}
|
||||
@@ -25,7 +27,7 @@ class views_plugin_localization_test extends views_plugin_localization {
|
||||
/**
|
||||
* Store the export strings.
|
||||
*/
|
||||
function export($source) {
|
||||
public function export($source) {
|
||||
if (!empty($source['value'])) {
|
||||
$this->export_strings[] = $source['value'];
|
||||
}
|
||||
@@ -34,7 +36,8 @@ class views_plugin_localization_test extends views_plugin_localization {
|
||||
/**
|
||||
* Return the stored strings for the simpletest.
|
||||
*/
|
||||
function get_export_strings() {
|
||||
public function get_export_strings() {
|
||||
return $this->export_strings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,13 +2,24 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for Views query features.
|
||||
* Abstract class for views testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Abstract class for views testing.
|
||||
*
|
||||
*/
|
||||
abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $sort_column = NULL;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $sort_order = 1;
|
||||
|
||||
/**
|
||||
* Helper function: verify a result set returned by view.
|
||||
*
|
||||
@@ -16,13 +27,13 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
* column map, taking the order of the rows into account, but not the order
|
||||
* of the columns.
|
||||
*
|
||||
* @param $view
|
||||
* An executed View.
|
||||
* @param $expected_result
|
||||
* An expected result set.
|
||||
* @param $column_map
|
||||
* An associative array mapping the columns of the result set from the view
|
||||
* (as keys) and the expected result set (as values).
|
||||
* @param view $view
|
||||
* An executed View.
|
||||
* @param array $expected_result
|
||||
* An expected result set.
|
||||
* @param array $column_map
|
||||
* An associative array mapping the columns of the result set from the view
|
||||
* (as keys) and the expected result set (as values).
|
||||
*/
|
||||
protected function assertIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') {
|
||||
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertIdentical');
|
||||
@@ -33,25 +44,29 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
*
|
||||
* Inverse of ViewsTestCase::assertIdenticalResultset().
|
||||
*
|
||||
* @param $view
|
||||
* An executed View.
|
||||
* @param $expected_result
|
||||
* An expected result set.
|
||||
* @param $column_map
|
||||
* An associative array mapping the columns of the result set from the view
|
||||
* (as keys) and the expected result set (as values).
|
||||
* @param view $view
|
||||
* An executed View.
|
||||
* @param array $expected_result
|
||||
* An expected result set.
|
||||
* @param array $column_map
|
||||
* An associative array mapping the columns of the result set from the view
|
||||
* (as keys) and the expected result set (as values).
|
||||
*/
|
||||
protected function assertNotIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') {
|
||||
return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertNotIdentical');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, $assert_method) {
|
||||
// Convert $view->result to an array of arrays.
|
||||
$result = array();
|
||||
foreach ($view->result as $key => $value) {
|
||||
$row = array();
|
||||
foreach ($column_map as $view_column => $expected_column) {
|
||||
// The comparison will be done on the string representation of the value.
|
||||
// The comparison will be done on the string representation of the
|
||||
// value.
|
||||
$row[$expected_column] = (string) $value->$view_column;
|
||||
}
|
||||
$result[$key] = $row;
|
||||
@@ -61,7 +76,8 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
foreach ($expected_result as $key => $value) {
|
||||
$row = array();
|
||||
foreach ($column_map as $expected_column) {
|
||||
// The comparison will be done on the string representation of the value.
|
||||
// The comparison will be done on the string representation of the
|
||||
// value.
|
||||
$row[$expected_column] = (string) (is_object($value) ? $value->$expected_column : $value[$expected_column]);
|
||||
}
|
||||
$expected_result[$key] = $row;
|
||||
@@ -71,14 +87,14 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
$result = array_values($result);
|
||||
$expected_result = array_values($expected_result);
|
||||
|
||||
$this->verbose('<pre>Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: ". print_r($expected_result, TRUE));
|
||||
$this->verbose('<pre>Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: " . print_r($expected_result, TRUE));
|
||||
|
||||
// Do the actual comparison.
|
||||
return $this->$assert_method($result, $expected_result, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function: order an array of array based on a column.
|
||||
* Order an array of array based on a column.
|
||||
*/
|
||||
protected function orderResultSet($result_set, $column, $reverse = FALSE) {
|
||||
$this->sort_column = $column;
|
||||
@@ -87,9 +103,6 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
return $result_set;
|
||||
}
|
||||
|
||||
protected $sort_column = NULL;
|
||||
protected $sort_order = 1;
|
||||
|
||||
/**
|
||||
* Helper comparison function for orderResultSet().
|
||||
*/
|
||||
@@ -97,20 +110,20 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
$value1 = $a[$this->sort_column];
|
||||
$value2 = $b[$this->sort_column];
|
||||
if ($value1 == $value2) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
return $this->sort_order * (($value1 < $value2) ? -1 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to check whether a button with a certain id exists and has a certain label.
|
||||
* Check whether a button with a certain id exists and has a certain label.
|
||||
*/
|
||||
protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
|
||||
return $this->assertFieldById($id, $expected_label, t($message, array('%label' => $expected_label)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to execute a view with debugging.
|
||||
* Execute a view with debugging.
|
||||
*
|
||||
* @param view $view
|
||||
* @param array $args
|
||||
@@ -121,14 +134,56 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
|
||||
$view->execute();
|
||||
$this->verbose('<pre>Executed view: ' . ((string) $view->build_info['query']) . '</pre>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Log in as user 1.
|
||||
*/
|
||||
protected function loginUser1() {
|
||||
$password = user_password();
|
||||
// Reset the user 1 password.
|
||||
$account = user_load(1);
|
||||
$edit = array(
|
||||
'pass' => $password,
|
||||
);
|
||||
$account = user_save($account, $edit);
|
||||
$account->pass_raw = $password;
|
||||
|
||||
// Log in as user 1.
|
||||
$this->drupalLogin($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function verbose($message, $title = NULL) {
|
||||
// Handle arrays, objects, etc.
|
||||
if (!is_string($message)) {
|
||||
$message = "<pre>\n" . print_r($message, TRUE) . "\n</pre>\n";
|
||||
}
|
||||
|
||||
// Optional title to go before the output.
|
||||
if (!empty($title)) {
|
||||
$title = '<h2>' . check_plain($title) . "</h2>\n";
|
||||
}
|
||||
|
||||
parent::verbose($title . $message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class ViewsSqlTest extends ViewsTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp('views', 'views_ui');
|
||||
|
||||
// Define the schema and views data variable before enabling the test module.
|
||||
// Define the schema and views data variable before enabling the test
|
||||
// module.
|
||||
variable_set('views_test_schema', $this->schemaDefinition());
|
||||
variable_set('views_test_views_data', $this->viewsData());
|
||||
variable_set('views_test_views_plugins', $this->viewsPlugins());
|
||||
@@ -147,14 +202,32 @@ abstract class ViewsSqlTest extends ViewsTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function allows to enable views ui from a higher class which can't change the setup function anymore.
|
||||
* Create a term.
|
||||
*
|
||||
* @TODO
|
||||
* Convert existing setUp functions.
|
||||
* @param int $vid
|
||||
* The vocabulary ID that the term is to be added to.
|
||||
*
|
||||
* @return object
|
||||
* A full term object with a random name.
|
||||
*/
|
||||
protected function drupalCreateTerm($vid) {
|
||||
$term = new stdClass();
|
||||
$term->name = $this->randomName();
|
||||
$term->description = $this->randomName();
|
||||
$term->vid = $vid;
|
||||
taxonomy_term_save($term);
|
||||
return $term;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function allows to enable views ui from a higher class which can't
|
||||
* change the setup function anymore.
|
||||
*
|
||||
* @todo Convert existing setUp functions.
|
||||
*/
|
||||
function enableViewsUi() {
|
||||
module_enable(array('views_ui'));
|
||||
// @TODO Figure out why it's required to clear the cache here.
|
||||
// @todo Figure out why it's required to clear the cache here.
|
||||
views_module_include('views_default', TRUE);
|
||||
views_get_all_views(TRUE);
|
||||
menu_rebuild();
|
||||
@@ -202,7 +275,7 @@ abstract class ViewsSqlTest extends ViewsTestCase {
|
||||
),
|
||||
'primary key' => array('id'),
|
||||
'unique keys' => array(
|
||||
'name' => array('name')
|
||||
'name' => array('name'),
|
||||
),
|
||||
'indexes' => array(
|
||||
'ages' => array('age'),
|
||||
@@ -314,6 +387,9 @@ abstract class ViewsSqlTest extends ViewsTestCase {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function viewsPlugins() {
|
||||
return array();
|
||||
}
|
||||
@@ -422,11 +498,12 @@ abstract class ViewsSqlTest extends ViewsTestCase {
|
||||
views_include('view');
|
||||
$view = $this->getBasicView();
|
||||
|
||||
// In order to test exposed filters, we have to disable
|
||||
// the exposed forms cache.
|
||||
// In order to test exposed filters, we have to disable the exposed forms
|
||||
// cache.
|
||||
drupal_static_reset('views_exposed_form_cache');
|
||||
|
||||
$display = $view->new_display('page', 'Page', 'page_1');
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -5,9 +5,8 @@ core = 7.x
|
||||
dependencies[] = views
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-08-23
|
||||
version = "7.x-3.18"
|
||||
; Information added by Drupal.org packaging script on 2019-05-10
|
||||
version = "7.x-3.23"
|
||||
core = "7.x"
|
||||
project = "views"
|
||||
datestamp = "1503495103"
|
||||
|
||||
datestamp = "1557505389"
|
||||
|
@@ -35,7 +35,7 @@ function views_test_views_data() {
|
||||
$count = variable_get('views_test_views_data_count', 0);
|
||||
$count++;
|
||||
variable_set('views_test_views_data_count', $count);
|
||||
return variable_get('views_test_views_data', array());
|
||||
return variable_get('views_test_views_data', array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function views_test_views_default_views() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_views_groupby_save';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -31,7 +31,7 @@ function views_test_views_default_views() {
|
||||
|
||||
$views[$view->name] = $view;
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_rename_reset_button';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -70,7 +70,7 @@ function views_test_views_default_views() {
|
||||
|
||||
$views[$view->name] = $view;
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_exposed_admin_ui';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -110,7 +110,7 @@ function views_test_views_default_views() {
|
||||
|
||||
$views[$view->name] = $view;
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_filter_in_operator_ui';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -142,7 +142,7 @@ function views_test_views_default_views() {
|
||||
|
||||
$views[$view->name] = $view;
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_argument_default_current_user';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
|
@@ -31,7 +31,7 @@ class ViewsTranslatableTest extends ViewsSqlTest {
|
||||
'help' => t('This is a test description.'),
|
||||
'handler' => 'views_plugin_localization_test',
|
||||
'parent' => 'parent',
|
||||
'path' => drupal_get_path('module', 'views') .'/tests',
|
||||
'path' => drupal_get_path('module', 'views') . '/tests',
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -100,7 +100,6 @@ class ViewsTranslatableTest extends ViewsSqlTest {
|
||||
$view->init_display();
|
||||
|
||||
// Don't run translation. We just want to get the right keys.
|
||||
|
||||
foreach ($view->display as $display_id => $display) {
|
||||
$translatables = array();
|
||||
$display->handler->unpack_translatables($translatables);
|
||||
@@ -145,7 +144,7 @@ class ViewsTranslatableTest extends ViewsSqlTest {
|
||||
}
|
||||
|
||||
public function view_unpack_translatable() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'view_unpack_translatable';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -218,4 +217,5 @@ class ViewsTranslatableTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@
|
||||
* Views UI wizard tests.
|
||||
*/
|
||||
class ViewsUIWizardHelper extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function setUp() {
|
||||
// Enable views_ui.
|
||||
parent::setUp('views_ui');
|
||||
@@ -17,12 +21,17 @@ class ViewsUIWizardHelper extends DrupalWebTestCase {
|
||||
$views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions'));
|
||||
$this->drupalLogin($views_admin);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creating views with the wizard and viewing them on the listing page.
|
||||
*/
|
||||
class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard basic functionality',
|
||||
@@ -31,6 +40,9 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function testViewsWizardAndListing() {
|
||||
// Check if we can access the main views admin page.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
@@ -46,7 +58,7 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
|
||||
$this->assertText(t('Your view was saved. You may edit it from the list below.'));
|
||||
$this->assertText($view1['human_name']);
|
||||
$this->assertText($view1['description']);
|
||||
foreach(array('delete', 'clone', 'edit') as $operation) {
|
||||
foreach (array('delete', 'clone', 'edit') as $operation) {
|
||||
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . '/' . $operation));
|
||||
}
|
||||
|
||||
@@ -146,12 +158,17 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
|
||||
// Make sure the listing page doesn't show disabled default views.
|
||||
$this->assertNoText('tracker', t('Default tracker view does not show on the listing page.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests enabling, disabling, and reverting default views via the listing page.
|
||||
*/
|
||||
class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI default views functionality',
|
||||
@@ -168,10 +185,9 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
||||
// the listing page).
|
||||
$edit_href = 'admin/structure/views/view/frontpage/edit';
|
||||
$this->drupalGet('admin/structure/views');
|
||||
// TODO: Disabled default views do now appear on the front page. Test this
|
||||
// @todo Disabled default views do now appear on the front page. Test this
|
||||
// behavior with templates instead.
|
||||
// $this->assertNoLinkByHref($edit_href);
|
||||
|
||||
// Enable the front page view, and make sure it is now visible on the main
|
||||
// listing page.
|
||||
$this->drupalGet('admin/structure/views/templates');
|
||||
@@ -205,7 +221,7 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
||||
// Now disable the view, and make sure it stops appearing on the main view
|
||||
// listing page but instead goes back to displaying on the disabled views
|
||||
// listing page.
|
||||
// TODO: Test this behavior with templates instead.
|
||||
// @todo Test this behavior with templates instead.
|
||||
$this->drupalGet('admin/structure/views');
|
||||
$this->clickViewsOperationLink(t('Disable'), '/frontpage/');
|
||||
// $this->assertUrl('admin/structure/views');
|
||||
@@ -225,15 +241,15 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
||||
* various views listing pages, and they might have tokens in them. So we
|
||||
* need special code to find the correct one to click.
|
||||
*
|
||||
* @param $label
|
||||
* @param string $label
|
||||
* Text between the anchor tags of the desired link.
|
||||
* @param $unique_href_part
|
||||
* @param string $unique_href_part
|
||||
* A unique string that is expected to occur within the href of the desired
|
||||
* link. For example, if the link URL is expected to look like
|
||||
* "admin/structure/views/view/frontpage/...", then "/frontpage/" could be
|
||||
* passed as the expected unique string.
|
||||
*
|
||||
* @return
|
||||
* @return string
|
||||
* The page content that results from clicking on the link, or FALSE on
|
||||
* failure. Failure also results in a failed assertion.
|
||||
*/
|
||||
@@ -254,18 +270,42 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability of the views wizard to create views filtered by taxonomy.
|
||||
*/
|
||||
class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $node_type_with_tags;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $node_type_without_tags;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $tag_vocabulary;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $tag_field;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected $tag_instance;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard taxonomy functionality',
|
||||
@@ -274,6 +314,9 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
@@ -392,7 +435,7 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the "tagged with" form element only shows for node types that support it.
|
||||
* Test the "tagged with" form element only shows for node types that support it.
|
||||
*/
|
||||
function testTaggedWithByNodeType() {
|
||||
// The tagging field is associated with one of our node types only. So the
|
||||
@@ -422,12 +465,17 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
|
||||
$this->drupalPost(NULL, $view, t('Update "of type" choice'));
|
||||
$this->assertFieldByXpath($tags_xpath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability of the views wizard to create views with sorts.
|
||||
*/
|
||||
class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard sorting functionality',
|
||||
@@ -492,12 +540,17 @@ class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper {
|
||||
$pos1 = strpos($content, $node1->title);
|
||||
$this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability of the views wizard to specify the number of items per page.
|
||||
* Tests the ability of the wizard to specify the number of items per page.
|
||||
*/
|
||||
class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard items per page functionality',
|
||||
@@ -577,12 +630,17 @@ class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper {
|
||||
$pos3 = strpos($content, $node3->title);
|
||||
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability of the views wizard to put views in a menu.
|
||||
*/
|
||||
class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard menu functionality',
|
||||
@@ -625,12 +683,17 @@ class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper {
|
||||
}
|
||||
$this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the ability of the views wizard to create views with a jump menu style plugin.
|
||||
* Tests the ability of the wizard to create views with a jump menu style.
|
||||
*/
|
||||
class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI wizard jump menu functionality',
|
||||
@@ -683,7 +746,6 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
// Submit the jump menu form, and check that we are redirected to the
|
||||
// expected URL.
|
||||
|
||||
$edit = array();
|
||||
$edit['jump'] = url($path, $options);
|
||||
|
||||
@@ -786,12 +848,17 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
|
||||
node_save($node);
|
||||
return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that displays can be correctly overridden via the user interface.
|
||||
*/
|
||||
class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views UI overridden displays',
|
||||
@@ -948,9 +1015,8 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper {
|
||||
* Tests that the revert to all displays select-option works as expected.
|
||||
*/
|
||||
function testRevertAllDisplays() {
|
||||
// Create a basic view with a page, block.
|
||||
// Because there is both a title on page and block we expect the title on
|
||||
// the block be overriden.
|
||||
// Create a basic view with a page, block. Because there is both a title on
|
||||
// page and block we expect the title on the block be overriden.
|
||||
$view['human_name'] = $this->randomName(16);
|
||||
$view['name'] = strtolower($this->randomName(16));
|
||||
$view['page[create]'] = 1;
|
||||
@@ -970,4 +1036,5 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper {
|
||||
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save'));
|
||||
$this->assertText($view['page[title]']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -11,6 +11,10 @@
|
||||
* You can find all conversions by searching for "moved to".
|
||||
*/
|
||||
class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Views Upgrade test',
|
||||
@@ -19,14 +23,21 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
// // To import a view the user needs use PHP for settings rights, so enable php module.
|
||||
// To import a view the user needs use PHP for settings rights, so enable
|
||||
// PHP module.
|
||||
parent::setUp();
|
||||
|
||||
module_enable(array('php'));
|
||||
$this->resetAll();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test']['old_field_1']['moved to'] = array('views_test', 'id');
|
||||
@@ -41,6 +52,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function debugField($field) {
|
||||
$keys = array('id', 'table', 'field', 'actual_field', 'original_field', 'real_field');
|
||||
$info = array();
|
||||
@@ -59,8 +73,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
$view->update();
|
||||
$view->build();
|
||||
|
||||
// $this->assertEqual('old_field_1', $view->field['old_field_1']->options['id'], "Id shouldn't change during conversion");
|
||||
// $this->assertEqual('id', $view->field['old_field_1']->field, 'The field should change during conversion');
|
||||
// $this->assertEqual('old_field_1',
|
||||
// $view->field['old_field_1']->options['id'],
|
||||
// "Id shouldn't change during conversion");
|
||||
// $this->assertEqual('id', $view->field['old_field_1']->field,
|
||||
// 'The field should change during conversion');
|
||||
$this->assertEqual('id', $view->field['old_field_1']->real_field);
|
||||
$this->assertEqual('views_test', $view->field['old_field_1']->table);
|
||||
$this->assertEqual('old_field_1', $view->field['old_field_1']->original_field, 'The field should have stored the original_field');
|
||||
@@ -70,11 +87,13 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
$view->update();
|
||||
$view->build();
|
||||
|
||||
// $this->assertEqual('old_field_2', $view->field['old_field_2']->options['id']);
|
||||
// $this->assertEqual('old_field_2',
|
||||
// $view->field['old_field_2']->options['id']);
|
||||
$this->assertEqual('name', $view->field['old_field_2']->real_field);
|
||||
$this->assertEqual('views_test', $view->field['old_field_2']->table);
|
||||
|
||||
// $this->assertEqual('old_field_3', $view->filter['old_field_3']->options['id']);
|
||||
// $this->assertEqual('old_field_3',
|
||||
// $view->filter['old_field_3']->options['id']);
|
||||
$this->assertEqual('age', $view->filter['old_field_3']->real_field);
|
||||
$this->assertEqual('views_test', $view->filter['old_field_3']->table);
|
||||
|
||||
@@ -84,7 +103,8 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
$view->build();
|
||||
|
||||
$this->assertEqual('views_test', $view->base_table, 'Make sure that view->base_table gets automatically converted.');
|
||||
// $this->assertEqual('id', $view->field['id']->field, 'If we move a whole table fields of this table should work, too.');
|
||||
// $this->assertEqual('id', $view->field['id']->field,
|
||||
// 'If we move a whole table fields of this table should work, too.');
|
||||
$this->assertEqual('id', $view->field['id']->real_field, 'To run the query right the real_field has to be set right.');
|
||||
$this->assertEqual('views_test', $view->field['id']->table);
|
||||
}
|
||||
@@ -106,8 +126,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
$this->assertText('Recent comments');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsMovedToField() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_views_move_to_field';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -127,8 +150,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsMovedToHandler() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_views_move_to_handler';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -152,8 +178,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function viewsMovedToTable() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_views_move_to_table';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -173,6 +202,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function viewUpgradeImport() {
|
||||
$import = '
|
||||
$view = new view;
|
||||
@@ -272,6 +304,7 @@ class ViewsUpgradeTestCase extends ViewsSqlTest {
|
||||
$handler->display->display_options["block_description"] = "Recent comments view"
|
||||
;';
|
||||
|
||||
return $import;
|
||||
return $import;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,26 +2,27 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of ViewsViewTest.
|
||||
* Views class tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Views class tests.
|
||||
*
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class ViewsViewTest extends ViewsSqlTest {
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
/**
|
||||
* Provide the test's meta information.
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Test the view class',
|
||||
'description' => 'Tests some functionality of the view class',
|
||||
'description' => 'Tests some functionality of the view class',
|
||||
'group' => 'Views',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the deconstructor to be sure that every kind of heavy objects are removed.
|
||||
* Ensure that every kind of heavy objects are removed by the destructor.
|
||||
*/
|
||||
function testDestroy() {
|
||||
$view = $this->view_test_destroy();
|
||||
@@ -39,6 +40,12 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
$this->assertViewDestroy($view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that a given view is destroyed properly.
|
||||
*
|
||||
* @param object $view
|
||||
* The view to destroy.
|
||||
*/
|
||||
function assertViewDestroy($view) {
|
||||
$this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.');
|
||||
$this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.');
|
||||
@@ -61,8 +68,11 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
$this->assertEqual($view->attachment_after, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting a view.
|
||||
*/
|
||||
function testDelete() {
|
||||
// Delete a database view
|
||||
// Delete a database view.
|
||||
$view = $this->view_test_delete();
|
||||
$view->save();
|
||||
$view = views_get_view($view->name);
|
||||
@@ -75,10 +85,13 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
$this->assertNull($view, "Make sure that the old view gets cleared by the reset parameter.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validation.
|
||||
*/
|
||||
function testValidate() {
|
||||
// Test a view with multiple displays.
|
||||
// Validating a view shouldn't change the active display.
|
||||
// @todo: Create an extra validation view.
|
||||
// @todo Create an extra validation view.
|
||||
$view = $this->view_test_destroy();
|
||||
$view->set_display('page_1');
|
||||
|
||||
@@ -86,17 +99,20 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
|
||||
$this->assertEqual('page_1', $view->current_display, "The display should be constant while validating");
|
||||
|
||||
// @todo: Write real tests for the validation.
|
||||
// @todo Write real tests for the validation.
|
||||
// In general the following things could be tested:
|
||||
// - Deleted displays shouldn't be validated
|
||||
// - Deleted displays shouldn't be validated.
|
||||
// - Multiple displays are validating and the errors are merged together.
|
||||
}
|
||||
|
||||
/**
|
||||
* This view provides some filters, fields, arguments, relationships, sorts, areas and attachments.
|
||||
* Generate an example view.
|
||||
*
|
||||
* Includes:
|
||||
* filters, fields, arguments, relationships, sorts, areas and attachments.
|
||||
*/
|
||||
function view_test_destroy() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_destroy';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -257,8 +273,12 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a test view.
|
||||
*/
|
||||
function view_test_delete() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'test_view_delete';
|
||||
$view->description = '';
|
||||
$view->tag = '';
|
||||
@@ -294,4 +314,5 @@ class ViewsViewTest extends ViewsSqlTest {
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user