26 private $objectManager;
31 private $engineResolverMock;
35 $this->engineResolverMock = $this->getMockBuilder(EngineResolverInterface::class)
36 ->getMockForAbstractClass();
38 $this->objectManager = $this->createMock(ObjectManagerInterface::class);
42 [
'engineName' =>
'engineFactoryClass'],
43 [
'engineName' =>
'engineOptionClass'],
44 $this->engineResolverMock
50 $this->engineResolverMock->expects($this->once())->method(
'getCurrentSearchEngine')
51 ->will($this->returnValue(
'engineName'));
53 $factoryMock = $this->createMock(ClientFactoryInterface::class);
55 $clientMock = $this->createMock(ClientInterface::class);
57 $clientOptionsMock = $this->createMock(ClientOptionsInterface::class);
59 $this->objectManager->expects($this->exactly(2))->method(
'create')
61 [$this->equalTo(
'engineFactoryClass')],
62 [$this->equalTo(
'engineOptionClass')]
64 ->willReturnOnConsecutiveCalls(
69 $clientOptionsMock->expects($this->once())->method(
'prepareClientOptions')
71 ->will($this->returnValue([
'parameters']));
73 $factoryMock->expects($this->once())->method(
'create')
74 ->with($this->equalTo([
'parameters']))
75 ->will($this->returnValue($clientMock));
77 $result = $this->model->create();
78 $this->assertInstanceOf(ClientInterface::class,
$result);
86 $this->objectManager->expects($this->once())->method(
'create')
87 ->with($this->equalTo(
'engineFactoryClass'))
88 ->will($this->returnValue(
't'));
90 $this->model->create(
'engineName');
98 $this->model->create(
'input');
103 $this->engineResolverMock->expects($this->once())->method(
'getCurrentSearchEngine')
104 ->will($this->returnValue(
'engineName'));
106 $this->assertEquals(
'engineName', $this->model->getCurrentEngine());
testCreateExceptionThrown()
testCreateLogicException()