diff --git a/tests/IntegrationTest/BaseLineTest.php b/tests/IntegrationTest/BaseLineTest.php index a87ee410..83356543 100644 --- a/tests/IntegrationTest/BaseLineTest.php +++ b/tests/IntegrationTest/BaseLineTest.php @@ -64,18 +64,6 @@ protected function tear_down() */ public function testBaseLineGlobal($phpcsVersion, $expectedStnds) { - if ( - $phpcsVersion === PHPCSVersions::MASTER - && \CLI_PHP_MINOR === '5.5' - && $this->onWindows() === true - && substr(\COMPOSER_VERSION, 0, 1) === '1' - ) { - $this->markTestSkipped( - 'Composer 1.x on Windows with PHP 5.5 does run the plugin when there are no external standards,' - . ' but doesn\'t consistently show this in the logs' - ); - } - $config = $this->composerConfig; $config['require-dev']['squizlabs/php_codesniffer'] = $phpcsVersion; @@ -83,10 +71,11 @@ public function testBaseLineGlobal($phpcsVersion, $expectedStnds) $this->assertComposerValidates(static::$tempGlobalPath); // Make sure the plugin runs. + $expectedStdOut = $this->willPluginOutputShow() ? 'Running PHPCodeSniffer Composer Installer' : null; $this->assertExecute( 'composer global install -v --no-ansi', 0, // Expected exit code. - 'Running PHPCodeSniffer Composer Installer', // Expected stdout. + $expectedStdOut, // Expected stdout. null, // No stderr expectation. 'Failed to install dependencies.' ); @@ -119,18 +108,6 @@ public function testBaseLineGlobal($phpcsVersion, $expectedStnds) */ public function testBaseLineLocal($phpcsVersion, $expectedStnds) { - if ( - $phpcsVersion === PHPCSVersions::MASTER - && \CLI_PHP_MINOR === '5.5' - && $this->onWindows() === true - && substr(\COMPOSER_VERSION, 0, 1) === '1' - ) { - $this->markTestSkipped( - 'Composer 1.x on Windows with PHP 5.5 does run the plugin when there are no external standards,' - . ' but doesn\'t consistently show this in the logs' - ); - } - $config = $this->composerConfig; $config['require-dev']['squizlabs/php_codesniffer'] = $phpcsVersion; @@ -138,10 +115,11 @@ public function testBaseLineLocal($phpcsVersion, $expectedStnds) $this->assertComposerValidates(static::$tempLocalPath); // Make sure the plugin runs. + $expectedStdOut = $this->willPluginOutputShow() ? 'Running PHPCodeSniffer Composer Installer' : null; $this->assertExecute( sprintf('composer install -v --no-ansi --working-dir=%s', escapeshellarg(static::$tempLocalPath)), 0, // Expected exit code. - 'Running PHPCodeSniffer Composer Installer', // Expected stdout. + $expectedStdOut, // Expected stdout. null, // No stderr expectation. 'Failed to install dependencies.' ); diff --git a/tests/TestCase.php b/tests/TestCase.php index c0f31d57..2375b1c0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -208,6 +208,25 @@ protected static function onWindows() return strpos(strtoupper(\PHP_OS), 'WIN') === 0; } + /** + * Determine whether output expectations can be set for a typical Composer `install`/`update` run. + * + * Composer 1.x on Windows with PHP 5.5 DOES run the plugin, but doesn't consistently show this in the logs. + * This method can be used to still test output expectations in _most_ cases, without failing the tests + * in the rare case they won't show. + * + * It is recommended to only add a call to this method to a test when it has been proven + * to fail without it. + * + * @return bool + */ + protected function willPluginOutputShow() + { + return ((\CLI_PHP_MINOR === '5.5' + && $this->onWindows() === true + && substr(\COMPOSER_VERSION, 0, 1) === '1') === false); + } + /** * Create a composer.json file based on a given configuration. *