Commit 228d8277 authored by RoSk0's avatar RoSk0

Issue #2987718 by RoSk0: Removed empty test.

parent 29a4f6cd
<?php
/**
* @file
* Contains \Drupal\Tests\crm_core_match\Unit\MatcherTest.
*/
namespace Drupal\Tests\crm_core_match\Unit;
use Drupal\crm_core_match\Matcher;
use Drupal\Tests\UnitTestCase;
/**
* Tests the matcher service.
*
* @covers \Drupal\crm_core_match\Matcher
*
* @group crm_core
*/
class MatcherTest extends UnitTestCase {
/**
* The tested matcher.
*
* @var \Drupal\crm_core_match\Entity\Matcher
*/
protected $matcher;
/**
* A set mocked match engines keyed by id.
*
* @var \Drupal\crm_core_match\Matcher\MatcherConfigInterface|\PHPUnit_Framework_MockObject_MockObject[]
*/
protected $engine = array();
/**
* An individual entity used to get matches.
*
* @var \Drupal\crm_core_contact\Entity\Individual
*/
protected $individual;
/**
* A mocked instance of the engine plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $pluginManager;
/**
* A mocked instance of the config.
*
* @var \Drupal\Core\Config\Config|\PHPUnit_Framework_MockObject_MockObject
*/
protected $config;
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Matcher',
'description' => 'Tests the matcher.',
'group' => 'CRM Core',
);
}
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->engine['a'] = $this->getMock('Drupal\crm_core_match\Plugin\crm_core_match\engine\MatchEngineInterface');
$this->engine['b'] = $this->getMock('Drupal\crm_core_match\Plugin\crm_core_match\engine\MatchEngineInterface');
$this->engine['c'] = $this->getMock('Drupal\crm_core_match\Plugin\crm_core_match\engine\MatchEngineInterface');
$this->pluginManager = $this->getMock('Drupal\Component\Plugin\PluginManagerInterface');
// $this->config = $this->getMockBuilder('\Drupal\Core\Config\Config')
// ->disableOriginalConstructor()
// ->getMock();
// $this->matcher = $this->getMock('Drupal\crm_core_match\Matcher');
$this->individual = $this->getMockBuilder('Drupal\crm_core_contact\Entity\Individual')
->disableOriginalConstructor()
->getMock();
}
/**
* Tests the sorting of engines.
*/
public function testEngineSort() {
// $engine_config = $this->getMockBuilder('\Drupal\Core\Config\Config')
// ->disableOriginalConstructor()
// ->getMock();
//
// $this->config->expects($this->once())
// ->method('get')
// ->with('engines')
// ->will($this->returnValue($engine_config));
//
// $engine_config->expects($this->exactly(3))
// ->method('get')
// ->will($this->returnValue(TRUE));
//
// $definitions = array(
// 'a' => array('priority' => 5),
// 'b' => array('priority' => 11),
// 'c' => array('priority' => -1),
// );
// $this->pluginManager->expects($this->once())
// ->method('getDefinitions')
// ->will($this->returnValue($definitions));
//
// $this->pluginManager->expects($this->at(1))
// ->method('createInstance')
// ->with('a', $definitions['a'])
// ->will($this->returnValue($this->engine['a']));
//
// $this->pluginManager->expects($this->at(2))
// ->method('createInstance')
// ->with('b', $definitions['b'])
// ->will($this->returnValue($this->engine['b']));
//
// $this->pluginManager->expects($this->at(3))
// ->method('createInstance')
// ->with('c', $definitions['c'])
// ->will($this->returnValue($this->engine['c']));
//
// $engines = $this->matcher->getEngines();
//
// $this->assertTrue(is_array($engines));
// $this->assertTrue(count($engines) == 3);
// $this->assertEquals($this->engine['b'], array_shift($engines));
// $this->assertEquals($this->engine['a'], array_shift($engines));
// $this->assertEquals($this->engine['c'], array_shift($engines));
}
/**
* Tests the execution of match engines.
*/
public function testEngineExecution() {
// $engine_config = $this->getMockBuilder('\Drupal\Core\Config\Config')
// ->disableOriginalConstructor()
// ->getMock();
//
// $this->config->expects($this->once())
// ->method('get')
// ->with('engines')
// ->will($this->returnValue($engine_config));
//
// $engine_config->expects($this->exactly(2))
// ->method('get')
// ->will($this->returnValue(TRUE));
// $definitions = array(
// 'a' => array('priority' => 5),
// 'b' => array('priority' => 11),
// );
// $this->pluginManager->expects($this->once())
// ->method('getDefinitions')
// ->will($this->returnValue($definitions));
//
// $this->pluginManager->expects($this->at(1))
// ->method('createInstance')
// ->with('a', $definitions['a'])
// ->will($this->returnValue($this->engine['a']));
//
// $this->pluginManager->expects($this->at(2))
// ->method('createInstance')
// ->with('b', $definitions['b'])
// ->will($this->returnValue($this->engine['b']));
// $this->engine['a']->expects($this->once())
// ->method('match')
// ->with($this->contact)
// ->will($this->returnValue(array(1, 2, 3, 5, 8, 13)));
//
// $this->engine['b']->expects($this->once())
// ->method('match')
// ->with($this->contact)
// ->will($this->returnValue(array(3, 8, 21, 34)));
// $this->matcher->expects($this->once())
// ->method('match')
// ->with($this->contact)
// ->will($this->)
//
// $ids = $this->matcher->match($this->contact);
// $ids = array_values($ids);
// sort($ids);
// $this->assertEquals(array(1, 2, 3, 5, 8, 13, 21, 34), $ids);
}
/**
* Tests disabled engines are not executed.
*/
public function testDisabledEngines() {
// $engine_config = $this->getMockBuilder('\Drupal\Core\Config\Config')
// ->disableOriginalConstructor()
// ->getMock();
//
// $this->config->expects($this->once())
// ->method('get')
// ->with('engines')
// ->will($this->returnValue($engine_config));
//
// $engine_config->expects($this->exactly(2))
// ->method('get')
// ->will($this->returnValueMap(array(
// array('a.status', TRUE),
// array('b.status', FALSE),
// )));
//
// $definitions = array(
// 'a' => array('priority' => 5),
// 'b' => array('priority' => 11),
// );
// $this->pluginManager->expects($this->once())
// ->method('getDefinitions')
// ->will($this->returnValue($definitions));
//
// $this->pluginManager->expects($this->once())
// ->method('createInstance')
// ->with('a', $definitions['a'])
// ->will($this->returnValue($this->engine['a']));
//
// $this->engine['a']->expects($this->once())
// ->method('match')
// ->with($this->contact)
// ->will($this->returnValue(array()));
//
// $this->engine['b']->expects($this->never())
// ->method('match');
//
// $this->assertEquals(1, count($this->matcher->getEngines()));
//
// $this->matcher->match($this->contact);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment