Passed
Push — zero-is-false ( 14c39e...85b8a2 )
by Sam
06:15
created

CurrencyFieldDisabledTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFieldWithCustomisedCurrencySymbol() 0 9 1
A testFieldWithValue() 0 8 1
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