Skip to content

Instantly share code, notes, and snippets.

@Rokt33r
Created May 7, 2015 07:39
Show Gist options
  • Save Rokt33r/ea96c40a52898058d17b to your computer and use it in GitHub Desktop.
Save Rokt33r/ea96c40a52898058d17b to your computer and use it in GitHub Desktop.
Laravel Test: `call` method wrapper for Angular $http ref: http://qiita.com/fluke8259/items/224dac74f62c921c9efd
<?php
use Illuminate\Http\Request;
class TestCase extends Illuminate\Foundation\Testing\TestCase {
use TestHelpersTrait;
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
return $app;
}
public function call($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
{
$server['HTTP_Accept'] = 'application/json, text/plain, * / *';
$method = strtoupper($method);
if($method == 'POST'|| $method == 'PUT') $server['HTTP_Content_Type'] = 'application/json';
return parent::call($method, $uri, $parameters, $cookies, $files, $server, $content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment