IssetTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testIssetVarInt() 0 18 1
A testIssetVarNull() 0 18 1
A testIssetVarNotExisting() 0 17 1
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