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

FormBlockTest::testCanView()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
3
class FormBlockTest 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 testGetPluralName()
14
    {
15
        $object = singleton('FormBlock');
16
        $this->assertEquals('Form Blocks', $object->plural_name());
0 ignored issues
show
Bug introduced by
The method assertEquals() does not seem to exist on object<FormBlockTest>.

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
    }
18
19
    /**
20
     *
21
     */
22
    public function testGetCMSFields()
23
    {
24
        $object = $this->objFromFixture('FormBlock', 'one');
25
        $fields = $object->getCMSFields();
26
        $this->assertInstanceOf('FieldList', $fields);
27
    }
28
29
    /**
30
     *
31
     */
32
    public function testBlockForm()
33
    {
34
        if (class_exists('UserDefinedForm')) {
35
            $object = $this->objFromFixture('FormBlock', 'one');
36
            $form = $object->Form();
37
            $this->assertInstanceOf('UserDefinedForm', $form);
38
        }
39
    }
40
41
    /**
42
     *
43
     */
44 View Code Duplication
    public function testCanView()
0 ignored issues
show
Duplication introduced by
This method 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...
45
    {
46
        $object = $this->objFromFixture('FormBlock', 'one');
47
        $admin = $this->objFromFixture('Member', 'admin');
48
        $member = $this->objFromFixture('Member', 'default');
49
        if (class_exists('UserDefinedForm')) {
50
            $this->assertTrue($object->canView($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 47 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<FormBlockTest>.

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

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
        } else {
53
            $this->assertFalse($object->canView($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 47 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 assertFalse() does not seem to exist on object<FormBlockTest>.

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
            $this->assertFalse($object->canView($member));
0 ignored issues
show
Bug introduced by
It seems like $member defined by $this->objFromFixture('Member', 'default') on line 48 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 assertFalse() does not seem to exist on object<FormBlockTest>.

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
     */
61 View Code Duplication
    public function testCanCreate()
0 ignored issues
show
Duplication introduced by
This method 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...
62
    {
63
        $object = $this->objFromFixture('FormBlock', 'one');
64
        $admin = $this->objFromFixture('Member', 'admin');
65
        $member = $this->objFromFixture('Member', 'default');
66
        if (class_exists('UserDefinedForm')) {
67
            $this->assertTrue($object->canCreate($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 64 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<FormBlockTest>.

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...
68
            $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<FormBlockTest>.

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
        } else {
70
            $this->assertFalse($object->canCreate($admin));
0 ignored issues
show
Bug introduced by
It seems like $admin defined by $this->objFromFixture('Member', 'admin') on line 64 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 assertFalse() does not seem to exist on object<FormBlockTest>.

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...
71
            $this->assertFalse($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 assertFalse() does not seem to exist on object<FormBlockTest>.

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
}