function it_increment_line_strategy(OccurrenceInterface $current, ConditionInterface $currentCondition, NodeInterface $currentNode, OccurrenceInterface $previous, NodeInterface $previousNode)
 {
     $current->getCondition()->shouldBeCalled()->willReturn($currentCondition);
     $current->getNode()->shouldBeCalled()->willReturn($currentNode);
     $previous->getNode()->shouldBeCalled()->willReturn($previousNode);
     $currentCondition->isStrategy(Argument::exact(ConditionInterface::STRATEGY_NEXT))->shouldBeCalled()->willReturn(false);
     $currentNode->getPosition()->shouldBeCalled()->willReturn(3);
     $previousNode->getPosition()->shouldBeCalled()->willReturn(1);
     $this->oughtToBeIncrement($current, $previous)->shouldReturn(true);
 }
 /**
  * {@inheritdoc}
  */
 public function oughtToBeIncrement(OccurrenceInterface $current, OccurrenceInterface $previous)
 {
     $currentCondition = $current->getCondition();
     $currentNode = $current->getNode();
     $previousNode = $previous->getNode();
     if ($currentCondition->isStrategy(ConditionInterface::STRATEGY_NEXT)) {
         return 1 === $currentNode->getPosition() - $previousNode->getPosition();
     }
     return $currentNode->getPosition() > $previousNode->getPosition();
 }
 /**
  * {@inheritdoc}
  */
 public function process(OccurrenceInterface $occurrence)
 {
     $condition = $occurrence->getCondition();
     $node = $occurrence->getNode();
     $rule = $occurrence->getRule();
     $dynamicCapabilities = $condition->getDynamicCapabilities();
     $matchesCapabilities = array();
     foreach ($dynamicCapabilities as $capability) {
         $matchesCapabilities[$capability] = $node->getValue();
     }
     $rule->setCapabilities(array_merge($rule->getCapabilities(), $matchesCapabilities));
 }
 function it_process_dynamic_capabilities(OccurrenceInterface $occurrence, ConditionInterface $condition, NodeInterface $node, RuleInterface $rule)
 {
     $occurrence->getCondition()->shouldBeCalled()->willReturn($condition);
     $occurrence->getNode()->shouldBeCalled()->willReturn($node);
     $occurrence->getRule()->shouldBeCalled()->willReturn($rule);
     $node->getValue()->shouldBeCalled()->willReturn('12.09b');
     $dynamicCapabilities = array('browser_version');
     $condition->getDynamicCapabilities()->shouldBeCalled()->willReturn($dynamicCapabilities);
     $capabilities = array('browser' => 'Chrome');
     $rule->getCapabilities()->shouldBeCalled()->willReturn($capabilities);
     $rule->setCapabilities(Argument::exact(array('browser' => 'Chrome', 'browser_version' => '12.09b')))->shouldBeCalled()->willReturn($rule);
     $this->process($occurrence);
 }
 function it_return_negative_analyse_occurrences(IncrementationInterface $incrementation, DynamicCapabilitiesProcessorInterface $dynamicCapabilitiesProcessor, OccurrencesInterface $occurences, OccurrenceInterface $occurence1, OccurrenceInterface $occurence2, RuleInterface $rule)
 {
     $this->beConstructedWith($incrementation, $dynamicCapabilitiesProcessor);
     $rule->getConditions()->shouldBeCalled()->willReturn(array(1, 2, 3));
     $occurence1->getRule()->shouldBeCalled()->willReturn($rule);
     $occurence2->getRule()->shouldBeCalled()->willReturn($rule);
     $dynamicCapabilitiesProcessor->process(Argument::exact($occurence1->getWrappedObject()))->shouldBeCalled();
     $dynamicCapabilitiesProcessor->process(Argument::exact($occurence2->getWrappedObject()))->shouldBeCalled();
     $occurencesIterator = array($occurence1, $occurence2);
     $occurences->getFirstOccurrences()->shouldBeCalled()->willReturn($occurencesIterator);
     $occurences->getNext(Argument::exact($occurence1->getWrappedObject()))->shouldBeCalled()->willReturn($occurence2);
     $occurences->getNext(Argument::exact($occurence2->getWrappedObject()))->shouldBeCalled()->willReturn(false);
     $incrementation->oughtToBeIncrement($occurence2->getWrappedObject(), $occurence1->getWrappedObject())->shouldBeCalled()->willReturn(true);
     $results = $this->analyse($occurences);
     $results->shouldBeAnInstanceOf('\\Iterator');
     $results->shouldHaveCount(0);
 }
 function it_add_and_clear_occurrences(OccurrenceInterface $occurence, RuleInterface $rule)
 {
     $occurence->getRule()->shouldBeCalled()->willReturn($rule);
     $this->add($occurence)->shouldReturn($this);
     $this->clear()->shouldReturn($this);
 }