testGetWholeSectoralDistributionActionActionCanBeAccessed()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 0
Metric Value
dl 20
loc 20
ccs 15
cts 15
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
4
 * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
5
 * @license   http://framework.zend.com/license/new-bsd New BSD License
6
 */
7
8
namespace ApiTest\Controller;
9
10
use Api\Controller\DistributionReportController;
11
use Zend\Stdlib\ArrayUtils;
12
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
13
use Zend\Json\Json;
14
15
class DistributionReportControllerTest extends AbstractHttpControllerTestCase
16
{
17 5
    public function setUp()
18
    {
19 5
        $configOverrides = [];
20
21 5
        $this->setApplicationConfig(ArrayUtils::merge(
22 5
            include __DIR__.'/../../../../config/application.config.php',
23
            $configOverrides
24
        ));
25
26 5
        parent::setUp();
27 5
    }
28
29 1 View Code Duplication
    public function testGetWholeSectoralDistributionActionActionCanBeAccessed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31 1
        $this->dispatch('/informe/distribucion-sectores/2014', 'GET');
32 1
        $this->assertResponseStatusCode(200);
33 1
        $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8');
34 1
        $this->assertModuleName('api');
35 1
        $this->assertControllerName(DistributionReportController::class);
36 1
        $this->assertControllerClass('DistributionReportController');
37 1
        $this->assertMatchedRouteName('informe-todos-sectores');
38
39 1
        $data = $this->getResponse()->getContent();
40
41 1
        $this->assertJson($data);
42
43 1
        $data = Json::decode($data, Json::TYPE_ARRAY);
44
45 1
        $this->assertArrayHasKey('sector_1', $data);
46 1
        $this->assertArrayHasKey('colores', $data);
47 1
        $this->assertArrayHasKey('descripciones', $data);
48 1
    }
49
50 1 View Code Duplication
    public function testGetSectoralDistributionActionCanBeAccessed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52 1
        $this->dispatch('/informe/distribucion-sector/2014/1', 'GET');
53 1
        $this->assertResponseStatusCode(200);
54 1
        $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8');
55 1
        $this->assertModuleName('api');
56 1
        $this->assertControllerName(DistributionReportController::class);
57 1
        $this->assertControllerClass('DistributionReportController');
58 1
        $this->assertMatchedRouteName('informe-por-sector');
59
60 1
        $data = $this->getResponse()->getContent();
61
62 1
        $this->assertJson($data);
63
64 1
        $data = Json::decode($data, Json::TYPE_ARRAY);
65
66 1
        $this->assertArrayHasKey('graph_data', $data);
67 1
        $this->assertArrayHasKey('sector', $data);
68 1
        $this->assertArrayHasKey('totalActividades', $data);
69 1
    }
70
71 1 View Code Duplication
    public function testGetGasesDistributionActionCanBeAccessed()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73 1
        $this->dispatch('/informe/distribucion-gases/2014', 'GET');
74 1
        $this->assertResponseStatusCode(200);
75 1
        $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8');
76 1
        $this->assertModuleName('api');
77 1
        $this->assertControllerName(DistributionReportController::class);
78 1
        $this->assertControllerClass('DistributionReportController');
79 1
        $this->assertMatchedRouteName('informe-gas');
80
81 1
        $data = $this->getResponse()->getContent();
82
83 1
        $this->assertJson($data);
84
85 1
        $data = Json::decode($data, Json::TYPE_ARRAY);
86
87 1
        $this->assertArrayHasKey('colores', $data);
88 1
        $this->assertArrayHasKey('gases', $data);
89 1
        $this->assertArrayHasKey('valores', $data);
90 1
    }
91
92 1
    public function testGetSectoralGasesDistributionActionCanBeAccessed()
93
    {
94 1
        $this->dispatch('/informe/distribucion-gases-sector/2014', 'GET');
95 1
        $this->assertResponseStatusCode(200);
96 1
        $this->assertResponseHeaderContains('Content-Type', 'application/json; charset=utf-8');
97 1
        $this->assertModuleName('api');
98 1
        $this->assertControllerName(DistributionReportController::class);
99 1
        $this->assertControllerClass('DistributionReportController');
100 1
        $this->assertMatchedRouteName('informe-gas-por-sector');
101
102 1
        $data = $this->getResponse()->getContent();
103
104 1
        $this->assertJson($data);
105
106 1
        $data = Json::decode($data, Json::TYPE_ARRAY);
0 ignored issues
show
Unused Code introduced by
$data is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
107 1
    }
108
109 1
    public function testInvalidRouteDoesNotCrash()
110
    {
111 1
        $this->dispatch('/invalid/route', 'GET');
112 1
        $this->assertResponseStatusCode(404);
113 1
    }
114
115
    // public function testInvalidHttpVerbDoesNotCrash()
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
116
    // {
117
    //     $this->dispatch('/informe/distribucion-sectores/2014', 'DELETE');
0 ignored issues
show
Unused Code Comprehensibility introduced by
73% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
118
    //     $this->assertResponseStatusCode(405);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
119
    // }
120
}
121