Completed
Pull Request — master (#62)
by Jason
11:55
created

AccordionBlockControllerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testAccordionClass() 0 6 1
1
<?php
2
3
namespace Dynamic\DynamicBlocks\Test;
4
5
use Dynamic\DynamicBlocks\Block\AccordionBlock;
6
use Dynamic\DynamicBlocks\Block\AccordionBlockController;
7
use SilverStripe\Core\Config\Config;
8
use SilverStripe\Dev\FunctionalTest;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\Forms\FieldList;
11
12 View Code Duplication
class AccordionBlockTest extends SapphireTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
{
14
    /**
15
     * @var string
16
     */
17
    protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml';
18
19
    /**
20
     *
21
     */
22
    public function testGetPluralName()
23
    {
24
        $object = singleton(AccordionBlock::class);
25
        $this->assertEquals('Accordion Blocks', $object->plural_name());
26
    }
27
28
    /**
29
     *
30
     */
31
    public function testGetCMSFields()
32
    {
33
        $object = $this->objFromFixture(AccordionBlock::class, 'one');
34
        $fields = $object->getCMSFields();
35
        $this->assertInstanceOf(FieldList::class, $fields);
36
        $this->assertNotNull($fields->dataFieldByName('Panels'));
37
    }
38
39
    /**
40
     *
41
     */
42
    public function testGetPanelList()
43
    {
44
        $object = $this->objFromFixture(AccordionBlock::class, 'one');
45
        $panels = $object->Panels()->sort('Sort');
46
        $this->assertEquals($panels, $object->getPanelList());
47
    }
48
}
49
50
class AccordionBlockControllerTest extends FunctionalTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
51
{
52
    /**
53
     *
54
     */
55
    public function testAccordionClass()
56
    {
57
        $object = singleton(AccordionBlockController::class);
58
        $expected = Config::inst()->get(AccordionBlockController::class, 'accordion_class');
59
        $this->assertEquals($object->AccordionClass(), $expected);
60
    }
61
}
62