/** * Tests the match method. */ public function testMatch() { $this->field->expects($this->any())->method('getType')->will($this->returnValue('crap')); $this->contact->expects($this->any())->method('getFieldDefinitions')->will($this->returnValue(array('foo' => $this->field))); $this->pluginManager->expects($this->any())->method('hasDefinition')->will($this->returnValue(TRUE)); $this->matchHandler->expects($this->any())->method('match')->will($this->returnValue(array('42' => array('value' => 100)))); // $this->pluginManager->expects($this->once()) // ->method('createInstance') // ->will($this->returnValue($this->matchHandler)); // $ids = $this->engine->match($this->contact); // $this->assertEquals([], $ids); }
/** * Builds a row for an rule in the rule listing. * * @param \Drupal\crm_core_match\Plugin\crm_core_match\field\FieldHandlerInterface $field * The match field of this rule. * @param string $name * The property name of this rule. * @param bool $disabled * Disables the form elements. * * @return array * A render array structure of fields for this rule. */ public function buildRow(FieldHandlerInterface $field, $name, $disabled) { $row = array(); $row['#attributes']['class'][] = 'draggable'; $row['#weight'] = $field->getWeight($name); $row['status'] = array('#type' => 'checkbox', '#default_value' => $field->getStatus($name), '#disabled' => $disabled); $row['label'] = array('#markup' => $field->getLabel($name)); $row['type'] = array('#markup' => $field->getType()); $row['operator'] = array('#type' => 'select', '#default_value' => $field->getOperator($name), '#empty_option' => !$disabled ? NULL : $this->t('- Please Select -'), '#options' => $field->getOperators($name), '#disabled' => $disabled); $row['options'] = array('#type' => 'textfield', '#maxlength' => 28, '#size' => 28, '#default_value' => $field->getOptions($name), '#disabled' => $disabled); $row['score'] = array('#type' => 'textfield', '#maxlength' => 4, '#size' => 3, '#default_value' => $field->getScore($name), '#disabled' => $disabled); $row['weight'] = array('#type' => 'weight', '#title' => $this->t('Weight for @field', array('@field' => $field->getLabel())), '#title_display' => 'invisible', '#default_value' => $field->getWeight($name), '#attributes' => array('class' => array('weight'))); return $row; }