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