You are here

public function DefaultEngineTest::testMultipleMatch in CRM Core 8

Same name and namespace in other branches
  1. 8.3 modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest::testMultipleMatch()
  2. 8.2 modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest::testMultipleMatch()

Tests the match method with multiple fields.

File

modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php, line 162

Class

DefaultEngineTest
Tests the default matching engine.

Namespace

Drupal\Tests\crm_core_match\Unit

Code

public function testMultipleMatch() {
  $this->field
    ->expects($this
    ->any())
    ->method('getType')
    ->will($this
    ->returnValue('crap'));
  $this->individual
    ->expects($this
    ->any())
    ->method('getFieldDefinitions')
    ->will($this
    ->returnValue([
    'foo' => $this->field,
    'bar' => $this->field,
  ]));
  $this->pluginManager
    ->expects($this
    ->any())
    ->method('hasDefinition')
    ->will($this
    ->returnValue(TRUE));
  $this->matchHandler
    ->expects($this
    ->any())
    ->method('match')
    ->will($this
    ->returnValue([
    '42' => [
      'value' => 40,
    ],
  ]))
    ->will($this
    ->returnValue([
    '42' => [
      'value' => 40,
    ],
    '30' => [
      'value' => 40,
    ],
  ]));
  $this->pluginManager
    ->expects($this
    ->any())
    ->method('createInstance')
    ->will($this
    ->returnValue($this->matchHandler));
  $ids = $this->engine
    ->match($this->individual);
  $this
    ->assertEquals([
    42,
  ], $ids);
}