Completed
Pull Request — master (#62)
by Jason
17:50 queued 02:52
created

PromoBlockTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetPluralName() 0 5 1
A testGetCMSFields() 0 12 1
A testGetPromoList() 0 6 1
1
<?php
2
3
namespace Dynamic\DynamicBlocks\Test;
4
5
use Dynamic\DynamicBlocks\Block\PromoBlock;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\ORM\DataList;
9
10
class PromoBlockTest extends SapphireTest
11
{
12
    /**
13
     * @var string
14
     */
15
    protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml';
16
17
    /**
18
     *
19
     */
20
    public function testGetPluralName()
21
    {
22
        $object = singleton(PromoBlock::class);
23
        $this->assertEquals('Promos Blocks', $object->plural_name());
24
    }
25
26
    /**
27
     *
28
     */
29
    public function testGetCMSFields()
30
    {
31
        $object = singleton(PromoBlock::class);
32
        $fields = $object->getCMSFields();
33
        $this->assertInstanceOf(FieldList::class, $fields);
34
        $this->assertNull($fields->dataFieldByName('Promos'));
35
36
        $object = $this->objFromFixture(PromoBlock::class, 'one');
37
        $fields = $object->getCMSFields();
38
        $this->assertInstanceOf(FieldList::class, $fields);
39
        $this->assertNotNull($fields->dataFieldByName('Promos'));
40
    }
41
42
    public function testGetPromoList()
43
    {
44
        $object = $this->objFromFixture(PromoBlock::class, 'one');
45
        $this->assertInstanceOf(DataList::class, $object->getPromoList());
46
        $this->assertEquals($object->getPromoList(), $object->Promos()->sort('SortOrder'));
47
    }
48
}