diff --git a/src/Console/Commands/CheckQueueIsRunning.php b/src/Console/Commands/CheckQueueIsRunning.php index 7e231ff..0aa2acb 100644 --- a/src/Console/Commands/CheckQueueIsRunning.php +++ b/src/Console/Commands/CheckQueueIsRunning.php @@ -28,13 +28,13 @@ class CheckQueueIsRunning extends Command protected $description = 'Crudely, check if the Redis queue worker is running'; /** @var string */ - protected $output = ''; + protected $commandOutput = ''; /** @var int */ protected $processCount = 0; - /** @var null */ - protected $process = null; + /** @var \Symfony\Component\Process\Process|null */ + protected $processObject = null; /** * Create a new command instance. @@ -59,12 +59,12 @@ public function handle() // the number of expected processes $expectedProcessCount = $options['processes'] ?? 1; - $process = $this->getProcess(); + $process = $this->getProcessObject(); $process->run(); - $this->output = $process->getOutput(); + $this->commandOutput = $process->getOutput(); - foreach (explode(PHP_EOL, $this->output) as $line) { + foreach (explode(PHP_EOL, $this->commandOutput) as $line) { if (Str::contains($line, $expectedOutput)) { $this->processCount++; } @@ -74,28 +74,28 @@ public function handle() // The process count differing to the expected count could // indicate issues too. if ($this->processCount < $expectedProcessCount) { - event(new QueueCheckFailed($this->output ?? '')); + event(new QueueCheckFailed($this->getProcessOutput() ?? '')); } } /** * @return \Symfony\Component\Process\Process|mixed */ - public function getProcess() + public function getProcessObject() { - if (null === $this->process) { - return new Process(['ps', 'aux']); + if (null === $this->processObject) { + return $this->processObject = new Process(['ps', 'aux']); } - return $this->process; + return $this->processObject; } /** * @return string */ - public function getOutput(): string + public function getProcessOutput(): string { - return $this->output; + return $this->commandOutput; } /** @@ -103,7 +103,7 @@ public function getOutput(): string */ public function setProcess($process): void { - $this->process = $process; + $this->processObject = $process; } /** diff --git a/src/Events/QueueCheckFailed.php b/src/Events/QueueCheckFailed.php index ee9aaae..eb91c36 100644 --- a/src/Events/QueueCheckFailed.php +++ b/src/Events/QueueCheckFailed.php @@ -7,14 +7,14 @@ class QueueCheckFailed { /** @var string */ - public $output; + public $processOutput; /** - * @param string|null $output + * @param string|null $processOutput */ - public function __construct(?string $output) + public function __construct(?string $processOutput) { - $this->output = $output; + $this->processOutput = $processOutput; } /** @@ -22,6 +22,6 @@ public function __construct(?string $output) */ public function getOutput(): ?string { - return $this->output ?? null; + return $this->processOutput ?? null; } } diff --git a/tests/CheckQueueIsRunningTest.php b/tests/CheckQueueIsRunningTest.php index 5b839f6..f5e1cb9 100644 --- a/tests/CheckQueueIsRunningTest.php +++ b/tests/CheckQueueIsRunningTest.php @@ -146,7 +146,7 @@ public function it_determines_the_console_output() $this->command->handle(); - $this->assertEquals("abc123\nabc1234\n", $this->command->getOutput()); + $this->assertEquals("abc123\nabc1234\n", $this->command->getProcessOutput()); } /** @test */ @@ -154,6 +154,6 @@ public function it_fetches_the_process() { $this->command->handle(); - $this->assertInstanceOf(Process::class, $this->command->getProcess()); + $this->assertInstanceOf(Process::class, $this->command->getProcessObject()); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 94dd172..a6f0b19 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -33,6 +33,10 @@ protected function getPackageProviders($app): array ]; } + /** + * @param string $stub + * @return \Illuminate\Support\HigherOrderTapProxy|mixed|\Mockery\LegacyMockInterface|\Mockery\MockInterface + */ public function getMockedObject(string $stub) { return tap(m::mock(Process::class), function ($mock) use ($stub) {