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

testCombinesMultipleConstraintAndPassesWhenAllAreFulfilled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 12
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Metadata\Constraint;
6
7
use Doctrine\Annotations\Metadata\Constraint\CompositeConstraint;
8
use Doctrine\Annotations\Metadata\Constraint\ConstraintNotFulfilled;
9
use Doctrine\Annotations\Metadata\Constraint\RequiredConstraint;
10
use Doctrine\Annotations\Metadata\Constraint\TypeConstraint;
11
use Doctrine\Annotations\Metadata\Type\StringType;
12
use Doctrine\Tests\Annotations\Metadata\Type\TestNullableType;
13
use PHPUnit\Framework\TestCase;
14
15
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