Completed
Pull Request — master (#149)
by Enrico
04:02
created

EchoTest::testEchoCreatesVar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 19
rs 9.4285
1
<?php
2
3
namespace Tests\PHPSA\Compiler\Statement;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
use PHPSA\Variable;
9
10
class EchoTest extends \Tests\PHPSA\TestCase
11
{
12
    /**
13
     * Tests echo $stmtTest = 2; creates the variable
14
     */
15
    public function testEchoCreatesVar()
16
    {
17
        $context = $this->getContext();
18
19
        $statement = new Node\Stmt\Echo_([
20
            new Node\Expr\Assign(
21
                new Node\Expr\Variable(
22
                    new Node\Name("stmtTest")
23
                ),
24
                $this->newScalarExpr(2)
25
            )
26
        ]);
27
        
28
        \PHPSA\nodeVisitorFactory($statement, $context);
29
30
        $variable = $context->getSymbol("stmtTest");
31
32
        parent::assertTrue($variable instanceof Variable);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertTrue() instead of testEchoCreatesVar()). Are you sure this is correct? If so, you might want to change this to $this->assertTrue().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
33
    }
34
}
35