Completed
Pull Request — master (#124)
by Enrico
04:01 queued 01:12
created

BooleanNotTest::getDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA\Compiler\Expression\Operators\Logical;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
9
/**
10
 * Class BooleanNotTest
11
 * @package Tests\PHPSA\Expression\Operators\Logical
12
 */
13
class BooleanNotTest extends \Tests\PHPSA\TestCase
14
{
15
    /**
16
     * @return array
17
     */
18
    public function getDataProvider()
19
    {
20
        return array(
21
            array(true, false),
22
            array(false, true),
23
            array(1, false),
24
            array(-1, false),
25
        );
26
    }
27
28
    /**
29
     * Tests !{expr}
30
     *
31
     * @see \PHPSA\Compiler\Expression\Operators\Logical\BooleanNot
32
     * @dataProvider getDataProvider
33
     */
34
    public function testSimpleSuccessCompile($a, $b)
35
    {
36
        $baseExpression = new Node\Expr\BooleanNot(
37
            $this->newScalarExpr($a)
38
        );
39
        $compiledExpression = $this->compileExpression($baseExpression);
40
41
        $this->assertInstanceOfCompiledExpression($compiledExpression);
42
        $this->assertSame(CompiledExpression::BOOLEAN, $compiledExpression->getType());
43
        $this->assertSame($b, $compiledExpression->getValue());
44
    }
45
46
    public function testUnexpectedType()
47
    {
48
        $baseExpression = new Node\Expr\BooleanNot(
49
            $this->newFakeScalarExpr()
50
        );
51
        $compiledExpression = $this->compileExpression($baseExpression);
52
53
        $this->assertInstanceOfCompiledExpression($compiledExpression);
54
        $this->assertSame(CompiledExpression::UNKNOWN, $compiledExpression->getType());
55
        $this->assertSame(null, $compiledExpression->getValue());
56
    }
57
}
58