GalleryImageTest::testGetPortletCaption()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
class GalleryImageTest extends TestWithImage {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
    protected static $fixture_file = 'ss3gallery/tests/ss3gallery.yml';
5
6
    public function testCMSFields() {
7
        $gi = new GalleryImage();
8
        $fields = $gi->getCMSFields();
9
        $tab = $fields->findOrMakeTab('Root.Main');
10
        $fields = $tab->FieldList();
11
12
        $names = array();
13
        foreach ($fields as $field) {
14
            array_push($names, $field->getName());
15
        }
16
17
        $expected = array('Title', 'Caption', 'Aperture', 'ShutterSpeed',
18
            'TakenAt', 'ISO', 'Orientation', 'Image');
19
        $this->assertEquals($expected, $names);
20
21
        $fields = $gi->getCMSFields();
22
        $tab = $fields->findOrMakeTab('Root.Location');
23
        $fields = $tab->FieldList();
24
25
        $names = array();
26
        foreach ($fields as $field) {
27
            array_push($names, $field->getName());
28
        }
29
        $expected = array('LatLonZoomLevel', 'MapPinIcon');
30
        $this->assertEquals($expected, $names);
31
    }
32
33
    public function testGetThumbnail() {
34
        $gi = $this->objFromFixture('GalleryImage', 'gi01');
35
        $thumbnail = $gi->getThumbnail();
36
        $this->assertEquals(100, $thumbnail->Width);
37
        $this->assertEquals(100, $thumbnail->Height);
38
    }
39
40
      public function testGetPortletTitle() {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 6
Loading history...
41
        $gi = $this->objFromFixture('GalleryImage', 'gi01');
42
        $this->assertEquals($gi->Title, $gi->getPortletTitle());
43
        $gi->Title = 'Another title';
44
        $this->assertEquals($gi->Title, $gi->getPortletTitle());
45
    }
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
Coding Style introduced by
Closing brace indented incorrectly; expected 6 spaces, found 4
Loading history...
46
47
    public function testGetPortletImage() {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 8 spaces, found 4
Loading history...
48
        $gi = $this->objFromFixture('GalleryImage', 'gi01');
0 ignored issues
show
Coding Style introduced by
It seems like the identation of this line is off (expected at least 12 spaces, but found 8).
Loading history...
49
        $this->assertEquals($gi->getPortletImage()->Filename,
0 ignored issues
show
Coding Style introduced by
It seems like the identation of this line is off (expected at least 12 spaces, but found 8).
Loading history...
50
                                        'assets/TestImageSS3Gallery/test.jpg');
51
    }
52
53
    public function testGetPortletCaption() {
54
        $gi = $this->objFromFixture('GalleryImage', 'gi01');
55
        $this->assertEquals('', $gi->getPortletCaption());
56
    }
57
}
58