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