function it_does_not_prompt_when_code_generation_is_disabled(IO $io, ExampleEvent $exampleEvent, SuiteEvent $suiteEvent)
 {
     $io->isCodeGenerationEnabled()->willReturn(false);
     $this->afterExample($exampleEvent);
     $this->afterSuite($suiteEvent);
     $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
 }
 /**
  * @param SuiteEvent $event
  */
 public function afterSuite(SuiteEvent $event)
 {
     if (!$this->io->isCodeGenerationEnabled()) {
         return;
     }
     foreach ($this->exceptions as $exception) {
         $resource = $this->resources->createResource($exception->getCollaboratorName());
         if ($this->resourceIsInSpecNamespace($exception, $resource)) {
             continue;
         }
         if ($this->io->askConfirmation(sprintf('Would you like me to generate an interface `%s` for you?', $exception->getCollaboratorName()))) {
             $this->generator->generate($resource, 'interface');
             $event->markAsWorthRerunning();
         }
     }
 }
 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_code_generation_is_disabled(IO $io, ExampleEvent $event, SuiteEvent $suiteEvent, MethodNotFoundException $exception)
 {
     $io->isCodeGenerationEnabled()->willReturn(false);
     $exception->getClassname()->willReturn('spec\\PhpSpec\\Listener\\DoubleOfInterface');
     $exception->getMethodName()->willReturn('aMethod');
     $this->afterExample($event);
     $this->afterSuite($suiteEvent);
     $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
 }
 /**
  * @param ExampleEvent $event
  * @return bool
  */
 private function getMethodNotFoundException(ExampleEvent $event)
 {
     if ($this->io->isCodeGenerationEnabled() && ($exception = $event->getException()) && $exception instanceof MethodNotFoundException) {
         return $exception;
     }
 }
 function it_does_not_prompt_when_input_is_not_interactive(MethodCallEvent $methodCallEvent, ExampleEvent $exampleEvent, IO $io, SuiteEvent $event)
 {
     $io->isCodeGenerationEnabled()->willReturn(false);
     $this->afterMethodCall($methodCallEvent);
     $this->afterExample($exampleEvent);
     $this->afterSuite($event);
     $io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
 }
 function let(ModuleGenerator $moduleGenerator, ConfigGenerator $configGenerator, IO $io, ClassDetector $detector)
 {
     $io->isCodeGenerationEnabled()->willReturn(true);
     $detector->classExists(Argument::any())->willReturn(true);
     $this->beConstructedWith($moduleGenerator, $configGenerator, $io, $detector);
 }