Skip to content

Commit edd774e

Browse files
committed
Updating phpunit bootstrap file
1 parent f93e13b commit edd774e

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

tests/DispatchTest.php

+13-22
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,7 @@ class DispatchTest extends \PHPUnit_Framework_TestCase
2020

2121
public function testDispatch()
2222
{
23-
// Setup autoloading and include PPI
24-
require_once realpath(__DIR__ . '/../app/init.php');
25-
26-
// Create...
27-
$app = new PPI\Framework\App(array(
28-
'environment' => 'dev',
29-
'rootDir' => realpath(__DIR__.'/../app'),
30-
));
31-
32-
$app->loadConfig($app->getEnvironment() . '/app.php');
33-
23+
$app = $this->createApp('dev');
3424
$request = HttpRequest::create('/');
3525
$response = HttpResponse::create();
3626

@@ -41,17 +31,7 @@ public function testDispatch()
4131

4232
public function testDispatchProd()
4333
{
44-
// Setup autoloading and include PPI
45-
require_once realpath(__DIR__ . '/../app/init.php');
46-
47-
// Create...
48-
$app = new PPI\Framework\App(array(
49-
'environment' => 'prod',
50-
'rootDir' => realpath(__DIR__.'/../app'),
51-
));
52-
53-
$app->loadConfig($app->getEnvironment() . '/app.php');
54-
34+
$app = $this->createApp('prod');
5535
$request = HttpRequest::create('/');
5636
$response = HttpResponse::create();
5737

@@ -60,6 +40,17 @@ public function testDispatchProd()
6040
$this->assertEquals(200, $response->getStatusCode());
6141
}
6242

43+
private function createApp($env)
44+
{
45+
$app = new PPI\Framework\App(array(
46+
'environment' => $env,
47+
'rootDir' => realpath(__DIR__.'/../app'),
48+
));
49+
$app->loadConfig($app->getEnvironment() . '/app.php');
50+
51+
return $app;
52+
}
53+
6354

6455

6556
}

0 commit comments

Comments
 (0)