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

EnumConstraintTest::testFulfilledByGivenValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Metadata\Constraint;
6
7
use Doctrine\Annotations\Assembler\Validator\Constraint\EnumConstraint;
8
use Doctrine\Annotations\Assembler\Validator\Constraint\Exception\InvalidValue;
9
use PHPUnit\Framework\TestCase;
10
11
final class EnumConstraintTest extends TestCase
12
{
13
    /**
14
     * @param mixed[] $allowedValues
15
     * @param mixed   $value
16
     *
17
     * @dataProvider fulfilledProvider
18
     */
19
    public function testFulfilledByGivenValue(array $allowedValues, $value) : void
20
    {
21
        $constraint = new EnumConstraint($allowedValues);
22
23
        $constraint->validate($value);
24
25
        self::assertTrue(true);
26
    }
27
28
    /**
29
     * @return mixed[]
30
     */
31
    public function fulfilledProvider() : iterable
32
    {
33
        yield 'matching string' => [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield 'matching string' ...y('foo', 'bar'), 'bar') returns the type Generator which is incompatible with the documented return type array<mixed,mixed>.
Loading history...
34
            ['foo', 'bar'],
35
            'bar',
36
        ];
37
    }
38
39
    /**
40
     * @param mixed[] $allowedValues
41
     * @param mixed   $value
42
     *
43
     * @dataProvider notFulfilledProvider
44
     */
45
    public function testNotFulfilledByGivenValue(array $allowedValues, $value) : void
46
    {
47
        $constraint = new EnumConstraint($allowedValues);
48
49
        $this->expectException(InvalidValue::class);
50
51
        $constraint->validate($value);
52
    }
53
54
    /**
55
     * @return mixed[]
56
     */
57
    public function notFulfilledProvider() : iterable
58
    {
59
        yield 'not matching string' => [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield 'not matching stri...y('foo', 'bar'), 'baz') returns the type Generator which is incompatible with the documented return type array<mixed,mixed>.
Loading history...
60
            ['foo', 'bar'],
61
            'baz',
62
        ];
63
    }
64
}
65