Completed
Push — master ( 89471b...f54cd5 )
by Дмитрий
11s
created

TypesTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetType() 0 4 1
A testGetTypeWithAnUnknownTypeThrows() 0 4 1
A typesAsStringProvider() 0 16 1
1
<?php
2
3
namespace Tests\PHPSA\Compiler;
4
5
use PHPSA\CompiledExpression;
6
use PHPSA\Compiler\Types;
7
use Tests\PHPSA\TestCase;
8
9
class TypesTest extends TestCase
10
{
11
    /**
12
     * @dataProvider typesAsStringProvider
13
     */
14
    public function testGetType($typeAsString, $expectedType)
15
    {
16
        static::assertSame($expectedType, Types::getType($typeAsString));
17
    }
18
19
    /**
20
     * @expectedException \RuntimeException
21
     * @expectedExceptionMessage Type 'not a valid type' is not supported
22
     */
23
    public function testGetTypeWithAnUnknownTypeThrows()
24
    {
25
        Types::getType('not a valid type');
26
    }
27
28
    public function typesAsStringProvider()
29
    {
30
        return [
31
            ['integer', CompiledExpression::INTEGER],
32
            ['int', CompiledExpression::INTEGER],
33
            ['double', CompiledExpression::DOUBLE],
34
            ['string', CompiledExpression::STRING],
35
            ['resource', CompiledExpression::RESOURCE],
36
            ['callable', CompiledExpression::CALLABLE_TYPE],
37
            ['object', CompiledExpression::OBJECT],
38
            ['array', CompiledExpression::ARR],
39
            ['boolean', CompiledExpression::BOOLEAN],
40
            ['bool', CompiledExpression::BOOLEAN],
41
            ['NULL', CompiledExpression::NULL],
42
        ];
43
    }
44
}
45