1 | <?php |
||
8 | class RangeFieldTest extends SapphireTest |
||
9 | { |
||
10 | public function testDefault() |
||
21 | |||
22 | public function testRange() |
||
23 | { |
||
24 | $rangeField = RangeField::create( |
||
25 | 'TestInt', |
||
26 | 'Test', |
||
27 | 50, |
||
28 | 25, |
||
29 | 75, |
||
30 | ['min' => 25, '17%' => 33, '50%' => 50, '83%' => 66, 'max' => 75] |
||
31 | ); |
||
32 | |||
33 | $rangeField->Field([]); |
||
34 | |||
35 | $expected = [ |
||
36 | 'start' => [50], |
||
37 | 'snap' => false, |
||
38 | 'animate' => true, |
||
39 | 'animationDuration' => 300, |
||
40 | 'range' => [ |
||
41 | 'min' => 25, |
||
42 | '17%' => 33, |
||
43 | '50%' => 50, |
||
44 | '83%' => 66, |
||
45 | 'max' => 75 |
||
46 | ], |
||
47 | 'unit' => '', |
||
48 | 'decimalPlaces' => 2, |
||
49 | 'pips' => [ // Show a scale with the slider |
||
50 | 'mode' => 'steps', |
||
51 | 'stepped' => true, |
||
52 | 'density' => 4 |
||
53 | ] |
||
54 | ]; |
||
55 | |||
56 | $this->assertEquals($expected, $rangeField->getData()); |
||
57 | } |
||
58 | |||
59 | public function testSnap() |
||
60 | { |
||
61 | $rangeField = RangeField::create( |
||
62 | 'TestInt', |
||
63 | 'Test', |
||
64 | 50, |
||
65 | 25, |
||
66 | 75, |
||
67 | ['min' => 25, '17%' => 33, '50%' => 50, '83%' => 66, 'max' => 75] |
||
68 | ); |
||
69 | |||
70 | $rangeField->setSnap(true); |
||
71 | |||
72 | $rangeField->Field([]); |
||
73 | |||
74 | $expected = [ |
||
75 | 'start' => [50], |
||
76 | 'snap' => true, |
||
77 | 'animate' => true, |
||
78 | 'animationDuration' => 300, |
||
79 | 'range' => [ |
||
80 | 'min' => 25, |
||
81 | '17%' => 33, |
||
82 | '50%' => 50, |
||
83 | '83%' => 66, |
||
84 | 'max' => 75 |
||
85 | ], |
||
86 | 'pips' => [ // Show a scale with the slider |
||
87 | 'mode' => 'steps', |
||
88 | 'stepped' => true, |
||
89 | 'density' => 4 |
||
90 | ], |
||
91 | 'unit' => '', |
||
92 | 'decimalPlaces' => 2, |
||
93 | ]; |
||
94 | |||
95 | $this->assertEquals($expected, $rangeField->getData()); |
||
96 | $rangeField->setStep(1); |
||
97 | |||
98 | $rangeField->Field([]); |
||
99 | |||
100 | $expected = [ |
||
101 | 'start' => [50], |
||
102 | 'snap' => true, |
||
103 | 'animate' => true, |
||
104 | 'animationDuration' => 300, |
||
105 | 'step' => 1, |
||
106 | 'range' => [ |
||
107 | 'min' => 25, |
||
108 | '17%' => 33, |
||
109 | '50%' => 50, |
||
110 | '83%' => 66, |
||
111 | 'max' => 75 |
||
112 | ], |
||
113 | 'pips' => [ // Show a scale with the slider |
||
114 | 'mode' => 'steps', |
||
115 | 'stepped' => true, |
||
116 | 'density' => 4 |
||
117 | ], |
||
118 | 'unit' => '', |
||
119 | 'decimalPlaces' => 2, |
||
120 | ]; |
||
121 | |||
122 | $this->assertEquals($expected, $rangeField->getData()); |
||
123 | } |
||
124 | |||
125 | public function testGetSetMin() |
||
133 | |||
134 | public function testGetSetStep() |
||
144 | |||
145 | public function testGetSetMax() |
||
153 | |||
154 | public function testGetSetRange() |
||
176 | |||
177 | public function testGetSetDensity() |
||
187 | |||
188 | public function testIsSetPips() |
||
198 | |||
199 | public function testIsSetSnap() |
||
209 | |||
210 | public function testGetSetStart() |
||
224 | |||
225 | public function testGetSetUnit() |
||
235 | |||
236 | public function testGetSetdecimalPlaces() |
||
246 | |||
247 | public function testSetFormat() |
||
260 | } |
||
261 |