Complete tests

This commit is contained in:
Bubka 2020-03-27 22:41:32 +01:00
parent eaabe6e9e3
commit ffd1199a28
2 changed files with 32 additions and 4 deletions

View File

@ -4,6 +4,7 @@ namespace Tests\Unit;
use App\User; use App\User;
use Tests\TestCase; use Tests\TestCase;
use App\TwoFAccount;
use App\Http\Controllers\TwoFAccountController; use App\Http\Controllers\TwoFAccountController;
use Illuminate\Auth\Authenticatable; use Illuminate\Auth\Authenticatable;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
@ -113,6 +114,20 @@ class ApiExceptionTest extends TestCase
*/ */
public function test_HTTP_INTERNAL_SERVER_ERROR() 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'
]);
} }

View File

@ -250,7 +250,7 @@ class TwoFAccountTest extends TestCase
*/ */
public function testTwoFAccountIndexListing() public function testTwoFAccountIndexListing()
{ {
$twofaccount = factory(TwoFAccount::class, 3)->create(); factory(TwoFAccount::class, 3)->create();
$response = $this->actingAs($this->user, 'api') $response = $this->actingAs($this->user, 'api')
->json('GET', '/api/twofaccounts') ->json('GET', '/api/twofaccounts')
@ -293,9 +293,7 @@ class TwoFAccountTest extends TestCase
*/ */
public function testTwoFAccountBatchDestroy() public function testTwoFAccountBatchDestroy()
{ {
$twofaccount = factory(TwoFAccount::class)->create(); factory(TwoFAccount::class, 3)->create();
$twofaccount = factory(TwoFAccount::class)->create();
$twofaccount = factory(TwoFAccount::class)->create();
$ids = \Illuminate\Support\Facades\DB::table('twofaccounts')->value('id'); $ids = \Illuminate\Support\Facades\DB::table('twofaccounts')->value('id');
@ -305,4 +303,19 @@ class TwoFAccountTest extends TestCase
->assertStatus(204); ->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);
}
} }