Projet

Général

Profil

Paste
Télécharger (3,97 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / tests / comment / views_handler_argument_comment_user_uid.test @ 4003efde

1
<?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
   * @param object $node
24
   *   Node to post comment on.
25
   * @param array $comment
26
   *   Comment to save.
27
   */
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
  /**
39
   * {@inheritdoc}
40
   */
41
  public function setUp(array $modules = array()) {
42
    parent::setUp($modules);
43

    
44
    // Add two users, create a node with the user1 as author and another node
45
    // with user2 as author. For the second node add a comment from user1.
46
    $this->account = $this->drupalCreateUser();
47
    $this->account2 = $this->drupalCreateUser();
48
    $this->drupalLogin($this->account);
49
    $this->node_user_posted = $this->drupalCreateNode();
50
    $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->uid));
51
    $this->postComment($this->node_user_commented);
52
  }
53

    
54
  function testCommentUserUidTest() {
55
    $view = $this->view_comment_user_uid();
56

    
57
    $this->executeView($view, array($this->account->uid));
58
    $resultset = array(
59
      array(
60
        'nid' => $this->node_user_posted->nid,
61
      ),
62
      array(
63
        'nid' => $this->node_user_commented->nid,
64
      ),
65
    );
66
    $this->column_map = array('nid' => 'nid');
67
    debug($view->result);
68
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
69
  }
70

    
71
  function view_comment_user_uid() {
72
    $view = new view();
73
    $view->name = 'test_comment_user_uid';
74
    $view->description = '';
75
    $view->tag = 'default';
76
    $view->base_table = 'node';
77
    $view->human_name = 'test_comment_user_uid';
78
    $view->core = 7;
79
    $view->api_version = '3.0';
80
    $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
81

    
82
    /* Display: Master */
83
    $handler = $view->new_display('default', 'Master', 'default');
84
    $handler->display->display_options['access']['type'] = 'perm';
85
    $handler->display->display_options['cache']['type'] = 'none';
86
    $handler->display->display_options['query']['type'] = 'views_query';
87
    $handler->display->display_options['query']['options']['query_comment'] = FALSE;
88
    $handler->display->display_options['exposed_form']['type'] = 'basic';
89
    $handler->display->display_options['pager']['type'] = 'full';
90
    $handler->display->display_options['style_plugin'] = 'default';
91
    $handler->display->display_options['row_plugin'] = 'node';
92
    /* Field: Content: nid */
93
    $handler->display->display_options['fields']['nid']['id'] = 'nid';
94
    $handler->display->display_options['fields']['nid']['table'] = 'node';
95
    $handler->display->display_options['fields']['nid']['field'] = 'nid';
96
    /* Contextual filter: Content: User posted or commented */
97
    $handler->display->display_options['arguments']['uid_touch']['id'] = 'uid_touch';
98
    $handler->display->display_options['arguments']['uid_touch']['table'] = 'node';
99
    $handler->display->display_options['arguments']['uid_touch']['field'] = 'uid_touch';
100
    $handler->display->display_options['arguments']['uid_touch']['default_argument_type'] = 'fixed';
101
    $handler->display->display_options['arguments']['uid_touch']['default_argument_skip_url'] = 0;
102
    $handler->display->display_options['arguments']['uid_touch']['summary']['number_of_records'] = '0';
103
    $handler->display->display_options['arguments']['uid_touch']['summary']['format'] = 'default_summary';
104
    $handler->display->display_options['arguments']['uid_touch']['summary_options']['items_per_page'] = '25';
105

    
106
    return $view;
107
  }
108

    
109
}