public function afterSuite(SuiteEvent $event) { if (!$this->io->isCodeGenerationEnabled()) { return; } if (!$this->io->isFakingEnabled()) { return; } foreach ($this->nullMethods as $methodString => $failedCall) { $failedCall['expected'] = array_unique($failedCall['expected']); if (count($failedCall['expected']) > 1) { continue; } $expected = current($failedCall['expected']); $class = $failedCall['class']; $message = sprintf('Do you want me to make `%s()` always return %s for you?', $methodString, var_export($expected, true)); try { $resource = $this->resources->createResource($class); } catch (\RuntimeException $exception) { continue; } if ($this->io->askConfirmation($message)) { $this->generator->generate($resource, 'returnConstant', array('method' => $failedCall['method'], 'expected' => $expected)); $event->markAsWorthRerunning(); } } }
function it_does_not_prompt_when_io_has_faking_disabled(MethodCallEvent $methodCallEvent, ExampleEvent $exampleEvent, ConsoleIO $io, SuiteEvent $event) { $io->isFakingEnabled()->willReturn(false); $this->afterMethodCall($methodCallEvent); $this->afterExample($exampleEvent); $this->afterSuite($event); $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled(); }