From 8c0efd0d9317ad92bd55cd6afcd41bdbab827bf8 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: Make basic routing work --- tests/Utils/TestCall.php | 16 ++++++++++ tests/Utils/TestCallable.php | 69 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 tests/Utils/TestCall.php create mode 100644 tests/Utils/TestCallable.php (limited to 'tests/Utils') diff --git a/tests/Utils/TestCall.php b/tests/Utils/TestCall.php new file mode 100644 index 0000000..971e6a7 --- /dev/null +++ b/tests/Utils/TestCall.php @@ -0,0 +1,16 @@ +cb = Closure::fromCallable($cb); + } + + public static function make(callable $cb): static + { + return new static($cb); + } + + public function __invoke(mixed ...$args): mixed + { + $call = new TestCall( + args: $args, + return: ($this->cb)(...$args), + ); + $this->calls[] = $call; + + return $call->return; + } + + public function getCallCount(): int + { + return count($this->calls); + } + + /** @return TestCall[] */ + public function getCalls(): array + { + return $this->calls; + } + + public function getLastCall(): ?TestCall + { + return $this->calls[$this->getCallCount() - 1] ?? null; + } + + public function assertIsCalled(): void + { + Assert::assertGreaterThan(0, $this->getCallCount(), 'Not been called'); + } + + public function assertNotCalled(): void + { + Assert::assertSame(0, $this->getCallCount()); + } + + public function assertCalledTimes(int $amount): void + { + Assert::assertSame($amount, $this->getCallCount()); + } + +} -- cgit v1.2.3