mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 09:47:23 +01:00
feat: move Expectations API out of external plugin
This commit is contained in:
50
tests/Features/Expect/HigherOrder/methodsAndProperties.php
Normal file
50
tests/Features/Expect/HigherOrder/methodsAndProperties.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
it('can access methods and properties', function () {
|
||||
expect(new HasMethodsAndProperties())
|
||||
->name->toEqual('Has Methods and Properties')->not()->toEqual('bar')
|
||||
->multiply(3, 4)->not->toBeString->toEqual(12)
|
||||
->posts->each(function ($post) {
|
||||
$post->is_published->toBeTrue;
|
||||
})->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); },
|
||||
);
|
||||
});
|
||||
|
||||
class HasMethodsAndProperties
|
||||
{
|
||||
public $name = 'Has Methods and Properties';
|
||||
|
||||
public $posts = [
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Foo',
|
||||
],
|
||||
[
|
||||
'is_published' => true,
|
||||
'title' => 'Bar',
|
||||
],
|
||||
];
|
||||
|
||||
public function books()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'title' => 'Foo',
|
||||
'cost' => 20,
|
||||
],
|
||||
[
|
||||
'title' => 'Bar',
|
||||
'cost' => 30,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function multiply($x, $y)
|
||||
{
|
||||
return $x * $y;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user