add new expectation

This commit is contained in:
abenerd
2022-05-08 11:09:35 +02:00
parent 3dd7b677bd
commit 452d4b26b9
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
beforeEach(function () {
$this->times = [new DateTimeImmutable(), new DateTimeImmutable()];
});
test('pass', function () {
expect($this->times)->toContainOnlyInstancesOf(DateTimeImmutable::class);
expect($this->times)->not->toContainOnlyInstancesOf(DateTime::class);
});
test('failures', function () {
expect($this->times)->toContainOnlyInstancesOf(DateTime::class);
})->throws(ExpectationFailedException::class);
test('not failures', function () {
expect($this->times)->not->toContainOnlyInstancesOf(DateTimeImmutable::class);
})->throws(ExpectationFailedException::class);