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

IssetTest::testIssetVarNull()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 16
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
use PHPSA\Variable;
9
10
class IssetTest extends \Tests\PHPSA\TestCase
11
{
12
    public function testIssetVarInt()
13
    {
14
        $context = $this->getContext();
15
        $context->addVariable(new Variable("name", 10, CompiledExpression::INTEGER));
16
17
        $baseExpression = new Node\Expr\Isset_([
18
            new Node\Expr\Variable(
19
                new Node\Name("name")
20
            )
21
        ]);
22
        $compiledExpression = $this->compileExpression($baseExpression, $context);
23
24
        parent::assertInstanceOfCompiledExpression($compiledExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertInstanceOfCompiledExpression() instead of testIssetVarInt()). 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...
25
        parent::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testIssetVarInt()). 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...
26
        parent::assertTrue($compiledExpression->getValue());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertTrue() instead of testIssetVarInt()). 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...
27
    }
28
29
    public function testIssetVarNull()
30
    {
31
        $context = $this->getContext();
32
        $context->addVariable(new Variable("name", null, CompiledExpression::NULL));
33
34
        $baseExpression = new Node\Expr\Isset_([
35
            new Node\Expr\Variable(
36
                new Node\Name("name")
37
            )
38
        ]);
39
        $compiledExpression = $this->compileExpression($baseExpression, $context);
40
41
        parent::assertInstanceOfCompiledExpression($compiledExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertInstanceOfCompiledExpression() instead of testIssetVarNull()). 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...
42
        parent::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testIssetVarNull()). 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...
43
        parent::assertFalse($compiledExpression->getValue());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertFalse() instead of testIssetVarNull()). Are you sure this is correct? If so, you might want to change this to $this->assertFalse().

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...
44
    }
45
46
    public function testIssetVarNotExisting()
47
    {
48
        $context = $this->getContext();
49
50
        $baseExpression = new Node\Expr\Isset_([
51
            new Node\Expr\Variable(
52
                new Node\Name("name")
53
            )
54
        ]);
55
        $compiledExpression = $this->compileExpression($baseExpression, $context);
56
57
        parent::assertInstanceOfCompiledExpression($compiledExpression);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertInstanceOfCompiledExpression() instead of testIssetVarNotExisting()). 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...
58
        parent::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertSame() instead of testIssetVarNotExisting()). 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...
59
        parent::assertFalse($compiledExpression->getValue());
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (assertFalse() instead of testIssetVarNotExisting()). Are you sure this is correct? If so, you might want to change this to $this->assertFalse().

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...
60
    }
61
}
62