Passed
Push — master ( 85839c...7d586d )
by Jason
03:54 queued 02:00
created

ElementPromosTest::testGetSummary()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Dynamic\Elements\Promos\Tests;
4
5
use Dynamic\Elements\Promos\Elements\ElementPromos;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\ORM\DataList;
9
10
class ElementPromosTest extends SapphireTest
11
{
12
    /**
13
     * @var string
14
     */
15
    protected static $fixture_file = '../fixtures.yml';
16
17
    protected static $extra_dataobjects = [
18
    ];
19
20
    /**
21
     *
22
     */
23
    public function testGetCMSFields()
24
    {
25
        $object = $this->objFromFixture(ElementPromos::class, 'one');
26
        $fields = $object->getCMSFields();
27
        $this->assertInstanceOf(FieldList::class, $fields);
28
        $this->assertNotNull($fields->dataFieldByName('Promos'));
29
    }
30
31
    /**
32
     *
33
     */
34
    public function testGetPromoList()
35
    {
36
        $object = $this->objFromFixture(ElementPromos::class, 'one');
37
        $this->assertInstanceOf(DataList::class, $object->getPromoList());
38
        $this->assertEquals($object->getPromoList(), $object->Promos()->sort('SortOrder'));
39
    }
40
41
    /**
42
     *
43
     */
44
    public function testGetSummary()
45
    {
46
        $object = $this->objFromFixture(ElementPromos::class, 'one');
47
        $this->assertEquals($object->getSummary(), '2 promos');
48
    }
49
50
    /**
51
     *
52
     */
53
    public function testGetType()
54
    {
55
        $object = $this->objFromFixture(ElementPromos::class, 'one');
56
        $this->assertEquals($object->getType(), 'Promos');
57
    }
58
}
59