Completed
Push — master ( fbfc98...86fc64 )
by Jason
9s
created

PhotoGalleryBlockImageTest::testGetCMSFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
class PhotoGalleryBlockImageTest extends SapphireTest
4
{
5
    /**
6
     * @var string
7
     */
8
    protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml';
9
10
    /**
11
     *
12
     */
13
    public function testGetCMSFields()
14
    {
15
        $object = $this->objFromFixture('PhotoGalleryBlockImage', 'one');
16
        $fields = $object->getCMSFields();
17
        $this->assertInstanceOf('FieldList', $fields);
18
        $this->assertNull($fields->dataFieldByName('PhotoGalleryID'));
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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
    /**
22
     *
23
     */
24
    public function testCanView()
25
    {
26
        $object = $this->objFromFixture('PhotoGalleryBlockImage', 'one');
27
        $admin = $this->objFromFixture('Member', 'admin');
28
        $this->assertTrue($object->canView($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 27 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
29
        $member = $this->objFromFixture('Member', 'default');
30
        $this->assertTrue($object->canView($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 29 can also be of type object<DataObject>; however, DataObject::canView() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
31
    }
32
33
    /**
34
     *
35
     */
36
    public function testCanEdit()
37
    {
38
        $object = $this->objFromFixture('PhotoGalleryBlockImage', 'one');
39
        $admin = $this->objFromFixture('Member', 'admin');
40
        $this->assertTrue($object->canEdit($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 39 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
41
        $member = $this->objFromFixture('Member', 'default');
42
        $this->assertTrue($object->canEdit($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 41 can also be of type object<DataObject>; however, DataObject::canEdit() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
43
    }
44
45
    /**
46
     *
47
     */
48
    public function testCanDelete()
49
    {
50
        $object = $this->objFromFixture('PhotoGalleryBlockImage', 'one');
51
        $admin = $this->objFromFixture('Member', 'admin');
52
        $this->assertTrue($object->canDelete($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 51 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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
        $member = $this->objFromFixture('Member', 'default');
54
        $this->assertTrue($object->canDelete($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 53 can also be of type object<DataObject>; however, DataObject::canDelete() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
55
    }
56
57
    /**
58
     *
59
     */
60
    public function testCanCreate()
61
    {
62
        $object = $this->objFromFixture('PhotoGalleryBlockImage', 'one');
63
        $admin = $this->objFromFixture('Member', 'admin');
64
        $this->assertTrue($object->canCreate($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 63 can also be of type object<DataObject>; however, DataObject::canCreate() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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...
65
        $member = $this->objFromFixture('Member', 'default');
66
        $this->assertTrue($object->canCreate($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 65 can also be of type object<DataObject>; however, DataObject::canCreate() does only seem to accept object<Member>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
Bug introduced by
The method assertTrue() does not seem to exist on object<PhotoGalleryBlockImageTest>.

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
    }
68
}
69