diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dc20d2c..34f6761 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [7.4, 8.0, 8.1] + php: [7.4, 8.0, 8.1, 8.2] steps: - name: Checkout code @@ -23,8 +23,16 @@ jobs: - name: Validate composer.json and composer.lock run: composer validate + - name: Install Codeception 4 on PHP 7.4 + if: matrix.php == '7.4' + run: composer require codeception/codeception:"^4.2" -W --no-update + + - name: Install Codeception 5 on PHP 8 + if: matrix.php != '7.4' + run: composer require codeception/codeception:"^5.0" -W --no-update + - name: Install dependencies run: composer install --prefer-dist --no-progress --no-interaction --no-suggest - name: Run test suite - run: php -l src/Codeception/Module/Cli.php + run: php vendor/bin/codecept run diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..204037d --- /dev/null +++ b/codeception.yml @@ -0,0 +1,20 @@ +namespace: Tests +support_namespace: Support +suites: + cli: + path: . + actor: CliTester + modules: + enabled: + - Asserts + - Cli + step_decorators: ~ + +settings: + shuffle: true + lint: true +paths: + tests: tests + output: tests/_output + support: tests/Support + data: tests/Support/Data diff --git a/composer.json b/composer.json index f4e3383..a86d93c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,9 @@ { "name": "codeception/module-cli", "description": "Codeception module for testing basic shell commands and shell output", - "keywords": [ "codeception" ], + "keywords": [ + "codeception" + ], "homepage": "https://codeception.com/", "type": "library", "license": "MIT", @@ -13,7 +15,8 @@ "minimum-stability": "RC", "require": { "php": "^7.4 || ^8.0", - "codeception/codeception": "*@dev" + "codeception/codeception": "*@dev", + "codeception/module-asserts": "*" }, "conflict": { "codeception/codeception": "<4.0" @@ -26,4 +29,4 @@ "config": { "classmap-authoritative": true } -} +} \ No newline at end of file diff --git a/src/Codeception/Module/Cli.php b/src/Codeception/Module/Cli.php index 8533543..c6438e0 100644 --- a/src/Codeception/Module/Cli.php +++ b/src/Codeception/Module/Cli.php @@ -45,6 +45,13 @@ public function _before(TestInterface $test): void public function runShellCommand(string $command, bool $failNonZero = true): void { $data = []; + /** + * \Symfony\Component\Console\Application::configureIO sets SHELL_VERBOSITY environment variable + * which may affect execution of shell command + */ + if (\function_exists('putenv')) { + @putenv('SHELL_VERBOSITY'); + } exec("{$command}", $data, $resultCode); $this->result = $resultCode; $this->output = implode("\n", $data); diff --git a/tests/ShellVerbosityIsNotInheritedCest.php b/tests/ShellVerbosityIsNotInheritedCest.php new file mode 100644 index 0000000..2481395 --- /dev/null +++ b/tests/ShellVerbosityIsNotInheritedCest.php @@ -0,0 +1,15 @@ +runShellCommand('php ' . codecept_data_dir('check_verbosity.php')); + $I->seeInShellOutput('bool(false)'); + } +} diff --git a/tests/Support/CliTester.php b/tests/Support/CliTester.php new file mode 100644 index 0000000..04549d1 --- /dev/null +++ b/tests/Support/CliTester.php @@ -0,0 +1,38 @@ +