21 private $tableStrategyMock;
26 private $resourceMock;
30 $this->tableStrategyMock = $this->createMock(\
Magento\Framework\Indexer\
Table\Strategy::class);
31 $this->resourceMock = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
33 $this->model = new \Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy(
34 $this->tableStrategyMock,
41 $this->tableStrategyMock->expects($this->once())->method(
'getUseIdxTable')->willReturn(
true);
42 $this->assertTrue($this->model->getUseIdxTable());
47 $this->tableStrategyMock->expects($this->once())->method(
'setUseIdxTable')->with(
true)->willReturnSelf();
48 $this->assertEquals($this->tableStrategyMock, $this->model->setUseIdxTable(
true));
53 $tablePrefix =
'prefix';
55 $this->tableStrategyMock->expects($this->once())->method(
'getUseIdxTable')->willReturn(
true);
56 $this->resourceMock->expects($this->once())
57 ->method(
'getTableName')
58 ->with($expectedResult)
59 ->willReturn($expectedResult);
60 $this->assertEquals($expectedResult, $this->model->getTableName($tablePrefix));
65 $tablePrefix =
'prefix';
69 $this->tableStrategyMock->expects($this->once())->method(
'getUseIdxTable')->willReturn(
false);
70 $connectionMock = $this->createMock(\
Magento\Framework\DB\Adapter\AdapterInterface::class);
72 $this->resourceMock->expects($this->once())
73 ->method(
'getConnection')
75 ->willReturn($connectionMock);
76 $this->resourceMock->expects($this->at(1))
77 ->method(
'getTableName')
78 ->with($expectedResult)
79 ->willReturn($expectedResult);
80 $this->resourceMock->expects($this->at(2))
81 ->method(
'getTableName')
82 ->with($tempTableName)
83 ->willReturn($tempTableName);
84 $connectionMock->expects($this->once())
85 ->method(
'createTemporaryTableLike')
86 ->with($expectedResult, $tempTableName,
true);
88 $this->assertEquals($expectedResult, $this->model->prepareTableName($tablePrefix));