33 lines
866 B
PHP
33 lines
866 B
PHP
<?php
|
|
|
|
use App\Http\Resources\PermissionResource;
|
|
use App\Models\Permission;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Http\Request;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->artisan('db:seed');
|
|
});
|
|
|
|
test('resource has expected keys', function () {
|
|
$permission = Permission::factory()->create();
|
|
|
|
$array = (new PermissionResource($permission))->toArray(new Request);
|
|
|
|
$this->assertSame([
|
|
'id', 'name', 'display_name', 'description', 'removable',
|
|
'updated_at', 'created_at',
|
|
], array_keys($array));
|
|
});
|
|
|
|
test('id is int removable is bool', function () {
|
|
$permission = Permission::factory()->create(['removable' => 1]);
|
|
|
|
$array = (new PermissionResource($permission))->toArray(new Request);
|
|
|
|
$this->assertIsInt($array['id']);
|
|
$this->assertTrue($array['removable']);
|
|
});
|