Version 1
[yaffs-website] / web / core / modules / options / tests / src / Kernel / Views / OptionsListArgumentTest.php
1 <?php
2
3 namespace Drupal\Tests\options\Kernel\Views;
4
5 use Drupal\views\Views;
6
7 /**
8  * Tests options list argument for views.
9  *
10  * @see \Drupal\options\Plugin\views\argument\NumberListField.
11  * @group views
12  */
13 class OptionsListArgumentTest extends OptionsTestBase {
14
15   /**
16    * Views used by this test.
17    *
18    * @var array
19    */
20   public static $testViews = ['test_options_list_argument_numeric', 'test_options_list_argument_string'];
21
22   /**
23    * Tests the options field argument.
24    */
25   public function testViewsTestOptionsListArgument() {
26     $view = Views::getView('test_options_list_argument_numeric');
27     $this->executeView($view, [1]);
28
29     $resultset = [
30       ['nid' => $this->nodes[0]->nid->value],
31       ['nid' => $this->nodes[1]->nid->value],
32     ];
33
34     $column_map = ['nid' => 'nid'];
35     $this->assertIdenticalResultset($view, $resultset, $column_map);
36
37     $view = Views::getView('test_options_list_argument_string');
38     $this->executeView($view, ['man', 'woman']);
39
40     $resultset = [
41       ['nid' => $this->nodes[0]->nid->value],
42       ['nid' => $this->nodes[1]->nid->value],
43     ];
44
45     $column_map = ['nid' => 'nid'];
46     $this->assertIdenticalResultset($view, $resultset, $column_map);
47   }
48
49 }