diff --git a/composer.json b/composer.json index a131379..c2a827a 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ }, "minimum-stability": "dev", "require": { - + "slim/slim": "2.4.*", + "phpunit/phpunit": "3.7.*" }, "autoload": { "psr-0": { diff --git a/src/There4/Slim/Test/WebTestCase.php b/src/There4/Slim/Test/WebTestCase.php index 8e0399d..df6f7c8 100644 --- a/src/There4/Slim/Test/WebTestCase.php +++ b/src/There4/Slim/Test/WebTestCase.php @@ -2,8 +2,13 @@ namespace There4\Slim\Test; +use \Slim\Slim; + class WebTestCase extends \PHPUnit_Framework_TestCase { + protected $app; + protected $client; + // Run for each unit test to setup our slim app environment public function setup() { @@ -14,13 +19,12 @@ public function setup() // Instantiate a Slim application for use in our testing environment. You // will most likely override this for your own application. - public function getSlimInstance() { - return new \Slim\Slim(array( + public function getSlimInstance() + { + return new Slim(array( 'version' => '0.0.0', 'debug' => false, 'mode' => 'testing' )); } } - -/* End of file WebTestCase.php */ \ No newline at end of file diff --git a/src/There4/Slim/Test/WebTestClient.php b/src/There4/Slim/Test/WebTestClient.php index ea50217..d30e67c 100644 --- a/src/There4/Slim/Test/WebTestClient.php +++ b/src/There4/Slim/Test/WebTestClient.php @@ -2,6 +2,8 @@ namespace There4\Slim\Test; +use \Slim; + class WebTestClient { public $app; @@ -13,12 +15,14 @@ class WebTestClient // `__call()` magic method below. public $testingMethods = array('get', 'post', 'patch', 'put', 'delete', 'head'); - public function __construct($slim) { - $this->app = $slim; + public function __construct(Slim\Slim $slim) + { + $this->app = $slim; } // Implement our `get`, `post`, and other http operations - public function __call($method, $arguments) { + public function __call($method, $arguments) + { if (in_array($method, $this->testingMethods)) { list($path, $formVars, $headers) = array_pad($arguments, 3, array()); return $this->request($method, $path, $formVars, $headers); @@ -46,7 +50,7 @@ private function request($method, $path, $formVars = array(), $optionalHeaders = } // Prepare a mock environment - \Slim\Environment::mock(array_merge($options, $optionalHeaders)); + Slim\Environment::mock(array_merge($options, $optionalHeaders)); // Establish some useful references to the slim app properties $this->request = $this->app->request(); @@ -58,7 +62,4 @@ private function request($method, $path, $formVars = array(), $optionalHeaders = // Return the application output. Also available in `response->body()` return ob_get_clean(); } - } - -/* end of file WebTestClient */ \ No newline at end of file