views_handler_manytoone.test 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. <?php
  2. /**
  3. * Tests the many to one helper handler class.
  4. */
  5. class ViewsHandlerManyToOneTest extends ViewsSqlTest {
  6. /**
  7. * Field definitions used by this test.
  8. *
  9. * @var array
  10. */
  11. protected $fields;
  12. /**
  13. * Instances of fields used by this test.
  14. *
  15. * @var array
  16. */
  17. protected $instances;
  18. /**
  19. * Nodes used by this test.
  20. *
  21. * @var object[]
  22. */
  23. protected $nodes;
  24. /**
  25. * Accounts used by this test.
  26. *
  27. * @var object[]
  28. */
  29. protected $accounts;
  30. /**
  31. * Terms used by this test.
  32. *
  33. * @var object[]
  34. */
  35. protected $terms;
  36. /**
  37. * Provide the test's meta information.
  38. */
  39. public static function getInfo() {
  40. return array(
  41. 'name' => 'Handler: Many To One Helper',
  42. 'description' => 'Tests the many to one helper handler',
  43. 'group' => 'Views Handlers',
  44. );
  45. }
  46. /**
  47. * Clears views data cache.
  48. */
  49. protected function clearViewsDataCache() {
  50. drupal_static_reset('_views_fetch_data_cache');
  51. drupal_static_reset('_views_fetch_data_recursion_protected');
  52. drupal_static_reset('_views_fetch_data_fully_loaded');
  53. }
  54. /**
  55. * Returns a new term with random properties.
  56. *
  57. * @param string $vocabulary
  58. * Vocabulary ID to create term in.
  59. *
  60. * @return object
  61. * Term with random properties.
  62. */
  63. protected function createTerm($vocabulary) {
  64. $term = new stdClass();
  65. $term->name = $this->randomName();
  66. $term->description = $this->randomName();
  67. // Use the first available text format.
  68. $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField();
  69. $term->vid = $vocabulary->vid;
  70. taxonomy_term_save($term);
  71. return $term;
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function setUp() {
  77. parent::setUp();
  78. // Create boolean field.
  79. $this->fields[0] = array(
  80. 'field_name' => 'field_bool',
  81. 'type' => 'list_boolean',
  82. 'cardinality' => 1,
  83. 'settings' => array(
  84. 'allowed_values' => array(
  85. 0 => '',
  86. 1 => '',
  87. ),
  88. ),
  89. );
  90. $this->fields[0] = field_create_field($this->fields[0]);
  91. // Create text list field.
  92. $this->fields[1] = array(
  93. 'field_name' => 'field_list',
  94. 'type' => 'list_text',
  95. 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
  96. 'settings' => array(
  97. 'allowed_values' => array(
  98. 1 => '1',
  99. 2 => '2',
  100. 3 => '3',
  101. ),
  102. ),
  103. );
  104. $this->fields[1] = field_create_field($this->fields[1]);
  105. // Create boolean field instance for article nodes.
  106. $instance = array(
  107. 'field_name' => $this->fields[0]['field_name'],
  108. 'entity_type' => 'node',
  109. 'bundle' => 'article',
  110. 'widget' => array(
  111. 'type' => 'options_onoff',
  112. ),
  113. );
  114. $this->instances[0][] = field_create_instance($instance);
  115. // Create text list field instance for article nodes.
  116. $instance = array(
  117. 'field_name' => $this->fields[1]['field_name'],
  118. 'entity_type' => 'node',
  119. 'bundle' => 'article',
  120. 'widget' => array(
  121. 'type' => 'options_buttons',
  122. ),
  123. );
  124. $this->instances[1][] = field_create_instance($instance);
  125. // Create boolean field instance for users.
  126. $instance = array(
  127. 'field_name' => $this->fields[0]['field_name'],
  128. 'entity_type' => 'user',
  129. 'bundle' => 'user',
  130. 'widget' => array(
  131. 'type' => 'options_onoff',
  132. ),
  133. );
  134. $this->instances[0][] = field_create_instance($instance);
  135. // Create text list field instance for users.
  136. $instance = array(
  137. 'field_name' => $this->fields[1]['field_name'],
  138. 'entity_type' => 'user',
  139. 'bundle' => 'user',
  140. 'widget' => array(
  141. 'type' => 'options_buttons',
  142. ),
  143. );
  144. $this->instances[1][] = field_create_instance($instance);
  145. // Create tags field instance for users.
  146. $instance = array(
  147. 'field_name' => 'field_tags',
  148. 'entity_type' => 'user',
  149. 'bundle' => 'user',
  150. );
  151. $this->instances[2][] = field_create_instance($instance);
  152. // Clear views data cache.
  153. $this->clearViewsDataCache();
  154. // Create 62 tags.
  155. $vocabulary = taxonomy_vocabulary_machine_name_load('tags');
  156. for ($i = 0; $i < 62; $i++) {
  157. $this->terms[] = $this->createTerm($vocabulary);
  158. }
  159. // Create a node where the field_bool is checked, field_list is '1' and
  160. // tag is term 2.
  161. $node = array();
  162. $node['type'] = 'article';
  163. $node[$this->fields[0]['field_name']][LANGUAGE_NONE][]['value'] = '1';
  164. $node[$this->fields[1]['field_name']][LANGUAGE_NONE][]['value'] = '1';
  165. $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid;
  166. $this->nodes[0] = $this->drupalCreateNode($node);
  167. // Create a node where the field_bool is not checked, field_list is empty
  168. // and tag is term 1.
  169. $node = array();
  170. $node['type'] = 'article';
  171. $node[$this->fields[0]['field_name']] = array();
  172. $node[$this->fields[1]['field_name']] = array();
  173. $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
  174. $this->nodes[1] = $this->drupalCreateNode($node);
  175. // Create a node where the field_bool is not checked, field_list is empty
  176. // and tag is term 1 and 2.
  177. $node = array();
  178. $node['type'] = 'article';
  179. $node[$this->fields[0]['field_name']] = array();
  180. $node[$this->fields[1]['field_name']] = array();
  181. $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
  182. $node['field_tags'][LANGUAGE_NONE][]['tid'] = $this->terms[1]->tid;
  183. $this->nodes[2] = $this->drupalCreateNode($node);
  184. // Create a user where field_bool is checked, field_list is '1' and tag is
  185. // term 1.
  186. $permissions = array('access content');
  187. $account = $this->drupalCreateUser($permissions);
  188. $account->{$this->fields[0]['field_name']}[LANGUAGE_NONE][]['value'] = '1';
  189. $account->{$this->fields[1]['field_name']}[LANGUAGE_NONE][]['value'] = '1';
  190. $account->field_tags[LANGUAGE_NONE][]['tid'] = $this->terms[0]->tid;
  191. $this->accounts[0] = user_save($account);
  192. }
  193. /**
  194. * Tests "none of" filter with terms in excess of JOIN limit selected.
  195. */
  196. public function testJoinLimitNoneOf() {
  197. $view = $this->getJoinLimitNoneOfTestView();
  198. $this->executeView($view);
  199. // Assert that nodes have been created and have expected field values.
  200. $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE);
  201. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  202. $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.');
  203. $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE);
  204. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  205. $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.');
  206. // Assert that user has been created and has expected field values.
  207. $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE);
  208. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  209. $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.');
  210. // Assert that node id with empty field value matches user id so that the
  211. // node would be excluded from the result, if the joins are missing extras.
  212. $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node id of second node matches uid of first user.');
  213. // Assert correct result set.
  214. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  215. $this->assertEqual($result_count, 1, 'View has one result.');
  216. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  217. $this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'View result has correct node id.');
  218. }
  219. /**
  220. * Tests duplicate grouped "none of" filters on boolean field.
  221. */
  222. public function testGroupedNoneOf() {
  223. $view = $this->getGroupedNoneOfTestView();
  224. $this->executeView($view);
  225. // Assert that nodes have been created and have expected field values.
  226. $value = field_get_items('node', $this->nodes[0], $this->fields[0]['field_name'], LANGUAGE_NONE);
  227. $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
  228. $this->assertIdentical($value, 1, 'First node has been created and boolean field is checked.');
  229. $value = field_get_items('node', $this->nodes[1], $this->fields[0]['field_name'], LANGUAGE_NONE);
  230. $this->assertFalse($value, 'Second node has been created and boolean field is not checked.');
  231. $value = field_get_items('node', $this->nodes[2], $this->fields[0]['field_name'], LANGUAGE_NONE);
  232. $this->assertFalse($value, 'Third node has been created and boolean field is not checked.');
  233. // Assert that user has been created and has expected field values.
  234. $value = field_get_items('user', $this->accounts[0], $this->fields[0]['field_name'], LANGUAGE_NONE);
  235. $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
  236. $this->assertIdentical($value, 1, 'User has been created and boolean field is checked.');
  237. // Assert that node ID with empty field value matches user ID so that the
  238. // node would be excluded from the result, if the joins are missing extras.
  239. $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.');
  240. // Assert correct result set.
  241. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  242. $this->assertEqual($result_count, 2, 'View has two results.');
  243. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  244. $result1 = ($nid === (int) $this->nodes[1]->nid);
  245. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  246. $result2 = ($nid === (int) $this->nodes[2]->nid);
  247. $this->assertTrue($result1 && $result2, 'View result has correct node IDs.');
  248. }
  249. /**
  250. * Tests duplicate grouped "one of" filters on taxonomy term field.
  251. */
  252. public function testGroupedOneOf() {
  253. $view = $this->getGroupedOneOfTestView();
  254. $this->executeView($view);
  255. // Assert that nodes have been created and have expected field values.
  256. $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE);
  257. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  258. $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.');
  259. $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE);
  260. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  261. $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.');
  262. $value = field_get_items('node', $this->nodes[2], 'field_tags', LANGUAGE_NONE);
  263. $value = !empty($value[0]['tid']) && !empty($value[1]['tid']);
  264. $this->assertTrue($value, 'Third node has been created and tags field references both terms 1 and 2.');
  265. // Assert that user has been created and has expected field values.
  266. $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE);
  267. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  268. $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.');
  269. // Assert that node ID with empty field value matches user ID so that the
  270. // node would be excluded from the result, if the joins are missing extras.
  271. $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.');
  272. // Assert correct result set.
  273. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  274. $this->assertEqual($result_count, 2, 'View has two results.');
  275. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  276. $result1 = ($nid === (int) $this->nodes[1]->nid);
  277. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  278. $result2 = ($nid === (int) $this->nodes[2]->nid);
  279. $this->assertTrue($result1 && $result2, 'View result has correct node IDs.');
  280. }
  281. /**
  282. * Tests exposed filter with "Reduce duplicates." and grouped options.
  283. */
  284. public function testReducedExposedGroupedOptions() {
  285. // Assert that nodes have been created and have expected field values.
  286. $value = field_get_items('node', $this->nodes[0], 'field_list', LANGUAGE_NONE);
  287. $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
  288. $this->assertIdentical($value, 1, 'First node has been created and list field has value 1.');
  289. $value = field_get_items('node', $this->nodes[1], 'field_list', LANGUAGE_NONE);
  290. $this->assertFalse($value, 'Second node has been created and list field is empty.');
  291. $value = field_get_items('node', $this->nodes[2], 'field_list', LANGUAGE_NONE);
  292. $this->assertFalse($value, 'Third node has been created and list field is empty.');
  293. // Assert that user has been created and has expected field values.
  294. $value = field_get_items('user', $this->accounts[0], 'field_list', LANGUAGE_NONE);
  295. $value = isset($value[0]['value']) ? (int) $value[0]['value'] : 0;
  296. $this->assertIdentical($value, 1, 'User has been created and list field has value 1.');
  297. // Assert that node ID with empty field value matches user ID so that the
  298. // node would be excluded from the result option 1, if the joins are missing
  299. // extras.
  300. $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.');
  301. // Default option: Any.
  302. $view = $this->getReducedExposedGroupedOptionsTestView();
  303. $this->executeView($view);
  304. // Assert correct result set.
  305. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  306. $this->assertEqual($result_count, 3, 'Default option: View has three results.');
  307. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  308. $result1 = ($nid === (int) $this->nodes[0]->nid);
  309. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  310. $result2 = ($nid === (int) $this->nodes[1]->nid);
  311. $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
  312. $result3 = ($nid === (int) $this->nodes[2]->nid);
  313. $this->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.');
  314. // Option 1: Is none of 1 or 2.
  315. $view = $this->getReducedExposedGroupedOptionsTestView();
  316. $view->set_exposed_input(array(
  317. 'field_list_value' => '1',
  318. ));
  319. $this->executeView($view);
  320. // Assert correct result set.
  321. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  322. $this->assertEqual($result_count, 2, 'Option 1: View has two results.');
  323. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  324. $result1 = ($nid === (int) $this->nodes[1]->nid);
  325. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  326. $result2 = ($nid === (int) $this->nodes[2]->nid);
  327. $this->assertTrue($result1 && $result2, 'Option 1: View result has correct node ID.');
  328. // Option 2: Is one of 1.
  329. $view = $this->getReducedExposedGroupedOptionsTestView();
  330. $view->set_exposed_input(array(
  331. 'field_list_value' => '2',
  332. ));
  333. $this->executeView($view);
  334. // Assert correct result set.
  335. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  336. $this->assertEqual($result_count, 1, 'Option 2: View has one result.');
  337. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  338. $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 2: View result has correct node ID.');
  339. // Option 3: Is one of 1 or 2.
  340. $view = $this->getReducedExposedGroupedOptionsTestView();
  341. $view->set_exposed_input(array(
  342. 'field_list_value' => '3',
  343. ));
  344. $this->executeView($view);
  345. // Assert correct result set.
  346. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  347. $this->assertEqual($result_count, 1, 'Option 3: View has one result.');
  348. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  349. $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 3: View result has correct node ID.');
  350. /* @todo: Fix and uncomment in issue #3045168.
  351. * // Option 4: Is all of 1 and 2.
  352. * $view = $this->getReducedExposedGroupedOptionsTestView();
  353. * $view->set_exposed_input(array(
  354. * 'field_list_value' => '4',
  355. * ));
  356. * $this->executeView($view);
  357. *
  358. * // Assert correct result set.
  359. * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
  360. * $this->assertEqual($result_count, 0, 'Option 4: View has empty result.');
  361. */
  362. // Option 5: Is empty.
  363. $view = $this->getReducedExposedGroupedOptionsTestView();
  364. $view->set_exposed_input(array(
  365. 'field_list_value' => '5',
  366. ));
  367. $this->executeView($view);
  368. // Assert correct result set.
  369. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  370. $this->assertEqual($result_count, 2, 'Option 5: View has two results.');
  371. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  372. $result1 = ($nid === (int) $this->nodes[1]->nid);
  373. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  374. $result2 = ($nid === (int) $this->nodes[2]->nid);
  375. $this->assertTrue($result1 && $result2, 'Option 5: View result has correct node IDs.');
  376. // Option 6: Is not empty.
  377. $view = $this->getReducedExposedGroupedOptionsTestView();
  378. $view->set_exposed_input(array(
  379. 'field_list_value' => '6',
  380. ));
  381. $this->executeView($view);
  382. // Assert correct result set.
  383. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  384. $this->assertEqual($result_count, 1, 'Option 6: View has one result.');
  385. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  386. $this->assertIdentical($nid, (int) $this->nodes[0]->nid, 'Option 6: View result has correct node ID.');
  387. }
  388. /**
  389. * Tests exposed filter on term ID with grouped options.
  390. */
  391. public function testTermIdExposedGroupedOptions() {
  392. // Assert that nodes have been created and have expected field values.
  393. $value = field_get_items('node', $this->nodes[0], 'field_tags', LANGUAGE_NONE);
  394. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  395. $this->assertIdentical($value, 2, 'First node has been created and tags field references term 2.');
  396. $value = field_get_items('node', $this->nodes[1], 'field_tags', LANGUAGE_NONE);
  397. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  398. $this->assertIdentical($value, 1, 'Second node has been created and tags field references term 1.');
  399. // Assert that user has been created and has expected field values.
  400. $value = field_get_items('user', $this->accounts[0], 'field_tags', LANGUAGE_NONE);
  401. $value = isset($value[0]['tid']) ? (int) $value[0]['tid'] : 0;
  402. $this->assertIdentical($value, 1, 'User has been created and tags field references term 1.');
  403. // Assert that node ID with empty field value matches user ID so that the
  404. // node would be excluded from the result option 1, if the joins are missing
  405. // extras.
  406. $this->assertIdentical((int) $this->accounts[0]->uid, (int) $this->nodes[1]->nid, 'Node ID of second node matches UID of first user.');
  407. // Default option: Any.
  408. $view = $this->getTermIdExposedGroupedOptionsTestView();
  409. $this->executeView($view);
  410. // Assert correct result set.
  411. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  412. $this->assertEqual($result_count, 3, 'Default option: View has three results.');
  413. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  414. $result1 = ($nid === (int) $this->nodes[0]->nid);
  415. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  416. $result2 = ($nid === (int) $this->nodes[1]->nid);
  417. $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
  418. $result3 = ($nid === (int) $this->nodes[2]->nid);
  419. $this->assertTrue($result1 && $result2 && $result3, 'Default option: View result has correct node ID.');
  420. // Option 1: Is none of 2.
  421. $view = $this->getTermIdExposedGroupedOptionsTestView();
  422. $view->set_exposed_input(array(
  423. 'field_tags_tid' => '1',
  424. ));
  425. $this->executeView($view);
  426. // Assert correct result set.
  427. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  428. $this->assertEqual($result_count, 1, 'Option 1: View has one result.');
  429. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  430. $this->assertIdentical($nid, (int) $this->nodes[1]->nid, 'Option 1: View result has correct node ID.');
  431. // Option 2: Is none of 1 or 2.
  432. $view = $this->getTermIdExposedGroupedOptionsTestView();
  433. $view->set_exposed_input(array(
  434. 'field_tags_tid' => '2',
  435. ));
  436. $this->executeView($view);
  437. // Assert correct result set.
  438. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
  439. $this->assertEqual($result_count, 0, 'Option 2: View has empty result.');
  440. // Option 3: Is one of 1.
  441. $view = $this->getTermIdExposedGroupedOptionsTestView();
  442. $view->set_exposed_input(array(
  443. 'field_tags_tid' => '3',
  444. ));
  445. $this->executeView($view);
  446. // Assert correct result set.
  447. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  448. $this->assertEqual($result_count, 2, 'Option 3: View has two results.');
  449. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  450. $result1 = ($nid === (int) $this->nodes[1]->nid);
  451. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  452. $result2 = ($nid === (int) $this->nodes[2]->nid);
  453. $this->assertTrue($result1 && $result2, 'Option 3: View result has correct node ID.');
  454. // Option 4: Is one of 1 or 2.
  455. $view = $this->getTermIdExposedGroupedOptionsTestView();
  456. $view->set_exposed_input(array(
  457. 'field_tags_tid' => '4',
  458. ));
  459. $this->executeView($view);
  460. // Assert correct result set.
  461. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  462. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  463. $result1 = ($nid === (int) $this->nodes[0]->nid);
  464. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  465. $result2 = ($nid === (int) $this->nodes[1]->nid);
  466. $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
  467. $result3 = ($nid === (int) $this->nodes[2]->nid);
  468. $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0;
  469. $result4 = ($nid === (int) $this->nodes[2]->nid);
  470. $this->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 4: View result has correct node ID.');
  471. $this->verbose($view->result);
  472. $this->assertEqual($result_count, 4, 'Option 4: View has four results.');
  473. /* @todo: Fix and uncomment in issue #3045168.
  474. * // Option 5: Is all of 1 and 2.
  475. * $view = $this->getTermIdExposedGroupedOptionsTestView();
  476. * $view->set_exposed_input(array(
  477. * 'field_tags_tid' => '5',
  478. * ));
  479. * $this->executeView($view);
  480. *
  481. * // Assert correct result set.
  482. * $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  483. * $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  484. * $this->assertIdentical($nid, (int) $this->nodes[2]->nid, 'Option 5: View result has correct node ID.');
  485. * $this->assertIdentical($result_count, 1, 'Option 5: View has one result.');
  486. */
  487. // Option 6: Is empty.
  488. $view = $this->getTermIdExposedGroupedOptionsTestView();
  489. $view->set_exposed_input(array(
  490. 'field_tags_tid' => '6',
  491. ));
  492. $this->executeView($view);
  493. // Assert correct result set.
  494. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 1;
  495. $this->assertIdentical($result_count, 0, 'Option 6: View has empty result.');
  496. // Option 7: Is not empty.
  497. $view = $this->getTermIdExposedGroupedOptionsTestView();
  498. $view->set_exposed_input(array(
  499. 'field_tags_tid' => '7',
  500. ));
  501. $this->executeView($view);
  502. // Assert correct result set.
  503. $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
  504. $nid = isset($view->result[0]->nid) ? (int) $view->result[0]->nid : 0;
  505. $result1 = ($nid === (int) $this->nodes[0]->nid);
  506. $nid = isset($view->result[1]->nid) ? (int) $view->result[1]->nid : 0;
  507. $result2 = ($nid === (int) $this->nodes[1]->nid);
  508. $nid = isset($view->result[2]->nid) ? (int) $view->result[2]->nid : 0;
  509. $result3 = ($nid === (int) $this->nodes[2]->nid);
  510. $nid = isset($view->result[3]->nid) ? (int) $view->result[3]->nid : 0;
  511. $result4 = ($nid === (int) $this->nodes[2]->nid);
  512. $this->assertTrue($result1 && $result2 && $result3 && $result4, 'Option 7: View result has correct node ID.');
  513. $this->verbose($view->result);
  514. $this->assertIdentical($result_count, 4, 'Option 7: View has four results.');
  515. }
  516. /**
  517. * Generates test_not view.
  518. */
  519. protected function getGroupedNoneOfTestView() {
  520. $view = new view();
  521. $view->name = 'test_not';
  522. $view->description = '';
  523. $view->tag = 'default';
  524. $view->base_table = 'node';
  525. $view->human_name = 'test_not';
  526. $view->core = 7;
  527. $view->api_version = '3.0';
  528. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  529. /* Display: Master */
  530. $handler = $view->new_display('default', 'Master', 'default');
  531. $handler->display->display_options['use_more_always'] = FALSE;
  532. $handler->display->display_options['access']['type'] = 'perm';
  533. $handler->display->display_options['cache']['type'] = 'none';
  534. $handler->display->display_options['query']['type'] = 'views_query';
  535. $handler->display->display_options['exposed_form']['type'] = 'basic';
  536. $handler->display->display_options['pager']['type'] = 'full';
  537. $handler->display->display_options['style_plugin'] = 'default';
  538. $handler->display->display_options['row_plugin'] = 'fields';
  539. /* Field: Content: Title */
  540. $handler->display->display_options['fields']['title']['id'] = 'title';
  541. $handler->display->display_options['fields']['title']['table'] = 'node';
  542. $handler->display->display_options['fields']['title']['field'] = 'title';
  543. $handler->display->display_options['fields']['title']['label'] = '';
  544. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  545. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  546. /* Sort criterion: Content: Nid */
  547. $handler->display->display_options['sorts']['nid']['id'] = 'nid';
  548. $handler->display->display_options['sorts']['nid']['table'] = 'node';
  549. $handler->display->display_options['sorts']['nid']['field'] = 'nid';
  550. $handler->display->display_options['filter_groups']['operator'] = 'OR';
  551. $handler->display->display_options['filter_groups']['groups'] = array(
  552. 1 => 'AND',
  553. 2 => 'AND',
  554. );
  555. /* Filter criterion: Content: Published */
  556. $handler->display->display_options['filters']['status']['id'] = 'status';
  557. $handler->display->display_options['filters']['status']['table'] = 'node';
  558. $handler->display->display_options['filters']['status']['field'] = 'status';
  559. $handler->display->display_options['filters']['status']['value'] = 1;
  560. $handler->display->display_options['filters']['status']['group'] = 1;
  561. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  562. /* Filter criterion: Content: Type */
  563. $handler->display->display_options['filters']['type']['id'] = 'type';
  564. $handler->display->display_options['filters']['type']['table'] = 'node';
  565. $handler->display->display_options['filters']['type']['field'] = 'type';
  566. $handler->display->display_options['filters']['type']['value'] = array(
  567. 'article' => 'article',
  568. );
  569. $handler->display->display_options['filters']['type']['group'] = 1;
  570. /* Filter criterion: Field: field_bool (field_bool) */
  571. $handler->display->display_options['filters']['field_bool_value']['id'] = 'field_bool_value';
  572. $handler->display->display_options['filters']['field_bool_value']['table'] = 'field_data_field_bool';
  573. $handler->display->display_options['filters']['field_bool_value']['field'] = 'field_bool_value';
  574. $handler->display->display_options['filters']['field_bool_value']['operator'] = 'not';
  575. $handler->display->display_options['filters']['field_bool_value']['value'] = array(
  576. 1 => '1',
  577. );
  578. $handler->display->display_options['filters']['field_bool_value']['group'] = 1;
  579. /* Filter criterion: Field: field_bool (field_bool) */
  580. $handler->display->display_options['filters']['field_bool_value_1']['id'] = 'field_bool_value_1';
  581. $handler->display->display_options['filters']['field_bool_value_1']['table'] = 'field_data_field_bool';
  582. $handler->display->display_options['filters']['field_bool_value_1']['field'] = 'field_bool_value';
  583. $handler->display->display_options['filters']['field_bool_value_1']['operator'] = 'not';
  584. $handler->display->display_options['filters']['field_bool_value_1']['value'] = array(
  585. 1 => '1',
  586. );
  587. $handler->display->display_options['filters']['field_bool_value_1']['group'] = 2;
  588. /* Filter criterion: Content: Type */
  589. $handler->display->display_options['filters']['type_1']['id'] = 'type_1';
  590. $handler->display->display_options['filters']['type_1']['table'] = 'node';
  591. $handler->display->display_options['filters']['type_1']['field'] = 'type';
  592. $handler->display->display_options['filters']['type_1']['value'] = array(
  593. 'article' => 'article',
  594. );
  595. $handler->display->display_options['filters']['type_1']['group'] = 2;
  596. /* Filter criterion: Content: Published */
  597. $handler->display->display_options['filters']['status_1']['id'] = 'status_1';
  598. $handler->display->display_options['filters']['status_1']['table'] = 'node';
  599. $handler->display->display_options['filters']['status_1']['field'] = 'status';
  600. $handler->display->display_options['filters']['status_1']['value'] = '1';
  601. $handler->display->display_options['filters']['status_1']['group'] = 2;
  602. return $view;
  603. }
  604. /**
  605. * Generates test_oneof view.
  606. */
  607. protected function getGroupedOneOfTestView() {
  608. $view = new view();
  609. $view->name = 'test_oneof';
  610. $view->description = '';
  611. $view->tag = 'default';
  612. $view->base_table = 'node';
  613. $view->human_name = 'test_oneof';
  614. $view->core = 7;
  615. $view->api_version = '3.0';
  616. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  617. /* Display: Master */
  618. $handler = $view->new_display('default', 'Master', 'default');
  619. $handler->display->display_options['use_more_always'] = FALSE;
  620. $handler->display->display_options['access']['type'] = 'perm';
  621. $handler->display->display_options['cache']['type'] = 'none';
  622. $handler->display->display_options['query']['type'] = 'views_query';
  623. $handler->display->display_options['exposed_form']['type'] = 'basic';
  624. $handler->display->display_options['pager']['type'] = 'full';
  625. $handler->display->display_options['style_plugin'] = 'default';
  626. $handler->display->display_options['row_plugin'] = 'fields';
  627. /* Field: Content: Title */
  628. $handler->display->display_options['fields']['title']['id'] = 'title';
  629. $handler->display->display_options['fields']['title']['table'] = 'node';
  630. $handler->display->display_options['fields']['title']['field'] = 'title';
  631. $handler->display->display_options['fields']['title']['label'] = '';
  632. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  633. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  634. /* Sort criterion: Content: Nid */
  635. $handler->display->display_options['sorts']['nid']['id'] = 'nid';
  636. $handler->display->display_options['sorts']['nid']['table'] = 'node';
  637. $handler->display->display_options['sorts']['nid']['field'] = 'nid';
  638. $handler->display->display_options['filter_groups']['operator'] = 'OR';
  639. $handler->display->display_options['filter_groups']['groups'] = array(
  640. 1 => 'AND',
  641. 2 => 'AND',
  642. );
  643. /* Filter criterion: Content: Tags (field_tags) */
  644. $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
  645. $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
  646. $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
  647. $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
  648. 1 => '1',
  649. );
  650. $handler->display->display_options['filters']['field_tags_tid']['group'] = 2;
  651. $handler->display->display_options['filters']['field_tags_tid']['reduce_duplicates'] = TRUE;
  652. $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
  653. $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
  654. /* Filter criterion: Content: Tags (field_tags) */
  655. $handler->display->display_options['filters']['field_tags_tid_1']['id'] = 'field_tags_tid_1';
  656. $handler->display->display_options['filters']['field_tags_tid_1']['table'] = 'field_data_field_tags';
  657. $handler->display->display_options['filters']['field_tags_tid_1']['field'] = 'field_tags_tid';
  658. $handler->display->display_options['filters']['field_tags_tid_1']['value'] = array(
  659. 1 => '1',
  660. );
  661. $handler->display->display_options['filters']['field_tags_tid_1']['reduce_duplicates'] = TRUE;
  662. $handler->display->display_options['filters']['field_tags_tid_1']['type'] = 'select';
  663. $handler->display->display_options['filters']['field_tags_tid_1']['vocabulary'] = 'tags';
  664. return $view;
  665. }
  666. /**
  667. * Generates test_reduced_exposed_grouped_options view.
  668. */
  669. protected function getReducedExposedGroupedOptionsTestView() {
  670. $view = new view();
  671. $view->name = 'test_reduced_exposed_grouped_options';
  672. $view->description = '';
  673. $view->tag = 'default';
  674. $view->base_table = 'node';
  675. $view->human_name = 'test_reduced_exposed_grouped_options';
  676. $view->core = 7;
  677. $view->api_version = '3.0';
  678. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  679. /* Display: Master */
  680. $handler = $view->new_display('default', 'Master', 'default');
  681. $handler->display->display_options['use_more_always'] = FALSE;
  682. $handler->display->display_options['access']['type'] = 'perm';
  683. $handler->display->display_options['cache']['type'] = 'none';
  684. $handler->display->display_options['query']['type'] = 'views_query';
  685. $handler->display->display_options['exposed_form']['type'] = 'basic';
  686. $handler->display->display_options['pager']['type'] = 'full';
  687. $handler->display->display_options['style_plugin'] = 'default';
  688. $handler->display->display_options['row_plugin'] = 'fields';
  689. /* Field: Content: Title */
  690. $handler->display->display_options['fields']['title']['id'] = 'title';
  691. $handler->display->display_options['fields']['title']['table'] = 'node';
  692. $handler->display->display_options['fields']['title']['field'] = 'title';
  693. $handler->display->display_options['fields']['title']['label'] = '';
  694. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  695. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  696. /* Sort criterion: Content: Nid */
  697. $handler->display->display_options['sorts']['nid']['id'] = 'nid';
  698. $handler->display->display_options['sorts']['nid']['table'] = 'node';
  699. $handler->display->display_options['sorts']['nid']['field'] = 'nid';
  700. /* Filter criterion: Content: Published */
  701. $handler->display->display_options['filters']['status']['id'] = 'status';
  702. $handler->display->display_options['filters']['status']['table'] = 'node';
  703. $handler->display->display_options['filters']['status']['field'] = 'status';
  704. $handler->display->display_options['filters']['status']['value'] = 1;
  705. $handler->display->display_options['filters']['status']['group'] = 1;
  706. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  707. /* Filter criterion: Content: list (field_list) */
  708. $handler->display->display_options['filters']['field_list_value']['id'] = 'field_list_value';
  709. $handler->display->display_options['filters']['field_list_value']['table'] = 'field_data_field_list';
  710. $handler->display->display_options['filters']['field_list_value']['field'] = 'field_list_value';
  711. $handler->display->display_options['filters']['field_list_value']['exposed'] = TRUE;
  712. $handler->display->display_options['filters']['field_list_value']['expose']['operator_id'] = 'field_list_value_op';
  713. $handler->display->display_options['filters']['field_list_value']['expose']['label'] = 'list (field_list)';
  714. $handler->display->display_options['filters']['field_list_value']['expose']['operator'] = 'field_list_value_op';
  715. $handler->display->display_options['filters']['field_list_value']['expose']['identifier'] = 'field_list_value';
  716. $handler->display->display_options['filters']['field_list_value']['is_grouped'] = TRUE;
  717. $handler->display->display_options['filters']['field_list_value']['group_info']['label'] = 'list (field_list)';
  718. $handler->display->display_options['filters']['field_list_value']['group_info']['identifier'] = 'field_list_value';
  719. $handler->display->display_options['filters']['field_list_value']['group_info']['group_items'] = array(
  720. 1 => array(
  721. 'title' => 'Not 1 or 2',
  722. 'operator' => 'not',
  723. 'value' => array(
  724. 1 => '1',
  725. 2 => '2',
  726. ),
  727. ),
  728. 2 => array(
  729. 'title' => '1',
  730. 'operator' => 'or',
  731. 'value' => array(
  732. 1 => '1',
  733. ),
  734. ),
  735. 3 => array(
  736. 'title' => '1 or 2',
  737. 'operator' => 'or',
  738. 'value' => array(
  739. 1 => '1',
  740. 2 => '2',
  741. ),
  742. ),
  743. 4 => array(
  744. 'title' => '1 and 2',
  745. 'operator' => 'and',
  746. 'value' => array(
  747. 1 => '1',
  748. 2 => '2',
  749. ),
  750. ),
  751. 5 => array(
  752. 'title' => 'empty',
  753. 'operator' => 'empty',
  754. 'value' => array(),
  755. ),
  756. 6 => array(
  757. 'title' => 'not empty',
  758. 'operator' => 'not empty',
  759. 'value' => array(),
  760. ),
  761. );
  762. return $view;
  763. }
  764. /**
  765. * Generates test_tid_exposed_grouped_options view.
  766. */
  767. protected function getTermIdExposedGroupedOptionsTestView() {
  768. $view = new view();
  769. $view->name = 'test_tid_exposed_grouped_options';
  770. $view->description = '';
  771. $view->tag = 'default';
  772. $view->base_table = 'node';
  773. $view->human_name = 'test_tid_exposed_grouped_options';
  774. $view->core = 7;
  775. $view->api_version = '3.0';
  776. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  777. /* Display: Master */
  778. $handler = $view->new_display('default', 'Master', 'default');
  779. $handler->display->display_options['use_more_always'] = FALSE;
  780. $handler->display->display_options['access']['type'] = 'perm';
  781. $handler->display->display_options['cache']['type'] = 'none';
  782. $handler->display->display_options['query']['type'] = 'views_query';
  783. $handler->display->display_options['exposed_form']['type'] = 'basic';
  784. $handler->display->display_options['pager']['type'] = 'full';
  785. $handler->display->display_options['style_plugin'] = 'default';
  786. $handler->display->display_options['row_plugin'] = 'fields';
  787. /* Field: Content: Title */
  788. $handler->display->display_options['fields']['title']['id'] = 'title';
  789. $handler->display->display_options['fields']['title']['table'] = 'node';
  790. $handler->display->display_options['fields']['title']['field'] = 'title';
  791. $handler->display->display_options['fields']['title']['label'] = '';
  792. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  793. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  794. /* Sort criterion: Content: Nid */
  795. $handler->display->display_options['sorts']['nid']['id'] = 'nid';
  796. $handler->display->display_options['sorts']['nid']['table'] = 'node';
  797. $handler->display->display_options['sorts']['nid']['field'] = 'nid';
  798. /* Filter criterion: Content: Published */
  799. $handler->display->display_options['filters']['status']['id'] = 'status';
  800. $handler->display->display_options['filters']['status']['table'] = 'node';
  801. $handler->display->display_options['filters']['status']['field'] = 'status';
  802. $handler->display->display_options['filters']['status']['value'] = 1;
  803. $handler->display->display_options['filters']['status']['group'] = 1;
  804. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  805. /* Filter criterion: Content: Tags (field_tags) */
  806. $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
  807. $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
  808. $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
  809. $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
  810. 1 => '1',
  811. 2 => '2',
  812. );
  813. $handler->display->display_options['filters']['field_tags_tid']['exposed'] = TRUE;
  814. $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op';
  815. $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)';
  816. $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op';
  817. $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid';
  818. $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array(
  819. 2 => '2',
  820. );
  821. $handler->display->display_options['filters']['field_tags_tid']['is_grouped'] = TRUE;
  822. $handler->display->display_options['filters']['field_tags_tid']['group_info']['label'] = 'Tags (field_tags)';
  823. $handler->display->display_options['filters']['field_tags_tid']['group_info']['identifier'] = 'field_tags_tid';
  824. $handler->display->display_options['filters']['field_tags_tid']['group_info']['group_items'] = array(
  825. 1 => array(
  826. 'title' => 'Is none of 2',
  827. 'operator' => 'not',
  828. 'value' => array(
  829. 2 => '2',
  830. ),
  831. ),
  832. 2 => array(
  833. 'title' => 'Is none of 1 or 2',
  834. 'operator' => 'not',
  835. 'value' => array(
  836. 1 => '1',
  837. 2 => '2',
  838. ),
  839. ),
  840. 3 => array(
  841. 'title' => 'Is one of 1',
  842. 'operator' => 'or',
  843. 'value' => array(
  844. 1 => '1',
  845. ),
  846. ),
  847. 4 => array(
  848. 'title' => 'Is one of 1 or 2',
  849. 'operator' => 'or',
  850. 'value' => array(
  851. 1 => '1',
  852. 2 => '2',
  853. ),
  854. ),
  855. 5 => array(
  856. 'title' => 'Is all of 1 and 2',
  857. 'operator' => 'and',
  858. 'value' => array(
  859. 1 => '1',
  860. 2 => '2',
  861. ),
  862. ),
  863. 6 => array(
  864. 'title' => 'Is empty',
  865. 'operator' => 'empty',
  866. 'value' => array(
  867. 1 => '1',
  868. 2 => '2',
  869. ),
  870. ),
  871. 7 => array(
  872. 'title' => 'Is not empty',
  873. 'operator' => 'not empty',
  874. 'value' => array(
  875. 1 => '1',
  876. 2 => '2',
  877. ),
  878. ),
  879. );
  880. $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
  881. $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
  882. return $view;
  883. }
  884. /**
  885. * Generates test_join_limit_none_of view.
  886. */
  887. protected function getJoinLimitNoneOfTestView() {
  888. $view = new view();
  889. $view->name = 'test_join_limit_none_of';
  890. $view->description = '';
  891. $view->tag = 'default';
  892. $view->base_table = 'node';
  893. $view->human_name = 'test_join_limit_none_of';
  894. $view->core = 7;
  895. $view->api_version = '3.0';
  896. $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  897. /* Display: Master */
  898. $handler = $view->new_display('default', 'Master', 'default');
  899. $handler->display->display_options['use_more_always'] = FALSE;
  900. $handler->display->display_options['access']['type'] = 'perm';
  901. $handler->display->display_options['cache']['type'] = 'none';
  902. $handler->display->display_options['query']['type'] = 'views_query';
  903. $handler->display->display_options['exposed_form']['type'] = 'basic';
  904. $handler->display->display_options['pager']['type'] = 'full';
  905. $handler->display->display_options['style_plugin'] = 'default';
  906. $handler->display->display_options['row_plugin'] = 'fields';
  907. /* Field: Content: Title */
  908. $handler->display->display_options['fields']['title']['id'] = 'title';
  909. $handler->display->display_options['fields']['title']['table'] = 'node';
  910. $handler->display->display_options['fields']['title']['field'] = 'title';
  911. $handler->display->display_options['fields']['title']['label'] = '';
  912. $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
  913. $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
  914. /* Sort criterion: Content: Post date */
  915. $handler->display->display_options['sorts']['created']['id'] = 'created';
  916. $handler->display->display_options['sorts']['created']['table'] = 'node';
  917. $handler->display->display_options['sorts']['created']['field'] = 'created';
  918. $handler->display->display_options['sorts']['created']['order'] = 'DESC';
  919. /* Filter criterion: Content: Published */
  920. $handler->display->display_options['filters']['status']['id'] = 'status';
  921. $handler->display->display_options['filters']['status']['table'] = 'node';
  922. $handler->display->display_options['filters']['status']['field'] = 'status';
  923. $handler->display->display_options['filters']['status']['value'] = 1;
  924. $handler->display->display_options['filters']['status']['group'] = 1;
  925. $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
  926. /* Filter criterion: Content: Tags (field_tags) */
  927. $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid';
  928. $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags';
  929. $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid';
  930. $handler->display->display_options['filters']['field_tags_tid']['operator'] = 'not';
  931. $handler->display->display_options['filters']['field_tags_tid']['value'] = array(
  932. 2 => '2',
  933. 3 => '3',
  934. 4 => '4',
  935. 5 => '5',
  936. 6 => '6',
  937. 7 => '7',
  938. 8 => '8',
  939. 9 => '9',
  940. 10 => '10',
  941. 11 => '11',
  942. 12 => '12',
  943. 13 => '13',
  944. 14 => '14',
  945. 15 => '15',
  946. 16 => '16',
  947. 17 => '17',
  948. 18 => '18',
  949. 19 => '19',
  950. 20 => '20',
  951. 21 => '21',
  952. 22 => '22',
  953. 23 => '23',
  954. 24 => '24',
  955. 25 => '25',
  956. 26 => '26',
  957. 27 => '27',
  958. 28 => '28',
  959. 29 => '29',
  960. 30 => '30',
  961. 31 => '31',
  962. 32 => '32',
  963. 33 => '33',
  964. 34 => '34',
  965. 35 => '35',
  966. 36 => '36',
  967. 37 => '37',
  968. 38 => '38',
  969. 39 => '39',
  970. 40 => '40',
  971. 41 => '41',
  972. 42 => '42',
  973. 43 => '43',
  974. 44 => '44',
  975. 45 => '45',
  976. 46 => '46',
  977. 47 => '47',
  978. 48 => '48',
  979. 49 => '49',
  980. 50 => '50',
  981. 51 => '51',
  982. 52 => '52',
  983. 53 => '53',
  984. 54 => '54',
  985. 55 => '55',
  986. 56 => '56',
  987. 57 => '57',
  988. 58 => '58',
  989. 59 => '59',
  990. 60 => '60',
  991. 61 => '61',
  992. 62 => '62',
  993. 63 => '63',
  994. 64 => '64',
  995. 65 => '65',
  996. 66 => '66',
  997. 67 => '67',
  998. 68 => '68',
  999. 69 => '69',
  1000. 61 => '61',
  1001. 62 => '62',
  1002. );
  1003. $handler->display->display_options['filters']['field_tags_tid']['type'] = 'select';
  1004. $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags';
  1005. return $view;
  1006. }
  1007. }