|
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 tooltip option |
|
10
|
|
|
*/ |
|
11
|
|
|
class TooltipTest extends \PHPUnit_Framework_TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Animation option (true/false) |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testAnimation() |
|
17
|
|
|
{ |
|
18
|
|
|
$chart = new Highchart(); |
|
19
|
|
|
|
|
20
|
|
|
$chart->tooltip->animation("true"); |
|
21
|
|
|
$this->assertRegExp('/tooltip: \{"animation":"true"\}/', $chart->render()); |
|
22
|
|
|
|
|
23
|
|
|
$chart->tooltip->animation("false"); |
|
24
|
|
|
$this->assertRegExp('/tooltip: \{"animation":"false"\}/', $chart->render()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* backgroundColor option (rgba) |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testBackgroundColor() |
|
31
|
|
|
{ |
|
32
|
|
|
$chart = new Highchart(); |
|
33
|
|
|
|
|
34
|
|
|
$chart->tooltip->backgroundColor("rgba(255, 255, 255, .85)"); |
|
35
|
|
|
$this->assertRegExp('/tooltip: \{"backgroundColor":"rgba\(255, 255, 255, .85\)"\}/', $chart->render()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* borderColor option (null/auto/rgba) |
|
40
|
|
|
*/ |
|
41
|
|
|
public function testBorderColor() |
|
42
|
|
|
{ |
|
43
|
|
|
$chart = new Highchart(); |
|
44
|
|
|
|
|
45
|
|
|
$chart->tooltip->borderColor('null'); |
|
46
|
|
|
$this->assertRegExp('/tooltip: \{"borderColor":"null"\}/', $chart->render()); |
|
47
|
|
|
|
|
48
|
|
|
$chart->tooltip->borderColor('auto'); |
|
49
|
|
|
$this->assertRegExp('/tooltip: \{"borderColor":"auto"\}/', $chart->render()); |
|
50
|
|
|
|
|
51
|
|
|
$chart->tooltip->borderColor('rgba(255, 255, 255, .85)'); |
|
52
|
|
|
$this->assertRegExp('/tooltip: \{"borderColor":"rgba\(255, 255, 255, .85\)"\}/', $chart->render()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* borderRadius option (integer - radius in px) |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testBorderRadius() |
|
59
|
|
|
{ |
|
60
|
|
|
$chart = new Highchart(); |
|
61
|
|
|
|
|
62
|
|
|
$chart->tooltip->borderRadius(5); |
|
63
|
|
|
$this->assertRegExp('/tooltip: \{"borderRadius":5\}/', $chart->render()); |
|
64
|
|
|
|
|
65
|
|
|
$chart->tooltip->borderRadius("5"); |
|
66
|
|
|
$this->assertRegExp('/tooltip: \{"borderRadius":"5"\}/', $chart->render()); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* borderWidth option (integer - width in px) |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testborderWidth() |
|
73
|
|
|
{ |
|
74
|
|
|
$chart = new Highchart(); |
|
75
|
|
|
|
|
76
|
|
|
$chart->tooltip->borderWidth(5); |
|
77
|
|
|
$this->assertRegExp('/tooltip: \{"borderWidth":5\}/', $chart->render()); |
|
78
|
|
|
|
|
79
|
|
|
$chart->tooltip->borderWidth("5"); |
|
80
|
|
|
$this->assertRegExp('/tooltip: \{"borderWidth":"5"\}/', $chart->render()); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* enabled option (true/false) |
|
85
|
|
|
*/ |
|
86
|
|
|
public function testEnabled() |
|
87
|
|
|
{ |
|
88
|
|
|
$chart = new Highchart(); |
|
89
|
|
|
|
|
90
|
|
|
$chart->tooltip->enabled("true"); |
|
91
|
|
|
$this->assertRegExp('/tooltip: \{"enabled":"true"\}/', $chart->render()); |
|
92
|
|
|
|
|
93
|
|
|
$chart->tooltip->enabled("false"); |
|
94
|
|
|
$this->assertRegExp('/tooltip: \{"enabled":"false"\}/', $chart->render()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Formatter option (Zend Json Expr) |
|
99
|
|
|
*/ |
|
100
|
|
|
public function testFormatter() |
|
101
|
|
|
{ |
|
102
|
|
|
$chart = new Highchart(); |
|
103
|
|
|
|
|
104
|
|
|
$func = new Expr('function () { return 1; }'); |
|
105
|
|
|
|
|
106
|
|
|
$chart->tooltip->formatter($func); |
|
107
|
|
|
$this->assertRegExp('/tooltip: \{"formatter":function\s?\(\)\s?\{ return 1; \}\}/', $chart->render()); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* shadow option (true/false) |
|
112
|
|
|
*/ |
|
113
|
|
|
public function testShadow() |
|
114
|
|
|
{ |
|
115
|
|
|
$chart = new Highchart(); |
|
116
|
|
|
|
|
117
|
|
|
$chart->tooltip->shadow("true"); |
|
118
|
|
|
$this->assertRegExp('/tooltip: \{"shadow":"true"\}/', $chart->render()); |
|
119
|
|
|
|
|
120
|
|
|
$chart->tooltip->shadow("false"); |
|
121
|
|
|
$this->assertRegExp('/tooltip: \{"shadow":"false"\}/', $chart->render()); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
|