diff --git a/src/Console/Command/Ci/CiRunCommand.php b/src/Console/Command/Ci/CiRunCommand.php index 95aab3f07..ea6876990 100644 --- a/src/Console/Command/Ci/CiRunCommand.php +++ b/src/Console/Command/Ci/CiRunCommand.php @@ -8,6 +8,7 @@ use Acquia\Orca\Enum\StatusCodeEnum; use Acquia\Orca\Event\CiEvent; use Acquia\Orca\Exception\OrcaInvalidArgumentException; +use Acquia\Orca\Helper\EnvFacade; use Acquia\Orca\Options\CiRunOptionsFactory; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; @@ -46,6 +47,13 @@ class CiRunCommand extends Command { */ private $eventDispatcher; + /** + * The environment facade. + * + * @var \Acquia\Orca\Helper\EnvFacade + */ + private EnvFacade $env; + /** * Constructs an instance. * @@ -55,11 +63,14 @@ class CiRunCommand extends Command { * The CI run options factory. * @param \Symfony\Component\EventDispatcher\EventDispatcher $eventDispatcher * The event dispatcher service. + * @param \Acquia\Orca\Helper\EnvFacade $env + * The environment facade. */ - public function __construct(CiJobFactory $job_factory, CiRunOptionsFactory $ci_run_options_factory, EventDispatcher $eventDispatcher) { + public function __construct(CiJobFactory $job_factory, CiRunOptionsFactory $ci_run_options_factory, EventDispatcher $eventDispatcher, EnvFacade $env) { $this->ciJobFactory = $job_factory; $this->ciRunOptionsFactory = $ci_run_options_factory; $this->eventDispatcher = $eventDispatcher; + $this->env = $env; parent::__construct(self::$defaultName); } @@ -131,6 +142,7 @@ public function execute(InputInterface $input, OutputInterface $output): int { $data['status'] = 'FAIL'; $job = $this->ciJobFactory->create($options->getJob()); $data['version'] = $job->getDrupalCoreVersion(); + $data['allowedToFail'] = $this->env->get("ORCA_IS_ALLOWED_FAILURE") ?? FALSE; $job->run($options); } diff --git a/tests/Console/Command/Ci/CiRunCommandTest.php b/tests/Console/Command/Ci/CiRunCommandTest.php index d91e98ee9..ec9d2430d 100644 --- a/tests/Console/Command/Ci/CiRunCommandTest.php +++ b/tests/Console/Command/Ci/CiRunCommandTest.php @@ -9,6 +9,7 @@ use Acquia\Orca\Enum\CiJobPhaseEnum; use Acquia\Orca\Enum\StatusCodeEnum; use Acquia\Orca\Exception\OrcaInvalidArgumentException; +use Acquia\Orca\Helper\EnvFacade; use Acquia\Orca\Options\CiRunOptions; use Acquia\Orca\Options\CiRunOptionsFactory; use Acquia\Orca\Tests\Console\Command\CommandTestBase; @@ -24,6 +25,8 @@ * @property \Acquia\Orca\Domain\Ci\Job\AbstractCiJob|\Prophecy\Prophecy\ObjectProphecy $ciJob * @property \Acquia\Orca\Options\CiRunOptionsFactory|\Prophecy\Prophecy\ObjectProphecy $ciRunOptionsFactory * @property \Acquia\Orca\Options\CiRunOptions|\Prophecy\Prophecy\ObjectProphecy $ciRunOptions + * @property \Symfony\Component\EventDispatcher\EventDispatcher|\Prophecy\Prophecy\ObjectProphecy $eventDispatcher + * @property \Acquia\Orca\Helper\EnvFacade|\Prophecy\Prophecy\ObjectProphecy $env * @coversDefaultClass \Acquia\Orca\Console\Command\Ci\CiRunCommand */ class CiRunCommandTest extends CommandTestBase { @@ -35,6 +38,7 @@ class CiRunCommandTest extends CommandTestBase { protected CiRunOptionsFactory|ObjectProphecy $ciRunOptionsFactory; protected CiRunOptions|ObjectProphecy $ciRunOptions; protected EventDispatcher|ObjectProphecy $eventDispatcher; + protected EnvFacade|ObjectProphecy $env; protected function setUp(): void { $this->ciRunOptions = $this->prophesize(CiRunOptions::class); @@ -54,13 +58,18 @@ protected function setUp(): void { $this->eventDispatcher ->dispatch(Argument::cetera()) ->willReturn(new \stdClass()); + $this->env = $this->prophesize(EnvFacade::class); + $this->env + ->get(Argument::any()) + ->willReturn(); } protected function createCommand(): Command { $ci_run_options_factory = $this->ciRunOptionsFactory->reveal(); $ci_job_factory = $this->ciJobFactory->reveal(); $event_dispatcher = $this->eventDispatcher->reveal(); - return new CiRunCommand($ci_job_factory, $ci_run_options_factory, $event_dispatcher); + $env = $this->env->reveal(); + return new CiRunCommand($ci_job_factory, $ci_run_options_factory, $event_dispatcher, $env); } private function validSutName(): string {