diff --git a/.github/workflows/3x.yml b/.github/workflows/3x.yml index 3af6c6259..af375135c 100644 --- a/.github/workflows/3x.yml +++ b/.github/workflows/3x.yml @@ -1,5 +1,14 @@ name: Terminus 3.x -on: push +on: + push: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + inputs: + functional_tests_all: + description: Run all functional tests + required: true + default: '1' jobs: # Checkout in separate job because docker image is alpine based and checkout action doesn't work. checkout_build: @@ -37,7 +46,7 @@ jobs: strategy: matrix: operating-system: [ 'macos-latest' ] - php-versions: [ '8.0' ] + php-versions: [ '8.0', '8.1' ] max-parallel: 1 env: TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }} @@ -66,7 +75,11 @@ jobs: - name: Install Composer Dependencies run: composer install --no-interaction --prefer-dist - name: Functional Tests (short) + if: ${{ github.event_name == 'push' }} run: composer test:short + - name: Functional Tests (long) + if: ${{ github.event_name == 'schedule' || github.event.inputs.functional_tests_all == '1' }} + run: composer test:long - name: Coverage Report run: composer coverage - name: Save coverage as artifact diff --git a/bin/terminus b/bin/terminus index 7726b77ce..36a2b7bd0 100755 --- a/bin/terminus +++ b/bin/terminus @@ -16,15 +16,8 @@ if (version_compare(PHP_VERSION, '7.4.0', '<') === true) { echo 'Upgrade to PHP 7.4 or newer to use Terminus 3. For PHP versions prior to 7.4, downgrade to Terminus 2.x.'; echo "\n\n"; exit(1); } elseif (version_compare(PHP_VERSION, '8.1.0', '>=') === true) { - echo "\n"; - echo 'PHP 8.1+ is not supported by this version of Terminus.' . "\n"; - echo 'Check for new versions at https://github.com/pantheon-systems/terminus/releases' . "\n"; - echo "\n"; - if (!getenv('TERMINUS_ALLOW_UNSUPPORTED_NEWER_PHP')) { - echo 'Set environment variable TERMINUS_ALLOW_UNSUPPORTED_NEWER_PHP to try continuing anyway.' . "\n"; - echo "Stopping.\n\n"; - exit(1); - } + // Prevent outputting PHP deprecation messages produced by vendors. + error_reporting(error_reporting() & ~E_DEPRECATED); } // This variable is automatically managed via updateDependenciesversion() in /RoboFile.php, diff --git a/composer.json b/composer.json index e9014e56b..c3de3c5af 100644 --- a/composer.json +++ b/composer.json @@ -118,7 +118,7 @@ "SHELL_INTERACTIVE=true TERMINUS_TEST_MODE=1 behat --colors --config tests/config/behat.yml --stop-on-failure --suite=default" ], "test:short": [ - "XDEBUG_MODE=coverage vendor/bin/phpunit --colors=always -c ./phpunit.xml --debug --group=short --do-not-cache-result --verbose" + "XDEBUG_MODE=coverage vendor/bin/phpunit --colors=always -c ./phpunit.xml --debug --group=short --do-not-cache-result --verbose --stop-on-failure" ], "test:long": [ "XDEBUG_MODE=coverage vendor/bin/phpunit --colors=always -c ./phpunit.xml --debug --group=long --do-not-cache-result --verbose" diff --git a/src/Collections/OrganizationOwnedCollection.php b/src/Collections/OrganizationOwnedCollection.php index 01ad5a060..b51d6ae4d 100644 --- a/src/Collections/OrganizationOwnedCollection.php +++ b/src/Collections/OrganizationOwnedCollection.php @@ -28,6 +28,6 @@ public function __construct($options = []) public function getUrl() { // Replace the {organization_id} token with the actual organization id. - return str_replace('{organization_id}', $this->getOrganization()->id, parent::getUrl()); + return str_replace('{organization_id}', $this->getOrganization()->id ?? '', parent::getUrl()); } } diff --git a/src/Collections/SiteOwnedCollection.php b/src/Collections/SiteOwnedCollection.php index 6967e597f..e97d28fff 100644 --- a/src/Collections/SiteOwnedCollection.php +++ b/src/Collections/SiteOwnedCollection.php @@ -34,6 +34,6 @@ public function __construct($options = []) */ public function getUrl() { - return str_replace('{site_id}', $this->getSite()->id, parent::getUrl()); + return str_replace('{site_id}', $this->getSite()->id ?? '', parent::getUrl()); } } diff --git a/src/Collections/UserOwnedCollection.php b/src/Collections/UserOwnedCollection.php index eff7c4ec5..add8a5b51 100644 --- a/src/Collections/UserOwnedCollection.php +++ b/src/Collections/UserOwnedCollection.php @@ -28,6 +28,6 @@ public function __construct($options = []) public function getUrl() { // Replace the {user_id} token with the actual user id. - return str_replace('{user_id}', $this->getUser()->id, parent::getUrl()); + return str_replace('{user_id}', $this->getUser()->id ?? '', parent::getUrl()); } } diff --git a/src/Friends/SiteTrait.php b/src/Friends/SiteTrait.php index 9ec4ab954..1ba63ddd5 100644 --- a/src/Friends/SiteTrait.php +++ b/src/Friends/SiteTrait.php @@ -42,7 +42,7 @@ public function getSite() */ public function getUrl() { - return str_replace('{site_id}', $this->getSite()->id, parent::getUrl()); + return str_replace('{site_id}', $this->getSite()->id ?? '', parent::getUrl()); } /** diff --git a/src/Helpers/LocalMachineHelper.php b/src/Helpers/LocalMachineHelper.php index 23a8250ab..cbe5b6099 100644 --- a/src/Helpers/LocalMachineHelper.php +++ b/src/Helpers/LocalMachineHelper.php @@ -29,7 +29,7 @@ class LocalMachineHelper implements ConfigAwareInterface, ContainerAwareInterfac use ContainerAwareTrait; use IO; use CommandExecutorTrait { - execute as executeUnbuffered; + CommandExecutorTrait::execute as executeUnbuffered; } /** @@ -165,7 +165,7 @@ public function writeFile($filename, $content) protected function fixFilename($filename) { $config = $this->getConfig(); - return $config->fixDirectorySeparators(str_replace('~', $config->get('user_home'), $filename)); + return $config->fixDirectorySeparators(str_replace('~', $config->get('user_home') ?? '', $filename)); } /** diff --git a/src/Models/TerminusModel.php b/src/Models/TerminusModel.php index 9e5f80365..65b31dfaf 100644 --- a/src/Models/TerminusModel.php +++ b/src/Models/TerminusModel.php @@ -106,7 +106,7 @@ public function getReferences() */ public function getUrl() { - return str_replace('{id}', $this->id, $this->url); + return str_replace('{id}', $this->id ?? '', $this->url); } /** diff --git a/src/Plugins/PluginInfo.php b/src/Plugins/PluginInfo.php index 6015def7a..b42cf159c 100644 --- a/src/Plugins/PluginInfo.php +++ b/src/Plugins/PluginInfo.php @@ -151,7 +151,7 @@ public function getLatestVersion() { $command = str_replace( '{package}', - $this->getName(), + $this->getName() ?? '', self::GET_LATEST_AVAILABLE_VERSION ); $results = $this->runCommand($command); @@ -223,7 +223,7 @@ public static function checkWhetherPackagistProject($project_name, LocalMachineH // Search for the Packagist project. $command = str_replace( '{project}', - $project_name, + $project_name ?? '', self::VALIDATION_COMMAND ); $results = $local_machine_helper->exec($command); diff --git a/src/Request/RequestOperationResult.php b/src/Request/RequestOperationResult.php index c1f9a38ab..308d34732 100644 --- a/src/Request/RequestOperationResult.php +++ b/src/Request/RequestOperationResult.php @@ -65,36 +65,33 @@ public function setStatusCodeReason(string $status_code_reason): void } /** - * @param mixed $offset - * @return bool + * @inheritdoc */ - public function offsetExists($offset) + public function offsetExists(mixed $offset): bool { return isset($this->{$offset}); } /** - * @param mixed $offset - * @return mixed|null + * @inheritdoc */ - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->{$offset} ?? null; } /** - * @param mixed $offset - * @param mixed $value + * @inheritdoc */ - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->{$offset} = $value; } /** - * @param mixed $offset + * @inheritdoc */ - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { unset($this->{$offset}); } diff --git a/tests/config/bootstrap.php b/tests/config/bootstrap.php index c8199762f..8fffa67f8 100644 --- a/tests/config/bootstrap.php +++ b/tests/config/bootstrap.php @@ -63,7 +63,11 @@ if (!getenv('TERMINUS_TESTING_RUNTIME_ENV')) { // Create a testing runtime multidev environment. - $sitename = TerminusTestTrait::getSiteName(); + $sitename = (new class { + use TerminusTestTrait; + + })::getSiteName(); + $multidev = sprintf('test-%s', substr(uniqid(), -6, 6)); $createMdCommand = sprintf('multidev:create %s.dev %s', $sitename, $multidev); exec( @@ -76,7 +80,10 @@ throw new Exception(sprintf('Command "%s" exited with non-zero code (%d)', $createMdCommand, $code)); } - TerminusTestTrait::setMdEnv($multidev); + (new class { + use TerminusTestTrait; + + })::setMdEnv($multidev); register_shutdown_function(function () use ($sitename, $multidev) { // Delete a testing runtime multidev environment.