From 28cb517cf227232f6c9559424e14bda28eb33cbb Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Fri, 5 Apr 2024 08:08:09 -0700 Subject: [PATCH] kill mutants --- src/Command/CommandBase.php | 2 +- .../src/Commands/App/LogTailCommandTest.php | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Command/CommandBase.php b/src/Command/CommandBase.php index 14bca3aff..289740424 100644 --- a/src/Command/CommandBase.php +++ b/src/Command/CommandBase.php @@ -396,7 +396,7 @@ protected function promptChooseLogs(): object|array|null { * @param array[]|object[] $items An array of objects or arrays. * @param string $uniqueProperty The property of the $item that will be used to identify the object. */ - public function promptChooseFromObjectsOrArrays(array|ArrayObject $items, string $uniqueProperty, string $labelProperty, string $questionText, bool $multiselect = FALSE): object|array|null { + protected function promptChooseFromObjectsOrArrays(array|ArrayObject $items, string $uniqueProperty, string $labelProperty, string $questionText, bool $multiselect = FALSE): object|array|null { $list = []; foreach ($items as $item) { if (is_array($item)) { diff --git a/tests/phpunit/src/Commands/App/LogTailCommandTest.php b/tests/phpunit/src/Commands/App/LogTailCommandTest.php index 12500bedc..8e3dabf14 100644 --- a/tests/phpunit/src/Commands/App/LogTailCommandTest.php +++ b/tests/phpunit/src/Commands/App/LogTailCommandTest.php @@ -8,6 +8,7 @@ use Acquia\Cli\Command\CommandBase; use Acquia\Cli\Tests\CommandTestBase; use AcquiaLogstream\LogstreamManager; +use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; /** @@ -17,8 +18,24 @@ class LogTailCommandTest extends CommandTestBase { protected LogstreamManager|ObjectProphecy $logStreamManagerProphecy; + /** + * @return int[] + */ + public function providerLogTailCommand(): array { + return [ + [0], + [NULL], + ]; + } + protected function createCommand(): CommandBase { + // Must initialize this here instead of in setUp() because we need the + // prophet to be initialized first. $this->logStreamManagerProphecy = $this->prophet->prophesize(LogstreamManager::class); + $this->logStreamManagerProphecy->setColourise(TRUE)->shouldBeCalled(); + $this->logStreamManagerProphecy->setParams(Argument::type('object'))->shouldBeCalled(); + $this->logStreamManagerProphecy->setLogTypeFilter(["bal-request"])->shouldBeCalled(); + $this->logStreamManagerProphecy->stream()->shouldBeCalled(); return new LogTailCommand( $this->localMachineHelper, @@ -35,7 +52,10 @@ protected function createCommand(): CommandBase { ); } - public function testLogTailCommand(): void { + /** + * @dataProvider providerLogTailCommand + */ + public function testLogTailCommand(?int $stream): void { $this->mockGetEnvironment(); $this->mockLogStreamRequest(); $this->executeCommand([], [ @@ -48,7 +68,7 @@ public function testLogTailCommand(): void { // Select environment. 0, // Select log. - 0, + $stream, ]); // Assert.