function it_orders_an_array_of_example_nodes(ExampleNode $a, ExampleNode $b, ExampleNode $c) { $a->getTitle()->willReturn('bar1'); $b->getTitle()->willReturn('bar2'); $c->getTitle()->willReturn('bar3'); $nodes = [$a, $b, $c]; $expected = [$c, $b, $a]; $this->setSpecificationTitle('foo'); $this->filter($nodes)->shouldReturn($expected); }
/** * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators) { $exampleNum = $this->getExampleNumber($example->getTitle()); $providedData = $this->getDataFromProvider($example); if (!array_key_exists($exampleNum, $providedData)) { return; } $data = $providedData[$exampleNum]; foreach ($example->getFunctionReflection()->getParameters() as $position => $parameter) { if (!isset($data[$position])) { continue; } $collaborators->set($parameter->getName(), $data[$position]); } }
function it_outputs_exceptions_for_failed_examples(SuiteEvent $event, ExampleEvent $pendingEvent, ConsoleIO $io, StatisticsCollector $stats, SpecificationNode $specification, ExampleNode $example) { $example->getLineNumber()->willReturn(37); $example->getTitle()->willReturn('it tests something'); $pendingEvent->getException()->willReturn(new PendingException()); $pendingEvent->getSpecification()->willReturn($specification); $pendingEvent->getExample()->willReturn($example); $stats->getEventsCount()->willReturn(1); $stats->getFailedEvents()->willReturn(array()); $stats->getBrokenEvents()->willReturn(array()); $stats->getPendingEvents()->willReturn(array($pendingEvent)); $stats->getSkippedEvents()->willReturn(array()); $stats->getTotalSpecs()->willReturn(1); $stats->getCountsHash()->willReturn(array('passed' => 0, 'pending' => 1, 'skipped' => 0, 'failed' => 0, 'broken' => 0)); $this->afterSuite($event); $expected = '<lineno> 37</lineno> <pending>- it tests something</pending>'; $io->writeln($expected)->shouldHaveBeenCalled(); }
/** * @return string */ public function getTitle() { return $this->example->getTitle(); }
function it_escapes_unicode_symbols(IO $io, ExampleNode $node) { $node->getTitle()->willReturn("Example 0x1234"); $io->write("##teamcity[testIgnored name='Example |0x1234' message='Exception |0x4321!']\n")->shouldBeCalled(); $this->afterExample($this->exampleEvent($node, ExampleEvent::PENDING, 0, 'Exception 0x4321!')); }