GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SeriesDataHelperTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 76
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B testBasicProcessing() 0 26 1
B testFancyDataProcessing() 0 31 1
A setupDataProvider() 0 8 1
1
<?php
2
namespace miloschumanunit\highcharts;
3
4
use miloschuman\highcharts\SeriesDataHelper;
5
use yii\data\ArrayDataProvider;
6
7
/**
8
 * SeriesDataHelperTest.php
9
 */
10
class SeriesDataHelperTest extends BaseTestCase
11
{
12
    /**
13
     * test basic data processing using current setup
14
     */
15
    public function testBasicProcessing()
16
    {
17
        $data = [
18
            [
19
                'date_measured' => '2016-03-01 03:00:00',
20
                'open'          => 3.14,
21
            ],
22
            [
23
                'date_measured' => '2016-03-02 03:00:00',
24
                'open'          => 4.14,
25
            ]
26
        ];
27
        $columns      = [
28
            [ 'date_measured', 'datetime' ],
29
            'open:int',
30
        ];
31
32
        $dataProvider = $this->setupDataProvider($data);
33
34
        $helper  = new SeriesDataHelper( $dataProvider, $columns );
35
        $results = $helper->process();
36
        $this->assertEquals( strtotime('2016-03-01 03:00:00') * 1000, $results[0][0] );
37
        $this->assertEquals( 3, $results[0][1] );
38
        $this->assertEquals( strtotime('2016-03-02 03:00:00') * 1000, $results[1][0] );
39
        $this->assertEquals( 4, $results[1][1] );
40
    }
41
42
    /**
43
     * test fancy data processing to produce JS objects instead of arrays
44
     */
45
    public function testFancyDataProcessing()
46
    {
47
        $data = [
48
            [
49
                'date_measured' => '2016-03-01 03:00:00',
50
                'open'          => 3.14,
51
                'pointData'     => 'Show this on the graph',
52
            ],
53
            [
54
                'date_measured' => '2016-03-02 03:00:00',
55
                'open'          => 4.14,
56
                'pointData'     => 'This as well',
57
            ]
58
        ];
59
        $columns      = [
60
            'x' => [ 'date_measured', 'datetime' ],
61
            'y' => 'open:int',
62
            'extra' => 'pointData:raw',
63
        ];
64
65
        $dataProvider = $this->setupDataProvider($data);
66
67
        $helper  = new SeriesDataHelper( $dataProvider, $columns );
68
        $results = $helper->jsonSerialize();
69
        $this->assertEquals( strtotime('2016-03-01 03:00:00') * 1000, $results[0]['x']);
70
        $this->assertEquals( 3, $results[0]['y'] );
71
        $this->assertEquals( 'Show this on the graph', $results[0]['extra'] );
72
        $this->assertEquals( strtotime('2016-03-02 03:00:00') * 1000, $results[1]['x'] );
73
        $this->assertEquals( 4, $results[1]['y'] );
74
        $this->assertEquals( 'This as well', $results[1]['extra'] );
75
    }
76
77
    private function setupDataProvider($data)
78
    {
79
        return new ArrayDataProvider( [
80
            'allModels' => $data,
81
            'sort' => false,
82
            'pagination' => false,
83
        ] );
84
    }
85
}