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() |
|
|
|
|
60
|
|
|
// { |
61
|
|
|
// $this->dispatch('/informe/distribucion-sectores/2014', 'DELETE'); |
|
|
|
|
62
|
|
|
// $this->assertResponseStatusCode(405); |
|
|
|
|
63
|
|
|
// } |
64
|
|
|
} |
65
|
|
|
|
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.