Failed Conditions
Push — new-parser-ast-metadata ( 6127e0...5a4a16 )
by Michael
12s
created

MapTypeTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

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

12 Methods

Rating   Name   Duplication   Size   Complexity  
A testDescribe() 0 3 1
A createType() 0 3 1
getValueType() 0 3 ?
validValidateValuesProvider() 0 15 ?
invalidValidateValuesProvider() 0 6 ?
A hp$0 ➔ validValidateValuesProvider() 0 15 1
A hp$0 ➔ getValueType() 0 3 1
testAcceptsNull() 0 3 ?
A hp$0 ➔ testAcceptsNull() 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
    /**
27
     * @return mixed[]
28
     */
29
    public function validValidateValuesProvider() : iterable
30
    {
31
        yield [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield array(array('foo' ...ll, 'types' => 'test')) returns the type Generator which is incompatible with the documented return type array<mixed,mixed>.
Loading history...
32
            ['foo' => 'bar'],
33
            ['baz' => 42],
34
            ['woof' => new stdClass()],
35
            ['meow' => null],
36
            [
37
                'multiple' => 1,
38
                'items' => static function () : void {
39
                },
40
                'with' => new class () {
41
                },
42
                'different' => null,
43
                'types' =>  'test',
44
            ],
45
        ];
46
    }
47
48
    /**
49
     * @return mixed[]
50
     */
51
    public function invalidValidateValuesProvider() : iterable
52
    {
53
        yield [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield array(array('foo',...tdClass(), 1 => 'zaz')) returns the type Generator which is incompatible with the documented return type array<mixed,mixed>.
Loading history...
54
            ['foo', 1],
55
            [1 => 'bar'],
56
            ['baz' => new stdClass(), 1 => 'zaz'],
57
        ];
58
    }
59
60
    public function testAcceptsNull() : void
61
    {
62
        self::assertSame($this->getValueType()->acceptsNull(), $this->getType()->acceptsNull());
63
    }
64
65
    private function getKeyType() : ScalarType
66
    {
67
        return new StringType();
68
    }
69
70
    private function getValueType() : Type
71
    {
72
        return new MixedType();
73
    }
74
}
75