Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by
unknown
02:16
created

MapTypeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 20
dl 0
loc 53
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
getValueType() 0 3 ?
validValidateValuesProvider() 0 15 ?
invalidValidateValuesProvider() 0 6 ?
A hp$0 ➔ validValidateValuesProvider() 0 15 1
A hp$0 ➔ getValueType() 0 3 1
A testDescribe() 0 3 1
testAcceptsNull() 0 3 ?
A hp$0 ➔ testAcceptsNull() 0 3 1
A createType() 0 3 1
getKeyType() 0 3 ?
A hp$0 ➔ getKeyType() 0 3 1
A hp$0 ➔ invalidValidateValuesProvider() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Metadata\Type;
6
7
use Doctrine\Annotations\Metadata\Type\MapType;
8
use Doctrine\Annotations\Metadata\Type\MixedType;
9
use Doctrine\Annotations\Metadata\Type\ScalarType;
10
use Doctrine\Annotations\Metadata\Type\StringType;
11
use Doctrine\Annotations\Metadata\Type\Type;
12
use stdClass;
13
14
final class MapTypeTest extends TypeTest
15
{
16
    protected function createType() : Type
17
    {
18
        return new MapType($this->getKeyType(), $this->getValueType());
19
    }
20
21
    public function testDescribe() : void
22
    {
23
        self::assertSame('array<string, mixed>', $this->getType()->describe());
24
    }
25
26
    public function validValidateValuesProvider() : iterable
27
    {
28
        yield [
29
            ['foo' => 'bar'],
30
            ['baz' => 42],
31
            ['woof' => new stdClass()],
32
            ['meow' => null],
33
            [
34
                'multiple' => 1,
35
                'items' => static function () : void {
36
                },
37
                'with' => new class () {
38
                },
39
                'different' => null,
40
                'types' =>  'test',
41
            ],
42
        ];
43
    }
44
45
    public function invalidValidateValuesProvider() : iterable
46
    {
47
        yield [
48
            ['foo', 1],
49
            [1 => 'bar'],
50
            ['baz' => new stdClass(), 1 => 'zaz'],
51
        ];
52
    }
53
54
    public function testAcceptsNull() : void
55
    {
56
        self::assertSame($this->getValueType()->acceptsNull(), $this->getType()->acceptsNull());
57
    }
58
59
    private function getKeyType() : ScalarType
60
    {
61
        return new StringType();
62
    }
63
64
    private function getValueType() : Type
65
    {
66
        return new MixedType();
67
    }
68
}
69