Completed
Push — master ( 2006ba...483d1e )
by Will
03:23
created

ElementPageExtensionTests::testElementalArea()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @package elemental
5
 * @subpackage tests
6
 */
7
class ElementPageExtensionTests extends FunctionalTest {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
9
    protected static $fixture_file = 'elemental/tests/fixtures.yml';
10
11
    public function setUp() {
12
        parent::setUp();
13
14
        Page::add_extension('ElementPageExtension');
15
    }
16
17
    public function testUpdateCmsFields() {
18
        $page = $this->objFromFixture('Page', 'elementaldemo');
19
20
        $elementarea = $page->getCMSFields()->dataFieldByName('ElementArea');
21
        $this->assertNotNull($elementarea);
0 ignored issues
show
Bug introduced by
The method assertNotNull() does not seem to exist on object<ElementPageExtensionTests>.

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...
22
23
24
        $elementarea = $page->getCMSFields()->dataFieldByName('Content');
0 ignored issues
show
Unused Code introduced by
$elementarea is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
25
        $this->assertNull($content);
0 ignored issues
show
Bug introduced by
The variable $content does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

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

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
27
        $redirect = $this->objFromFixture('Page', 'elementredirectpage');
0 ignored issues
show
Unused Code introduced by
$redirect is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
28
        $elementarea = $page->getCMSFields()->dataFieldByName('ElementArea');
29
        $this->assertNull($elementarea);
0 ignored issues
show
Bug introduced by
The method assertNull() does not seem to exist on object<ElementPageExtensionTests>.

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...
30
    }
31
32
    public function testDuplicatePageCopiesContent() {
33
34
    }
35
36
    public function testPublishingPagePublishesElement() {
37
38
    }
39
40
    public function testElementalArea() {
41
42
    }
43
}
44