Completed
Pull Request — master (#304)
by Enrico
03:09
created

BitwiseOrTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDataProvider() 0 15 1
A testSimpleSuccessCompile() 0 12 1
A buildExpression() 0 4 1
1
<?php
2
3
namespace Tests\PHPSA\Compiler\Expression\AssignOp;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
use Tests\PHPSA\Compiler\Expression\AbstractBinaryOp;
9
10
class BitwiseOrTest extends AbstractBinaryOp
11
{
12
    /**
13
     * @return array
14
     */
15
    public function getDataProvider()
16
    {
17
        return [
18
            [0, 5, 5],
19
            [1, 5, 5],
20
            [4, 5, 5],
21
            [-1, 5, -1],
22
            [1.4, 5, 5],
23
            [-19.7, 1, -19],
24
            [true, true, 1],
25
            [false, true, 1],
26
            [true, false, 1],
27
            [false, false, 0],
28
        ];
29
    }
30
31
    /**
32
     * Tests {var} |= {expr}
33
     *
34
     * @dataProvider getDataProvider
35
     */
36
    public function testSimpleSuccessCompile($a, $b, $c)
37
    {
38
        $baseExpression = new Node\Expr\AssignOp\BitwiseOr(
39
            $this->newScalarExpr($a),
40
            $this->newScalarExpr($b)
41
        );
42
        $compiledExpression = $this->compileExpression($baseExpression);
43
44
        $this->assertInstanceOfCompiledExpression($compiledExpression);
45
        $this->assertSame(CompiledExpression::INTEGER, $compiledExpression->getType());
46
        $this->assertSame($c, $compiledExpression->getValue());
47
    }
48
49
    /**
50
     * @param Node\Scalar $a
51
     * @param Node\Scalar $b
52
     * @return Node\Expr\AssignOp\BitwiseOr
53
     */
54
    protected function buildExpression($a, $b)
55
    {
56
        return new Node\Expr\AssignOp\BitwiseOr($a, $b);
57
    }
58
}
59