當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Console\IO類代碼示例

本文整理匯總了PHP中PhpSpec\Console\IO的典型用法代碼示例。如果您正苦於以下問題:PHP IO類的具體用法?PHP IO怎麽用?PHP IO使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IO類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 function it_does_not_generate_interface_when_prompt_is_answered_with_no(IO $io, ExampleEvent $exampleEvent, SuiteEvent $suiteEvent, GeneratorManager $generator)
 {
     $io->askConfirmation('Would you like me to generate an interface `Example\\ExampleClass` for you?')->willReturn(false);
     $this->afterExample($exampleEvent);
     $this->afterSuite($suiteEvent);
     $generator->generate(Argument::cetera())->shouldNotHaveBeenCalled();
     $suiteEvent->markAsWorthRerunning()->shouldNotHaveBeenCalled();
 }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:8,代碼來源:CollaboratorNotFoundListenerSpec.php

示例2:

 function it_prompts_and_warns_when_one_method_name_is_correct_but_other_reserved($exampleEvent, SuiteEvent $suiteEvent, IO $io, NameCheckerInterface $nameChecker)
 {
     $this->callAfterExample($exampleEvent, $nameChecker, 'throw', false);
     $this->callAfterExample($exampleEvent, $nameChecker, 'foo');
     $io->writeBrokenCodeBlock("I cannot generate the method 'throw' for you because it is a reserved keyword", 2)->shouldBeCalled();
     $io->askConfirmation('Do you want me to create `stdClass::foo()` for you?')->shouldBeCalled();
     $suiteEvent->markAsNotWorthRerunning()->shouldBeCalled();
     $this->afterSuite($suiteEvent);
 }
開發者ID:drickferreira,項目名稱:rastreador,代碼行數:9,代碼來源:MethodNotFoundListenerSpec.php

示例3:

 function it_outputs_progress_as_33_when_3_of_3_examples_have_run_and_one_passed(ExampleEvent $event, IO $io, StatisticsCollector $stats)
 {
     $stats->getEventsCount()->willReturn(3);
     $stats->getCountsHash()->willReturn(array('passed' => 1, 'pending' => 0, 'skipped' => 0, 'failed' => 2, 'broken' => 0));
     $stats->getTotalSpecs()->willReturn(3);
     $stats->getTotalSpecsCount()->willReturn(3);
     $this->afterExample($event);
     $expected = '/  skipped: 0%  /  pending: 0%  /  passed: 33%  /  failed: 66%  /  broken: 0%   /  3 examples';
     $io->writeTemp($expected)->shouldHaveBeenCalled();
 }
開發者ID:umpirsky,項目名稱:phpspec,代碼行數:10,代碼來源:ProgressFormatterSpec.php

示例4: array

 function it_should_provide_extra_output_in_verbose_mode(\PHP_CodeCoverage $coverage, \PHP_CodeCoverage_Report_HTML $html, SuiteEvent $event, IO $io)
 {
     $reports = array('html' => $html);
     $this->beConstructedWith($coverage, $reports);
     $this->setOptions(array('format' => 'html', 'output' => array('html' => 'coverage')));
     $io->isVerbose()->willReturn(true);
     $this->setIO($io);
     $io->writeln('')->shouldBeCalled();
     $io->writeln('Generating code coverage report in html format ...')->shouldBeCalled();
     $this->afterSuite($event);
 }
開發者ID:Jvbzephir,項目名稱:PhpSpecCodeCoverageExtension,代碼行數:11,代碼來源:CodeCoverageListenerSpec.php

示例5: displayFatal

 public function displayFatal(CurrentExampleTracker $currentExample, $error)
 {
     if (null !== $error && $currentExample->getCurrentExample() || is_null($currentExample->getCurrentExample()) && defined('HHVM_VERSION')) {
         ini_set('display_errors', "stderr");
         $failedOpen = $this->io->isDecorated() ? '<failed>' : '';
         $failedClosed = $this->io->isDecorated() ? '</failed>' : '';
         $failedCross = $this->io->isDecorated() ? '✘' : '';
         $this->io->writeln("{$failedOpen}{$failedCross} Fatal error happened while executing the following {$failedClosed}");
         $this->io->writeln("{$failedOpen}    {$currentExample->getCurrentExample()} {$failedClosed}");
         $this->io->writeln("{$failedOpen}    {$error['message']} in {$error['file']} on line {$error['line']} {$failedClosed}");
     }
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:12,代碼來源:ConsoleFormatter.php

示例6: beforeSuite

 public function beforeSuite()
 {
     if ($bootstrap = $this->io->getBootstrapPath()) {
         if (!is_file($bootstrap)) {
             throw new \RuntimeException(sprintf("Bootstrap file '%s' does not exist", $bootstrap));
         }
         require $bootstrap;
     }
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:9,代碼來源:BootstrapListener.php

示例7: afterExample

 /**
  *
  * @param ExampleEvent $event        	
  *
  * @throws \PhpSpec\Exception\Example\StopOnFailureException
  */
 public function afterExample(ExampleEvent $event)
 {
     if (!$this->io->isStopOnFailureEnabled()) {
         return;
     }
     if ($event->getResult() === ExampleEvent::FAILED || $event->getResult() === ExampleEvent::BROKEN) {
         throw new StopOnFailureException('Example failed', 0, null, $event->getResult());
     }
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:15,代碼來源:StopOnFailureListener.php

示例8: generate

 /**
  * @param ResourceInterface $resource
  * @param array             $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $methodName = $data['name'];
     $arguments = $data['arguments'];
     $content = $this->getContent($resource, $methodName, $arguments);
     $code = $this->appendMethodToCode($this->filesystem->getFileContents($filepath), $content);
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln(sprintf("<info>Method <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $methodName), 2);
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:14,代碼來源:NamedConstructorGenerator.php

示例9: generate

 /**
  * @param ResourceInterface $resource
  * @param array             $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $methodName = $data['name'];
     $arguments = $data['arguments'];
     $content = $this->getContent($resource, $methodName, $arguments);
     $code = $this->filesystem->getFileContents($filepath);
     $code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $resource->getSrcClassname(), $methodName), 2);
 }
開發者ID:franzliedke,項目名稱:phpspec,代碼行數:15,代碼來源:NamedConstructorGenerator.php

示例10: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $filepath = $resource->getSrcFilename();
     if (!($content = $this->templates->render('private-constructor', array()))) {
         $content = $this->templates->renderString($this->getTemplate(), array());
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = $this->codeWriter->insertMethodFirstInClass($code, $content);
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:15,代碼來源:PrivateConstructorGenerator.php

示例11: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $filepath = $resource->getSrcFilename();
     if (!($content = $this->templates->render('private-constructor', array()))) {
         $content = $this->templates->renderString($this->getTemplate(), array());
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
 }
開發者ID:araines,項目名稱:phpspec,代碼行數:15,代碼來源:PrivateConstructorGenerator.php

示例12: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = $this->buildArgumentString($arguments);
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('interface-method-signature', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $this->insertMethodSignature($filepath, $content);
     $this->io->writeln(sprintf("<info>Method signature <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:edwardricardo,項目名稱:zenska,代碼行數:17,代碼來源:MethodSignatureGenerator.php

示例13: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  */
 public function generate(ResourceInterface $resource, array $data)
 {
     $destination = $this->getSavePath($resource);
     if (file_exists($destination) && !$this->io->askConfirmation(sprintf('File "%s" already exists. Overwrite?', basename($destination)), false)) {
         return;
     }
     $directory = dirname($destination);
     if (!file_exists($directory)) {
         $this->createDir($directory);
     }
     $code = $this->generateCodeForResource($resource, $data);
     $this->filesystem->putFileContents($destination, $code);
     $this->io->writeln($this->getPromptMessage($resource, $resource->getSrcFilename()));
 }
開發者ID:ulabox,項目名稱:bus-spec,代碼行數:18,代碼來源:AbstractGenerator.php

示例14: generate

 /**
  * @param ResourceInterface $resource
  * @param array             $data
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = count($arguments) ? '$argument' . implode(', $argument', range(1, count($arguments))) : '';
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('method', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $code = $this->filesystem->getFileContents($filepath);
     $this->filesystem->putFileContents($filepath, $this->getUpdatedCode($name, $content, $code));
     $this->io->writeln(sprintf("<info>Method <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:focuslife,項目名稱:v0.1,代碼行數:18,代碼來源:MethodGenerator.php

示例15: generate

 /**
  * @param ResourceInterface $resource
  * @param array $data
  *
  * @return mixed
  */
 public function generate(ResourceInterface $resource, array $data = array())
 {
     $filepath = $resource->getSrcFilename();
     $name = $data['name'];
     $arguments = $data['arguments'];
     $argString = $this->argumentBuilder->buildFrom($arguments);
     $values = array('%name%' => $name, '%arguments%' => $argString);
     if (!($content = $this->templates->render('method', $values))) {
         $content = $this->templates->renderString($this->getTemplate(), $values);
     }
     $code = $this->filesystem->getFileContents($filepath);
     $code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
     $this->filesystem->putFileContents($filepath, $code);
     $this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $resource->getSrcClassname(), $name), 2);
 }
開發者ID:amir20202000,項目名稱:phpspec-typehintedmethods,代碼行數:21,代碼來源:TypeHintedMethodGenerator.php


注:本文中的PhpSpec\Console\IO類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。