|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Tests\Highcharts; |
|
4
|
|
|
|
|
5
|
|
|
use Ob\HighchartsBundle\Highcharts\Highchart; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* This class hold Unit tests for the series option |
|
9
|
|
|
*/ |
|
10
|
|
|
class ScrollbarTest extends \PHPUnit_Framework_TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var array |
|
14
|
|
|
*/ |
|
15
|
|
|
private $scrollbar; |
|
16
|
|
|
|
|
17
|
|
|
/* |
|
18
|
|
|
* @var array |
|
19
|
|
|
*/ |
|
20
|
|
|
private $usedOptions = array(); |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Initialises the data |
|
24
|
|
|
*/ |
|
25
|
|
|
public function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->scrollbar = array( |
|
28
|
|
|
'enabled' => true, |
|
29
|
|
|
'barBackgroundColor' => 'gray', |
|
30
|
|
|
'barBorderRadius' => 7, |
|
31
|
|
|
'barBorderWidth' => 0, |
|
32
|
|
|
'buttonBackgroundColor' => 'gray', |
|
33
|
|
|
'buttonBorderWidth' => 0, |
|
34
|
|
|
'buttonArrowColor' => 'yellow', |
|
35
|
|
|
'buttonBorderRadius' => 7, |
|
36
|
|
|
'rifleColor' => 'yellow', |
|
37
|
|
|
'trackBackgroundColor' => 'white', |
|
38
|
|
|
'trackBorderWidth' => 1, |
|
39
|
|
|
'trackBorderColor' => 'silver', |
|
40
|
|
|
'trackBorderRadius' => 7 |
|
41
|
|
|
); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Scrollbar config output |
|
46
|
|
|
*/ |
|
47
|
|
|
public function testConfig() |
|
48
|
|
|
{ |
|
49
|
|
|
$chart = new Highchart(); |
|
50
|
|
|
foreach ($this->scrollbar as $key => $value) { |
|
51
|
|
|
// Config randomization |
|
52
|
|
|
if(mt_rand(0, 5) === 0) continue; |
|
53
|
|
|
|
|
54
|
|
|
$this->usedOptions[$key] = $value; |
|
55
|
|
|
$chart->scrollbar->$key($value); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
preg_match('|scrollbar: (\{[^\}]+\})+|', $chart->render(), $matches); |
|
59
|
|
|
$options = json_decode($matches[1], true); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertEquals(count($this->usedOptions), count(array_intersect($this->usedOptions, $options))); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|