Completed
Push — master ( 1d2fd9...fbfc98 )
by Jason
10s
created

PromoObjectTest::testCanEdit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3 View Code Duplication
class PromoObjectTest extends SapphireTest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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('PromoObject', 'one');
16
        $fields = $object->getCMSFields();
17
        $this->assertInstanceOf('FieldList', $fields);
18
        $this->assertNotNull($fields->dataFieldByName('BlockLinkID'));
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<PromoObjectTest>.

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 testValidateName()
25
    {
26
        $object = $this->objFromFixture('PromoObject', 'one');
27
        $object->Name = '';
28
        $this->setExpectedException('ValidationException');
0 ignored issues
show
Bug introduced by
The method setExpectedException() does not seem to exist on object<PromoObjectTest>.

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
        $object->write();
30
    }
31
32
    /**
33
     *
34
     */
35
    public function testCanView()
36
    {
37
        $object = $this->objFromFixture('PromoObject', 'one');
38
        $admin = $this->objFromFixture('Member', 'admin');
39
        $this->assertTrue($object->canView($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 38 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<PromoObjectTest>.

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
        $member = $this->objFromFixture('Member', 'default');
41
        $this->assertTrue($object->canView($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 40 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<PromoObjectTest>.

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...
42
    }
43
44
    /**
45
     *
46
     */
47
    public function testCanEdit()
48
    {
49
        $object = $this->objFromFixture('PromoObject', 'one');
50
        $admin = $this->objFromFixture('Member', 'admin');
51
        $this->assertTrue($object->canEdit($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 50 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<PromoObjectTest>.

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...
52
        $member = $this->objFromFixture('Member', 'default');
53
        $this->assertTrue($object->canEdit($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 52 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<PromoObjectTest>.

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
    }
55
56
    /**
57
     *
58
     */
59
    public function testCanDelete()
60
    {
61
        $object = $this->objFromFixture('PromoObject', 'one');
62
        $admin = $this->objFromFixture('Member', 'admin');
63
        $this->assertTrue($object->canDelete($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 62 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<PromoObjectTest>.

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...
64
        $member = $this->objFromFixture('Member', 'default');
65
        $this->assertTrue($object->canDelete($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 64 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<PromoObjectTest>.

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...
66
    }
67
68
    /**
69
     *
70
     */
71
    public function testCanCreate()
72
    {
73
        $object = $this->objFromFixture('PromoObject', 'one');
74
        $admin = $this->objFromFixture('Member', 'admin');
75
        $this->assertTrue($object->canCreate($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 74 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<PromoObjectTest>.

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...
76
        $member = $this->objFromFixture('Member', 'default');
77
        $this->assertTrue($object->canCreate($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 76 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<PromoObjectTest>.

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
    }
79
}