1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Tests\Highstock; |
4
|
|
|
|
5
|
|
|
use Ob\HighchartsBundle\Highcharts\Highstock; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
class CreditsTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
protected $chart; |
11
|
|
|
protected $credits; |
12
|
|
|
|
13
|
|
|
protected function setUp() |
14
|
|
|
{ |
15
|
|
|
$this->chart = new Highstock(); |
16
|
|
|
$this->credits = $this->chart->credits; |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function testEnabled() |
20
|
|
|
{ |
21
|
|
|
$this->credits->enabled(true); |
22
|
|
|
$this->assertTrue($this->credits->enabled); |
23
|
|
|
$this->assertRegExp('/"enabled":true/', $this->chart->render()); |
24
|
|
|
|
25
|
|
|
$this->credits->enabled(false); |
26
|
|
|
$this->assertFalse($this->credits->enabled); |
27
|
|
|
$this->assertRegExp('/"enabled":false/', $this->chart->render()); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function testHref() |
31
|
|
|
{ |
32
|
|
|
$link = "http://www.highcharts.com"; |
33
|
|
|
$this->credits->href($link); |
34
|
|
|
$this->assertEquals($link, $this->credits->href); |
35
|
|
|
// $this->assertRegExp('/"href":"http:\/\/www\.highcharts\.com"/', $this->chart->render()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testPosition() |
39
|
|
|
{ |
40
|
|
|
$position = array( |
41
|
|
|
'align' => 'right', |
42
|
|
|
'x' => -10, |
43
|
|
|
'verticalAlign' => 'bottom', |
44
|
|
|
'y' => -5 |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
$this->credits->position($position); |
48
|
|
|
$this->assertEquals($this->credits->position, $position); |
49
|
|
|
$this->assertRegExp('/"position":{"align":"right","x":-10,"verticalAlign":"bottom","y":-5}/', $this->chart->render()); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testStyle() |
53
|
|
|
{ |
54
|
|
|
$style = array( |
55
|
|
|
'cursor' => 'pointer', |
56
|
|
|
'color' => '#909090', |
57
|
|
|
'fontSize' => '10px' |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
$this->credits->style($style); |
61
|
|
|
$this->assertEquals($style, $this->credits->style); |
62
|
|
|
$this->assertRegExp('/"style":{"cursor":"pointer","color":"#909090","fontSize":"10px"}/', $this->chart->render()); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function testText() |
66
|
|
|
{ |
67
|
|
|
$text = "Highcharts.com"; |
68
|
|
|
$this->credits->text($text); |
69
|
|
|
$this->assertEquals($text, $this->credits->text); |
70
|
|
|
$this->assertRegExp('/"text":"Highcharts.com"/', $this->chart->render()); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|