mirror of
https://github.com/pestphp/pest.git
synced 2026-07-24 10:30:03 +02:00
fix: package lock fingerprint
This commit is contained in:
@@ -2,16 +2,15 @@
|
||||
|
||||
use Pest\Expectation;
|
||||
|
||||
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 (): void {
|
||||
expect('Foobar')->each()->toEqual('Foobar');
|
||||
})->throws(BadMethodCallException::class, 'Expectation value is not iterable.');
|
||||
|
||||
it('expects on each item', function () {
|
||||
it('expects on each item', function (): void {
|
||||
expect([1, 1, 1])
|
||||
->each()
|
||||
->toEqual(1);
|
||||
|
||||
expect(static::getCount())->toBe(3); // + 1 assertion
|
||||
->toEqual(1)
|
||||
->and(static::getCount())->toBe(3); // + 1 assertion
|
||||
|
||||
expect([1, 1, 1])
|
||||
->each
|
||||
@@ -20,13 +19,12 @@ it('expects on each item', function () {
|
||||
expect(static::getCount())->toBe(7);
|
||||
});
|
||||
|
||||
it('chains expectations on each item', function () {
|
||||
it('chains expectations on each item', function (): void {
|
||||
expect([1, 1, 1])
|
||||
->each()
|
||||
->toBeInt()
|
||||
->toEqual(1);
|
||||
|
||||
expect(static::getCount())->toBe(6); // + 1 assertion
|
||||
->toEqual(1)
|
||||
->and(static::getCount())->toBe(6); // + 1 assertion
|
||||
|
||||
expect([2, 2, 2])
|
||||
->each
|
||||
@@ -36,13 +34,12 @@ it('chains expectations on each item', function () {
|
||||
expect(static::getCount())->toBe(13);
|
||||
});
|
||||
|
||||
test('opposite expectations on each item', function () {
|
||||
test('opposite expectations on each item', function (): void {
|
||||
expect([1, 2, 3])
|
||||
->each()
|
||||
->not()
|
||||
->toEqual(4);
|
||||
|
||||
expect(static::getCount())->toBe(3);
|
||||
->toEqual(4)
|
||||
->and(static::getCount())->toBe(3);
|
||||
|
||||
expect([1, 2, 3])
|
||||
->each()
|
||||
@@ -51,17 +48,16 @@ test('opposite expectations on each item', function () {
|
||||
expect(static::getCount())->toBe(7);
|
||||
});
|
||||
|
||||
test('chained opposite and non-opposite expectations', function () {
|
||||
test('chained opposite and non-opposite expectations', function (): void {
|
||||
expect([1, 2, 3])
|
||||
->each()
|
||||
->not()
|
||||
->toEqual(4)
|
||||
->toBeInt();
|
||||
|
||||
expect(static::getCount())->toBe(6);
|
||||
->toBeInt()
|
||||
->and(static::getCount())->toBe(6);
|
||||
});
|
||||
|
||||
it('can add expectations via "and"', function () {
|
||||
it('can add expectations via "and"', function (): void {
|
||||
expect([1, 2, 3])
|
||||
->each()
|
||||
->toBeInt // + 3
|
||||
@@ -78,20 +74,18 @@ it('can add expectations via "and"', function () {
|
||||
expect(static::getCount())->toBe(14);
|
||||
});
|
||||
|
||||
it('accepts callables', function () {
|
||||
expect([1, 2, 3])->each(function ($number) {
|
||||
expect($number)->toBeInstanceOf(Expectation::class);
|
||||
expect($number->value)->toBeInt();
|
||||
it('accepts callables', function (): void {
|
||||
expect([1, 2, 3])->each(function ($number): void {
|
||||
expect($number)->toBeInstanceOf(Expectation::class)
|
||||
->and($number->value)->toBeInt();
|
||||
$number->toBeInt->not->toBeString;
|
||||
});
|
||||
|
||||
expect(static::getCount())->toBe(12);
|
||||
})
|
||||
->and(static::getCount())->toBe(12);
|
||||
});
|
||||
|
||||
it('passes the key of the current item to callables', function () {
|
||||
expect([1, 2, 3])->each(function ($number, $key) {
|
||||
it('passes the key of the current item to callables', function (): void {
|
||||
expect([1, 2, 3])->each(function ($number, $key): void {
|
||||
expect($key)->toBeInt();
|
||||
});
|
||||
|
||||
expect(static::getCount())->toBe(3);
|
||||
})
|
||||
->and(static::getCount())->toBe(3);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user