Code Duplication    Length = 32-39 lines in 3 locations

tests/AccordionBlockTest.php 1 location

@@ 12-48 (lines=37) @@
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\Forms\FieldList;
11
12
class AccordionBlockTest extends SapphireTest
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
51
{

tests/PageSectionBlockTest.php 1 location

@@ 12-50 (lines=39) @@
9
/**
10
 * Class PageSectionBlockTest
11
 */
12
class PageSectionBlockTest extends SapphireTest
13
{
14
15
    /**
16
     * @var string
17
     */
18
    protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml';
19
20
    /**
21
     *
22
     */
23
    public function testGetPluralName()
24
    {
25
        $object = singleton(PageSectionBlock::class);
26
        $this->assertEquals('Page Sections Blocks', $object->plural_name());
27
    }
28
29
    /**
30
     *
31
     */
32
    public function testGetCMSFields()
33
    {
34
        $object = $this->objFromFixture(PageSectionBlock::class, 'one');
35
        $fields = $object->getCMSFields();
36
        $this->assertInstanceOf(FieldList::class, $fields);
37
        $this->assertNotNull($fields->dataFieldByName('Sections'));
38
    }
39
40
    /**
41
     *
42
     */
43
    public function testGetPageSections()
44
    {
45
        $object = $this->objFromFixture(PageSectionBlock::class, 'one');
46
        $expected = $object->Sections()->sort('SortOrder');
47
        $this->assertEquals($expected, $object->getPageSections());
48
    }
49
50
}

tests/PhotoGalleryBlockTest.php 1 location

@@ 9-40 (lines=32) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class PhotoGalleryBlockTest extends SapphireTest
10
{
11
    /**
12
     * @var string
13
     */
14
    protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml';
15
16
    /**
17
     *
18
     */
19
    public function testPluralName()
20
    {
21
        $object = singleton(PhotoGalleryBlock::class);
22
        $this->assertEquals('Photo Gallery Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = singleton(PhotoGalleryBlock::class);
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        $this->assertNull($fields->dataFieldByName('Images'));
34
35
        $object = $this->objFromFixture(PhotoGalleryBlock::class, 'one');
36
        $fields = $object->getCMSFields();
37
        $this->assertInstanceOf(FieldList::class, $fields);
38
        $this->assertNotNull($fields->dataFieldByName('Images'));
39
    }
40
}
41