mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 09:47:23 +01:00
feat(mock): adds work in progress
This commit is contained in:
@ -1,17 +1,24 @@
|
||||
<?php
|
||||
|
||||
use function Tests\mock;
|
||||
use Mockery\CompositeExpectation;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
interface Foo
|
||||
interface Http
|
||||
{
|
||||
public function bar(): int;
|
||||
public function get(): string;
|
||||
}
|
||||
|
||||
it('has bar', function () {
|
||||
$mock = mock(Foo::class);
|
||||
$mock->shouldReceive('bar')
|
||||
->times(1)
|
||||
->andReturn(2);
|
||||
it('can mock methods', function () {
|
||||
$mock = mock(Http::class)->expect(
|
||||
get: 'foo',
|
||||
);
|
||||
|
||||
$mock->bar();
|
||||
});
|
||||
expect($mock->get())->toBe('foo');
|
||||
})->skip(((float) phpversion()) < 8.0);
|
||||
|
||||
test('access to the mock object', function () {
|
||||
$mock = mock(Http::class);
|
||||
expect($mock->expect())->toBeInstanceOf(MockInterface::class);
|
||||
|
||||
expect($mock->shouldReceive())->toBeInstanceOf(CompositeExpectation::class);
|
||||
})->skip(((float) phpversion()) < 8.0);
|
||||
|
||||
Reference in New Issue
Block a user