Code Duplication    Length = 21-39 lines in 6 locations

tests/CallToActionBlockTest.php 1 location

@@ 9-47 (lines=39) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class CallToActionBlockTest 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 testGetPluralName()
20
    {
21
        $object = singleton(CallToActionBlock::class);
22
        $this->assertEquals('Call To Action Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = $this->objFromFixture(CallToActionBlock::class, 'one');
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        //$this->assertNotNull($fields->dataFieldByName('BlockLinkID')); // todo readd once Linkable is SS4 compatible
34
    }
35
36
    /**
37
     *
38
     */
39
    /* // todo readd once Linkable is SS4 compatible
40
    public function testGetTitle()
41
    {
42
        $object = $this->objFromFixture(CallToActionBlock::class, 'one');
43
        $link = $object->BlockLink();
44
        $this->assertEquals($link->Title, $object->getTitle());
45
    }
46
    */
47
}
48

tests/CustomerServiceBlockTest.php 1 location

@@ 9-35 (lines=27) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class CustomerServiceBlockTest 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 testGetPluralName()
20
    {
21
        $object = singleton(CustomerServiceBlock::class);
22
        $this->assertEquals('Customer Service Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = $this->objFromFixture(CustomerServiceBlock::class, 'one');
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        //$this->assertNotNull($fields->dataFieldByName('Address')); // todo readd once Addressable is SS4 compatible
34
    }
35
}

tests/DynamicContentBlockDataExtensionTest.php 1 location

@@ 10-30 (lines=21) @@
7
use SilverStripe\Dev\SapphireTest;
8
use SilverStripe\Forms\FieldList;
9
10
class DynamicContentBlockDataExtensionTest 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 testGetCMSFields()
21
    {
22
        $object = $this->objFromFixture(ContentBlock::class, 'one');
23
        $fields = $object->getCMSFields();
24
        $extension = new DynamicContentBlockDataExtension();
25
        $extension->updateCMSFields($fields);
26
27
        $this->assertInstanceOf(FieldList::class, $fields);
28
        $this->assertNotNull($fields->dataFieldByName('Image'));
29
    }
30
}

tests/EmailSignupBlockTest.php 1 location

@@ 9-35 (lines=27) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class EmailSignupBlockTest 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 testGetPluralName()
20
    {
21
        $object = singleton(EmailSignupBlock::class);
22
        $this->assertEquals('Email Signup Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = $this->objFromFixture(EmailSignupBlock::class, 'one');
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        $this->assertNotNull($fields->dataFieldByName('EmbedCode'));
34
    }
35
}

tests/EmbedCodeBlockTest.php 1 location

@@ 9-36 (lines=28) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class EmbedCodeBlockTest 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 testGetPluralName()
20
    {
21
        $object = singleton(EmbedCodeBlock::class);
22
        $this->assertEquals('Embed Code Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = $this->objFromFixture(EmbedCodeBlock::class, 'one');
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        $this->assertNotNull($fields->dataFieldByName('Code'));
34
    }
35
36
}

tests/ImageBlockTest.php 1 location

@@ 9-35 (lines=27) @@
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\FieldList;
8
9
class ImageBlockTest 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 testGetPluralName()
20
    {
21
        $object = singleton(ImageBlock::class);
22
        $this->assertEquals('Image Blocks', $object->plural_name());
23
    }
24
25
    /**
26
     *
27
     */
28
    public function testGetCMSFields()
29
    {
30
        $object = singleton(ImageBlock::class);
31
        $fields = $object->getCMSFields();
32
        $this->assertInstanceOf(FieldList::class, $fields);
33
        $this->assertNotNull($fields->dataFieldByName('Image'));
34
    }
35
}