Skip to content

Commit

Permalink
Merge pull request #2 from guillermoandrae/master
Browse files Browse the repository at this point in the history
Updated for PSR-2 compliance.
  • Loading branch information
craig-davis committed Oct 21, 2014
2 parents f857ca0 + 6ef2b87 commit aabeed9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"minimum-stability": "dev",
"require": {

"slim/slim": "2.4.*",
"phpunit/phpunit": "3.7.*"
},
"autoload": {
"psr-0": {
Expand Down
12 changes: 8 additions & 4 deletions src/There4/Slim/Test/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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 */
15 changes: 8 additions & 7 deletions src/There4/Slim/Test/WebTestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace There4\Slim\Test;

use \Slim;

class WebTestClient
{
public $app;
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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 */

0 comments on commit aabeed9

Please sign in to comment.