You are here

public function DefaultEngineTest::testMatch in CRM Core 8.2

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::testMatch()
  2. 8 modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest::testMatch()

Tests the match method.

File

modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php, line 132
Contains \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest.

Class

DefaultEngineTest
Tests the default matching engine.

Namespace

Drupal\Tests\crm_core_match\Unit

Code

public function testMatch() {
  $this->field
    ->expects($this
    ->any())
    ->method('getType')
    ->will($this
    ->returnValue('crap'));
  $this->individual
    ->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->individual);
  $this
    ->assertEquals([
    42,
  ], $ids);
}