change test

This commit is contained in:
Mert Aşan
2021-09-16 18:09:59 +03:00
parent 12e63c7376
commit 3dd10b3c7c

View File

@ -1,5 +1,7 @@
<?php <?php
use PHPUnit\Framework\ExpectationFailedException;
test('an exception is thrown if the the type is not iterable', function () { test('an exception is thrown if the the type is not iterable', function () {
expect('Foobar')->each->sequence(); expect('Foobar')->each->sequence();
})->throws(BadMethodCallException::class, 'Expectation value is not iterable.'); })->throws(BadMethodCallException::class, 'Expectation value is not iterable.');
@ -26,16 +28,14 @@ test('loops back to the start if it runs out of sequence items', function () {
expect(static::getCount())->toBe(16); expect(static::getCount())->toBe(16);
}); });
test('it works if the number of items in the iterable is smaller than the number of expectations', function () { test('fails if the number of iterable items is greater than the number of expectations', function () {
expect([1, 2]) expect([1, 2])
->sequence( ->sequence(
function ($expectation) { $expectation->toBeInt()->toEqual(1); }, function ($expectation) { $expectation->toBeInt()->toEqual(1); },
function ($expectation) { $expectation->toBeInt()->toEqual(2); }, function ($expectation) { $expectation->toBeInt()->toEqual(2); },
function ($expectation) { $expectation->toBeInt()->toEqual(3); }, function ($expectation) { $expectation->toBeInt()->toEqual(3); },
); );
})->throws(ExpectationFailedException::class);
expect(static::getCount())->toBe(4);
});
test('it works with associative arrays', function () { test('it works with associative arrays', function () {
expect(['foo' => 'bar', 'baz' => 'boom']) expect(['foo' => 'bar', 'baz' => 'boom'])