diff --git a/composer.json b/composer.json index 01a44da2..7706e556 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,6 @@ "illuminate/console": "^8.32.1", "illuminate/support": "^8.32.1", "laravel/dusk": "^6.13.0", - "mockery/mockery": "^1.4.3", "pestphp/pest-dev-tools": "dev-master" }, "minimum-stability": "dev", diff --git a/src/Functions.php b/src/Functions.php index 6138cd22..a7e1354a 100644 --- a/src/Functions.php +++ b/src/Functions.php @@ -3,7 +3,6 @@ declare(strict_types=1); use Pest\Datasets; -use Pest\Mock; use Pest\PendingObjects\AfterEachCall; use Pest\PendingObjects\BeforeEachCall; use Pest\PendingObjects\TestCall; @@ -105,15 +104,3 @@ function afterAll(Closure $closure): void { TestSuite::getInstance()->afterAll->set($closure); } - -if (!function_exists('mock')) { - /** - * Creates a new mock with the given class or object. - * - * @param string|object $object - */ - function mock($object): Mock - { - return new Mock($object); - } -} diff --git a/src/Mock.php b/src/Mock.php deleted file mode 100644 index 12dfed94..00000000 --- a/src/Mock.php +++ /dev/null @@ -1,76 +0,0 @@ -mock = Mockery::mock($object); - } - - /** - * Define mock expectations. - * - * @param mixed ...$methods - * - * @return \Mockery\MockInterface|\Mockery\LegacyMockInterface - */ - public function expect(...$methods) - { - foreach ($methods as $method => $expectation) { - /* @phpstan-ignore-next-line */ - $method = $this->mock - ->shouldReceive((string) $method) - ->once(); - - if (!is_callable($expectation)) { - throw new InvalidArgumentException(sprintf('Method %s from %s expects a callable as expectation.', $method, $method->mock()->mockery_getName(), )); - } - - $method->andReturnUsing($expectation); - } - - return $this->mock; - } - - /** - * Proxies calls to the original mock object. - * - * @param array $arguments - * - * @return mixed - */ - public function __call(string $method, array $arguments) - { - /* @phpstan-ignore-next-line */ - return $this->mock->{$method}($arguments); - } -} diff --git a/src/Repositories/AfterEachRepository.php b/src/Repositories/AfterEachRepository.php index b0357e86..b4d99e5d 100644 --- a/src/Repositories/AfterEachRepository.php +++ b/src/Repositories/AfterEachRepository.php @@ -41,7 +41,6 @@ final class AfterEachRepository return ChainableClosure::from(function (): void { if (class_exists(Mockery::class)) { - /* @phpstan-ignore-next-line */ if ($container = Mockery::getContainer()) { /* @phpstan-ignore-next-line */ $this->addToAssertionCount($container->mockery_getExpectationCount()); diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index b471823f..301abcea 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -77,10 +77,6 @@ ✓ it can call chained macro method ✓ it will throw exception from call if no macro exists - PASS Tests\Features\Mocks - ✓ it can mock methods - ✓ it allows access to the underlying mockery mock - PASS Tests\Features\PendingHigherOrderTests ✓ get 'foo' → get 'bar' → expect true → toBeTrue ✓ get 'foo' → expect true → toBeTrue @@ -223,5 +219,5 @@ ✓ it is a test ✓ it uses correct parent class - Tests: 7 skipped, 121 passed + Tests: 7 skipped, 119 passed \ No newline at end of file diff --git a/tests/Features/Mocks.php b/tests/Features/Mocks.php deleted file mode 100644 index 7d1b213f..00000000 --- a/tests/Features/Mocks.php +++ /dev/null @@ -1,32 +0,0 @@ -expect( - get: fn () => 'foo', - ); - - expect($mock->get())->toBe('foo'); -})->skip(((float) phpversion()) < 8.0); - -it('can access to arguments', function () { - $mock = mock(Http::class)->expect( - get: fn ($foo) => $foo, - ); - - expect($mock->get('foo'))->toBe('foo'); -})->skip(((float) phpversion()) < 8.0); - -it('allows access to the underlying mockery mock', function () { - $mock = mock(Http::class); - - expect($mock->expect())->toBeInstanceOf(MockInterface::class); - expect($mock->shouldReceive())->toBeInstanceOf(CompositeExpectation::class); -})->skip(((float) phpversion()) < 8.0);