expectException(FunctionNotFound::class); $this->expectExceptionCode(1647523444); $this->expectExceptionMessage('The function `unknown` was not found.'); (new FunctionsContainer(new FakeFunctionDefinitionRepository(), []))->get('unknown'); } public function test_get_unknown_callback_throws_exception(): void { $function = FakeFunctionDefinition::new(); $this->expectException(CallbackNotFound::class); $this->expectExceptionCode(1647523495); $this->expectExceptionMessage("The callback associated to `{$function->signature()}` could not be found."); (new FunctionsContainer(new FakeFunctionDefinitionRepository(), []))->callback($function); } public function test_keys_are_kept_when_iterating(): void { $functions = (new FunctionsContainer(new FakeFunctionDefinitionRepository(), [ 'foo' => fn () => 'foo', 'bar' => fn () => 'bar', ])); $functions = iterator_to_array($functions); self::assertArrayHasKey('foo', $functions); self::assertArrayHasKey('bar', $functions); } }