Completed
Push — master ( b23224...622181 )
by Nic
10s
created

ElementCountDownTest::testEncodeArrayValues()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Dynamic\Elements\CountDown\Tests;
4
5
use Dynamic\Elements\CountDown\Elements\ElementCountDown;
6
use SilverStripe\Core\Injector\Injector;
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\View\ArrayData;
9
10
/**
11
 * Class ElementCountDownTest
12
 * @package Dynamic\Elements\Tests
13
 */
14
class ElementCountDownTest extends SapphireTest
15
{
16
    /**
17
     * @var string
18
     */
19
    protected static $fixture_file = '../fixtures.yml';
20
21
    /**
22
     *
23
     */
24
    public function testGetType()
25
    {
26
        $object = Injector::inst()->create(ElementCountDown::class);
27
        $this->assertEquals($object->getType(), 'Count Down');
28
    }
29
30
    /**
31
     *
32
     */
33
    public function testGetClientConfig()
34
    {
35
        $element = $this->objFromFixture(ElementCountDown::class, 'endonly');
36
        $this->assertInstanceOf(ArrayData::class, $element->getClientConfig());
37
    }
38
39
    /**
40
     *
41
     */
42
    public function testEncodeArrayValues()
43
    {
44
        $element = $this->objFromFixture(ElementCountDown::class, 'elapse');
45
        $config = $element->getClientConfig();
46
47
        $this->assertEquals(json_decode($config->getField('End')), $element->End);
48
        $this->assertEquals(json_decode($config->getField('Elapse')), $element->Elapse);
49
    }
50
}
51