IndicatorsReportControllerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 50
ccs 28
cts 28
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A testGetIndicatorActionCanBeAccessed() 0 23 1
A testInvalidRouteDoesNotCrash() 0 5 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\IndicatorsReportController;
11
use Zend\Stdlib\ArrayUtils;
12
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
13
use Zend\Json\Json;
14
15
class IndicatorsReportControllerTest extends AbstractHttpControllerTestCase
16
{
17 2
    public function setUp()
18
    {
19 2
        $configOverrides = [];
20
21 2
        $this->setApplicationConfig(ArrayUtils::merge(
22 2
            include __DIR__.'/../../../../config/application.config.php',
23
            $configOverrides
24
        ));
25
26 2
        parent::setUp();
27 2
    }
28
    
29 1
    public function testGetIndicatorActionCanBeAccessed()
30
    {
31 1
        $this->dispatch('/informe/indicador/2', '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(IndicatorsReportController::class);
36 1
        $this->assertControllerClass('IndicatorsReportController');
37 1
        $this->assertMatchedRouteName('informe-indicador');
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('column_1', $data);
46 1
        $this->assertArrayHasKey('colores', $data);
47 1
        $this->assertArrayHasKey('column_2', $data);
48 1
        $this->assertArrayHasKey('descripcion', $data);
49 1
        $this->assertArrayHasKey('unidad', $data);
50 1
        $this->assertArrayHasKey('indicador', $data);
51 1
    }
52
53 1
    public function testInvalidRouteDoesNotCrash()
54
    {
55 1
        $this->dispatch('/invalid/route', 'GET');
56 1
        $this->assertResponseStatusCode(404);
57 1
    }
58
59
    // 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...
60
    // {
61
    //     $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...
62
    //     $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...
63
    // }
64
}
65