views_user.test 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * @file
  4. * Definition of ViewsUserTestCase.
  5. */
  6. /**
  7. * Tests basic user module integration into views.
  8. */
  9. class ViewsUserTestCase extends ViewsSqlTest {
  10. /**
  11. *
  12. */
  13. var $users = array();
  14. /**
  15. *
  16. */
  17. var $nodes = array();
  18. /**
  19. *
  20. */
  21. public static function getInfo() {
  22. return array(
  23. 'name' => 'Tests basic user integration',
  24. 'description' => 'Tests the integration of user module',
  25. 'group' => 'Views Modules',
  26. );
  27. }
  28. /**
  29. *
  30. */
  31. protected function setUp() {
  32. parent::setUp();
  33. $this->users[] = $this->drupalCreateUser();
  34. $this->users[] = user_load(1);
  35. $this->nodes[] = $this->drupalCreateNode(array('uid' => $this->users[0]->uid));
  36. $this->nodes[] = $this->drupalCreateNode(array('uid' => 1));
  37. }
  38. /**
  39. * Add a view which has no explicit relationship to the author.
  40. *
  41. * @todo: Remove the following comment once the relationship is required.
  42. * One day a view will require the relationship so it should still work
  43. */
  44. public function testRelationship() {
  45. $view = $this->test_view_user_relationship();
  46. $view->execute_display();
  47. $expected = array();
  48. for ($i = 0; $i <= 1; $i++) {
  49. $expected[$i] = array(
  50. 'node_title' => $this->nodes[$i]->title,
  51. 'users_uid' => $this->nodes[$i]->uid,
  52. 'users_name' => $this->users[$i]->name,
  53. );
  54. }
  55. $this->assertIdenticalResultset($view, $expected);
  56. }
  57. /**
  58. *
  59. */
  60. function test_view_user_relationship() {
  61. $view = new view();
  62. $view->name = 'test_user_relationship';
  63. $view->description = '';
  64. $view->tag = 'default';
  65. $view->base_table = 'node';
  66. $view->human_name = 'test_user_relationship';
  67. $view->core = 7;
  68. $view->api_version = '3.0-alpha1';
  69. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  70. /* Display: Master */
  71. $handler = $view->new_display('default', 'Master', 'default');
  72. $handler->display->display_options['title'] = 'test_user_relationship';
  73. $handler->display->display_options['access']['type'] = 'perm';
  74. $handler->display->display_options['cache']['type'] = 'none';
  75. $handler->display->display_options['query']['type'] = 'views_query';
  76. $handler->display->display_options['query']['options']['query_comment'] = FALSE;
  77. $handler->display->display_options['exposed_form']['type'] = 'basic';
  78. $handler->display->display_options['pager']['type'] = 'full';
  79. $handler->display->display_options['pager']['options']['items_per_page'] = '10';
  80. $handler->display->display_options['style_plugin'] = 'default';
  81. $handler->display->display_options['row_plugin'] = 'fields';
  82. $handler->display->display_options['row_options']['hide_empty'] = 0;
  83. $handler->display->display_options['row_options']['default_field_elements'] = 1;
  84. /* Field: Content: Title */
  85. $handler->display->display_options['fields']['title']['id'] = 'title';
  86. $handler->display->display_options['fields']['title']['table'] = 'node';
  87. $handler->display->display_options['fields']['title']['field'] = 'title';
  88. $handler->display->display_options['fields']['title']['label'] = '';
  89. $handler->display->display_options['fields']['title']['alter']['alter_text'] = 0;
  90. $handler->display->display_options['fields']['title']['alter']['make_link'] = 0;
  91. $handler->display->display_options['fields']['title']['alter']['absolute'] = 0;
  92. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = 0;
  93. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = 0;
  94. $handler->display->display_options['fields']['title']['alter']['strip_tags'] = 0;
  95. $handler->display->display_options['fields']['title']['alter']['trim'] = 0;
  96. $handler->display->display_options['fields']['title']['alter']['html'] = 0;
  97. $handler->display->display_options['fields']['title']['hide_empty'] = 0;
  98. $handler->display->display_options['fields']['title']['empty_zero'] = 0;
  99. $handler->display->display_options['fields']['title']['link_to_node'] = 1;
  100. /* Field: User: Name */
  101. $handler->display->display_options['fields']['name']['id'] = 'name';
  102. $handler->display->display_options['fields']['name']['table'] = 'users';
  103. $handler->display->display_options['fields']['name']['field'] = 'name';
  104. $handler->display->display_options['fields']['name']['alter']['alter_text'] = 0;
  105. $handler->display->display_options['fields']['name']['alter']['make_link'] = 0;
  106. $handler->display->display_options['fields']['name']['alter']['absolute'] = 0;
  107. $handler->display->display_options['fields']['name']['alter']['external'] = 0;
  108. $handler->display->display_options['fields']['name']['alter']['replace_spaces'] = 0;
  109. $handler->display->display_options['fields']['name']['alter']['trim_whitespace'] = 0;
  110. $handler->display->display_options['fields']['name']['alter']['nl2br'] = 0;
  111. $handler->display->display_options['fields']['name']['alter']['word_boundary'] = 1;
  112. $handler->display->display_options['fields']['name']['alter']['ellipsis'] = 1;
  113. $handler->display->display_options['fields']['name']['alter']['strip_tags'] = 0;
  114. $handler->display->display_options['fields']['name']['alter']['trim'] = 0;
  115. $handler->display->display_options['fields']['name']['alter']['html'] = 0;
  116. $handler->display->display_options['fields']['name']['element_label_colon'] = 1;
  117. $handler->display->display_options['fields']['name']['element_default_classes'] = 1;
  118. $handler->display->display_options['fields']['name']['hide_empty'] = 0;
  119. $handler->display->display_options['fields']['name']['empty_zero'] = 0;
  120. $handler->display->display_options['fields']['name']['hide_alter_empty'] = 0;
  121. $handler->display->display_options['fields']['name']['link_to_user'] = 1;
  122. $handler->display->display_options['fields']['name']['overwrite_anonymous'] = 0;
  123. /* Field: User: Uid */
  124. $handler->display->display_options['fields']['uid']['id'] = 'uid';
  125. $handler->display->display_options['fields']['uid']['table'] = 'users';
  126. $handler->display->display_options['fields']['uid']['field'] = 'uid';
  127. $handler->display->display_options['fields']['uid']['alter']['alter_text'] = 0;
  128. $handler->display->display_options['fields']['uid']['alter']['make_link'] = 0;
  129. $handler->display->display_options['fields']['uid']['alter']['absolute'] = 0;
  130. $handler->display->display_options['fields']['uid']['alter']['external'] = 0;
  131. $handler->display->display_options['fields']['uid']['alter']['replace_spaces'] = 0;
  132. $handler->display->display_options['fields']['uid']['alter']['trim_whitespace'] = 0;
  133. $handler->display->display_options['fields']['uid']['alter']['nl2br'] = 0;
  134. $handler->display->display_options['fields']['uid']['alter']['word_boundary'] = 1;
  135. $handler->display->display_options['fields']['uid']['alter']['ellipsis'] = 1;
  136. $handler->display->display_options['fields']['uid']['alter']['strip_tags'] = 0;
  137. $handler->display->display_options['fields']['uid']['alter']['trim'] = 0;
  138. $handler->display->display_options['fields']['uid']['alter']['html'] = 0;
  139. $handler->display->display_options['fields']['uid']['element_label_colon'] = 1;
  140. $handler->display->display_options['fields']['uid']['element_default_classes'] = 1;
  141. $handler->display->display_options['fields']['uid']['hide_empty'] = 0;
  142. $handler->display->display_options['fields']['uid']['empty_zero'] = 0;
  143. $handler->display->display_options['fields']['uid']['hide_alter_empty'] = 0;
  144. $handler->display->display_options['fields']['uid']['link_to_user'] = 1;
  145. return $view;
  146. }
  147. }