Skip to content

Commit a00e8bf

Browse files
author
janatzend
authored
Merge pull request #14 from tobias-trozowski/feature/improved-autoloading
Improved autoloading
2 parents 5b504b8 + 5b3ac77 commit a00e8bf

File tree

17 files changed

+276
-205
lines changed

17 files changed

+276
-205
lines changed

ZendServer/DepH/Deployment/Deployment.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public function getCurrentAction() {
8383
$stack = array_reverse(debug_backtrace(), true);
8484

8585
foreach ($stack as $item) {
86+
if (!isset($item['file'])) {
87+
continue;
88+
}
8689
$filename = basename($item['file']);
8790
if (false !== $key = array_search($filename, $this->actionScriptNames)) {
8891
return $key;

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@
77
"phpunit/phpunit" : "=3.7.32",
88
"mockery/mockery" : "=0.9.4"
99
},
10+
"autoload": {
11+
"psr-4": {
12+
"ZendServer\\DepH\\": "ZendServer/DepH"
13+
}
14+
},
15+
"autoload-dev": {
16+
"psr-4": {
17+
"ZendServerTest\\DepH\\": "tests/ZendServer/DepH"
18+
},
19+
"classmap": ["tests/ZendServer/DepHSuite.php"]
20+
},
21+
"scripts": {
22+
"test": "phpunit --colors=auto --no-coverage"
23+
},
1024
"repositories" : [ {
1125
"type" : "composer",
1226
"url" : "https://packagist.org/"

phpunit.xml.dist

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
3+
bootstrap="tests/bootstrap.php"
4+
backupGlobals="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
beStrictAboutOutputDuringTests="true"
9+
forceCoversAnnotation="false"
10+
stopOnError="false"
11+
stopOnFailure="false"
12+
stopOnIncomplete="false"
13+
stopOnSkipped="false"
14+
verbose="true"
15+
colors="false">
16+
<testsuites>
17+
<!--<testsuite name="Zend Server DepH Deployment Suite">-->
18+
<!--<directory>./tests/Deployment</directory>-->
19+
<!--</testsuite>-->
20+
<!--<testsuite name="Zend Server DepH File Suite">-->
21+
<!--<directory>./tests/File</directory>-->
22+
<!--</testsuite>-->
23+
<!--<testsuite name="Zend Server DepH Params Suite">-->
24+
<!--<directory>./tests/Params</directory>-->
25+
<!--</testsuite>-->
26+
<!--<testsuite name="Zend Server DepH Path Suite">-->
27+
<!--<directory>./tests/Path</directory>-->
28+
<!--</testsuite>-->
29+
<!--<testsuite name="Zend Server DepH SystemCall Suite">-->
30+
<!--<directory>./tests/SystemCall</directory>-->
31+
<!--</testsuite>-->
32+
<testsuite name="Zend Server DepH Suite">
33+
<file>./tests/ZendServer/DepHSuite.php</file>
34+
</testsuite>
35+
</testsuites>
36+
37+
<filter>
38+
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="false">
39+
<directory suffix=".php">ZendServer/DepH</directory>
40+
<exclude>
41+
<directory suffix=".php">test/ZendServer/DepH</directory>
42+
</exclude>
43+
</whitelist>
44+
</filter>
45+
46+
<groups>
47+
<exclude>
48+
<group>disable</group>
49+
<group>integration</group>
50+
</exclude>
51+
</groups>
52+
53+
<php>
54+
<ini name="date.timezone" value="UTC"/>
55+
<ini name="memory_limit" value="128M"/>
56+
<ini name="error_reporting" value="-1" />
57+
<ini name="zend.enable_gc" value="0"/>
58+
</php>
59+
60+
</phpunit>

tests/ZendServer/DepH/Deployment/DeploymentTest.php

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
2-
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/bootstrap.php';
2+
3+
namespace ZendServerTest\DepH\Deployment;
34

45
use \ZendServer\DepH\Deployment\Deployment;
6+
use PHPUnit_Framework_TestCase as TestCase;
57

68
/**
79
* Deployment test case.
810
*/
9-
class DeploymentTest extends PHPUnit_Framework_TestCase
11+
class DeploymentTest extends TestCase
1012
{
1113

1214
/**
@@ -21,7 +23,7 @@ class DeploymentTest extends PHPUnit_Framework_TestCase
2123
protected function setUp()
2224
{
2325
parent::setUp();
24-
26+
2527
$this->Deployment = new Deployment();
2628
}
2729

@@ -31,35 +33,28 @@ protected function setUp()
3133
protected function tearDown()
3234
{
3335
$this->Deployment = null;
34-
35-
parent::tearDown();
36-
}
3736

38-
/**
39-
* Constructs the test case.
40-
*/
41-
public function __construct()
42-
{
37+
parent::tearDown();
4338
}
4439

4540
/**
4641
* Tests Deployment->getCurrentAction()
47-
*
48-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
42+
*
43+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
4944
*/
5045
public function testGetCurrentActionException()
5146
{
5247
$this->Deployment->getCurrentAction();
5348
}
54-
49+
5550
/**
5651
* Tests Deployment->getCurrentAction()
5752
*/
5853
public function testGetCurrentAction()
5954
{
6055
$methodToCall = 'getCurrentAction';
6156
$actual = require '_files/pre_activate.php';
62-
57+
6358
$this->assertEquals(\ZendServer\DepH\Deployment\Deployment::PRE_ACTIVATE, $actual);
6459
}
6560

@@ -70,14 +65,14 @@ public function testGetCurrentActionScript()
7065
{
7166
$methodToCall = 'getCurrentActionScript';
7267
$actual = require '_files/pre_activate.php';
73-
68+
7469
$this->assertEquals('pre_activate.php', $actual);
7570
}
76-
71+
7772
/**
7873
* Tests Deployment->getCurrentActionScript()
79-
*
80-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
74+
*
75+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
8176
*/
8277
public function testGetCurrentActionScriptException()
8378
{
@@ -91,18 +86,18 @@ public function testIsPreStageAction()
9186
{
9287
$methodToCall = 'isPreStageAction';
9388
$actual = require '_files/pre_activate.php';
94-
89+
9590
$this->assertFalse($actual);
96-
91+
9792
$actual = require '_files/pre_stage.php';
98-
93+
9994
$this->assertTrue($actual);
10095
}
101-
96+
10297
/**
10398
* Tests Deployment->isPreStageAction()
104-
*
105-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
99+
*
100+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
106101
*/
107102
public function testIsPreStageActionException()
108103
{
@@ -116,18 +111,18 @@ public function testIsPostStageAction()
116111
{
117112
$methodToCall = 'isPostStageAction';
118113
$actual = require '_files/pre_activate.php';
119-
114+
120115
$this->assertFalse($actual);
121-
116+
122117
$actual = require '_files/post_stage.php';
123-
118+
124119
$this->assertTrue($actual);
125120
}
126-
121+
127122
/**
128123
* Tests Deployment->isPostStageAction()
129-
*
130-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
124+
*
125+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
131126
*/
132127
public function testIsPostStageActionException()
133128
{
@@ -141,18 +136,18 @@ public function testIsPreActivateAction()
141136
{
142137
$methodToCall = 'isPreActivateAction';
143138
$actual = require '_files/pre_activate.php';
144-
139+
145140
$this->assertTrue($actual);
146-
141+
147142
$actual = require '_files/post_stage.php';
148-
143+
149144
$this->assertFalse($actual);
150145
}
151-
146+
152147
/**
153148
* Tests Deployment->isPreActivateAction()
154-
*
155-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
149+
*
150+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
156151
*/
157152
public function testIsPreActivateActionException()
158153
{
@@ -166,18 +161,18 @@ public function testIsPostActivateAction()
166161
{
167162
$methodToCall = 'isPostActivateAction';
168163
$actual = require '_files/pre_activate.php';
169-
164+
170165
$this->assertFalse($actual);
171-
166+
172167
$actual = require '_files/post_activate.php';
173-
168+
174169
$this->assertTrue($actual);
175170
}
176-
171+
177172
/**
178173
* Tests Deployment->isPostActivateAction()
179-
*
180-
* @expectedException ZendServer\DepH\Deployment\Exception\RuntimeException
174+
*
175+
* @expectedException \ZendServer\DepH\Deployment\Exception\RuntimeException
181176
*/
182177
public function testIsPostActivateActionException()
183178
{

tests/ZendServer/DepH/DeploymentSuite.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
2-
require_once 'PHPUnit/Framework/TestSuite.php';
32

4-
require_once 'Deployment/DeploymentTest.php';
3+
namespace ZendServerTest\DepH;
4+
5+
use PHPUnit_Framework_TestSuite as TestSuite;
56

67
/**
78
* Static test suite.
89
*/
9-
class DeploymentSuite extends PHPUnit_Framework_TestSuite
10+
class DeploymentSuite extends TestSuite
1011
{
1112

1213
/**
@@ -15,8 +16,8 @@ class DeploymentSuite extends PHPUnit_Framework_TestSuite
1516
public function __construct()
1617
{
1718
$this->setName('DeploymentSuite');
18-
19-
$this->addTestSuite('DeploymentTest');
19+
20+
$this->addTestSuite('ZendServerTest\DepH\Deployment\DeploymentTest');
2021
}
2122

2223
/**

0 commit comments

Comments
 (0)