Files
CRM/tests/Api/Settings/ApiCurrencyControllerTest.php
Kroonk a213a1dba0
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
refactor: replace custom CRM with Monica fork
2026-05-22 16:19:55 +02:00

71 lines
1.6 KiB
PHP

<?php
namespace Tests\Api\Settings;
use Tests\ApiTestCase;
use App\Models\Settings\Currency;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ApiCurrencyControllerTest extends ApiTestCase
{
use DatabaseTransactions;
protected $jsonStructureCurrency = [
'id',
'object',
'iso',
'name',
'symbol',
];
/** @test */
public function it_gets_all_the_currencies()
{
// in theory the currencies table is seeded by the initial script
$response = $this->json('GET', '/api/currencies/');
$response->assertStatus(200);
$this->assertCount(
15,
$response->decodeResponseJson()['data']
);
$response->assertJsonFragment([
'total' => 153,
'current_page' => 1,
]);
$response->assertJsonStructure([
'data' => ['*' => $this->jsonStructureCurrency],
]);
}
/** @test */
public function it_gets_one_currency()
{
$currency = factory(Currency::class)->create([]);
$response = $this->json('GET', '/api/currencies/'.$currency->id);
$response->assertStatus(200);
$response->assertJsonFragment([
'id' => $currency->id,
'object' => 'currency',
]);
$response->assertJsonStructure([
'data' => $this->jsonStructureCurrency,
]);
}
/** @test */
public function it_gets_a_currency_that_is_invalid()
{
$response = $this->json('GET', '/api/currencies/0');
$this->expectNotFound($response);
}
}