function it_handle_configuration(RuleInterface $rule) { $configuration = array('priority' => 1, 'category' => 'browser', 'capabilities' => array('is_bot' => true), 'conditions' => array(array('type' => 'text', 'value' => 'chrome', 'strategy' => 'sequence', 'capabilities' => array('is_modile' => true)))); $rule->setPriority(Argument::exact($configuration['priority']))->shouldBeCalled(); $rule->setCategory(Argument::exact($configuration['category']))->shouldBeCalled(); $rule->setCapabilities(Argument::exact($configuration['capabilities']))->shouldBeCalled(); $rule->addCondition(Argument::type('DeviceDetectorIO\\DeviceDetector\\Rule\\Condition\\ConditionInterface'))->shouldBeCalled(); $this->handle($configuration, $rule); }
/** * @param array $configuration * @param RuleInterface $rule */ private function handleConditions(array $configuration, RuleInterface $rule) { foreach ($configuration['conditions'] as $position => $conditionConfiguration) { $condition = new Condition(); $condition->setType($conditionConfiguration['type']); $condition->setValue($conditionConfiguration['value']); $condition->setStrategy(isset($conditionConfiguration['strategy']) ? $conditionConfiguration['strategy'] : ConditionInterface::STRATEGY_NEXT); $condition->setPosition($position); $condition->setDynamicCapabilities(isset($conditionConfiguration['capabilities']) ? $conditionConfiguration['capabilities'] : array()); $rule->addCondition($condition); } }