mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
Uses Collision ^7.0
This commit is contained in:
@ -40,8 +40,12 @@ it('works inside of each', function () {
|
||||
it('works with sequence', function () {
|
||||
expect(new HasMethods())
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -54,8 +58,12 @@ it('can compose complex expectations', function () {
|
||||
->attributes()->toBeArray()
|
||||
->books()->toBeArray->each->not->toBeEmpty
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -9,8 +9,12 @@ it('can access methods and properties', function () {
|
||||
})->books()->toBeArray()
|
||||
->posts->toBeArray->each->not->toBeEmpty
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -53,7 +57,9 @@ it('can start a new higher order expectation using the and syntax without nestin
|
||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||
->meta
|
||||
->sequence(
|
||||
function ($value, $key) { $value->toBeArray()->and($key)->toBe('foo'); },
|
||||
function ($value, $key) {
|
||||
$value->toBeArray()->and($key)->toBe('foo');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -35,8 +35,12 @@ it('works inside of each', function () {
|
||||
it('works with sequence', function () {
|
||||
expect(['books' => [['title' => 'Foo', 'cost' => 20], ['title' => 'Bar', 'cost' => 30]]])
|
||||
->books->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -51,10 +55,16 @@ it('can compose complex expectations', function () {
|
||||
it('works with objects', function () {
|
||||
expect(new HasProperties())
|
||||
->name->toEqual('foo')->not->toEqual('world')
|
||||
->posts->toHaveCount(2)->each(function ($post) { $post->is_published->toBeTrue(); })
|
||||
->posts->toHaveCount(2)->each(function ($post) {
|
||||
$post->is_published->toBeTrue();
|
||||
})
|
||||
->posts->sequence(
|
||||
function ($post) { $post->title->toEqual('Foo'); },
|
||||
function ($post) { $post->title->toEqual('Bar'); },
|
||||
function ($post) {
|
||||
$post->title->toEqual('Foo');
|
||||
},
|
||||
function ($post) {
|
||||
$post->title->toEqual('Bar');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user