ElementAccordionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 14
c 3
b 0
f 1
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetType() 0 4 1
A testGetCMSFields() 0 6 1
A testGetSummary() 0 8 1
1
<?php
2
3
namespace Dynamic\Elements\Accordion\Tests;
4
5
use Dynamic\Elements\Accordion\Elements\ElementAccordion;
6
use Dynamic\Elements\Accordion\Model\AccordionPanel;
7
use SilverStripe\Core\Injector\Injector;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\Forms\FieldList;
10
11
class ElementAccordionTest extends SapphireTest
12
{
13
    /**
14
     * @var string
15
     */
16
    protected static $fixture_file = '../fixtures.yml';
17
18
    /**
19
     *
20
     */
21
    public function testGetCMSFields()
22
    {
23
        $object = $this->objFromFixture(ElementAccordion::class, 'one');
24
        $fields = $object->getCMSFields();
25
        $this->assertInstanceOf(FieldList::class, $fields);
26
        $this->assertNotNull($fields->dataFieldByName('Panels'));
27
    }
28
29
    /**
30
     *
31
     */
32
    public function testGetSummary()
33
    {
34
        $object = $this->objFromFixture(ElementAccordion::class, 'one');
35
        $count = $object->Panels()->count();
36
        $this->assertEquals($object->getSummary(), _t(
37
            AccordionPanel::class . 'PLURALS',
38
            '{count} Accordion Panel|{count} Accordion Panels',
39
            [ 'count' => $count ]
40
        ));
41
    }
42
43
    /**
44
     *
45
     */
46
    public function testGetType()
47
    {
48
        $object = Injector::inst()->create(ElementAccordion::class);
49
        $this->assertEquals($object->getType(), 'Accordion');
50
    }
51
}
52