Completed
Pull Request — master (#52)
by Jason
03:49
created

SlideImageTest::testCanCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 9
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 testValidateName()
13
    {
14
        $object = $this->objFromFixture('SlideImage', 'slide1');
15
        $object->Name = '';
16
        $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...
17
        $object->write();
18
    }
19
20
    public function testValidateImage()
21
    {
22
        $object = $this->objFromFixture('SlideImage', 'slide1');
23
        $object->ImageID = '';
24
        $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...
25
        $object->write();
26
    }
27
28
    public function testCanView()
29
    {
30
        $object = $this->objFromFixture('SlideImage', 'slide1');
31
        $image = $this->objFromFixture('Image', 'image1');
32
        $object->ImageID = $image->ID;
33
        $object->write();
34
        $this->logInWithPermission('ADMIN');
35
        $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...
36
        $this->logOut();
37
        $nullMember = Member::create();
38
        $nullMember->write();
39
        $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...
40
        $nullMember->delete();
41
    }
42
43
    public function testCanEdit()
44
    {
45
        $object = $this->objFromFixture('SlideImage', 'slide1');
46
        $image = $this->objFromFixture('Image', 'image1');
47
        $object->ImageID = $image->ID;
48
        $object->write();
49
        $objectID = $object->ID;
50
        $this->logInWithPermission('ADMIN');
51
        $originalName = $object->Name;
52
        $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...
53
        $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...
54
        $object->Name = 'Changed Name';
55
        $object->write();
56
        $testEdit = SlideImage::get()->byID($objectID);
57
        $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...
58
        $this->logOut();
59
    }
60
61
    public function testCanDelete()
62
    {
63
        $object = $this->objFromFixture('SlideImage', 'slide1');
64
        $image = $this->objFromFixture('Image', 'image1');
65
        $object->ImageID = $image->ID;
66
        $object->write();
67
        $this->logInWithPermission('ADMIN');
68
        $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...
69
        $checkObject = $object;
70
        $object->delete();
71
        $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...
72
    }
73
74
    public function testCanCreate()
75
    {
76
        $object = singleton('SlideImage');
77
        $this->logInWithPermission('ADMIN');
78
        $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...
79
        $this->logOut();
80
        $nullMember = Member::create();
81
        $nullMember->write();
82
        $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...
83
        $nullMember->delete();
84
    }
85
86
    public function testProvidePermissions()
87
    {
88
        $object = singleton('SlideImage');
89
        $expected = array(
90
            'Slide_EDIT' => 'Edit a Slide',
91
            'Slide_DELETE' => 'Delete a Slide',
92
            'Slide_CREATE' => 'Create a Slide',
93
        );
94
        $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...
95
    }
96
}
97