@@ -20,17 +20,7 @@ class DispatchTest extends \PHPUnit_Framework_TestCase
20
20
21
21
public function testDispatch ()
22
22
{
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 ' );
34
24
$ request = HttpRequest::create ('/ ' );
35
25
$ response = HttpResponse::create ();
36
26
@@ -41,17 +31,7 @@ public function testDispatch()
41
31
42
32
public function testDispatchProd ()
43
33
{
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 ' );
55
35
$ request = HttpRequest::create ('/ ' );
56
36
$ response = HttpResponse::create ();
57
37
@@ -60,6 +40,17 @@ public function testDispatchProd()
60
40
$ this ->assertEquals (200 , $ response ->getStatusCode ());
61
41
}
62
42
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
+
63
54
64
55
65
56
}
0 commit comments