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

CompositeConstraintTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 7
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCombinesMultipleConstraintAndPassesWhenAllAreFulfilled() 0 12 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Metadata\Constraint;
6
7
use Doctrine\Annotations\Assembler\Validator\Constraint\CompositeConstraint;
8
use Doctrine\Annotations\Assembler\Validator\Constraint\Exception\ConstraintNotFulfilled;
9
use Doctrine\Annotations\Assembler\Validator\Constraint\RequiredConstraint;
10
use Doctrine\Annotations\Assembler\Validator\Constraint\TypeConstraint;
11
use Doctrine\Annotations\Metadata\Type\StringType;
12
use Doctrine\Tests\Annotations\Metadata\Type\TestNullableType;
13
use PHPUnit\Framework\TestCase;
14
15
final class CompositeConstraintTest extends TestCase
16
{
17
    public function testCombinesMultipleConstraintAndPassesWhenAllAreFulfilled() : void
18
    {
19
        $constraint = new CompositeConstraint(
20
            new TypeConstraint(TestNullableType::fromType(new StringType())),
21
            new RequiredConstraint()
22
        );
23
24
        $constraint->validate('foo');
25
26
        $this->expectException(ConstraintNotFulfilled::class);
27
28
        $constraint->validate(null);
29
    }
30
}
31