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

TypesTest::testGetType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 1
b 0
f 0
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