IssetTest::testIssetVarInt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 18
rs 9.6666
c 0
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
        $this->markTestSkipped('Unsupported now, because it is not possible to get good results');
15
16
        $context = $this->getContext();
17
        $context->addVariable(new Variable("name", 10, CompiledExpression::INTEGER));
18
19
        $baseExpression = new Node\Expr\Isset_([
20
            new Node\Expr\Variable(
21
                new Node\Name("name")
22
            )
23
        ]);
24
        $compiledExpression = $this->compileExpression($baseExpression, $context);
25
26
        self::assertInstanceOfCompiledExpression($compiledExpression);
27
        self::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
28
        self::assertTrue($compiledExpression->getValue());
29
    }
30
31
    public function testIssetVarNull()
32
    {
33
        $this->markTestSkipped('Unsupported now, because it is not possible to get good results');
34
35
        $context = $this->getContext();
36
        $context->addVariable(new Variable("name", null, CompiledExpression::NULL));
37
38
        $baseExpression = new Node\Expr\Isset_([
39
            new Node\Expr\Variable(
40
                new Node\Name("name")
41
            )
42
        ]);
43
        $compiledExpression = $this->compileExpression($baseExpression, $context);
44
45
        self::assertInstanceOfCompiledExpression($compiledExpression);
46
        self::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
47
        self::assertFalse($compiledExpression->getValue());
48
    }
49
50
    public function testIssetVarNotExisting()
51
    {
52
        $this->markTestSkipped('Unsupported now, because it is not possible to get good results');
53
54
        $context = $this->getContext();
55
56
        $baseExpression = new Node\Expr\Isset_([
57
            new Node\Expr\Variable(
58
                new Node\Name("name")
59
            )
60
        ]);
61
        $compiledExpression = $this->compileExpression($baseExpression, $context);
62
63
        self::assertInstanceOfCompiledExpression($compiledExpression);
64
        self::assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
65
        self::assertFalse($compiledExpression->getValue());
66
    }
67
}
68