CommandExecutorTestCase
Shell command test case
Tags
Table of Contents
Properties
- $commandExecutor : CommandExecutor|MockInterface|null
Methods
- receiveAsyncCommand() : void
- Receives an async command
- receiveCommand() : void
- Receives a command
- receiveCommandExist() : void
- Receives a command existence check
- setUp() : void
- Sets up the test environment
- setUpCommandExecutor() : void
- Sets up the command executor for test environment
- tearDown() : void
- Cleanups the test environment
- getCommandExecutorMock() : MockInterface
- Returns the command executor mock
- matchCommandArguments() : bool
- Matches the command arguments
Properties
$commandExecutor
protected
CommandExecutor|MockInterface|null
$commandExecutor
= null
Mocked command executor
Methods
receiveAsyncCommand()
Receives an async command
protected
receiveAsyncCommand(callable(Array $type, string $buffer): void|MatcherInterface|null $callback, string $command[, bool|null $needSudo = null ][, int|null $timeout = null ][, resource|string|Traversable<string|int, mixed>|MatcherInterface|null $input = null ][, int|null $count = 1 ][, string $stdout = '' ][, string $stderr = '' ][, int $exitCode = 0 ][, bool|null $trimOutput = null ]) : void
Arguments set to null are not checked. Arguments omitted by the caller are compared using their default values. Arguments are compared strictly, Mockery matchers (e.g. Mockery::type()) can be used for loose comparison. The standard and error outputs are passed to the callback given by the caller.
Parameters
- $callback : callable(Array $type, string $buffer): void|MatcherInterface|null
-
Command's callback, null to accept any callback
- $command : string
-
Command
- $needSudo : bool|null = null
-
Is sudo needed?
- $timeout : int|null = null
-
Command's timeout
- $input : resource|string|Traversable<string|int, mixed>|MatcherInterface|null = null
-
Command's input
- $count : int|null = 1
-
Number of command calls
- $stdout : string = ''
-
Command's standard output
- $stderr : string = ''
-
Command's standard error output
- $exitCode : int = 0
-
Command's exit code
- $trimOutput : bool|null = null
-
Trim standard and error outputs?
receiveCommand()
Receives a command
protected
receiveCommand(string $command[, bool|null $needSudo = null ][, int|null $timeout = null ][, resource|string|Traversable<string|int, mixed>|MatcherInterface|null $input = null ][, string $stdout = '' ][, string $stderr = '' ][, int $exitCode = 0 ][, int|null $count = 1 ][, bool|null $trimOutput = null ]) : void
Arguments set to null are not checked. Arguments omitted by the caller are compared using their default values. Arguments are compared strictly, Mockery matchers (e.g. Mockery::type()) can be used for loose comparison.
Parameters
- $command : string
-
Command
- $needSudo : bool|null = null
-
Is sudo needed?
- $timeout : int|null = null
-
Command's timeout
- $input : resource|string|Traversable<string|int, mixed>|MatcherInterface|null = null
-
Command's input
- $stdout : string = ''
-
Command's standard output
- $stderr : string = ''
-
Command's standard error output
- $exitCode : int = 0
-
Command's exit code
- $count : int|null = 1
-
Number of command calls
- $trimOutput : bool|null = null
-
Trim standard and error outputs?
receiveCommandExist()
Receives a command existence check
protected
receiveCommandExist(string $command, bool $output[, int|null $count = 1 ]) : void
Parameters
- $command : string
-
Command
- $output : bool
-
Is the command exist?
- $count : int|null = 1
-
Number of command calls
setUp()
Sets up the test environment
protected
setUp() : void
setUpCommandExecutor()
Sets up the command executor for test environment
protected
setUpCommandExecutor() : void
tearDown()
Cleanups the test environment
protected
tearDown() : void
getCommandExecutorMock()
Returns the command executor mock
private
getCommandExecutorMock() : MockInterface
Tags
Return values
MockInterface —Command executor mock
matchCommandArguments()
Matches the command arguments
private
static matchCommandArguments(array<int, mixed> $expected, array<int, mixed> $defaults, array<int|string, mixed> $actual) : bool
Parameters
- $expected : array<int, mixed>
-
Expected arguments, null values are not checked
- $defaults : array<int, mixed>
-
Default values of arguments omitted by the caller
- $actual : array<int|string, mixed>
-
Actual arguments
Return values
bool —Do the arguments match?