Completed
Pull Request — master (#105)
by Nic
05:01
created

FlexSliderDataExtensionTest::testTabNameConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Dynamic\FlexSlider\Test\ORM;
4
5
use Dynamic\FlexSlider\Test\FlexSliderTest;
6
use Dynamic\FlexSlider\ORM\FlexSlider;
7
use SilverStripe\Core\Config\Config;
8
use Dynamic\FlexSlider\Test\TestOnly\TestOnlyPage;
9
use SilverStripe\ORM\DataList;
10
use SilverStripe\Core\Injector\Injector;
11
12
/**
13
 * Class FlexSliderDataExtensionTest
14
 * @package Dynamic\FlexSlider\Test\ORM
15
 */
16
class FlexSliderDataExtensionTest extends FlexSliderTest
17
{
18
19
    /**
20
     * @var array
21
     */
22
    protected static $extra_dataobjects = array(
23
        TestOnlyPage::class,
24
    );
25
26
    public function testTabNameConfig()
27
    {
28
        $page = TestOnlyPage::create();
29
        $page->write();
30
        $pageFields = $page->getCMSFields();
31
        //$extension->updateCMSFields($pageFields);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
        $this->assertNotNull($pageFields->fieldByName('Slides'));
33
34
        Config::modify()
35
            ->set(TestOnlyPage::class, 'slide_tab_title', 'MyCustomSlideTitle');
36
        $page2 = TestOnlyPage::create();
37
        $page2->write();
38
        $page2Fields = $page2->getCMSFields();
39
        //$extension->updateCMSFields($page2Fields);
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
        $this->assertNull($page2Fields->fieldByName('Root.Slides'));
41
        $this->assertNotNull($page2Fields->fieldByName('Root.MyCustomSlideTitle'));
42
    }
43
44
    public function testUpdateCMSFields()
45
    {
46
        $object = TestOnlyPage::create();
47
        $object->write();
48
        $fields = $object->getCMSFields();
49
        $this->assertNotNull($fields->dataFieldbyName('Slides'));
50
    }
51
52
    public function testGetSlideShow()
53
    {
54
        $object = TestOnlyPage::create();
55
        $object->write();
56
        $slide1 = $this->objFromFixture(
57
            'Dynamic\\FlexSlider\\Model\\SlideImage',
58
            'slide1'
59
        );
60
        /*$image = $this->objFromFixture('Image', 'image1');
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
61
        $slide1->ImageID = $image->ID;*/
62
        $object->Slides()->add($slide1);
63
        $slides = $object->getSlideShow();
64
        $this->assertInstanceOf(DataList::class, $slides);
65
    }
66
}
67