14 use Magento\Translation\Model\ResourceModel\TranslateFactory;
27 private $translationFactory;
37 private $storeManager;
57 private $deploymentConfigMock;
66 $this->translationFactory = $this->getMockBuilder(TranslateFactory::class)
67 ->disableOriginalConstructor()
68 ->setMethods([
'create'])
70 $this->translation = $this->getMockBuilder(Translate::class)
71 ->disableOriginalConstructor()
73 $this->storeManager = $this->getMockBuilder(StoreManager::class)
74 ->disableOriginalConstructor()
76 $this->store = $this->getMockBuilder(Store::class)
77 ->disableOriginalConstructor()
79 $this->connection = $this->getMockBuilder(AdapterInterface::class)
80 ->disableOriginalConstructor()
82 $this->select = $this->getMockBuilder(Select::class)
83 ->disableOriginalConstructor()
85 $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
86 ->disableOriginalConstructor()
90 $this->translationFactory,
92 $this->deploymentConfigMock
98 $this->deploymentConfigMock->expects($this->once())
99 ->method(
'isDbAvailable')
101 $this->translationFactory->expects($this->once())
103 ->willReturn($this->translation);
104 $this->translation->expects($this->atLeastOnce())
105 ->method(
'getConnection')
106 ->willReturn($this->connection);
107 $this->connection->expects($this->once())
109 ->willReturn($this->select);
110 $this->translation->expects($this->once())
111 ->method(
'getMainTable')
112 ->willReturn(
'main_table.translate');
113 $this->select->expects($this->once())
115 ->with(
'main_table.translate', [
'string',
'translate',
'store_id',
'locale'])
117 $this->select->expects($this->once())
121 $this->connection->expects($this->once())
123 ->with($this->select)
129 'translate' =>
'bonjour' 132 $this->storeManager->expects($this->once())
135 ->willReturn($this->store);
136 $this->store->expects($this->once())
138 ->willReturn(
'myStore');
154 $this->deploymentConfigMock->expects($this->once())
155 ->method(
'isDbAvailable')
157 $this->assertEquals([], $this->source->get());
testGetWithoutAvailableDb()