Code Duplication    Length = 24-28 lines in 2 locations

src/CarlosIO/Geckoboard/Tests/Widgets/HighchartsChartTest.php 2 locations

@@ 7-30 (lines=24) @@
4
5
class HighchartsChartTest extends \PHPUnit_Framework_TestCase
6
{
7
    public function testJsonForSingleSeriesData()
8
    {
9
        $myWidget = new HighchartsChart();
10
        $myWidget->setId('56797-7e3d4237-f798-433a-abe7-ac1857dfdf0f');
11
12
        $myWidget->setType('line');
13
        $myWidget->setTitle('Monthly Average Temperature');
14
        $myWidget->setSubtitle('Source: WorldClimate.com');
15
        $myWidget->setXAxisLabels(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
16
        $myWidget->setYAxisTitle('Temperature (°C)');
17
        $myWidget->setSingleSerie('Tokyo', array(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6));
18
        $myWidget->setSingleSerie('London', array(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8));
19
20
        $data = $myWidget->getData();
21
        $json = json_encode($data);
22
23
        $testJson = '{"highchart":{"chart":{"type":"line"},"title":{"text":"Monthly Average Temperature"},"subtitle":{"text":"Source: WorldClimate.com"},'.
24
            '"xAxis":{"categories":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},'.
25
            '"yAxis":{"title":{"text":"Temperature (\u00b0C)"}},"plotOptions":{"line":{"dataLabels":{"enabled":true},"enableMouseTracking":false}},'.
26
            '"series":[{"name":"Tokyo","data":[7,6.9,9.5,14.5,18.4,21.5,25.2,26.5,23.3,18.3,13.9,9.6],"type":"line"},{"name":"London","data":[3.9,4.2,5.7,8.5,'.
27
            '11.9,15.2,17,16.6,14.2,10.3,6.6,4.8],"type":"line"}]}}';
28
29
        $this->assertEquals($testJson, $json);
30
    }
31
32
    public function testJsonForFullData()
33
    {
@@ 32-59 (lines=28) @@
29
        $this->assertEquals($testJson, $json);
30
    }
31
32
    public function testJsonForFullData()
33
    {
34
        $myWidget = new HighchartsChart();
35
        $myWidget->setId('56797-7e3d4237-f798-433a-abe7-ac1857dfdf0f');
36
37
        $myWidget->setType('line');
38
        $myWidget->setTitle('Monthly Average Temperature');
39
        $myWidget->setSubtitle('Source: WorldClimate.com');
40
        $myWidget->setXAxisLabels(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'));
41
        $myWidget->setXAxisTitle('Month');
42
        $series = array(
43
            'Tokyo' => array(7.0, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6),
44
            'London' => array(3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8),
45
        );
46
        $myWidget->setSeries($series);
47
48
        $data = $myWidget->getData();
49
        $json = json_encode($data);
50
51
        $testJson = '{"highchart":{"chart":{"type":"line"},"title":{"text":"Monthly Average Temperature"},"subtitle":{"text":"Source: WorldClimate.com"},'.
52
            '"xAxis":{"categories":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"title":{"text":"Month"}},'.
53
            '"plotOptions":{"line":{"dataLabels":{"enabled":true},"enableMouseTracking":false}},'.
54
            '"series":[{"name":"Tokyo","data":[7,6.9,9.5,14.5,18.4,21.5,25.2,26.5,23.3,18.3,13.9,9.6],"type":"line"},{"name":"London","data":[3.9,4.2,5.7,8.5,'.
55
            '11.9,15.2,17,16.6,14.2,10.3,6.6,4.8],"type":"line"}]}}';
56
57
        $this->assertEquals($testJson, $json);
58
    }
59
60
    public function testJsonAddingData()
61
    {
62
        $myWidget = new HighchartsChart();