1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of viewsHandlerArgumentCommentUserUidTest.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Tests the argument_comment_user_uid handler.
|
10 |
|
|
*/
|
11 |
|
|
class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Tests handler argument_comment_user_uid',
|
15 |
|
|
'description' => 'Tests the user posted or commented argument handler',
|
16 |
|
|
'group' => 'Views Modules',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
/**
|
21 |
|
|
* Post comment.
|
22 |
|
|
*
|
23 |
5d12d676
|
Assos Assos
|
* @param object $node
|
24 |
85ad3d82
|
Assos Assos
|
* Node to post comment on.
|
25 |
5d12d676
|
Assos Assos
|
* @param array $comment
|
26 |
|
|
* Comment to save.
|
27 |
85ad3d82
|
Assos Assos
|
*/
|
28 |
|
|
function postComment($node, $comment = array()) {
|
29 |
|
|
$comment += array(
|
30 |
|
|
'uid' => $this->loggedInUser->uid,
|
31 |
|
|
'nid' => $node->nid,
|
32 |
|
|
'cid' => '',
|
33 |
|
|
'pid' => '',
|
34 |
|
|
);
|
35 |
|
|
return comment_save((object) $comment);
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
function setUp() {
|
39 |
|
|
parent::setUp();
|
40 |
|
|
|
41 |
5d12d676
|
Assos Assos
|
// Add two users, create a node with the user1 as author and another node
|
42 |
|
|
// with user2 as author. For the second node add a comment from user1.
|
43 |
85ad3d82
|
Assos Assos
|
$this->account = $this->drupalCreateUser();
|
44 |
|
|
$this->account2 = $this->drupalCreateUser();
|
45 |
|
|
$this->drupalLogin($this->account);
|
46 |
|
|
$this->node_user_posted = $this->drupalCreateNode();
|
47 |
|
|
$this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->uid));
|
48 |
|
|
$this->postComment($this->node_user_commented);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
function testCommentUserUidTest() {
|
52 |
|
|
$view = $this->view_comment_user_uid();
|
53 |
|
|
|
54 |
|
|
$this->executeView($view, array($this->account->uid));
|
55 |
|
|
$resultset = array(
|
56 |
|
|
array(
|
57 |
|
|
'nid' => $this->node_user_posted->nid,
|
58 |
|
|
),
|
59 |
|
|
array(
|
60 |
|
|
'nid' => $this->node_user_commented->nid,
|
61 |
|
|
),
|
62 |
|
|
);
|
63 |
|
|
$this->column_map = array('nid' => 'nid');
|
64 |
|
|
debug($view->result);
|
65 |
|
|
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
function view_comment_user_uid() {
|
69 |
5d12d676
|
Assos Assos
|
$view = new view();
|
70 |
85ad3d82
|
Assos Assos
|
$view->name = 'test_comment_user_uid';
|
71 |
|
|
$view->description = '';
|
72 |
|
|
$view->tag = 'default';
|
73 |
|
|
$view->base_table = 'node';
|
74 |
|
|
$view->human_name = 'test_comment_user_uid';
|
75 |
|
|
$view->core = 7;
|
76 |
|
|
$view->api_version = '3.0';
|
77 |
|
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
78 |
|
|
|
79 |
|
|
/* Display: Master */
|
80 |
|
|
$handler = $view->new_display('default', 'Master', 'default');
|
81 |
|
|
$handler->display->display_options['access']['type'] = 'perm';
|
82 |
|
|
$handler->display->display_options['cache']['type'] = 'none';
|
83 |
|
|
$handler->display->display_options['query']['type'] = 'views_query';
|
84 |
|
|
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
|
85 |
|
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
86 |
|
|
$handler->display->display_options['pager']['type'] = 'full';
|
87 |
|
|
$handler->display->display_options['style_plugin'] = 'default';
|
88 |
|
|
$handler->display->display_options['row_plugin'] = 'node';
|
89 |
|
|
/* Field: Content: nid */
|
90 |
|
|
$handler->display->display_options['fields']['nid']['id'] = 'nid';
|
91 |
|
|
$handler->display->display_options['fields']['nid']['table'] = 'node';
|
92 |
|
|
$handler->display->display_options['fields']['nid']['field'] = 'nid';
|
93 |
|
|
/* Contextual filter: Content: User posted or commented */
|
94 |
|
|
$handler->display->display_options['arguments']['uid_touch']['id'] = 'uid_touch';
|
95 |
|
|
$handler->display->display_options['arguments']['uid_touch']['table'] = 'node';
|
96 |
|
|
$handler->display->display_options['arguments']['uid_touch']['field'] = 'uid_touch';
|
97 |
|
|
$handler->display->display_options['arguments']['uid_touch']['default_argument_type'] = 'fixed';
|
98 |
|
|
$handler->display->display_options['arguments']['uid_touch']['default_argument_skip_url'] = 0;
|
99 |
|
|
$handler->display->display_options['arguments']['uid_touch']['summary']['number_of_records'] = '0';
|
100 |
|
|
$handler->display->display_options['arguments']['uid_touch']['summary']['format'] = 'default_summary';
|
101 |
|
|
$handler->display->display_options['arguments']['uid_touch']['summary_options']['items_per_page'] = '25';
|
102 |
|
|
|
103 |
|
|
return $view;
|
104 |
|
|
}
|
105 |
5d12d676
|
Assos Assos
|
|
106 |
85ad3d82
|
Assos Assos
|
} |