diff --git a/images/linux/scripts/installers/php.sh b/images/linux/scripts/installers/php.sh index 1fbb66a6..b54b4379 100644 --- a/images/linux/scripts/installers/php.sh +++ b/images/linux/scripts/installers/php.sh @@ -7,23 +7,16 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/invoke-tests.sh # add repository apt-add-repository ppa:ondrej/php -y apt-get update # Install PHP -if isUbuntu16 ; then - php_versions="5.6 7.0 7.1 7.2 7.3 7.4 8.0" -fi +toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -if isUbuntu18 ; then - php_versions="7.1 7.2 7.3 7.4 8.0" -fi - -if isUbuntu20 ; then - php_versions="7.4 8.0" -fi +php_versions=$(jq -r '.php.versions[]' $toolset) for version in $php_versions; do echo "Installing PHP $version" @@ -111,28 +104,11 @@ wget -q -O phpunit https://phar.phpunit.de/phpunit-8.phar chmod +x phpunit mv phpunit /usr/local/bin/phpunit -# Run tests to determine that the software installed as expected -echo "Testing to make sure that script performed as expected, and basic scenarios work" -for cmd in composer pear pecl phpunit; do - if ! command -v $cmd; then - echo "$cmd was not installed" - exit 1 - fi -done - -for version in $php_versions; do - if ! command -v php$version; then - echo "php$version was not installed" - exit 1 - elif ! command -v php-config$version || ! command -v phpize$version; then - echo "php$version-dev was not installed" - exit 1 - fi -done - # ubuntu 20.04 libzip-dev is libzip5 based and is not compatible libzip-dev of ppa:ondrej/php # see https://github.com/actions/virtual-environments/issues/1084 if isUbuntu20 ; then rm /etc/apt/sources.list.d/ondrej-ubuntu-php-focal.list apt-get update fi + +invoke_tests "Common" "PHP" \ No newline at end of file diff --git a/images/linux/scripts/tests/Common.Tests.ps1 b/images/linux/scripts/tests/Common.Tests.ps1 new file mode 100644 index 00000000..c56edc23 --- /dev/null +++ b/images/linux/scripts/tests/Common.Tests.ps1 @@ -0,0 +1,30 @@ +Describe "PHP" { + + [array]$testCases = (Get-ToolsetContent).php.versions | ForEach-Object { @{phpVersion = $_} } + + It "php " -TestCases $testCases { + param ( + [string] $phpVersion + ) + + "php$phpVersion --version" | Should -ReturnZeroExitCode + "php-config$phpVersion --version" | Should -ReturnZeroExitCode + "phpize$phpVersion --version" | Should -ReturnZeroExitCode + } + + It "PHPUnit" { + "phpunit --version" | Should -ReturnZeroExitCode + } + + It "Composer" { + "composer --version" | Should -ReturnZeroExitCode + } + + It "Pear" { + "pear" | Should -ReturnZeroExitCode + } + + It "Pecl" { + "pecl" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/linux/toolsets/toolset-1604.json b/images/linux/toolsets/toolset-1604.json index 0297fa57..5001ae1c 100644 --- a/images/linux/toolsets/toolset-1604.json +++ b/images/linux/toolsets/toolset-1604.json @@ -235,5 +235,16 @@ "gfortran-8", "gfortran-9" ] + }, + "php": { + "versions": [ + "5.6", + "7.0", + "7.1", + "7.2", + "7.3", + "7.4", + "8.0" + ] } } diff --git a/images/linux/toolsets/toolset-1804.json b/images/linux/toolsets/toolset-1804.json index bc17b6a1..75b23383 100644 --- a/images/linux/toolsets/toolset-1804.json +++ b/images/linux/toolsets/toolset-1804.json @@ -241,5 +241,14 @@ "gfortran-9", "gfortran-10" ] + }, + "php": { + "versions": [ + "7.1", + "7.2", + "7.3", + "7.4", + "8.0" + ] } } diff --git a/images/linux/toolsets/toolset-2004.json b/images/linux/toolsets/toolset-2004.json index 761e6daa..104e9f60 100644 --- a/images/linux/toolsets/toolset-2004.json +++ b/images/linux/toolsets/toolset-2004.json @@ -213,5 +213,11 @@ "gfortran-9", "gfortran-10" ] + }, + "php": { + "versions": [ + "7.4", + "8.0" + ] } }