function CurrencyCRUDWebTestCase::testCRUD in Currency 7.2
Test CRUD functionality.
File
- currency/
tests/ CurrencyCRUDWebTestCase.test, line 53 - Contains class CurrencyCRUDWebTestCase.
Class
- CurrencyCRUDWebTestCase
- Tests CRUD.
Code
function testCRUD() {
// Test creating a new currency.
$this
->assertEqual(ctools_export_crud_new('currency'), new Currency(), 'Chaos tools correctly creates a new currency.');
// Test inserting a currency.
$currency = new Currency(array(
'ISO4217Code' => 'XXX',
'subunits' => 5,
'title' => $this
->randomName(),
));
currency_save($currency);
$this
->assertTrue($this
->currencyExists($currency), 'Chaos tools correctly inserts a currency.');
// Test loading a currency.
$currency_loaded = currency_load($currency->ISO4217Code);
// The "export_type" and "type" properties are supposed to change.
unset($currency->export_type);
unset($currency->type);
unset($currency_loaded->export_type);
unset($currency_loaded->type);
$this
->assertEqual($currency, $currency_loaded, 'Chaos tools correctly loads a currency.');
// Test updating a currency.
$currency->ISO4217Code = 'EUR';
$currency->export_module = 'foo';
$currency->export_type = EXPORT_IN_CODE;
$currency->rounding_step = 100;
$currency->sign = 'bar';
$currency->subunits = 100;
$currency->title = 'baz';
currency_save($currency);
$this
->assertTrue($this
->currencyExists($currency), 'Chaos tools correctly updates a currency.');
// Test deleting a currency.
currency_delete($currency->ISO4217Code);
$this
->assertFalse($this
->currencyExists($currency), 'Chaos tools correctly deletes a currency.');
}