Files
cattr/tests/Feature/Users/CountTest.php
Noor E Ilahi 7ccf44f7da first commit
2026-01-09 12:54:53 +05:30

41 lines
815 B
PHP

<?php
namespace Tests\Feature\Users;
use App\Models\User;
use Tests\Facades\UserFactory;
use Tests\TestCase;
class CountTest extends TestCase
{
private const URI = 'users/count';
private const USERS_AMOUNT = 10;
private User $admin;
protected function setUp(): void
{
parent::setUp();
$this->admin = UserFactory::asAdmin()->withTokens()->create();
UserFactory::createMany(self::USERS_AMOUNT);
}
public function test_count(): void
{
$response = $this->actingAs($this->admin)->getJson(self::URI);
$response->assertOk();
$response->assertJson(['total' => User::count()]);
}
public function test_unauthorized(): void
{
$response = $this->getJson(self::URI);
$response->assertUnauthorized();
}
}