Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
20 changes: 20 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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"
Expand All @@ -26,4 +29,4 @@
"config": {
"classmap-authoritative": true
}
}
}
7 changes: 7 additions & 0 deletions src/Codeception/Module/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions tests/ShellVerbosityIsNotInheritedCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php


namespace Tests\Cli;

use Tests\Support\CliTester;

class ShellVerbosityIsNotInheritedCest
{
public function shellVerbosityIsNotInheritedFromCodeception(CliTester $I)
{
$I->runShellCommand('php ' . codecept_data_dir('check_verbosity.php'));
$I->seeInShellOutput('bool(false)');
}
}
38 changes: 38 additions & 0 deletions tests/Support/CliTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);

namespace Tests\Support;

require_once __DIR__ . '/_generated/CliTesterActions.php';

if (trait_exists(\Tests\_generated\CliTesterActions::class, false)) {
class_alias(\Tests\_generated\CliTesterActions::class, \Tests\Support\_generated\CliTesterActions::class);
}

/**
* Inherited Methods
*
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method void pause($vars = [])
*
* @SuppressWarnings(PHPMD)
*/
class CliTester extends \Codeception\Actor
{
use _generated\CliTesterActions;

/**
* Define custom actions here
*/
}

class_alias(CliTester::class, \Tests\CliTester::class);
3 changes: 3 additions & 0 deletions tests/Support/Data/check_verbosity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

var_dump(getenv('SHELL_VERBOSITY'));
2 changes: 2 additions & 0 deletions tests/Support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
2 changes: 2 additions & 0 deletions tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore