pitchart /
phlunit
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | |||
| 4 | namespace Pitchart\Phlunit\Checks\Mixin; |
||
| 5 | |||
| 6 | use PHPUnit\Framework\Assert; |
||
| 7 | use PHPUnit\Framework\Constraint\Constraint; |
||
| 8 | use PHPUnit\Framework\Constraint\LogicalNot; |
||
| 9 | |||
| 10 | trait ConstraintCheck |
||
| 11 | { |
||
| 12 | 1 | public function has(Constraint $constraint): self |
|
| 13 | { |
||
| 14 | 1 | Assert::assertThat($this->value, $constraint); |
|
| 15 | 1 | $this->resetMessage(); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 16 | 1 | return $this; |
|
| 17 | } |
||
| 18 | |||
| 19 | 1 | public function is(Constraint $constraint): self |
|
| 20 | { |
||
| 21 | 1 | return $this->has($constraint); |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | public function hasNot(Constraint $constraint): self |
|
| 25 | { |
||
| 26 | 1 | Assert::assertThat($this->value, new LogicalNot($constraint)); |
|
| 27 | 1 | $this->resetMessage(); |
|
| 28 | 1 | return $this; |
|
| 29 | } |
||
| 30 | |||
| 31 | 1 | public function isNot(Constraint $constraint): self |
|
| 32 | { |
||
| 33 | 1 | return $this->hasNot($constraint); |
|
| 34 | } |
||
| 35 | } |
||
| 36 |