11 use Psr\Log\LoggerInterface;
32 private $clientFactory;
37 private $clientConfig;
46 $this->logger = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)
47 ->disableOriginalConstructor()
49 $this->clientFactory = $this->getMockBuilder(\
Magento\AdvancedSearch\Model\Client\ClientFactoryInterface::class)
50 ->disableOriginalConstructor()
51 ->setMethods([
'create'])
53 $this->clientConfig = $this->getMockBuilder(ClientOptionsInterface::class)
54 ->disableOriginalConstructor()
57 $this->clientConfig->expects($this->any())
58 ->method(
'prepareClientOptions')
60 'hostname' =>
'localhost',
65 'password' =>
'passwd',
68 $objectManagerHelper =
new ObjectManagerHelper($this);
69 $this->model = $objectManagerHelper->getObject(
70 \
Magento\Elasticsearch\SearchAdapter\ConnectionManager::class,
72 'clientFactory' => $this->clientFactory,
73 'clientConfig' => $this->clientConfig,
74 'logger' => $this->logger
84 $client = $this->getMockBuilder(\
Magento\Elasticsearch\Model\Client\Elasticsearch::class)
85 ->disableOriginalConstructor()
87 $this->clientFactory->expects($this->once())
89 ->willReturn($client);
91 $this->model->getConnection();
100 $this->clientFactory->expects($this->any())
102 ->willThrowException(
new \Exception(
'Something went wrong'));
103 $this->model->getConnection();
testGetConnectionSuccessfull()
testGetConnectionFailure()