ElementPromosTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 14
c 2
b 0
f 1
dl 0
loc 47
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetSummary() 0 4 1
A testGetPromoList() 0 5 1
A testGetType() 0 4 1
A testGetCMSFields() 0 6 1
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