Completed
Pull Request — master (#304)
by Enrico
02:50
created

ArrayCastTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 6 1
A testArrayCastCompile() 0 11 1
A buildExpression() 0 4 1
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
use Tests\PHPSA\Compiler\Expression\AbstractUnaryOp;
9
10
class ArrayCastTest extends AbstractUnaryOp
11
{
12
    /**
13
     * @return array
14
     */
15
    public function getDataProvider()
16
    {
17
        return [
18
            [[], []],
19
        ];
20
    }
21
22
    /**
23
     * Tests (array) {expr} = {expr}
24
     *
25
     * @dataProvider getDataProvider
26
     */
27
    public function testArrayCastCompile($a, $b)
28
    {
29
        $baseExpression = new Node\Expr\Cast\Array_(
30
            $this->newScalarExpr($a)
31
        );
32
        $compiledExpression = $this->compileExpression($baseExpression);
33
34
        $this->assertInstanceOfCompiledExpression($compiledExpression);
35
        $this->assertSame(CompiledExpression::ARR, $compiledExpression->getType());
36
        $this->assertSame($b, $compiledExpression->getValue());
37
    }
38
39
    /**
40
     * @param Node\Scalar $a
41
     * @return Node\Expr\Cast\Array_
42
     */
43
    protected function buildExpression($a)
44
    {
45
        return new Node\Expr\Cast\Array_($a);
46
    }
47
}
48