/**
  * @param $category
  * @param $priority
  * @param $capabilities
  * @return Rule
  */
 private function createRule($category, $priority, $capabilities)
 {
     $rule = new Rule();
     $rule->setCategory($category);
     $rule->setPriority($priority);
     $rule->setCapabilities($capabilities);
     return $rule;
 }
 function it_match_bu_using_repository_and_resolver(TokenInterface $token, RepositoryInterface $repository, ResolverInterface $resolver, Rule $rule, EvaluatorInterface $evaluator)
 {
     $this->beConstructedWith($repository, $resolver);
     $condition = new Condition();
     $conditions = array($condition);
     $rule->getConditions()->shouldBeCalled()->willReturn($conditions);
     $rules = array($rule);
     $repository->getNonIndexableRules()->shouldBeCalled()->willReturn($rules);
     $resolver->resolve(Argument::exact($condition))->shouldBeCalled()->willReturn($evaluator);
     $evaluator->evaluate(Argument::exact($token->getWrappedObject()), $condition, Argument::exact($rule->getWrappedObject()))->shouldBeCalled()->willReturn(true);
     $results = $this->match($token);
     $results->shouldReturnAnInstanceOf('\\Iterator');
     $results->shouldHaveCount(1);
     $results->shouldHaveKey($rule);
 }
 function it_find_occurrences(RepositoryInterface $repository, ComparerInterface $comparer, UserAgentTokenizedToken $token, Rule $rule)
 {
     $this->beConstructedWith($repository, $comparer);
     $node1 = new Node('chrome', 0, Node::TYPE_TEXT);
     $node2 = new Node('/', 1, Node::TYPE_TEXT);
     $node3 = new Node('12.05b', 2, Node::TYPE_TEXT);
     $token->getData()->shouldBeCalled()->willReturn(array($node1, $node2, $node3));
     $condition = new Condition();
     $condition->setPosition(0);
     $conditions = new \ArrayIterator(array($condition));
     $rule->getConditions()->shouldBeCalled()->willReturn($conditions);
     $repository->getIndexableRulesByUserAgentToken(Argument::exact($token->getWrappedObject()))->shouldBeCalled()->willReturn(array($rule));
     $comparer->areEquals(Argument::exact($node1), Argument::exact($condition))->shouldBeCalled()->willReturn(true);
     $comparer->areEquals(Argument::exact($node2), Argument::exact($condition))->shouldBeCalled()->willReturn(false);
     $comparer->areEquals(Argument::exact($node3), Argument::exact($condition))->shouldBeCalled()->willReturn(true);
     $occurrences = $this->find($token);
     $occurrences->shouldBeAnInstanceOf('DeviceDetectorIO\\DeviceDetector\\Rule\\Occurrence\\Occurrences');
     $firstOccurrences = $occurrences->getFirstOccurrences();
     $firstOccurrences->shouldHaveCount(2);
 }