mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Some new tests.
This commit is contained in:
parent
b9000519e4
commit
bcf7452312
@ -38,16 +38,6 @@ class HomeController extends Controller
|
||||
Session::put('end', $end);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
Cache::flush();
|
||||
|
||||
return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
|
@ -22,6 +22,7 @@ class Kernel extends HttpKernel
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'FireflyIII\Http\Middleware\ReplaceTestVars',
|
||||
'FireflyIII\Http\Middleware\VerifyCsrfToken',
|
||||
];
|
||||
|
||||
@ -38,6 +39,7 @@ class Kernel extends HttpKernel
|
||||
'range' => 'FireflyIII\Http\Middleware\Range',
|
||||
'reminders' => 'FireflyIII\Http\Middleware\Reminders',
|
||||
'piggybanks' => 'FireflyIII\Http\Middleware\PiggyBanks',
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
54
app/Http/Middleware/ReplaceTestVars.php
Normal file
54
app/Http/Middleware/ReplaceTestVars.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Routing\Middleware;
|
||||
|
||||
/**
|
||||
* Class ReplaceTestVars
|
||||
*
|
||||
* @package App\Http\Middleware
|
||||
*/
|
||||
class ReplaceTestVars implements Middleware
|
||||
{
|
||||
/**
|
||||
* The application implementation.
|
||||
*
|
||||
* @var Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Application $app
|
||||
*
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ('testing' === $this->app->environment() && $request->has('_token')) {
|
||||
$input = $request->all();
|
||||
$input['_token'] = $request->session()->token();
|
||||
// we need to update _token value to make sure we get the POST / PUT tests passed.
|
||||
$request->replace($input);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
@ -26,31 +26,38 @@ class HomeControllerTest extends TestCase
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\HomeController::dateRange
|
||||
*/
|
||||
public function testDateRangeWarning()
|
||||
{
|
||||
$start = '2014-03-01';
|
||||
$end = '2015-03-31';
|
||||
|
||||
$this->be(new FireflyIII\User);
|
||||
$this->call('POST', '/daterange', ['end' => $end, 'start' => $start]);
|
||||
$this->assertResponseOk();
|
||||
|
||||
$this->assertSessionHas('start');
|
||||
$this->assertSessionHas('end');
|
||||
$this->assertSessionHas('warning');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\HomeController::dateRange
|
||||
*/
|
||||
public function testDateRange()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete('This test has not been implemented yet.');
|
||||
}
|
||||
$start = '2015-03-01';
|
||||
$end = '2015-03-31';
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\HomeController::flush
|
||||
*/
|
||||
public function testFlush()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete('This test has not been implemented yet.');
|
||||
}
|
||||
$this->be(new FireflyIII\User);
|
||||
$this->call('POST', '/daterange', ['end' => $end, 'start' => $start]);
|
||||
$this->assertResponseOk();
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\HomeController::index
|
||||
*/
|
||||
public function testIndexNoLogin()
|
||||
{
|
||||
$response = $this->call('GET', '/');
|
||||
$this->assertRedirectedTo('auth/login');
|
||||
$this->assertSessionHas('start');
|
||||
$this->assertSessionHas('end');
|
||||
|
||||
}
|
||||
|
||||
@ -65,4 +72,14 @@ class HomeControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers FireflyIII\Http\Controllers\HomeController::index
|
||||
*/
|
||||
public function testIndexNoLogin()
|
||||
{
|
||||
$response = $this->call('GET', '/');
|
||||
$this->assertRedirectedTo('auth/login');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user