From fe463e13a86886e980ec75e6d26b3eff93a5c1e5 Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Sat, 28 Sep 2024 13:15:53 +0700 Subject: [PATCH] refactor: FFI client hide call() method --- helper/FFI/ClientTrait.php | 19 ------------------- src/PhpPact/FFI/Client.php | 2 +- src/PhpPact/FFI/ClientInterface.php | 5 ----- tests/PhpPact/FFI/ClientTest.php | 7 ------- 4 files changed, 1 insertion(+), 32 deletions(-) diff --git a/helper/FFI/ClientTrait.php b/helper/FFI/ClientTrait.php index 3a7789e3..354c0c63 100644 --- a/helper/FFI/ClientTrait.php +++ b/helper/FFI/ClientTrait.php @@ -25,25 +25,6 @@ trait ClientTrait { protected ClientInterface&MockObject $client; - /** - * @param mixed[][] $calls - */ - protected function assertClientCalls(array $calls): void - { - $this->client - ->expects($this->exactly(count($calls))) - ->method('call') - ->willReturnCallback(function (...$args) use (&$calls) { - $call = array_shift($calls); - $return = array_pop($call); - foreach ($args as $key => $arg) { - $this->assertThat($arg, $call[$key] instanceof Constraint ? $call[$key] : new IsIdentical($call[$key])); - } - - return $return; - }); - } - protected function expectsSetInteractionKey(int $interaction, string $description, ?string $key, bool $result): void { $this->client diff --git a/src/PhpPact/FFI/Client.php b/src/PhpPact/FFI/Client.php index ed8660d2..6b7c6ec4 100644 --- a/src/PhpPact/FFI/Client.php +++ b/src/PhpPact/FFI/Client.php @@ -559,7 +559,7 @@ private function getEnum(string $name): int return $value; } - public function call(string $name, ...$arguments): mixed + private function call(string $name, mixed ...$arguments): mixed { return $this->ffi->{$name}(...$arguments); } diff --git a/src/PhpPact/FFI/ClientInterface.php b/src/PhpPact/FFI/ClientInterface.php index 1fb83e0e..909ce607 100644 --- a/src/PhpPact/FFI/ClientInterface.php +++ b/src/PhpPact/FFI/ClientInterface.php @@ -138,9 +138,4 @@ public function getPactSpecificationV3(): int; public function getPactSpecificationV4(): int; public function getPactSpecificationUnknown(): int; - - /** - * @param array $arguments - */ - public function call(string $name, ...$arguments): mixed; } diff --git a/tests/PhpPact/FFI/ClientTest.php b/tests/PhpPact/FFI/ClientTest.php index f89aecef..62beaf72 100644 --- a/tests/PhpPact/FFI/ClientTest.php +++ b/tests/PhpPact/FFI/ClientTest.php @@ -394,11 +394,4 @@ public function testGetPactSpecificationUnknown(): void { $this->assertSame(0, $this->client->getPactSpecificationUnknown()); } - - #[TestWith(['abc123', true])] - #[TestWith(['testing', false])] - public function testCall(string $example, bool $result): void - { - $this->assertSame($result, $this->client->call('pactffi_check_regex', '\w{3}\d+', $example)); - } }