diff --git a/composer.json b/composer.json index 42003e07cd..2b512311e5 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,11 @@ "phpweb\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "phpweb\\Test\\EndToEnd\\": "tests/EndToEnd/" + } + }, "config": { "platform": { "php": "8.2.0" diff --git a/tests/EndToEnd/SmokeTest.php b/tests/EndToEnd/SmokeTest.php new file mode 100644 index 0000000000..a902df6adc --- /dev/null +++ b/tests/EndToEnd/SmokeTest.php @@ -0,0 +1,80 @@ + true, + CURLOPT_URL => $url, + ]; + + curl_setopt_array($handle, $options); + + curl_exec($handle); + + $httpStatusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); + + self::assertTrue(in_array($httpStatusCode, $successfulHttpStatusCodes, true), sprintf( + 'Failed asserting that the URL "%s" returns a successful HTTP response status code, got "%d" instead.', + $url, + $httpStatusCode, + )); + } + + /** + * @return \Generator + */ + public static function provideUrl(): \Generator + { + $httpHost = getenv('HTTP_HOST'); + + if (!is_string($httpHost)) { + throw new \RuntimeException('Environment variable "HTTP_HOST" is not set.'); + } + + $pathToRoot = realpath(__DIR__ . '/../..'); + + $patterns = [ + $pathToRoot . '/*.php', + $pathToRoot . '/archive/*.php', + $pathToRoot . '/conferences/*.php', + $pathToRoot . '/license/*.php', + $pathToRoot . '/manual/*.php', + $pathToRoot . '/manual/en/*.php', + $pathToRoot . '/releases/*.php', + $pathToRoot . '/releases/*/*.php', + $pathToRoot . '/releases/*/*/*.php', + ]; + + foreach ($patterns as $pattern) { + $pathsToFiles = glob($pattern); + + $paths = str_replace($pathToRoot, '', $pathsToFiles); + + foreach ($paths as $path) { + $url = sprintf( + 'http://%s%s', + $httpHost, + $path, + ); + + yield $url => [ + $url, + ]; + } + } + } +} diff --git a/tests/EndToEnd/paths-return-http-response-status-code-200-301-or-302.phpt b/tests/EndToEnd/paths-return-http-response-status-code-200-301-or-302.phpt deleted file mode 100644 index 15f1bc8bde..0000000000 --- a/tests/EndToEnd/paths-return-http-response-status-code-200-301-or-302.phpt +++ /dev/null @@ -1,65 +0,0 @@ ---TEST-- -paths return HTTP response status code 200, 301, or 302 ---FILE-- - true, - CURLOPT_URL => sprintf( - '%s%s', - $baseUrl, - $url, - ), - ]; - - curl_setopt_array($handle, $options); - - curl_exec($handle); - - return curl_getinfo($handle, CURLINFO_HTTP_CODE); - }, $paths), -); - -$pathsWithUnexpectedStatusCodes = array_filter($pathsToStatusCodes, static function (int $statusCode): bool { - return !in_array($statusCode, [200, 301, 302], true); -}); - -var_dump($pathsWithUnexpectedStatusCodes); -?> ---EXPECT-- -array(0) { -} diff --git a/tests/phpunit.xml b/tests/phpunit.xml index c8343aa037..3eac985e8a 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -32,7 +32,7 @@ - EndToEnd/ + EndToEnd/ Unit/