mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Fix all tests.
This commit is contained in:
@@ -25,10 +25,12 @@ namespace FireflyIII\Exceptions;
|
|||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use FireflyIII\Jobs\MailError;
|
use FireflyIII\Jobs\MailError;
|
||||||
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Request;
|
use Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
/**
|
/**
|
||||||
* Class Handler
|
* Class Handler
|
||||||
*/
|
*/
|
||||||
@@ -70,6 +72,11 @@ class Handler extends ExceptionHandler
|
|||||||
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
|
||||||
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($exception instanceof AuthenticationException && $request->expectsJson()) {
|
||||||
|
return response()->json(['message' => 'Unauthenticated', 'exception' => 'AuthenticationException'], 401);
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->expectsJson()) {
|
if ($request->expectsJson()) {
|
||||||
$isDebug = env('APP_DEBUG', false);
|
$isDebug = env('APP_DEBUG', false);
|
||||||
if ($isDebug) {
|
if ($isDebug) {
|
||||||
|
@@ -177,6 +177,7 @@ class PiggyBankControllerTest extends TestCase
|
|||||||
$two->account_id = $one->account_id;
|
$two->account_id = $one->account_id;
|
||||||
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
$journalRepos->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||||
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$one, $two]));
|
$repository->shouldReceive('getPiggyBanks')->andReturn(new Collection([$one, $two]));
|
||||||
|
$repository->shouldReceive('getCurrentAmount')->andReturn('10');
|
||||||
|
|
||||||
Steam::shouldReceive('balanceIgnoreVirtual')->twice()->andReturn('1');
|
Steam::shouldReceive('balanceIgnoreVirtual')->twice()->andReturn('1');
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ class AuthenticateTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testMiddlewareAjax()
|
public function testMiddlewareAjax()
|
||||||
{
|
{
|
||||||
|
//$this->withoutExceptionHandling();
|
||||||
$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
|
$server = ['HTTP_X-Requested-With' => 'XMLHttpRequest'];
|
||||||
$response = $this->get('/_test/authenticate', $server);
|
$response = $this->get('/_test/authenticate', $server);
|
||||||
$this->assertEquals(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
|
$this->assertEquals(Response::HTTP_UNAUTHORIZED, $response->getStatusCode());
|
||||||
|
Reference in New Issue
Block a user