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

AbstractBinaryOp   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
buildExpression() 0 1 ?
A testFirstArgUnexpectedType() 0 12 1
A testSecondArgUnexpectedType() 0 12 1
1
<?php
2
3
namespace Tests\PHPSA\Compiler\Expression;
4
5
use PhpParser\Node;
6
use PHPSA\CompiledExpression;
7
use PHPSA\Compiler\Expression;
8
9
abstract class AbstractBinaryOp extends \Tests\PHPSA\TestCase
10
{
11
    /**
12
     * @param $a
13
     * @param $b
14
     * @return Node\Expr
15
     */
16
    abstract protected function buildExpression($a, $b);
17
18
    /**
19
     * Tests {left-expr::UNKNOWN} $operator {right-expr}
20
     */
21
    public function testFirstArgUnexpectedType()
22
    {
23
        $baseExpression = $this->buildExpression(
24
            $this->newFakeScalarExpr(),
25
            $this->newScalarExpr(1)
26
        );
27
        $compiledExpression = $this->compileExpression($baseExpression);
28
29
        $this->assertInstanceOfCompiledExpression($compiledExpression);
30
        $this->assertSame(CompiledExpression::UNKNOWN, $compiledExpression->getType());
31
        $this->assertSame(null, $compiledExpression->getValue());
32
    }
33
34
    /**
35
     * Tests {left-expr} $operator {right-expr::UNKNOWN}
36
     */
37
    public function testSecondArgUnexpectedType()
38
    {
39
        $baseExpression = $this->buildExpression(
40
            $this->newScalarExpr(1),
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