object group controller test

This commit is contained in:
TasneemTantawy
2024-12-22 16:29:56 +03:00
parent 4fb61646b4
commit 9e373a9b0d
2 changed files with 173 additions and 2 deletions

View File

@@ -100,7 +100,6 @@ final class CurrencyControllerTest extends TestCase {
// create test data
$this->createTestCurrencies(10, true);
$this->createTestCurrencies(5, false);
// test API
$response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']);
@@ -121,6 +120,22 @@ final class CurrencyControllerTest extends TestCase {
$response->assertJsonCount(10);
}
public function testGivenAuthenticatedRequestWhenCallingTheCurrenciesEndpointDoesNotReturnDisabledCurrencies(): void
{
// act as a user
$user = $this->createAuthenticatedUser();
$this->actingAs($user);
// create test data
$this->createTestCurrencies(10, false);
// test API
$response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonCount(0);
}
public function testGivenAuthenticatedRequestWhenCallingTheCurrenciesEndpointWithQueryThenReturnsCurrenciesWithLimit(): void
{
// act as a user
@@ -168,5 +183,4 @@ final class CurrencyControllerTest extends TestCase {
}
}