Skip to content

Commit 6c55fc8

Browse files
committed
changes to test framework for using restful-unit
1 parent c907343 commit 6c55fc8

File tree

8 files changed

+138
-171
lines changed

8 files changed

+138
-171
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
"require-dev" : {
2929
"phpunit/phpunit" : "~4.8",
30+
"php-platform/restful-unit" : "~0.1",
3031
"guzzlehttp/guzzle" : "~3.8",
3132
"php-platform/mock-config" : "~0.1"
3233
},

composer.lock

Lines changed: 125 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22

3-
<phpunit colors="true" bootstrap="tests/autoload.php" >
3+
<phpunit colors="true" bootstrap="vendor/php-platform/restful-unit/resources/autoload.php" >
44
<php>
55
<const name="APP_DOMAIN" value="http://localhost"/>
66
<const name="APP_PATH" value="restful"/>

tests/RESTFul/ServerSide/TestHTTPResponse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44

55
use PhpPlatform\RESTFul\HTTPResponse;
66
use PhpPlatform\Errors\Exceptions\Application\BadInputException;
7+
use PhpPlatform\Tests\RESTFul\TestBase;
78

8-
class TestHTTPResponse extends TestServerSide{
9+
class TestHTTPResponse extends TestBase{
910

1011
function testConstruct(){
1112
$isException = false;

tests/RESTFul/ServerSide/TestServerSide.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/RESTFul/TestBase.php

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@
99
abstract class TestBase extends \PHPUnit_Framework_TestCase {
1010

1111
private static $errorLogDir = null;
12-
private static $coverage = null;
1312

1413
static function setUpBeforeClass(){
1514
parent::setUpBeforeClass();
1615

17-
// generate coverage for tests run in php-cli process
18-
if(defined('COVERAGE_DIR')){
19-
$filter = new \PHP_CodeCoverage_Filter();
20-
$filter->addDirectoryToWhitelist(dirname(__FILE__).'/../../src');
21-
self::$coverage = new \PHP_CodeCoverage(null,$filter);
22-
self::$coverage->start('testRESTful');
23-
}
24-
2516
// create a temporary error log directory
2617
$errorLogDir = sys_get_temp_dir().'/php-platform/restful/errors/'.microtime(true);
2718
mkdir($errorLogDir,0777,true);
@@ -53,13 +44,15 @@ function setUp(){
5344
}
5445

5546
function tearDown(){
56-
// display error log if any
57-
$errorlogFile = self::$errorLogDir.'/'. $this->getName();
58-
if(file_exists($errorlogFile)){
59-
echo PHP_EOL.file_get_contents($errorlogFile).PHP_EOL;
60-
unlink($errorlogFile);
61-
}
62-
}
47+
parent::tearDown();
48+
// display error log if any on error
49+
$errorlogFile = self::$errorLogDir.'/'. md5($this->getName());
50+
if(file_exists($errorlogFile)){
51+
if($this->hasFailed()){
52+
echo PHP_EOL.file_get_contents($errorlogFile).PHP_EOL;
53+
}
54+
unlink($errorlogFile);
55+
}}
6356

6457
function clearErrorLog(){
6558
$errorlogFile = self::$errorLogDir.'/'. $this->getName();
@@ -81,13 +74,6 @@ function assertContainsAndClearLog($message){
8174
static function tearDownAfterClass(){
8275
// delete error log directory
8376
rmdir(self::$errorLogDir);
84-
85-
if(defined('COVERAGE_DIR')){
86-
self::$coverage->stop();
87-
$writer = new \PHP_CodeCoverage_Report_PHP();
88-
$coverageFileName = md5(microtime()).'.php';
89-
$writer->process(self::$coverage, COVERAGE_DIR.'/'.$coverageFileName);
90-
}
9177
}
9278

9379
}

0 commit comments

Comments
 (0)