updated contrib modules
This commit is contained in:
@@ -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 = '';
|
||||
|
Reference in New Issue
Block a user