protected function DefaultEngineTest::setUp in CRM Core 8
Same name and namespace in other branches
- 8.3 modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest::setUp()
- 8.2 modules/crm_core_match/tests/src/Unit/DefaultEngineTest.php \Drupal\Tests\crm_core_match\Unit\DefaultEngineTest::setUp()
Overrides UnitTestCase::setUp
File
- modules/
crm_core_match/ tests/ src/ Unit/ DefaultEngineTest.php, line 77
Class
- DefaultEngineTest
- Tests the default matching engine.
Namespace
Drupal\Tests\crm_core_match\UnitCode
protected function setUp() {
$this->pluginManager = $this
->getMock('\\Drupal\\Core\\Entity\\EntityTypeManagerInterface');
$this->entityTypeManager = $this
->getMockBuilder('\\Drupal\\Core\\Entity\\EntityTypeManagerInterface')
->disableOriginalConstructor()
->getMock();
$this->entityFieldManager = $this
->getMockBuilder('\\Drupal\\Core\\Entity\\EntityFieldManagerInterface')
->disableOriginalConstructor()
->getMock();
$this->individual = $this
->getMockBuilder('Drupal\\crm_core_contact\\Entity\\Individual')
->disableOriginalConstructor()
->getMock();
$this->individual
->expects($this
->any())
->method('bundle')
->will($this
->returnValue('dogs'));
$this->matcher = $this
->getMockBuilder('Drupal\\crm_core_match\\Entity\\Matcher')
->disableOriginalConstructor()
->getMock();
$this->matcher
->expects($this
->any())
->method('status')
->will($this
->returnValue(TRUE));
$storage = $this
->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
$storage
->expects($this
->any())
->method('load')
->with('dogs')
->will($this
->returnValue($this->matcher));
$this->entityTypeManager
->expects($this
->any())
->method('getStorage')
->will($this
->returnValue($storage));
$this->field = $this
->getMock('Drupal\\Core\\Field\\FieldDefinitionInterface');
$this->matchHandler = $this
->getMock('Drupal\\crm_core_match\\Plugin\\crm_core_match\\field\\FieldHandlerInterface');
$this->matchHandler
->expects($this
->any())
->method('getPropertyNames')
->will($this
->returnValue([
'value',
]));
$this->engine = new DefaultMatchingEngine([
'rules' => [
'foo' => [],
'bar' => [],
],
'threshold' => 50,
], 'default', [], $this->pluginManager, $this->entityTypeManager, $this->entityFieldManager);
}