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

TernaryTest::testTernaryTrue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA\Expression;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
9
class TernaryTest extends \Tests\PHPSA\TestCase
10
{
11
    public function testTernaryTrue()
12
    {
13
        // (2 == 2) ? "if" : "else"
14
        $baseExpression = new Node\Expr\Ternary(
15
            new Node\Expr\BinaryOp\Equal($this->newScalarExpr(2), $this->newScalarExpr(2)),
16
            $this->newScalarExpr("if"),
17
            $this->newScalarExpr("else")
18
        );
19
        $compiledExpression = $this->compileExpression($baseExpression);
20
21
        parent::assertInstanceOfCompiledExpression($compiledExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertInstanceOfCompiledExpression() instead of testTernaryTrue()). Are you sure this is correct? If so, you might want to change this to $this->assertInstanceOfCompiledExpression().

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...
22
        parent::assertSame(CompiledExpression::STRING, $compiledExpression->getType());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testTernaryTrue()). Are you sure this is correct? If so, you might want to change this to $this->assertSame().

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...
23
        parent::assertSame("if", $compiledExpression->getValue());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testTernaryTrue()). Are you sure this is correct? If so, you might want to change this to $this->assertSame().

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...
24
    }
25
26
    public function testTernaryFalse()
27
    {
28
        // (2 == 3) ? "if" : "else"
29
        $baseExpression = new Node\Expr\Ternary(
30
            new Node\Expr\BinaryOp\Equal($this->newScalarExpr(2), $this->newScalarExpr(3)),
31
            $this->newScalarExpr("if"),
32
            $this->newScalarExpr("else")
33
        );
34
        $compiledExpression = $this->compileExpression($baseExpression);
35
36
        parent::assertInstanceOfCompiledExpression($compiledExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertInstanceOfCompiledExpression() instead of testTernaryFalse()). Are you sure this is correct? If so, you might want to change this to $this->assertInstanceOfCompiledExpression().

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...
37
        parent::assertSame(CompiledExpression::STRING, $compiledExpression->getType());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testTernaryFalse()). Are you sure this is correct? If so, you might want to change this to $this->assertSame().

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...
38
        parent::assertSame("else", $compiledExpression->getValue());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testTernaryFalse()). Are you sure this is correct? If so, you might want to change this to $this->assertSame().

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...
39
    }
40
}
41