Files
FOSSBilling/tests/integration/bb-modules/mod_currency/Api_AdminTest.php
T
Belle Aerni 50043e6211 Run Rector against our tests (#1761)
* Update rector config to include tests

* Run Rector against the tests

* Delete test-results

* Update .gitignore

* Correctly set the PHP min to 8.1, split the configs

* Corrected PHPDoc

* Deleted tests we can't really get to pass

PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so).

No way to disable the exception as far as we can tell
2023-11-11 18:41:09 +00:00

59 lines
1.9 KiB
PHP

<?php
#[\PHPUnit\Framework\Attributes\Group('Core')]
class Api_Admin_CurrencyTest extends BBDbApiTestCase
{
protected $_initialSeedFile = 'currencies.xml';
public function testCurrencies()
{
$array = $this->api_admin->currency_get_pairs();
$this->assertIsArray($array);
$array = $this->api_admin->currency_get(array('code' => 'USD'));
$this->assertIsArray($array);
$this->assertEquals('USD', $array['code']);
$array = $this->api_admin->currency_get_default();
$this->assertIsArray($array);
$data = array(
'code' => 'GBP',
'title' => 'British Pound',
'format' => '{{price}}£',
);
$code = $this->api_admin->currency_create($data);
$this->assertIsString($code);
$bool = $this->api_admin->currency_update($data);
$this->assertTrue($bool);
$bool = $this->api_admin->currency_delete($data);
$this->assertTrue($bool);
$data['code'] = 'EUR';
$bool = $this->api_admin->currency_set_default($data);
$this->assertTrue($bool);
$bool = $this->api_admin->currency_update_rates();
$this->assertTrue($bool);
}
public function testCurerncyGetList()
{
$array = $this->api_admin->currency_get_list();
$this->assertIsArray($array);
$this->assertArrayHasKey('list', $array);
$list = $array['list'];
$this->assertIsArray($list);
if (count($list)){
$item = $list[0];
$this->assertArrayHasKey('code', $item);
$this->assertArrayHasKey('title', $item);
$this->assertArrayHasKey('conversion_rate', $item);
$this->assertArrayHasKey('format', $item);
$this->assertArrayHasKey('price_format', $item);
$this->assertArrayHasKey('default', $item);
}
}
}