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