Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ActiveTableSwitcherTest.php
Go to the documentation of this file.
1 <?php
8 
9 class ActiveTableSwitcherTest extends \PHPUnit\Framework\TestCase
10 {
14  private $model;
15 
16  protected function setUp()
17  {
18  $this->model = new \Magento\Catalog\Model\ResourceModel\Indexer\ActiveTableSwitcher();
19  }
20 
21  public function testSwitch()
22  {
23  $connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
24  ->disableOriginalConstructor()
25  ->getMock();
26  $tableName = 'tableName';
27 
28  $connectionMock->expects($this->once())->method('renameTablesBatch')->with(
29  [
30  [
31  'oldName' => 'tableName',
32  'newName' => 'tableName_outdated'
33  ],
34  [
35  'oldName' => 'tableName_replica',
36  'newName' => 'tableName'
37  ],
38  [
39  'oldName' => 'tableName_outdated',
40  'newName' => 'tableName_replica'
41  ],
42  ]
43  );
44 
45  $this->model->switchTable($connectionMock, [$tableName]);
46  }
47 
48  public function testGetAdditionalTableName()
49  {
50  $tableName = 'table_name';
51  $this->assertEquals(
52  $tableName . '_replica',
53  $this->model->getAdditionalTableName($tableName)
54  );
55  }
56 }
$tableName
Definition: trigger.php:13