From 5ba72ef8764b3161b712fe59f93a652dbf461127 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Apr 2022 03:41:31 +0200 Subject: [PATCH 1/2] TestCase::willPluginOutputShow(): make static ... to allow the function to be called from data providers. --- tests/TestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index fb6a5ee3..7309aea2 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -220,10 +220,10 @@ protected static function onWindows() * * @return bool */ - protected function willPluginOutputShow() + protected static function willPluginOutputShow() { return ((\CLI_PHP_MINOR === '5.5' - && $this->onWindows() === true + && self::onWindows() === true && strpos(\COMPOSER_VERSION, '1') === 0) === false); } From f0251b838a3c0461056192db13d4dab66bc7d013 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Mon, 18 Apr 2022 20:19:03 +0200 Subject: [PATCH 2/2] PlayNiceWithScriptsTest: wrap output expectation in condition Yet another one which fails on the notorious PHP 5.5 / Composer 1.x on Windows combination. --- .../PlayNiceWithScriptsTest.php | 94 +++++++++++-------- 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/tests/IntegrationTest/PlayNiceWithScriptsTest.php b/tests/IntegrationTest/PlayNiceWithScriptsTest.php index 9efaae0c..9f908a30 100644 --- a/tests/IntegrationTest/PlayNiceWithScriptsTest.php +++ b/tests/IntegrationTest/PlayNiceWithScriptsTest.php @@ -86,15 +86,18 @@ public function testScriptsAreNotBlockedFromRunning($command, $expectedOutputs) $this->assertSame(0, $result['exitcode'], 'Exitcode for initial composer install did not match 0'); - $this->assertStringContainsString( - Plugin::MESSAGE_RUNNING_INSTALLER, - $result['stdout'], - 'Output from initial composer install missing expected contents.' - ); + if ($this->willPluginOutputShow()) { + $this->assertStringContainsString( + Plugin::MESSAGE_RUNNING_INSTALLER, + $result['stdout'], + 'Output from initial composer install missing expected contents.' + ); + } + $output = $this->willPluginOutputShow() ? $result['stdout'] : $result['stderr']; $this->assertStringContainsString( 'post-update-cmd successfully run', - $result['stdout'], + $output, 'Output from initial composer install missing expected contents.' ); @@ -122,42 +125,59 @@ public function testScriptsAreNotBlockedFromRunning($command, $expectedOutputs) */ public function dataScriptsAreNotBlockedFromRunning() { - return array( - 'install:command' => array( - 'command' => 'composer install', - 'expectedOutputs' => array( - 'post-install-cmd successfully run', - Plugin::MESSAGE_RUNNING_INSTALLER, - ), + $data = array(); + $willOutputShow = self::willPluginOutputShow(); + + $data['install:command'] = array( + 'command' => 'composer install', + 'expectedOutputs' => array( + 'post-install-cmd successfully run', ), - 'update:command' => array( - 'command' => 'composer update', - 'expectedOutputs' => array( - 'post-update-cmd successfully run', - Plugin::MESSAGE_RUNNING_INSTALLER, - ), + ); + if ($willOutputShow) { + $data['install:command']['expectedOutputs'][] = Plugin::MESSAGE_RUNNING_INSTALLER; + } + + $data['update:command'] = array( + 'command' => 'composer update', + 'expectedOutputs' => array( + 'post-update-cmd successfully run', ), - 'post-install-cmd:script' => array( - 'command' => 'composer run-script post-install-cmd', - 'expectedOutputs' => array( - Plugin::MESSAGE_RUNNING_INSTALLER, - 'post-install-cmd successfully run', - ), + ); + if ($willOutputShow) { + $data['update:command']['expectedOutputs'][] = Plugin::MESSAGE_RUNNING_INSTALLER; + } + + $data['post-install-cmd:script'] = array( + 'command' => 'composer run-script post-install-cmd', + 'expectedOutputs' => array( + 'post-install-cmd successfully run', ), - 'post-update-cmd:script' => array( - 'command' => 'composer run-script post-update-cmd', - 'expectedOutputs' => array( - Plugin::MESSAGE_RUNNING_INSTALLER, - 'post-update-cmd successfully run', - ), + ); + if ($willOutputShow) { + $data['post-install-cmd:script']['expectedOutputs'][] = Plugin::MESSAGE_RUNNING_INSTALLER; + } + + $data['post-update-cmd:script'] = array( + 'command' => 'composer run-script post-update-cmd', + 'expectedOutputs' => array( + 'post-update-cmd successfully run', ), - 'install-codestandards:script' => array( - 'command' => 'composer run-script install-codestandards', - 'expectedOutputs' => array( - Plugin::MESSAGE_RUNNING_INSTALLER, - 'install-codestandards successfully run', - ), + ); + if ($willOutputShow) { + $data['post-update-cmd:script']['expectedOutputs'][] = Plugin::MESSAGE_RUNNING_INSTALLER; + } + + $data['install-codestandards:script'] = array( + 'command' => 'composer run-script install-codestandards', + 'expectedOutputs' => array( + 'install-codestandards successfully run', ), ); + if ($willOutputShow) { + $data['install-codestandards:script']['expectedOutputs'][] = Plugin::MESSAGE_RUNNING_INSTALLER; + } + + return $data; } }