GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#101)
by joseph
18:59
created

TypeHelperTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 35
dl 0
loc 68
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 11 2
A normaliseValueToType() 0 32 3
A setup() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Small\CodeGeneration;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\TypeHelper;
6
use EdmondsCommerce\DoctrineStaticMeta\MappingHelper;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * Class TypeHelperTest
11
 *
12
 * @package EdmondsCommerce\DoctrineStaticMeta\Small\CodeGeneration
13
 * @coversDefaultClass \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\TypeHelper
14
 */
15
class TypeHelperTest extends TestCase
16
{
17
    /**
18
     * @var TypeHelper
19
     */
20
    private $helper;
21
22
    public function setup()
23
    {
24
        $this->helper = new TypeHelper();
25
    }
26
27
    /**
28
     * @test
29
     * @small
30
     * @covers ::getType
31
     */
32
    public function getType(): void
33
    {
34
        $expectedTypesToVars = [
35
            'string' => 'string',
36
            'float'  => 1.01,
37
            'int'    => 2,
38
            'bool'   => true,
39
            'null'   => null,
40
        ];
41
        foreach ($expectedTypesToVars as $expected => $var) {
42
            self::assertSame($expected, $this->helper->getType($var));
43
        }
44
    }
45
46
    /**
47
     * @test
48
     * @small
49
     * @covers ::normaliseValueToType
50
     */
51
    public function normaliseValueToType(): void
52
    {
53
        $defaultValuesToTypes = [
54
            MappingHelper::PHP_TYPE_INTEGER => [
55
                [1, 1],
56
                ['1', 1],
57
                [' 1', 1],
58
                [' 1 ', 1],
59
            ],
60
            MappingHelper::PHP_TYPE_FLOAT   => [
61
                [1, 1.0],
62
                [1.0, 1.0],
63
                ['1', 1.0],
64
                ['1.1', 1.1],
65
                [' 1.1 ', 1.1],
66
                [' 1.1 ', 1.1],
67
            ],
68
            MappingHelper::PHP_TYPE_BOOLEAN => [
69
                ['true', true],
70
                ['false', false],
71
                ['TRUE', true],
72
                ['FALSE', false],
73
                [' TRue ', true],
74
                [' FaLse ', false],
75
            ],
76
        ];
77
78
        foreach ($defaultValuesToTypes as $type => $valueAndExpecteds) {
79
            foreach ($valueAndExpecteds as $valueAndExpected) {
80
                list($value, $expected) = $valueAndExpected;
81
                $normalised = $this->helper->normaliseValueToType($value, $type);
82
                self::assertSame($expected, $normalised);
83
            }
84
        }
85
    }
86
}
87