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