Completed
Push — master ( 5f2691...53c2bd )
by Enrico
03:49
created

ArrayCastTest::getDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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