diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5058435..dc20d2c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - php: [5.6, 7.0, 7.1, 7.2, 7.3, 7.4] + php: [7.4, 8.0, 8.1] steps: - name: Checkout code diff --git a/composer.json b/composer.json index a41212f..f4e3383 100644 --- a/composer.json +++ b/composer.json @@ -1,25 +1,27 @@ { - "name":"codeception/module-cli", - "description":"Codeception module for testing basic shell commands and shell output", - "keywords":["codeception"], - "homepage":"http://codeception.com/", - "type":"library", - "license":"MIT", - "authors":[ + "name": "codeception/module-cli", + "description": "Codeception module for testing basic shell commands and shell output", + "keywords": [ "codeception" ], + "homepage": "https://codeception.com/", + "type": "library", + "license": "MIT", + "authors": [ { - "name":"Michael Bodnarchuk" + "name": "Michael Bodnarchuk" } ], "minimum-stability": "RC", "require": { - "php": ">=5.6.0 <9.0", + "php": "^7.4 || ^8.0", "codeception/codeception": "*@dev" }, "conflict": { "codeception/codeception": "<4.0" }, - "autoload":{ - "classmap": ["src/"] + "autoload": { + "classmap": [ + "src/" + ] }, "config": { "classmap-authoritative": true diff --git a/readme.md b/readme.md index 6def036..c28bb9f 100644 --- a/readme.md +++ b/readme.md @@ -1,13 +1,30 @@ -# Codeception module for testing basic shell commands and shell output +# Codeception Module CLI -![Build Status](https://github.com/Codeception/module-cli/workflows/CI/badge.svg) +A Codeception module for testing basic shell commands and shell output. + +[![Actions Status](https://github.com/Codeception/module-cli/workflows/CI/badge.svg)](https://github.com/Codeception/module-cli/actions) +[![Latest Stable Version](https://poser.pugx.org/codeception/module-cli/v/stable)](https://github.com/Codeception/module-cli/releases) +[![Total Downloads](https://poser.pugx.org/codeception/module-cli/downloads)](https://packagist.org/packages/codeception/module-cli) +[![License](https://poser.pugx.org/codeception/module-cli/license)](/LICENSE) + +## Requirements + +* `PHP 7.4` or higher. ## Installation ``` -composer require --dev "codeception/module-cli" +composer require "codeception/module-cli" --dev ``` ## Documentation -Module documentation +See [the module documentation](https://codeception.com/docs/modules/Cli). + +[Changelog](https://github.com/Codeception/module-cli/releases) + +## License + +`Codeception Module CLI` is open-sourced software licensed under the [MIT](/LICENSE) License. + +© Codeception PHP Testing Framework diff --git a/src/Codeception/Module/Cli.php b/src/Codeception/Module/Cli.php index 4be45b6..8533543 100644 --- a/src/Codeception/Module/Cli.php +++ b/src/Codeception/Module/Cli.php @@ -1,8 +1,13 @@ output = ''; } @@ -36,59 +41,50 @@ public function _before(TestInterface $test) * // do not fail test when command fails * $I->runShellCommand('phpunit', false); * ``` - * - * @param $command - * @param bool $failNonZero */ - public function runShellCommand($command, $failNonZero = true) + public function runShellCommand(string $command, bool $failNonZero = true): void { $data = []; - exec("$command", $data, $resultCode); + exec("{$command}", $data, $resultCode); $this->result = $resultCode; $this->output = implode("\n", $data); if ($this->output === null) { - \PHPUnit\Framework\Assert::fail("$command can't be executed"); + Assert::fail("{$command} can't be executed"); } + if ($resultCode !== 0 && $failNonZero) { - \PHPUnit\Framework\Assert::fail("Result code was $resultCode.\n\n" . $this->output); + Assert::fail("Result code was {$resultCode}.\n\n" . $this->output); } - $this->debug(preg_replace('~s/\e\[\d+(?>(;\d+)*)m//g~', '', $this->output)); + + $this->debug(preg_replace('#s/\e\[\d+(?>(;\d+)*)m//g#', '', $this->output)); } /** * Checks that output from last executed command contains text - * - * @param $text */ - public function seeInShellOutput($text) + public function seeInShellOutput(string $text): void { - \Codeception\PHPUnit\TestCase::assertStringContainsString($text, $this->output); + TestCase::assertStringContainsString($text, $this->output); } /** * Checks that output from latest command doesn't contain text - * - * @param $text - * */ - public function dontSeeInShellOutput($text) + public function dontSeeInShellOutput(string $text): void { $this->debug($this->output); - \Codeception\PHPUnit\TestCase::assertStringNotContainsString($text, $this->output); + TestCase::assertStringNotContainsString($text, $this->output); } - /** - * @param $regex - */ - public function seeShellOutputMatches($regex) + public function seeShellOutputMatches(string $regex): void { - \Codeception\PHPUnit\TestCase::assertRegExp($regex, $this->output); + TestCase::assertMatchesRegularExpression($regex, $this->output); } /** * Returns the output from latest command */ - public function grabShellOutput() + public function grabShellOutput(): string { return $this->output; } @@ -100,12 +96,10 @@ public function grabShellOutput() * seeResultCodeIs(0); * ``` - * - * @param $code */ - public function seeResultCodeIs($code) + public function seeResultCodeIs(int $code): void { - $this->assertEquals($this->result, $code, "result code is $code"); + $this->assertEquals($this->result, $code, "result code is {$code}"); } /** @@ -115,11 +109,9 @@ public function seeResultCodeIs($code) * seeResultCodeIsNot(0); * ``` - * - * @param $code */ - public function seeResultCodeIsNot($code) + public function seeResultCodeIsNot(int $code): void { - $this->assertNotEquals($this->result, $code, "result code is $code"); + $this->assertNotEquals($this->result, $code, "result code is {$code}"); } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy