Skip to content

Instantly share code, notes, and snippets.

@cod3beat
Last active August 29, 2015 13:55
Show Gist options
  • Save cod3beat/8748074 to your computer and use it in GitHub Desktop.
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.
<?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