1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Tests\Highcharts; |
4
|
|
|
|
5
|
|
|
use Ob\HighchartsBundle\Highcharts\Highchart; |
6
|
|
|
use Zend\Json\Expr; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This class hold Unit tests for the exporting option |
11
|
|
|
*/ |
12
|
|
|
class ExportingTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* buttons option |
16
|
|
|
*/ |
17
|
|
|
public function testButtons() |
18
|
|
|
{ |
19
|
|
|
$chart = new Highchart(); |
20
|
|
|
|
21
|
|
|
// align option (string - left/center/right) |
22
|
|
|
$chart->exporting->buttons(array('exportButton' => array('align' => 'center'))); |
23
|
|
|
$this->assertRegExp('/exporting: \{"buttons":\{"exportButton":\{"align":"center"\}\}\}/', $chart->render()); |
24
|
|
|
$chart->exporting->buttons(array('printButton' => array('align' => 'center'))); |
25
|
|
|
$this->assertRegExp('/exporting: \{"buttons":\{"printButton":\{"align":"center"\}\}\}/', $chart->render()); |
26
|
|
|
|
27
|
|
|
// backgroundColor option |
28
|
|
|
$chart->exporting->buttons(array('exportButton' => array('backgroundColor' => 'blue'))); |
29
|
|
|
$this->assertRegExp('/exporting: \{"buttons":\{"exportButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render()); |
30
|
|
|
$chart->exporting->buttons(array('printButton' => array('backgroundColor' => 'blue'))); |
31
|
|
|
$this->assertRegExp('/exporting: \{"buttons":\{"printButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render()); |
32
|
|
|
|
33
|
|
|
// borderColor option |
34
|
|
|
// borderRadius option |
35
|
|
|
// borderWidth option |
36
|
|
|
// enabled option |
37
|
|
|
// height option |
38
|
|
|
// hoverBorderColor option |
39
|
|
|
// hoverSymbolFill option |
40
|
|
|
// hoverSymbolStroke option |
41
|
|
|
// menuItems option |
42
|
|
|
// onclick option |
43
|
|
|
// symbol option |
44
|
|
|
// symbolFill option |
45
|
|
|
// symbolSize option |
46
|
|
|
// symbolStroke option (color) |
47
|
|
|
// symbolStrokeWidth option (integer - stroke width in px) |
48
|
|
|
// symbolX option (float) |
49
|
|
|
// symbolY option (float) |
50
|
|
|
// verticalAlign option (string - top/middle/bottom) |
51
|
|
|
// width option (integer - width in px) |
52
|
|
|
// x option (integer - horizontal offset in px) |
53
|
|
|
// y option (integer - vertical offset in px) |
54
|
|
|
$this->markTestIncomplete( |
55
|
|
|
'This test has not been implemented yet.' |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* chartOptions option |
61
|
|
|
*/ |
62
|
|
|
public function testChartOptions() |
63
|
|
|
{ |
64
|
|
|
$this->markTestIncomplete( |
65
|
|
|
'This test has not been implemented yet.' |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* enabled option (true/false) |
71
|
|
|
*/ |
72
|
|
|
public function testEnabled() |
73
|
|
|
{ |
74
|
|
|
$chart = new Highchart(); |
75
|
|
|
|
76
|
|
|
$chart->exporting->enabled(true); |
77
|
|
|
$this->assertRegExp('/exporting: \{"enabled":true\}/', $chart->render()); |
78
|
|
|
|
79
|
|
|
$chart->exporting->enabled(false); |
80
|
|
|
$this->assertRegExp('/exporting: \{"enabled":false\}/', $chart->render()); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* filename option (string) |
85
|
|
|
*/ |
86
|
|
|
public function testFilename() |
87
|
|
|
{ |
88
|
|
|
$chart = new Highchart(); |
89
|
|
|
$chart->exporting->filename("graph"); |
90
|
|
|
|
91
|
|
|
$this->assertRegExp('/exporting: \{"filename":"graph"\}/', $chart->render()); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* type option (string - image/png, image/jpeg, application/pdf or image/svg+xml) |
96
|
|
|
*/ |
97
|
|
|
public function testType() |
98
|
|
|
{ |
99
|
|
|
$chart = new Highchart(); |
100
|
|
|
|
101
|
|
|
// We need to use a Json Expr or else the slashes are escaped |
102
|
|
|
$chart->exporting->type(new Expr('"image/png"')); |
103
|
|
|
$this->assertRegExp('/exporting: \{"type":"image\/png"\}/', $chart->render()); |
104
|
|
|
|
105
|
|
|
$chart->exporting->type(new Expr('"image/jpeg"')); |
106
|
|
|
$this->assertRegExp('/exporting: \{"type":"image\/jpeg"\}/', $chart->render()); |
107
|
|
|
|
108
|
|
|
$chart->exporting->type(new Expr('"application/pdf"')); |
109
|
|
|
$this->assertRegExp('/exporting: \{"type":"application\/pdf"\}/', $chart->render()); |
110
|
|
|
|
111
|
|
|
$chart->exporting->type(new Expr('"image/svg+xml"')); |
112
|
|
|
$this->assertRegExp('/exporting: \{"type":"image\/svg\+xml"\}/', $chart->render()); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* url option (string) |
117
|
|
|
*/ |
118
|
|
|
public function testUrl() |
119
|
|
|
{ |
120
|
|
|
$chart = new Highchart(); |
121
|
|
|
|
122
|
|
|
// We need to use a Json Expr or else the slashes are escaped |
123
|
|
|
$chart->exporting->url(new Expr('"http://www.google.com"')); |
124
|
|
|
|
125
|
|
|
$this->assertRegExp('/exporting: \{"url":"http:\/\/www.google.com"\}/', $chart->render()); |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* width option (integer - width in px) |
130
|
|
|
*/ |
131
|
|
|
public function testWidth() |
132
|
|
|
{ |
133
|
|
|
$chart = new Highchart(); |
134
|
|
|
$chart->exporting->width(300); |
135
|
|
|
|
136
|
|
|
$this->assertRegExp('/exporting: \{"width":300\}/', $chart->render()); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|