diff --git a/bin/compile b/bin/compile index 2865bc4a..0f1a0f53 100755 --- a/bin/compile +++ b/bin/compile @@ -46,28 +46,32 @@ function detect_framework() { function best_composer_version() { local require_composer="" - if [ -f "$BUILD_DIR/composer.json" ] ; then + + if [ -f "${BUILD_DIR}/composer.json" ]; then require_composer=$(jq --raw-output ".extra.${composer_extra_key}.engines.composer // \"\"" < "$BUILD_DIR/composer.json") fi - if [ -n "$COMPOSER_VERSION" ] ; then - require_composer="$COMPOSER_VERSION" + + if [ -z "${require_composer}" ] ; then + require_composer="${COMPOSER_VERSION:-${DEFAULT_COMPOSER}}" fi - [ -z "${require_composer}" ] && require_composer="$DEFAULT_COMPOSER" + curl --fail --location --silent "${SEMVER_SERVER}/composer-${STACK}/resolve/${require_composer}" } function best_nginx_version() { local require_nginx="" - if [ -f "$BUILD_DIR/composer.json" ] ; then - for key in ".require.nginx" ".extra.${composer_extra_key}.engines.nginx" ; do - require_nginx=$(jq --raw-output "${key} // \"\"" < "$BUILD_DIR/composer.json") + + if [ -f "${BUILD_DIR}/composer.json" ]; then + for key in ".require.nginx" ".extra.${composer_extra_key}.engines.nginx"; do + require_nginx=$(jq --raw-output "${key} // \"\"" < "${BUILD_DIR}/composer.json") [ -n "${require_nginx}" ] && break done fi - if [ -n "$NGINX_VERSION" ] ; then - require_nginx="$NGINX_VERSION" + + if [ -z "${require_nginx}" ]; then + require_nginx="${NGINX_VERSION:-${DEFAULT_NGINX}}" fi - [ -z "${require_nginx}" ] && require_nginx="$DEFAULT_NGINX" + curl --fail --location --silent "${SEMVER_SERVER}/nginx-${STACK}/resolve/${require_nginx}" } @@ -76,8 +80,8 @@ function best_php_version() { # First check if we have something in composer.json # If so, this is the value we want. It must always prevail: - if [ -f "${BUILD_DIR}/composer.json" ] ; then - for key in ".require.php" ".config.platform.php" ".extra.${composer_extra_key}.engines.php" ; do + if [ -f "${BUILD_DIR}/composer.json" ]; then + for key in ".require.php" ".config.platform.php" ".extra.${composer_extra_key}.engines.php"; do require_php="$( jq --raw-output "${key} // \"\"" < "${BUILD_DIR}/composer.json" )" [ -n "${require_php}" ] && break done @@ -85,12 +89,8 @@ function best_php_version() { # If nothing is specified in composer.json # Or if this is a Classic app, we should check PHP_VERSION: - if [ -z "${require_php}" ] && [ -n "${PHP_VERSION}" ] ; then - require_php="${PHP_VERSION}" - fi - if [ -z "${require_php}" ]; then - require_php="${DEFAULT_PHP}" + require_php="${PHP_VERSION:-${DEFAULT_PHP}}" fi curl --fail --location --silent "${SEMVER_SERVER}/php-${STACK}/resolve/${require_php}" diff --git a/test/fixtures/composer_composer-2.6.0/composer.json b/test/fixtures/composer_composer-2.6.0/composer.json new file mode 100644 index 00000000..c6d57679 --- /dev/null +++ b/test/fixtures/composer_composer-2.6.0/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "composer": "2.6.0" + } + } + } +} diff --git a/test/fixtures/composer_composer-2.6.0/composer.lock b/test/fixtures/composer_composer-2.6.0/composer.lock new file mode 100644 index 00000000..33632337 --- /dev/null +++ b/test/fixtures/composer_composer-2.6.0/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "9179b212c7578e2a08870927cc6364e4", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/fixtures/composer_composer-2.7.0/composer.json b/test/fixtures/composer_composer-2.7.0/composer.json new file mode 100644 index 00000000..68cb7b1b --- /dev/null +++ b/test/fixtures/composer_composer-2.7.0/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "composer": "2.7.0" + } + } + } +} diff --git a/test/fixtures/composer_composer-2.7.0/composer.lock b/test/fixtures/composer_composer-2.7.0/composer.lock new file mode 100644 index 00000000..daa13a50 --- /dev/null +++ b/test/fixtures/composer_composer-2.7.0/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "568ca2d660481edbb1a0dccec744b88b", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/fixtures/composer_nginx-1.21.6/composer.json b/test/fixtures/composer_nginx-1.21.6/composer.json new file mode 100644 index 00000000..f79531f9 --- /dev/null +++ b/test/fixtures/composer_nginx-1.21.6/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "nginx": "1.21.6" + } + } + } +} diff --git a/test/fixtures/composer_nginx-1.21.6/composer.lock b/test/fixtures/composer_nginx-1.21.6/composer.lock new file mode 100644 index 00000000..4f967fe3 --- /dev/null +++ b/test/fixtures/composer_nginx-1.21.6/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "df7fd9ca7fdce9bf5ca88bbdb6baeb5f", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/fixtures/composer_nginx-1.22.1/composer.json b/test/fixtures/composer_nginx-1.22.1/composer.json new file mode 100644 index 00000000..14d4f7a0 --- /dev/null +++ b/test/fixtures/composer_nginx-1.22.1/composer.json @@ -0,0 +1,9 @@ +{ + "extra": { + "paas": { + "engines": { + "nginx": "1.22.1" + } + } + } +} diff --git a/test/fixtures/composer_nginx-1.22.1/composer.lock b/test/fixtures/composer_nginx-1.22.1/composer.lock new file mode 100644 index 00000000..6f29c345 --- /dev/null +++ b/test/fixtures/composer_nginx-1.22.1/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "5de61e8cb50f2a8cfa605126cf684bcc", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.2.0" +} diff --git a/test/fixtures/composer_php80/composer.json b/test/fixtures/composer_php-8.0/composer.json similarity index 100% rename from test/fixtures/composer_php80/composer.json rename to test/fixtures/composer_php-8.0/composer.json diff --git a/test/fixtures/composer_php80/composer.lock b/test/fixtures/composer_php-8.0/composer.lock similarity index 100% rename from test/fixtures/composer_php80/composer.lock rename to test/fixtures/composer_php-8.0/composer.lock diff --git a/test/fixtures/composer_php81/composer.json b/test/fixtures/composer_php-8.1/composer.json similarity index 100% rename from test/fixtures/composer_php81/composer.json rename to test/fixtures/composer_php-8.1/composer.json diff --git a/test/fixtures/composer_php81/composer.lock b/test/fixtures/composer_php-8.1/composer.lock similarity index 100% rename from test/fixtures/composer_php81/composer.lock rename to test/fixtures/composer_php-8.1/composer.lock diff --git a/test/fixtures/composer_php82/composer.json b/test/fixtures/composer_php-8.2/composer.json similarity index 100% rename from test/fixtures/composer_php82/composer.json rename to test/fixtures/composer_php-8.2/composer.json diff --git a/test/fixtures/composer_php82/composer.lock b/test/fixtures/composer_php-8.2/composer.lock similarity index 100% rename from test/fixtures/composer_php82/composer.lock rename to test/fixtures/composer_php-8.2/composer.lock diff --git a/test/fixtures/composer_php83/composer.json b/test/fixtures/composer_php-8.3/composer.json similarity index 100% rename from test/fixtures/composer_php83/composer.json rename to test/fixtures/composer_php-8.3/composer.json diff --git a/test/fixtures/composer_php83/composer.lock b/test/fixtures/composer_php-8.3/composer.lock similarity index 100% rename from test/fixtures/composer_php83/composer.lock rename to test/fixtures/composer_php-8.3/composer.lock diff --git a/test/helpers b/test/helpers index 24af3f49..923828bf 100644 --- a/test/helpers +++ b/test/helpers @@ -2,12 +2,11 @@ ### Helpers functions -test::helpers::deploy() { - # Deploys a PHP app step by step and tests that everything is working as - # expected. +test::helpers::common_deploy() { + # Deploys a PHP app step by step and tests that everything related to the + # PHP setup is as expected. # To do so, this function runs the buildpack scripts and mimicks the # platform behavior wherever needed. - # The different fixtures allow us to test different setup and conditions. # # Globals: # STD_OUT @@ -15,22 +14,87 @@ test::helpers::deploy() { # # Arguments: # $1 > $detect_expectation - # See `test::helpers::test_detect`. + # See `test::helpers::detect`. # - # $2 > $version - # See `test::helpers::test_compile`. + # $2 > $php_version + # See `test::helpers::php`. local detect_expectation="${1}" - local version="${2}" + local php_version="${2}" - # Test that bin/detect works as expected: + # Test bin/detect: test::helpers::detect "${detect_expectation}" - # Test that bin/compile works as expected: - test::helpers::compile "${version}" + # Test bin/compile: + test::helpers::compile - # Test that all default PHP modules are available: - test::helpers::default_modules + # Switch environment: + test::helpers::enter_prod + + # Test PHP version: + test::helpers::php "${php_version}" + + # Test PHP default modules: + test::helpers::default_php_modules +} + +test::helpers::classic_deploy() { + # Deploys a classic PHP app step by step and tests that everything is + # working as expected, including the Nginx version. + # + # Globals: + # STD_OUT + # default_modules + # + # Arguments: + # $1 > $php_version + # See `test::helpers::php`. + # + # $2 > $nginx_version + # See `test::helpers::nginx` + + local php_version="${1}" + local nginx_version="${2}" + + # Test everything related to PHP: + test::helpers::common_deploy "PHP (classic)" "${php_version}" + + # Test Nginx version: + test::helpers::nginx "${nginx_version}" + + # No Composer +} + +test::helpers::composer_deploy() { + # Deploys a Composer PHP app step by step and tests that everything is + # working as expected, including the Nginx and the Composer versions. + # + # Globals: + # STD_OUT + # default_modules + # + # Arguments: + # $1 > $php_version + # See `test::helpers::php`. + # + # $2 > $nginx_version + # See `test::helpers::nginx`. + # + # $3 > $composer_version + # See `test::helpers::composer`. + + local php_version="${1}" + local nginx_version="${2}" + local composer_version="${3}" + + # Test everything related to PHP: + test::helpers::common_deploy "PHP (composer.json)" "${php_version}" + + # Test Nginx version: + test::helpers::nginx "${nginx_version}" + + # Test Composer version: + test::helpers::composer "${composer_version}" } test::helpers::detect() { @@ -54,7 +118,17 @@ test::helpers::detect() { test::helpers::compile() { # Runs the `bin/compile` script of the buildpack and then: # - Asserts that is succeeded - # - Asserts that the version of installed PHP is the one expected + + test::utils::compile + # We can't use assertCapturedSuccess here: + # With an empty composer.json file, composer will use stderr to warn us + # that nothing had to be installed, causing the test to fail for no + # reason -_- + test::utils::assertSuccess +} + +test::helpers::php() { + # Tests that PHP has the expected version. # # Arguments: # $1 > $version: Expected version of PHP. @@ -74,49 +148,54 @@ test::helpers::compile() { local version="${1}" - test::utils::compile - # We can't use assertCapturedSuccess here: - # With an empty composer.json file, composer will use stderr to warn us - # that nothing had to be installed, causing the test to fail for no - # reason -_- - test::utils::assertSuccess - - # Switch environment: - test::helpers::enter_prod - - # Test that PHP has the expected version: - test::helpers::get_php_version + test::utils::capture php --version test::utils::assertCapturedStartswith "PHP ${version}" } -test::helpers::default_modules() { - # Test that all default PHP modules are available. +test::helpers::default_php_modules() { + # Tests that all default PHP modules are available. # # Globals: # default_modules - # List all installed modules in STD_OUT: - test::helpers::list_php_modules + test::utils::capture php --modules for module in "${default_modules[@]}"; do test::utils::assertFileContains "${module}" "${STD_OUT}" done } -test::helpers::get_php_version() { - # Captures the output of `php --version` so we can check that the version - # installed is the expected one. +test::helpers::composer() { + # Tests that Composer has the expected version. + # + # Arguments: + # $1 > $version: Expected Composer version + + local version="${1}" + + test::utils::capture composer --version - test::utils::capture ./vendor/php/bin/php --version + test::utils::assertCapturedStartswith "Composer version ${version}" } -test::helpers::list_php_modules() { - # Captures the output of `php --modules` so we can check that all default - # modules are indeed available. +test::helpers::nginx() { + # Tests that Nginx has the expected version. + # + # Arguments: + # $1 > $version: Expected Nginx version + + local version="${1}" - test::utils::capture ./vendor/php/bin/php --modules + test::utils::capture nginx -version + # For some reason known to Nginx, `-version` outputs on stderr... + # See https://trac.nginx.org/test/ticket/592 for further details. + # Consequently, we have to use this assertion: + test::utils::assertFileStartswith \ + "nginx version: nginx/${version}" \ + "${STD_ERR}" } + test::helpers::enter_prod() { # Helper to switch to a production-like environment: # - $HOME is set to /app @@ -137,9 +216,7 @@ test::helpers::enter_prod() { # HOME # PREV_HOME # BUILD_DIR - - PREV_HOME="${HOME}" - export PREV_HOME + # PATH HOME="/app" export HOME @@ -147,4 +224,7 @@ test::helpers::enter_prod() { pushd "${HOME}" > /dev/null cp --archive --recursive "${BUILD_DIR}"/* "${HOME}/" + + PATH="${PATH}:${HOME}/bin:${HOME}/vendor/php/bin:${HOME}/vendor/nginx/sbin" + export PATH } diff --git a/test/run b/test/run index a54e8bc4..49ad7db6 100755 --- a/test/run +++ b/test/run @@ -12,7 +12,7 @@ oneTimeSetUp() { } oneTimeTearDown() { - rm -rf "${TEST_SUITE_CACHE}" + rm --recursive --force "${TEST_SUITE_CACHE}" } setUp() { @@ -29,22 +29,41 @@ setUp() { mkdir -p "${OUTPUT_DIR}" "${BUILD_DIR}" "${CACHE_DIR}" export OUTPUT_DIR STD_OUT STD_ERR BUILD_DIR CACHE_DIR HOME BUILDPACK_DIR + # We'll probably update PATH during the test, + # let's keep the original value safe + PREV_PATH="${PATH}" + export PREV_PATH + # Copy the buildpack code into BUILDPACK_DIR: cp --archive "$( pwd )"/* "${BUILDPACK_DIR}/" + + # Make sure we have a /app directory: + mkdir --parents "/app" } tearDown() { - # Empty OUTPUT_DIR and BUILDPACK_DIR - rm -rf "${OUTPUT_DIR}" - rm -rf "${BUILDPACK_DIR}" - - unset BUILDPACK_DIR BUILD_DIR CACHE_DIR PHP_VERSION + # Set HOME back to its original value: + HOME="/root" + export HOME # We may have changed working dir, let's switch back to the initial one: popd > /dev/null 2>&1 - # Make sure /app is empty: - rm -rf "/app"/* + # Set PATH back to its original value: + PATH="${PREV_PATH}" + export PATH + + # Remove /app: + rm --recursive --force "/app" + + # Remove OUTPUT_DIR, which also removes BUILD_DIR and CACHE_DIR: + rm --recursive --force "${OUTPUT_DIR}" + + # Remove BUILDPACK_DIR: + rm --recursive --force "${BUILDPACK_DIR}" + + unset BUILDPACK_DIR BUILD_DIR CACHE_DIR + unset PHP_VERSION NGINX_VERSION COMPOSER_VERSION } # Load shUnit2, which also run the tests: diff --git a/test/tests b/test/tests index 28ecc1cd..1d82c9e2 100755 --- a/test/tests +++ b/test/tests @@ -15,13 +15,29 @@ readonly default_modules=( "tokenizer" "xml" "xmlreader" "xmlwriter" "xsl" "Zend OPcache" "zip" "zlib" ) +declare -gA default_php +declare -gA default_nginx +declare -gA default_composer + +# Defaults for scalingo-20: +default_php["scalingo-20"]="8.1." +default_nginx["scalingo-20"]="1.20." +default_composer["scalingo-20"]="2.7." + +# Defaults for scalingo-22: +default_php["scalingo-22"]="8.1." +default_nginx["scalingo-22"]="1.22." +default_composer["scalingo-22"]="2.7." + test::classic::defaults() { # Test a deployment of a classic app (not using Composer) # With default settings test::utils::setupFixture "classic_default" - test::helpers::deploy "PHP (classic)" "8.1." + test::helpers::classic_deploy \ + "${default_php["${STACK}"]}" \ + "${default_nginx["${STACK}"]}" } test::classic::php80() { @@ -31,14 +47,15 @@ test::classic::php80() { PHP_VERSION="8.0" export PHP_VERSION - # PHP 8.0 is only available on stack `scalingo-20`: if [[ "${STACK}" != "scalingo-20" ]]; then echo "[skipping] PHP 8.0 is not available on scalingo-22" startSkipping fi test::utils::setupFixture "classic_default" - test::helpers::deploy "PHP (classic)" "8.0." + test::helpers::classic_deploy \ + "8.0." \ + "${default_nginx["${STACK}"]}" } test::classic::php81() { @@ -49,7 +66,9 @@ test::classic::php81() { export PHP_VERSION test::utils::setupFixture "classic_default" - test::helpers::deploy "PHP (classic)" "8.1." + test::helpers::classic_deploy \ + "8.1." \ + "${default_nginx["${STACK}"]}" } test::classic::php82() { @@ -60,7 +79,9 @@ test::classic::php82() { export PHP_VERSION test::utils::setupFixture "classic_default" - test::helpers::deploy "PHP (classic)" "8.2." + test::helpers::classic_deploy \ + "8.2." \ + "${default_nginx["${STACK}"]}" } test::classic::php83() { @@ -71,94 +92,250 @@ test::classic::php83() { export PHP_VERSION test::utils::setupFixture "classic_default" - test::helpers::deploy "PHP (classic)" "8.3." + test::helpers::classic_deploy \ + "8.3." \ + "${default_nginx["${STACK}"]}" +} + + +test::classic::nginx_version_via_env() { + # Test a deployment of a classic app (not using Composer) + # Specifying we want Nginx 1.22.1 via environment + # We don't test every step here, we just test that the Nginx version is + # the one expected. + + NGINX_VERSION="1.22.1" + export NGINX_VERSION + + test::utils::setupFixture "classic_default" + test::utils::compile + test::helpers::enter_prod + + test::helpers::nginx "1.22.1" } + test::composer::defaults() { # Test a deployment of a PHP app using Composer # With default settings test::utils::setupFixture "composer_default" - test::helpers::deploy "PHP (composer.json)" "8.1." + test::helpers::composer_deploy \ + "${default_php["${STACK}"]}" \ + "${default_nginx["${STACK}"]}" \ + "${default_composer["${STACK}"]}" } test::composer::php80() { # Test a deployment of a PHP app using Composer - # Specifying we want PHP 8.0.x in composer.json + # Specifying we want PHP 8.0.x via composer.json - # PHP 8.0 is only available on stack `scalingo-20`: if [[ "${STACK}" != "scalingo-20" ]]; then echo "[skipping] PHP 8.0 is not available on scalingo-22" startSkipping fi - test::utils::setupFixture "composer_php80" - test::helpers::deploy "PHP (composer.json)" "8.0." + test::utils::setupFixture "composer_php-8.0" + test::helpers::composer_deploy \ + "8.0." \ + "${default_nginx["${STACK}"]}" \ + "${default_composer["${STACK}"]}" } test::composer::php81() { # Test a deployment of a PHP app using Composer - # Specifying we want PHP 8.1.x in composer.json + # Specifying we want PHP 8.1.x via composer.json - test::utils::setupFixture "composer_php81" - test::helpers::deploy "PHP (composer.json)" "8.1." + test::utils::setupFixture "composer_php-8.1" + test::helpers::composer_deploy \ + "8.1." \ + "${default_nginx["${STACK}"]}" \ + "${default_composer["${STACK}"]}" } test::composer::php82() { # Test a deployment of a PHP app using Composer - # Specifying we want PHP 8.2.x in composer.json + # Specifying we want PHP 8.2.x via composer.json - test::utils::setupFixture "composer_php82" - test::helpers::deploy "PHP (composer.json)" "8.2." + test::utils::setupFixture "composer_php-8.2" + test::helpers::composer_deploy \ + "8.2." \ + "${default_nginx["${STACK}"]}" \ + "${default_composer["${STACK}"]}" } test::composer::php83() { # Test a deployment of a PHP app using Composer - # Specifying we want PHP 8.3.x in composer.json + # Specifying we want PHP 8.3.x via composer.json - test::utils::setupFixture "composer_php83" - test::helpers::deploy "PHP (composer.json)" "8.3." + test::utils::setupFixture "composer_php-8.3" + test::helpers::composer_deploy \ + "8.3." \ + "${default_nginx["${STACK}"]}" \ + "${default_composer["${STACK}"]}" } -test::composer::php_version_defaults() { + +test::composer::php_version_via_env() { # Test a deployment of a PHP app using Composer - # Where the PHP version requirement is only specified in PHP_VERSION. + # Specifying the PHP version only via PHP_VERSION. PHP_VERSION="8.3" export PHP_VERSION test::utils::setupFixture "composer_default" - test::helpers::compile "8.3." + test::utils::compile + test::helpers::enter_prod + + test::helpers::php "8.3." } -test::composer::php_version_greater_than_env() { +test::composer::php_version_via_composer_over_lower_env() { # Test a deployment of a PHP app using Composer - # Where the PHP version requirement is specified in both composer.json - # and PHP_VERSION. + # Specifying the PHP version via both composer.json and PHP_VERSION. # And where the version specified in composer.json is greater than the one # specified in PHP_VERSION. PHP_VERSION="8.2" export PHP_VERSION - test::utils::setupFixture "composer_php83" - test::helpers::compile "8.3." + test::utils::setupFixture "composer_php-8.3" + test::utils::compile + test::helpers::enter_prod + + test::helpers::php "8.3." } -test::composer::php_version_lower_than_env() { +test::composer::php_version_via_composer_over_greater_env() { # Test a deployment of a PHP app using Composer - # Where PHP version requirement is specified in both composer.json - # and PHP_VERSION. + # Specifying the PHP version via both composer.json and PHP_VERSION. # And where the version specified in composer.json is lower than the one # specified in PHP_VERSION. PHP_VERSION="8.3" export PHP_VERSION - test::utils::setupFixture "composer_php82" - test::helpers::compile "8.2." + test::utils::setupFixture "composer_php-8.2" + test::utils::compile + test::helpers::enter_prod + + test::helpers::php "8.2." +} + +test::composer::nginx_version_via_env() { + # Test a deployment of a PHP app using Composer + # Specifying the Nginx version only via NGINX_VERSION. + + NGINX_VERSION="1.21.6" + export NGINX_VERSION + + test::utils::setupFixture "composer_default" + test::utils::compile + test::helpers::enter_prod + + test::helpers::nginx "1.21.6" +} + +test::composer::nginx_version_via_composer() { + # Test a deployment of a PHP app using Composer + # Specifying the Nginx version only via composer.json. + + test::utils::setupFixture "composer_nginx-1.21.6" + test::utils::compile + test::helpers::enter_prod + + test::helpers::nginx "1.21.6" +} + +test::composer::nginx_version_via_composer_over_lower_env() { + # Test a deployment of a PHP app using Composer + # Specifying the Nginx version via both composer.json and NGINX_VERSION. + # And where the version specified in composer.json is greater than the one + # specified in NGINX_VERSION. + + NGINX_VERSION="1.21.6" + export NGINX_VERSION + + test::utils::setupFixture "composer_nginx-1.22.1" + test::utils::compile + test::helpers::enter_prod + + test::helpers::nginx "1.22.1" } +test::composer::nginx_version_via_composer_over_greater_env() { + # Test a deployment of a PHP app using Composer + # Specifying the Nginx version via both composer.json and NGINX_VERSION. + # And where the version specified in composer.json is lower than the one + # specified in NGINX_VERSION. + + NGINX_VERSION="1.22.1" + export NGINX_VERSION + + test::utils::setupFixture "composer_nginx-1.21.6" + test::utils::compile + test::helpers::enter_prod + + test::helpers::nginx "1.21.6" +} + + +test::composer::composer_version_via_env() { + # Test a deployment of a PHP app using Composer + # Specifying the Composer version only via environment. + + COMPOSER_VERSION="2.7.0" + export COMPOSER_VERSION + + test::utils::setupFixture "composer_default" + test::utils::compile + test::helpers::enter_prod + + test::helpers::composer "2.7.0" +} + +test::composer::composer_version_via_composer() { + # Test a deployment of a PHP app using Composer + # Specifying the Composer version only via composer.json. + + test::utils::setupFixture "composer_composer-2.7.0" + test::utils::compile + test::helpers::enter_prod + + test::helpers::composer "2.7.0" +} + +test::composer::composer_version_via_composer_over_lower_env() { + # Test a deployment of a PHP app using Composer + # Specifying Composer version via both composer.json and COMPOSER_VERSION. + # And where the version specified in composer.json is greater than the one + # specified in COMPOSER_VERSION. + + COMPOSER_VERSION="2.6.0" + export COMPOSER_VERSION + + test::utils::setupFixture "composer_composer-2.7.0" + test::utils::compile + test::helpers::enter_prod + + test::helpers::composer "2.7.0" +} + +test::composer::composer_version_via_composer_over_greater_env() { + # Test a deployment of a PHP app using Composer + # Specifying Composer version via both composer.json and COMPOSER_VERSION. + # And where the version specified in composer.json is greater than the one + # specified in COMPOSER_VERSION. + + COMPOSER_VERSION="2.7.0" + export COMPOSER_VERSION + + test::utils::setupFixture "composer_composer-2.6.0" + test::utils::compile + test::helpers::enter_prod + + test::helpers::composer "2.6.0" +} # Add these functions to the test suite: @@ -168,13 +345,24 @@ suite_addTest test::classic::php81 suite_addTest test::classic::php82 suite_addTest test::classic::php83 +suite_addTest test::classic::nginx_version_via_env + suite_addTest test::composer::defaults suite_addTest test::composer::php80 suite_addTest test::composer::php81 suite_addTest test::composer::php82 suite_addTest test::composer::php83 -suite_addTest test::composer::php_version_defaults -suite_addTest test::composer::php_version_greater_than_env -suite_addTest test::composer::php_version_lower_than_env +suite_addTest test::composer::php_version_via_env +suite_addTest test::composer::php_version_via_composer_over_lower_env +suite_addTest test::composer::php_version_via_composer_over_greater_env + +suite_addTest test::composer::nginx_version_via_env +suite_addTest test::composer::nginx_version_via_composer +suite_addTest test::composer::nginx_version_via_composer_over_lower_env +suite_addTest test::composer::nginx_version_via_composer_over_greater_env +suite_addTest test::composer::composer_version_via_env +suite_addTest test::composer::composer_version_via_composer +suite_addTest test::composer::composer_version_via_composer_over_lower_env +suite_addTest test::composer::composer_version_via_composer_over_greater_env