routeAssert($url, $method); break; case ActionType::EXECUTE: $url = "$baseUrl/$uri/execute.$format"; $this->routeAssert($url, $method); break; default: $url = "$baseUrl/$uri.$format"; $this->routeAssert($url, $method); } } } } } } } private function routeAssert(string $url, string $method): void { $request = new Request([], [], [], [], [], [ 'REQUEST_URI' => $url, ]); $request->setMethod($method); $response = static::$kernel->handle($request); $this->assertTrue($this->isResponseValid($response), "Route $url with Method $method sends an 404 response and doesn't throw an EntityNotFoundException!"); } private function isResponseValid(Response $response): bool { $is404 = 404 === $response->getStatusCode(); $isEntityNotFoundHttpException = strpos($response->getContent(), 'EntityNotFoundException'); return !$is404 || $isEntityNotFoundHttpException; } }