1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Tests\Highcharts; |
4
|
|
|
|
5
|
|
|
use Ob\HighchartsBundle\Highcharts\Highchart; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* This class hold Unit tests for the legend option |
10
|
|
|
*/ |
11
|
|
|
class LegendTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Align option (left/center/right) |
15
|
|
|
*/ |
16
|
|
|
public function testAlign() |
17
|
|
|
{ |
18
|
|
|
$chart = new Highchart(); |
19
|
|
|
|
20
|
|
|
$chart->legend->align("left"); |
21
|
|
|
$this->assertRegExp('/legend: \{"align":"left"\}/', $chart->render()); |
22
|
|
|
|
23
|
|
|
$chart->legend->align("center"); |
24
|
|
|
$this->assertRegExp('/legend: \{"align":"center"\}/', $chart->render()); |
25
|
|
|
|
26
|
|
|
$chart->legend->align("right"); |
27
|
|
|
$this->assertRegExp('/legend: \{"align":"right"\}/', $chart->render()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Layout option (horizontal/vertical) |
32
|
|
|
*/ |
33
|
|
|
public function testLayout() |
34
|
|
|
{ |
35
|
|
|
$chart = new Highchart(); |
36
|
|
|
|
37
|
|
|
$chart->legend->layout("horizontal"); |
38
|
|
|
$this->assertRegExp('/legend: \{"layout":"horizontal"\}/', $chart->render()); |
39
|
|
|
|
40
|
|
|
$chart->legend->layout("vertical"); |
41
|
|
|
$this->assertRegExp('/legend: \{"layout":"vertical"\}/', $chart->render()); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Enabled option (true/false) |
46
|
|
|
*/ |
47
|
|
|
public function testEnabledDisabled() |
48
|
|
|
{ |
49
|
|
|
$chart = new Highchart(); |
50
|
|
|
|
51
|
|
|
$chart->legend->enabled(false); |
52
|
|
|
$this->assertRegExp('/legend: \{"enabled":false\}/', $chart->render()); |
53
|
|
|
|
54
|
|
|
$chart->legend->enabled(true); |
55
|
|
|
$this->assertRegExp('/legend: \{"enabled":true\}/', $chart->render()); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|