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
2 changes: 1 addition & 1 deletion system/Commands/Utilities/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ final class Environment extends BaseCommand
*/
public function run(array $params)
{
if ($params === []) {
if (! isset($params[0])) {
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color(service('superglobals')->server('CI_ENVIRONMENT', ENVIRONMENT), 'green')));
CLI::newLine();

Expand Down
7 changes: 7 additions & 0 deletions tests/system/Commands/Utilities/EnvironmentCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public function testUsingCommandWithNoArgumentsGivesCurrentEnvironment(): void
$this->assertStringContainsString(ENVIRONMENT, $this->getStreamFilterBuffer());
}

public function testUsingCommandWithOptionsOnlyGivesCurrentEnvironment(): void
{
command('env --foo');
$this->assertStringContainsString('testing', $this->getStreamFilterBuffer());
$this->assertStringContainsString(ENVIRONMENT, $this->getStreamFilterBuffer());
}

public function testProvidingTestingAsEnvGivesErrorMessage(): void
{
command('env testing');
Expand Down
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Bugs Fixed
**********

- **Autoloader:** Fixed a bug where ``Autoloader::unregister()`` (used during tests) silently failed to remove handlers from the SPL autoload stack, causing closures to accumulate permanently.
- **Commands:** Fixed a bug in the ``env`` command where passing options only would cause the command to throw a ``TypeError`` instead of showing the current environment.
- **Common:** Fixed a bug where the ``command()`` helper function did not properly clean up output buffers, which could lead to risky tests when exceptions were thrown.
- **Validation:** Fixed a bug where ``Validation::getValidated()`` dropped fields whose validated value was explicitly ``null``.

Expand Down
Loading