ERP-API/tests/Feature/Accounting/Account/ListTest.php

50 lines
1.1 KiB
PHP

<?php
namespace Tests\Feature\Accounting\Account;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\Account;
use App\Models\Role;
use App\Models\Permission;
use App\Models\User;
use Laravel\Sanctum\Sanctum;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ListTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic feature test example.
*/
public function test_success(): void
{
$permission = Permission::where("code","accounting.account:read")->first();
$role = Role::factory()->create();
$role->permissions()->attach($permission->id);
$user = User::factory()->create();
$user->roles()->attach($role->id);
Sanctum::actingAs($user);
$data = Account::factory()->create();
$response = $this->get('/accounting/account/');
$response->assertStatus(200);
$response->assertJson([
"data" => [
[
"id" => $data->id,
"name" => $data->name
]
]
]);
}
}