Completed
Push — master ( cfdfa6...b435f2 )
by Jason
28s
created

SlideImageTest::testProvidePermissions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
class SlideImageTest extends FlexSliderTest
4
{
5
    protected static $use_draft_site = true;
6
7
    public function setUp()
8
    {
9
        parent::setUp();
10
    }
11
12
    public function testGetCMSFields()
13
    {
14
        $object = new SlideImage();
15
        $fieldset = $object->getCMSFields();
16
        $this->assertTrue(is_a($fieldset, 'FieldList'));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
17
        $this->assertNotNull($fieldset->dataFieldByName('Name'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
18
        $this->assertNotNull($fieldset->dataFieldByName('Image'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
19
    }
20
21
    public function testValidateName()
22
    {
23
        $object = $this->objFromFixture('SlideImage', 'slide1');
24
        $object->Name = '';
25
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
        $object->write();
27
    }
28
29
    public function testValidateImage()
30
    {
31
        $object = $this->objFromFixture('SlideImage', 'slide1');
32
        $object->ImageID = '';
33
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
34
        $object->write();
35
    }
36
37
    public function testCanView()
38
    {
39
        $object = $this->objFromFixture('SlideImage', 'slide1');
40
        $image = $this->objFromFixture('Image', 'image1');
41
        $object->ImageID = $image->ID;
42
        $object->write();
43
        $this->logInWithPermission('ADMIN');
44
        $this->assertTrue($object->canView());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
45
        $this->logOut();
46
        $nullMember = Member::create();
47
        $nullMember->write();
48
        $this->assertTrue($object->canView($nullMember));
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
49
        $nullMember->delete();
50
    }
51
52
    public function testCanEdit()
53
    {
54
        $object = $this->objFromFixture('SlideImage', 'slide1');
55
        $image = $this->objFromFixture('Image', 'image1');
56
        $object->ImageID = $image->ID;
57
        $object->write();
58
        $objectID = $object->ID;
59
        $this->logInWithPermission('ADMIN');
60
        $originalName = $object->Name;
61
        $this->assertEquals($originalName, 'Hello World');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
        $this->assertTrue($object->canEdit());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
63
        $object->Name = 'Changed Name';
64
        $object->write();
65
        $testEdit = SlideImage::get()->byID($objectID);
66
        $this->assertEquals($testEdit->Name, 'Changed Name');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
        $this->logOut();
68
    }
69
70
    public function testCanDelete()
71
    {
72
        $object = $this->objFromFixture('SlideImage', 'slide1');
73
        $image = $this->objFromFixture('Image', 'image1');
74
        $object->ImageID = $image->ID;
75
        $object->write();
76
        $this->logInWithPermission('ADMIN');
77
        $this->assertTrue($object->canDelete());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
78
        $checkObject = $object;
79
        $object->delete();
80
        $this->assertEquals($checkObject->ID, 0);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
81
    }
82
83
    public function testCanCreate()
84
    {
85
        $object = singleton('SlideImage');
86
        $this->logInWithPermission('ADMIN');
87
        $this->assertTrue($object->canCreate());
0 ignored issues
show
Bug introduced by
The method assertTrue() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
88
        $this->logOut();
89
        $nullMember = Member::create();
90
        $nullMember->write();
91
        $this->assertFalse($object->canCreate($nullMember));
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92
        $nullMember->delete();
93
    }
94
95
    public function testProvidePermissions()
96
    {
97
        $object = singleton('SlideImage');
98
        $expected = array(
99
            'Slide_EDIT' => 'Slide Edit',
100
            'Slide_DELETE' => 'Slide Delete',
101
            'Slide_CREATE' => 'Slide Create',
102
        );
103
        $this->assertEquals($expected, $object->providePermissions());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<SlideImageTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
    }
105
}
106