作者:qasem2rubi
项目:larave
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();
}
作者:edwardricard
项目:zensk
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();
}
作者:ciaranmcnult
项目:phpspec-emoji-formatte
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();
}
作者:ngitimfoy
项目:Nyari-AppPH
/**
*
* @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();
}
}
}
作者:ProgrammingPete
项目:nba-schedule-ap
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();
}
作者:phpguar
项目:plugin-phpspe
public function afterExample(ExampleEvent $event)
{
$type = $this->map[$event->getResult()];
$this->addResult($type, $event->getSpecification(), $event->getTitle());
if ($this->coverage) {
$this->coverage->stop();
}
}
作者:phpguar
项目:plugin-phpspe
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);
}
作者:kbulloc
项目:MageSpec_v
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();
}
作者:focuslif
项目:v0.
function it_should_call_afterCurrentExample(ExampleEvent $example)
{
$currentExample = new CurrentExampleTracker();
$currentExample->setCurrentExample(null);
$example->getTitle()->willReturn(null);
$this->afterCurrentExample($example);
$example->getTitle()->shouldNotHaveBeenCalled();
}
作者:ngitimfoy
项目:Nyari-AppPH
/**
*
* @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());
}
}
作者:samsonasi
项目:PhpSpecCodeCoverageExtensio
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);
}
作者:mawah
项目:tracke
/**
* @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');
}
}
作者:edwardricard
项目:zensk
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);
}
作者:HarveyChen
项目:myblo
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();
}
作者:EnmanuelCod
项目:backend-larave
/**
* @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;
}
作者:addvil
项目:phpspec-cove
public function beforeExample(ExampleEvent $event)
{
if (!$this->enabled) {
return;
}
$example = $event->getExample();
$resource = $example->getSpecification()->getResource();
$this->coverage->filter()->setWhitelistedFiles([]);
$this->coverage->filter()->addFileToWhitelist($resource->getSrcFilename());
$this->coverage->start($resource->getSrcClassname());
}
作者:focuslif
项目:v0.
/**
* @param ExampleEvent $event
* @param string $type
*/
protected function printSpecificException(ExampleEvent $event, $type)
{
$title = str_replace('\\', DIRECTORY_SEPARATOR, $event->getSpecification()->getTitle());
$message = $this->getPresenter()->presentException($event->getException(), $this->io->isVerbose());
foreach (explode("\n", wordwrap($title, $this->io->getBlockWidth(), "\n", true)) as $line) {
$this->io->writeln(sprintf('<%s-bg>%s</%s-bg>', $type, str_pad($line, $this->io->getBlockWidth()), $type));
}
$this->io->writeln(sprintf('<lineno>%4d</lineno> <%s>- %s</%s>', $event->getExample()->getFunctionReflection()->getStartLine(), $type, $event->getExample()->getTitle(), $type));
$this->io->writeln(sprintf('<%s>%s</%s>', $type, lcfirst($message), $type), 6);
$this->io->writeln();
}
作者:phpspe
项目:phpspe
public function afterExample(ExampleEvent $event)
{
if (null === ($exception = $event->getException())) {
return;
}
if (!$exception instanceof MethodNotFoundException) {
return;
}
$classname = get_class($exception->getSubject());
$methodName = $exception->getMethodName();
$this->methods[$classname . '::' . $methodName] = $exception->getArguments();
$this->checkIfMethodNameAllowed($methodName);
}
作者:mawah
项目:tracke
/**
* @param ExampleEvent $event
* @param PresenterInterface $presenter
*
* @return ReportFailedItem|ReportPassedItem|ReportPendingItem
*/
public function create(ExampleEvent $event, PresenterInterface $presenter = null)
{
switch ($event->getResult()) {
case ExampleEvent::PASSED:
return new ReportPassedItem($this->template, $event);
case ExampleEvent::PENDING:
return new ReportPendingItem($this->template, $event);
case ExampleEvent::FAILED:
case ExampleEvent::BROKEN:
return new ReportFailedItem($this->template, $event, $presenter);
default:
$this->invalidResultException($event->getResult());
}
}
作者:kbulloc
项目:MageSpec_v
public function getClassNameAfterExample(ExampleEvent $event)
{
if (null === ($exception = $event->getException())) {
return;
}
if (!$exception instanceof PhpSpecClassException && !$exception instanceof ProphecyClassException) {
return;
}
$className = $exception->getClassname();
if (strlen($className)) {
$parts = explode('_', $className);
if (!isset($parts[0]) || !isset($parts[1])) {
return;
}
$this->classNames[$className] = $parts[0] . '_' . $parts[1];
}
}