Last active
August 29, 2015 13:55
-
-
Save cod3beat/8748074 to your computer and use it in GitHub Desktop.
Test helper for Laravel. Inspired by http://net.tutsplus.com/tutorials/php/testing-laravel-controllers/ with a little change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestCase extends Illuminate\Foundation\Testing\TestCase { | |
/** | |
* Creates the application. | |
* | |
* @return \Symfony\Component\HttpKernel\HttpKernelInterface | |
*/ | |
public function createApplication() | |
{ | |
$unitTesting = true; | |
$testEnvironment = 'testing'; | |
return require __DIR__.'/../../bootstrap/start.php'; | |
} | |
/** | |
* Allow user to do something like this: | |
* | |
* $this->post('user', array('name' => 'keripix')); | |
*/ | |
public function __call($method, $args) | |
{ | |
if (in_array($method, ['get', 'post', 'put', 'patch', 'delete'])) | |
{ | |
array_unshift($args, $method); | |
return call_user_func_array(array($this, 'call'), $args); | |
} | |
throw new BadMethodCallException; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment