Skip to content

Commit 625433e

Browse files
committed
Add preProcessIndex tests to HasSelectOptions
1 parent 5ea4bc7 commit 625433e

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

tests/Fieldtypes/HasSelectOptionsTests.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,52 @@ public static function optionsProvider()
5858
],
5959
];
6060
}
61+
62+
#[Test]
63+
#[DataProvider('preProcessIndexProvider')]
64+
public function it_preprocesses_index_values($options, $value, $expected)
65+
{
66+
$field = $this->field(['options' => $options]);
67+
68+
$this->assertSame($expected, $field->preProcessIndex($value));
69+
}
70+
71+
public static function preProcessIndexProvider()
72+
{
73+
return [
74+
'list' => [
75+
['one', 'two', 'three'],
76+
'two',
77+
['two'],
78+
],
79+
'associative with labels' => [
80+
['one' => 'One', 'two' => 'Two', 'three' => 'Three'],
81+
'two',
82+
['Two'],
83+
],
84+
'associative without labels' => [
85+
['one' => null, 'two' => null, 'three' => null],
86+
'two',
87+
['two'],
88+
],
89+
'multidimensional with labels' => [
90+
[
91+
['key' => 'one', 'value' => 'One'],
92+
['key' => 'two', 'value' => 'Two'],
93+
['key' => 'three', 'value' => 'Three'],
94+
],
95+
'two',
96+
['Two'],
97+
],
98+
'multidimensional without labels' => [
99+
[
100+
['key' => 'one', 'value' => null],
101+
['key' => 'two', 'value' => null],
102+
['key' => 'three', 'value' => null],
103+
],
104+
'two',
105+
['two'],
106+
],
107+
];
108+
}
61109
}

0 commit comments

Comments
 (0)