|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverStripe\Forms\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
6
|
|
|
use SilverStripe\Forms\CurrencyField_Disabled; |
|
7
|
|
|
use SilverStripe\ORM\FieldType\DBCurrency; |
|
8
|
|
|
|
|
9
|
|
|
class CurrencyFieldDisabledTest extends SapphireTest |
|
10
|
|
|
{ |
|
11
|
|
|
public function testFieldWithValue() |
|
12
|
|
|
{ |
|
13
|
|
|
$field = new CurrencyField_Disabled('Test', '', '$5.00'); |
|
14
|
|
|
$result = $field->Field(); |
|
15
|
|
|
|
|
16
|
|
|
$this->assertContains('<input', $result, 'An input should be rendered'); |
|
17
|
|
|
$this->assertContains('disabled', $result, 'The input should be disabled'); |
|
18
|
|
|
$this->assertContains('$5.00', $result, 'The value should be rendered'); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @todo: Update the expectation when intl for currencies is implemented |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testFieldWithCustomisedCurrencySymbol() |
|
25
|
|
|
{ |
|
26
|
|
|
DBCurrency::config()->update('currency_symbol', '€'); |
|
27
|
|
|
$field = new CurrencyField_Disabled('Test', '', '€5.00'); |
|
28
|
|
|
$result = $field->Field(); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertContains('<input', $result, 'An input should be rendered'); |
|
31
|
|
|
$this->assertContains('disabled', $result, 'The input should be disabled'); |
|
32
|
|
|
$this->assertContains('€5.00', $result, 'The value should be rendered'); |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|