2018-10-20 17:41:41 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms\Tests;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Forms\CurrencyField_Disabled;
|
|
|
|
use SilverStripe\ORM\FieldType\DBCurrency;
|
|
|
|
|
2018-11-10 13:55:11 +01:00
|
|
|
class CurrencyFieldDisabledTest extends SapphireTest
|
2018-10-20 17:41:41 +02:00
|
|
|
{
|
|
|
|
public function testFieldWithValue()
|
|
|
|
{
|
|
|
|
$field = new CurrencyField_Disabled('Test', '', '$5.00');
|
|
|
|
$result = $field->Field();
|
|
|
|
|
2021-10-27 04:39:47 +02:00
|
|
|
$this->assertStringContainsString('<input', $result, 'An input should be rendered');
|
|
|
|
$this->assertStringContainsString('disabled', $result, 'The input should be disabled');
|
|
|
|
$this->assertStringContainsString('$5.00', $result, 'The value should be rendered');
|
2018-10-20 17:41:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo: Update the expectation when intl for currencies is implemented
|
|
|
|
*/
|
|
|
|
public function testFieldWithCustomisedCurrencySymbol()
|
|
|
|
{
|
|
|
|
DBCurrency::config()->update('currency_symbol', '€');
|
|
|
|
$field = new CurrencyField_Disabled('Test', '', '€5.00');
|
|
|
|
$result = $field->Field();
|
|
|
|
|
2021-10-27 04:39:47 +02:00
|
|
|
$this->assertStringContainsString('<input', $result, 'An input should be rendered');
|
|
|
|
$this->assertStringContainsString('disabled', $result, 'The input should be disabled');
|
|
|
|
$this->assertStringContainsString('€5.00', $result, 'The value should be rendered');
|
2018-10-20 17:41:41 +02:00
|
|
|
}
|
|
|
|
}
|