From ffd1199a28974601547748cefc413f0209f86b50 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Fri, 27 Mar 2020 22:41:32 +0100 Subject: [PATCH] Complete tests --- tests/Unit/ApiExceptionTest.php | 15 +++++++++++++++ tests/Unit/TwoFAccountTest.php | 21 +++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/Unit/ApiExceptionTest.php b/tests/Unit/ApiExceptionTest.php index c778a530..f72a9ca7 100644 --- a/tests/Unit/ApiExceptionTest.php +++ b/tests/Unit/ApiExceptionTest.php @@ -4,6 +4,7 @@ namespace Tests\Unit; use App\User; use Tests\TestCase; +use App\TwoFAccount; use App\Http\Controllers\TwoFAccountController; use Illuminate\Auth\Authenticatable; use Illuminate\Support\Facades\Auth; @@ -113,7 +114,21 @@ class ApiExceptionTest extends TestCase */ public function test_HTTP_INTERNAL_SERVER_ERROR() { + factory(TwoFAccount::class, 3)->create(); + $response = $this->actingAs($this->user, 'api') + ->json('PATCH', '/api/twofaccounts/reorder', [ + 'orderedIds' => 'x']) + ->assertStatus(500) + ->assertJsonStructure([ + 'message', + 'originalMessage', + 'debug' + ]) + ->assertJsonFragment([ + 'message' => 'Whoops, looks like something went wrong' + ]); + } } \ No newline at end of file diff --git a/tests/Unit/TwoFAccountTest.php b/tests/Unit/TwoFAccountTest.php index 3d06ab79..fcd32dbf 100644 --- a/tests/Unit/TwoFAccountTest.php +++ b/tests/Unit/TwoFAccountTest.php @@ -250,7 +250,7 @@ class TwoFAccountTest extends TestCase */ public function testTwoFAccountIndexListing() { - $twofaccount = factory(TwoFAccount::class, 3)->create(); + factory(TwoFAccount::class, 3)->create(); $response = $this->actingAs($this->user, 'api') ->json('GET', '/api/twofaccounts') @@ -293,9 +293,7 @@ class TwoFAccountTest extends TestCase */ public function testTwoFAccountBatchDestroy() { - $twofaccount = factory(TwoFAccount::class)->create(); - $twofaccount = factory(TwoFAccount::class)->create(); - $twofaccount = factory(TwoFAccount::class)->create(); + factory(TwoFAccount::class, 3)->create(); $ids = \Illuminate\Support\Facades\DB::table('twofaccounts')->value('id'); @@ -305,4 +303,19 @@ class TwoFAccountTest extends TestCase ->assertStatus(204); } + + /** + * test TwoFAccounts reorder + * + * @test + */ + public function testTwoFAccountReorder() + { + factory(TwoFAccount::class, 3)->create(); + + $response = $this->actingAs($this->user, 'api') + ->json('PATCH', '/api/twofaccounts/reorder', [ + 'orderedIds' => [3,2,1]]) + ->assertStatus(200); + } }