本文整理汇总了PHP中PhpSpec\Event\ExampleEvent类的典型用法代码示例。如果您正苦于以下问题:PHP ExampleEvent类的具体用法?PHP ExampleEvent怎么用?PHP ExampleEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ExampleEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RuntimeException
function it_does_not_prompt_when_wrong_exception_is_thrown(IO $io, ExampleEvent $event, SuiteEvent $suiteEvent)
{
$event->getException()->willReturn(new RuntimeException());
$this->afterExample($event);
$this->afterSuite($suiteEvent);
$io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
}
示例2:
function it_does_not_prompt_to_generate_when_there_was_an_exception_of_the_wrong_type(IO $io, ExampleEvent $exampleEvent, SuiteEvent $suiteEvent, \InvalidArgumentException $otherException)
{
$exampleEvent->getException()->willReturn($otherException);
$this->afterExample($exampleEvent);
$this->afterSuite($suiteEvent);
$io->askConfirmation(Argument::any())->shouldNotHaveBeenCalled();
}
示例3:
function it_outputs_monkey_when_example_is_pending(IO $io, ExampleEvent $event)
{
$event->getResult()->willReturn(ExampleEvent::PENDING);
$this->outputEmoji($event);
$io->write(mb_convert_encoding('🙉', 'UTF-8', 'HTML-ENTITIES'))->shouldHaveBeenCalled();
$io->write(' ')->shouldHaveBeenCalled();
}
示例4: afterExample
/**
*
* @param ExampleEvent $event
*/
public function afterExample(ExampleEvent $event)
{
$io = $this->getIO();
$eventsCount = $this->getStatisticsCollector()->getEventsCount();
if ($eventsCount === 1) {
$io->writeln();
}
switch ($event->getResult()) {
case ExampleEvent::PASSED:
$io->write('<passed>.</passed>');
break;
case ExampleEvent::PENDING:
$io->write('<pending>P</pending>');
break;
case ExampleEvent::SKIPPED:
$io->write('<skipped>S</skipped>');
break;
case ExampleEvent::FAILED:
$io->write('<failed>F</failed>');
break;
case ExampleEvent::BROKEN:
$io->write('<broken>B</broken>');
break;
}
if ($eventsCount % 50 === 0) {
$length = strlen((string) $this->examplesCount);
$format = sprintf(' %%%dd / %%%dd', $length, $length);
$io->write(sprintf($format, $eventsCount, $this->examplesCount));
if ($eventsCount !== $this->examplesCount) {
$io->writeLn();
}
}
}
示例5: afterExample
public function afterExample(ExampleEvent $exampleEvent)
{
$exception = $exampleEvent->getException();
if (!$exception instanceof NotEqualException) {
return;
}
if ($exception->getActual() !== null) {
return;
}
if (is_object($exception->getExpected()) || is_array($exception->getExpected()) || is_resource($exception->getExpected())) {
return;
}
if (!$this->lastMethodCallEvent) {
return;
}
$class = get_class($this->lastMethodCallEvent->getSubject());
$method = $this->lastMethodCallEvent->getMethod();
if (!$this->methodAnalyser->methodIsEmpty($class, $method)) {
return;
}
$key = $class . '::' . $method;
if (!array_key_exists($key, $this->nullMethods)) {
$this->nullMethods[$key] = array('class' => $this->methodAnalyser->getMethodOwnerName($class, $method), 'method' => $method, 'expected' => array());
}
$this->nullMethods[$key]['expected'][] = $exception->getExpected();
}
示例6: afterExample
public function afterExample(ExampleEvent $event)
{
$type = $this->map[$event->getResult()];
$this->addResult($type, $event->getSpecification(), $event->getTitle());
if ($this->coverage) {
$this->coverage->stop();
}
}
示例7:
function it_should_creates_result_event(ExampleEvent $exampleEvent, SpecificationNode $specificationNode, CodeCoverageSession $coverageSession)
{
$exampleEvent->getResult()->shouldBeCalled()->willReturn(ExampleEvent::PASSED);
$specificationNode->getTitle()->shouldBeCalled()->willReturn('SomeSpesification');
$coverageSession->stop()->shouldBeCalled();
$this->afterExample($exampleEvent);
$this->getResults()->shouldHaveCount(1);
}
示例8:
function it_identifies_a_resource_model_type(ExampleEvent $exampleEvent, ClassNotFoundException $exception, SuiteEvent $suiteEvent, $configGenerator)
{
$exampleEvent->getException()->willReturn($exception);
$exception->getClassname()->willReturn('Vendor_Module_Model_Resource_Foo');
$this->getClassNameAfterExample($exampleEvent);
$this->createXmlAfterSuite($suiteEvent);
$configGenerator->generateElement('resource_model', 'Vendor_Module')->shouldHavebeenCalled();
}
示例9: CurrentExampleTracker
function it_should_call_afterCurrentExample(ExampleEvent $example)
{
$currentExample = new CurrentExampleTracker();
$currentExample->setCurrentExample(null);
$example->getTitle()->willReturn(null);
$this->afterCurrentExample($example);
$example->getTitle()->shouldNotHaveBeenCalled();
}
示例10: 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());
}
}
示例11: beforeExample
public function beforeExample(ExampleEvent $event)
{
if (!$this->enabled) {
return;
}
$example = $event->getExample();
$name = strtr('%spec%::%example%', array('%spec%' => $example->getSpecification()->getClassReflection()->getName(), '%example%' => $example->getFunctionReflection()->getName()));
$this->coverage->start($name);
}
示例12: afterExample
/**
* @param ExampleEvent $event
*
* @throws \PhpSpec\Exception\Example\StopOnFailureException
*/
public function afterExample(ExampleEvent $event)
{
if (!$this->input->hasOption('stop-on-failure') || !$this->input->getOption('stop-on-failure')) {
return;
}
if ($event->getResult() === ExampleEvent::FAILED || $event->getResult() === ExampleEvent::BROKEN) {
throw new StopOnFailureException('Example failed');
}
}
示例13: array
function it_writes_a_fail_message_for_a_failing_example(Template $template, ExampleEvent $event, Presenter $presenter)
{
$event->getTitle()->willReturn(self::EVENT_TITLE);
$event->getMessage()->willReturn(self::EVENT_MESSAGE);
$event->getBacktrace()->willReturn(self::$BACKTRACE);
$event->getException()->willReturn(new \Exception());
$template->render(Template::DIR . '/Template/ReportFailed.html', array('title' => self::EVENT_TITLE, 'message' => self::EVENT_MESSAGE, 'backtrace' => self::BACKTRACE, 'code' => self::CODE, 'index' => 1, 'specification' => 1))->shouldBeCalled();
$presenter->presentException(Argument::cetera())->willReturn(self::CODE);
$this->write(1);
}
示例14: afterExample
public function afterExample(ExampleEvent $event)
{
if (null === ($exception = $event->getException())) {
return;
}
if (!$exception instanceof MethodNotFoundException) {
return;
}
$this->methods[get_class($exception->getSubject()) . '::' . $exception->getMethodName()] = $exception->getArguments();
}
示例15: afterExample
/**
* @param ExampleEvent $event
*/
public function afterExample(ExampleEvent $event)
{
if (null === ($exception = $event->getException())) {
return;
}
if (!$exception instanceof PhpSpecClassException && !$exception instanceof ProphecyClassException) {
return;
}
$this->classes[$exception->getClassname()] = true;
}