public function testGetPatternDirsModular()
 {
     $inputParams = ['param' => 'value', 'module_name' => 'Magento_Core'];
     $expectedResult = new \stdClass();
     $this->ruleNonModular->expects($this->never())->method('getPatternDirs');
     $this->ruleModular->expects($this->once())->method('getPatternDirs')->with($inputParams)->will($this->returnValue($expectedResult));
     $this->assertSame($expectedResult, $this->object->getPatternDirs($inputParams));
 }
 /**
  * Delegate execution to either modular or non-modular sub-rule depending on input parameters
  *
  * @param array $params
  * @return array
  */
 public function getPatternDirs(array $params)
 {
     if (isset($params['module_name'])) {
         return $this->ruleModular->getPatternDirs($params);
     } else {
         return $this->ruleNonModular->getPatternDirs($params);
     }
 }
Example #3
0
 /**
  * カウントアップ
  */
 public function countUp()
 {
     for ($i = 1; $i <= $this->maxNum; $i++) {
         if ($this->rule->isAho($i)) {
             $this->action->actAsAho($i);
         } else {
             $this->action->actAsNormal($i);
         }
     }
 }
 /**
  * Delegate execution to either modular or non-modular sub-rule depending on input parameters
  *
  * @param array $params
  * @return array
  * @throws \InvalidArgumentException
  */
 public function getPatternDirs(array $params)
 {
     $isNamespaceDefined = isset($params['namespace']);
     $isModuleDefined = isset($params['module']);
     if ($isNamespaceDefined && $isModuleDefined) {
         return $this->ruleModular->getPatternDirs($params);
     } elseif (!$isNamespaceDefined && !$isModuleDefined) {
         return $this->ruleNonModular->getPatternDirs($params);
     }
     throw new \InvalidArgumentException("Parameters 'namespace' and 'module' should either be both set or unset.");
 }
 /**
  * Checks if any operation actions on a rule grant $operation access.
  *
  * This does not evaluate conditions.
  *
  * @param \Drupal\rng\RuleInterface $rule
  *   A rule entity.
  * @param string $operation
  *   A registration operation.
  *
  * @return bool
  *   Whether $operation is granted by the actions.
  */
 protected function ruleGrantsOperation(RuleInterface $rule, $operation)
 {
     $actions = $rule->getActions();
     $operations_actions = array_filter($actions, function ($action) use($actions, $operation) {
         if ($action->getPluginId() == 'registration_operations') {
             $config = $action->getConfiguration();
             return !empty($config['operations'][$operation]);
         }
         return FALSE;
     });
     return (bool) count($operations_actions);
 }