1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Tests\Highstock; |
4
|
|
|
|
5
|
|
|
use Ob\HighchartsBundle\Highcharts\Highstock; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
class RangeSelectorTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
protected $chart; |
11
|
|
|
protected $range; |
12
|
|
|
|
13
|
|
|
protected function setUp() |
14
|
|
|
{ |
15
|
|
|
$this->chart = new Highstock(); |
16
|
|
|
$this->range = $this->chart->rangeSelector; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function testButtonSpacing() |
20
|
|
|
{ |
21
|
|
|
$spacing = 0; |
22
|
|
|
$this->range->buttonSpacing($spacing); |
23
|
|
|
$this->assertEquals($spacing, $this->range->buttonSpacing); |
24
|
|
|
$this->assertRegExp('/"buttonSpacing":0/', $this->chart->render()); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function testButtonTheme() |
28
|
|
|
{ |
29
|
|
|
$this->markTestIncomplete(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testButtons() |
33
|
|
|
{ |
34
|
|
|
$buttons = array(array( |
35
|
|
|
'type' => 'month', |
36
|
|
|
'count' => 3, |
37
|
|
|
'text' => '3m' |
38
|
|
|
)); |
39
|
|
|
|
40
|
|
|
$this->range->buttons($buttons); |
41
|
|
|
$this->assertEquals($buttons, $this->range->buttons); |
42
|
|
|
$this->assertRegExp('/"buttons":\[{"type":"month","count":3,"text":"3m"}\]/', $this->chart->render()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testEnabled() |
46
|
|
|
{ |
47
|
|
|
$this->range->enabled(true); |
48
|
|
|
$this->assertTrue($this->range->enabled); |
49
|
|
|
$this->assertRegExp('/"enabled":true/', $this->chart->render()); |
50
|
|
|
|
51
|
|
|
$this->range->enabled(false); |
52
|
|
|
$this->assertFalse($this->range->enabled); |
53
|
|
|
$this->assertRegExp('/"enabled":false/', $this->chart->render()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testInputBoxBorderColor() |
57
|
|
|
{ |
58
|
|
|
$color = 'silver'; |
59
|
|
|
$this->range->inputBoxBorderColor($color); |
60
|
|
|
$this->assertEquals($color, $this->range->inputBoxBorderColor); |
61
|
|
|
$this->assertRegExp('/"inputBoxBorderColor":"silver"/', $this->chart->render()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testInputBoxHeight() |
65
|
|
|
{ |
66
|
|
|
$height = 16; |
67
|
|
|
$this->range->inputBoxHeight($height); |
68
|
|
|
$this->assertEquals($height, $this->range->inputBoxHeight); |
69
|
|
|
$this->assertRegExp('/"inputBoxHeight":16/', $this->chart->render()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testInputBoxWidth() |
73
|
|
|
{ |
74
|
|
|
$width = 16; |
75
|
|
|
$this->range->inputBoxWidth($width); |
76
|
|
|
$this->assertEquals($width, $this->range->inputBoxWidth); |
77
|
|
|
$this->assertRegExp('/"inputBoxWidth":16/', $this->chart->render()); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function testInputDateFormat() |
81
|
|
|
{ |
82
|
|
|
$format = '%b %e, %Y'; |
83
|
|
|
$this->range->inputDateFormat($format); |
84
|
|
|
$this->assertEquals($format, $this->range->inputDateFormat); |
85
|
|
|
$this->assertRegExp('/"inputDateFormat":"%b %e, %Y"/', $this->chart->render()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testInputDateParser() |
89
|
|
|
{ |
90
|
|
|
$this->markTestIncomplete(); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function testInputEditDateFormat() |
94
|
|
|
{ |
95
|
|
|
$format = '%b %e, %Y'; |
96
|
|
|
$this->range->inputEditDateFormat($format); |
97
|
|
|
$this->assertEquals($format, $this->range->inputEditDateFormat); |
98
|
|
|
$this->assertRegExp('/"inputEditDateFormat":"%b %e, %Y"/', $this->chart->render()); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function testinputEnabled() |
102
|
|
|
{ |
103
|
|
|
$this->range->inputEnabled(true); |
104
|
|
|
$this->assertTrue($this->range->inputEnabled); |
105
|
|
|
$this->assertRegExp('/"inputEnabled":true/', $this->chart->render()); |
106
|
|
|
|
107
|
|
|
$this->range->inputEnabled(false); |
108
|
|
|
$this->assertFalse($this->range->inputEnabled); |
109
|
|
|
$this->assertRegExp('/"inputEnabled":false/', $this->chart->render()); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testInputPosition() |
113
|
|
|
{ |
114
|
|
|
$position= array( |
115
|
|
|
'align' => 'right' |
116
|
|
|
); |
117
|
|
|
$this->range->position($position); |
118
|
|
|
$this->assertEquals($position, $this->range->position); |
119
|
|
|
$this->assertRegExp('/"position":{"align":"right"}/', $this->chart->render()); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function testInputStyle() |
123
|
|
|
{ |
124
|
|
|
$this->markTestIncomplete(); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function testLabelStyle() |
128
|
|
|
{ |
129
|
|
|
$this->markTestIncomplete(); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function testSelected() |
133
|
|
|
{ |
134
|
|
|
$index = 3; |
135
|
|
|
$this->range->selected($index); |
136
|
|
|
$this->assertEquals($index, $this->range->selected); |
137
|
|
|
$this->assertRegExp('/"selected":3/', $this->chart->render()); |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|