mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 17:57:23 +01:00
lint
This commit is contained in:
@ -9,9 +9,15 @@ test('an exception is thrown if the the type is not iterable', function () {
|
|||||||
test('allows for sequences of checks to be run on iterable data', function () {
|
test('allows for sequences of checks to be run on iterable data', function () {
|
||||||
expect([1, 2, 3])
|
expect([1, 2, 3])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(6);
|
expect(static::getCount())->toBe(6);
|
||||||
@ -20,9 +26,15 @@ test('allows for sequences of checks to be run on iterable data', function () {
|
|||||||
test('loops back to the start if it runs out of sequence items', function () {
|
test('loops back to the start if it runs out of sequence items', function () {
|
||||||
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
function ($expectation) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(static::getCount())->toBe(16);
|
expect(static::getCount())->toBe(16);
|
||||||
@ -31,19 +43,29 @@ test('loops back to the start if it runs out of sequence items', function () {
|
|||||||
test('fails if the number of iterable items is greater 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) {
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
$expectation->toBeInt()->toEqual(1);
|
||||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(2);
|
||||||
|
},
|
||||||
|
function ($expectation) {
|
||||||
|
$expectation->toBeInt()->toEqual(3);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('it works with associative arrays', function () {
|
test('it works with associative arrays', function () {
|
||||||
expect(['foo' => 'bar', 'baz' => 'boom'])
|
expect(['foo' => 'bar', 'baz' => 'boom'])
|
||||||
->sequence(
|
->sequence(
|
||||||
function ($expectation, $key) { $expectation->toEqual('bar');
|
function ($expectation, $key) {
|
||||||
$key->toEqual('foo'); },
|
$expectation->toEqual('bar');
|
||||||
function ($expectation, $key) { $expectation->toEqual('boom');
|
$key->toEqual('foo');
|
||||||
$key->toEqual('baz'); },
|
},
|
||||||
|
function ($expectation, $key) {
|
||||||
|
$expectation->toEqual('boom');
|
||||||
|
$key->toEqual('baz');
|
||||||
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,7 +78,9 @@ test('it can be passed non-callable values', function () {
|
|||||||
test('it can be passed a mixture of value types', function () {
|
test('it can be passed a mixture of value types', function () {
|
||||||
expect(['foo', 'bar', 'baz'])->sequence(
|
expect(['foo', 'bar', 'baz'])->sequence(
|
||||||
'foo',
|
'foo',
|
||||||
function ($expectation) { $expectation->toEqual('bar')->toBeString(); },
|
function ($expectation) {
|
||||||
|
$expectation->toEqual('bar')->toBeString();
|
||||||
|
},
|
||||||
'baz'
|
'baz'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user