- <?php
- * @file
- * Definition of CommentViewsHandlerArgumentUserUidTest.
- */
-
- require_once BACKDROP_ROOT . '/core/modules/views/tests/views_query.test';
-
- * Tests the argument_comment_user_uid handler.
- */
- class CommentViewsHandlerArgumentUserUidTest extends ViewsSqlTest {
- protected $profile = 'testing';
-
-
- * @var User
- */
- protected $account;
-
-
- * @var Node
- */
- protected $node_user_posted;
-
-
- * @var Node
- */
- protected $node_user_commented;
-
-
- * @var array
- */
- protected $column_map;
-
-
- * Post comment.
- *
- * @param object $node
- * Node to post comment on.
- * @param array $comment
- * Comment to save.
- */
- public function postComment($node, $comment = array()) {
- $comment += array(
- 'uid' => $this->loggedInUser->uid,
- 'nid' => $node->nid,
- 'cid' => NULL,
-
-
- 'pid' => 0,
- );
- $comment = entity_create('comment', $comment);
- return comment_save($comment);
- }
-
- protected function setUp(array $modules = array()) {
- $modules[] = 'comment';
- parent::setUp($modules);
-
-
- $this->backdropCreateContentType(array(
- 'type' => 'post',
- 'name' => 'Post',
- 'settings' => array(
- 'comment_default' => COMMENT_NODE_OPEN,
- ),
- 'is_new' => TRUE,
- ));
- user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, array(
- 'access content',
- 'access comments',
- 'post comments',
- 'skip comment approval',
- ));
-
-
-
- $this->account = $this->backdropCreateUser();
- $account2 = $this->backdropCreateUser();
- $this->backdropLogin($this->account);
- $this->node_user_posted = $this->backdropCreateNode();
- $this->node_user_commented = $this->backdropCreateNode(array(
- 'type' => 'post',
- 'uid' => $account2->uid,
- ));
- $this->postComment($this->node_user_commented);
- }
-
- function testCommentUserUidTest() {
- $view = $this->view_comment_user_uid();
-
-
- $this->executeView($view, array($this->account->uid));
- $resultset = array(
- array(
- 'nid' => $this->node_user_posted->nid,
- ),
- array(
- 'nid' => $this->node_user_commented->nid,
- ),
- );
- $this->column_map = array('nid' => 'nid');
- debug($view->result);
- $this->assertIdenticalResultset($view, $resultset, $this->column_map);
- }
-
- function view_comment_user_uid() {
- $view = new view;
- $view->name = 'test_comment_user_uid';
- $view->description = '';
- $view->tag = 'default';
- $view->base_table = 'node';
- $view->human_name = 'test_comment_user_uid';
- $view->core = 7;
- $view->api_version = '3.0';
- $view->disabled = FALSE;
-
-
- $handler = $view->new_display('default', 'Default', 'default');
- $handler->display->display_options['access']['type'] = 'perm';
- $handler->display->display_options['cache']['type'] = 'none';
- $handler->display->display_options['query']['type'] = 'views_query';
- $handler->display->display_options['query']['options']['query_comment'] = FALSE;
- $handler->display->display_options['exposed_form']['type'] = 'basic';
- $handler->display->display_options['pager']['type'] = 'full';
- $handler->display->display_options['style_plugin'] = 'default';
- $handler->display->display_options['row_plugin'] = 'node';
-
- $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['arguments']['uid_touch']['id'] = 'uid_touch';
- $handler->display->display_options['arguments']['uid_touch']['table'] = 'node';
- $handler->display->display_options['arguments']['uid_touch']['field'] = 'uid_touch';
- $handler->display->display_options['arguments']['uid_touch']['default_argument_type'] = 'fixed';
- $handler->display->display_options['arguments']['uid_touch']['default_argument_skip_url'] = 0;
- $handler->display->display_options['arguments']['uid_touch']['summary']['number_of_records'] = '0';
- $handler->display->display_options['arguments']['uid_touch']['summary']['format'] = 'default_summary';
- $handler->display->display_options['arguments']['uid_touch']['summary_options']['items_per_page'] = '25';
-
- return $view;
- }
- }