feat(mock): adds work in progress

This commit is contained in:
Nuno Maduro
2021-04-10 21:11:57 +01:00
parent 3205b571b0
commit c9f723530d
7 changed files with 134 additions and 18 deletions

View File

@ -42,3 +42,5 @@ it('throws error if method do not exist', function () {
})->throws(\ReflectionException::class, 'Call to undefined method PHPUnit\Framework\TestCase::name()');
it('can forward unexpected calls to any global function')->_assertThat();
it('can use helpers from helpers file')->myAssertTrue(true);

View File

@ -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);