currentRequest = new Request(); $this->requestStack = $this->createMock(RequestStack::class); $this->requestStack->method('getCurrentRequest')->willReturn($this->currentRequest); $this->parameterFactory = new ParameterFactory(); $this->validator = self::$container->get(ValidatorInterface::class); $this->validGetParameterService = new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator); } public function testVersionCorrectType(): void { $key = VersionParameter::getKey(); $value = 123; $this->currentRequest->query->set($key, $value); $result = $this->validGetParameterService->getParameter($key); $this->assertEquals($value, $result); } public function testVersionWrongType(): void { $versionKey = VersionParameter::getKey(); $this->currentRequest->query->set($versionKey, 'adasdas'); $this->expectException(GetParameterInvalidException::class); $this->validGetParameterService->getParameter($versionKey); } public function testConstructorInvalid(): void { $this->currentRequest->query->set(VersionParameter::getKey(), 'adasa'); $this->expectException(GetParameterInvalidException::class); new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator); } public function testConstructorNotImplemented(): void { $this->currentRequest->query->set('asdwgwe', 'adasa'); $this->expectException(NotImplementedCoreException::class); new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator); } public function testSetParameterException(): void { $this->expectException(NotSetElementException::class); $this->validGetParameterService->getParameter(VersionParameter::getKey()); } }