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.
Completed
Pull Request — master (#34)
by
unknown
04:07
created

SeriesDataHelperTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

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