indexName = $this->createMock(IndexName::class); $this->resourceConnection = $this->createMock(ResourceConnection::class); $this->indexNameResolver = $this->createMock(IndexNameResolverInterface::class); $this->adapter = $this->createMock(AdapterInterface::class); $this->indexTableSwitcher = $objectManager->getObject( IndexTableSwitcher::class, [ 'resourceConnection' => $this->resourceConnection, 'indexNameResolver' => $this->indexNameResolver, ] ); } public function testSwitch() { $connectionName = 'testConnection'; $tableName = 'some_table_name'; $toRename = [ [ 'oldName' => $tableName, 'newName' => $tableName . '_outdated', ], [ 'oldName' => $tableName . '_replica', 'newName' => $tableName, ], [ 'oldName' => $tableName . '_outdated', 'newName' => $tableName . '_replica', ], ]; $this->resourceConnection->expects($this->once())->method('getConnection') ->with($connectionName)->willReturn($this->adapter); $this->indexNameResolver->expects($this->once())->method('resolveName') ->with($this->indexName)->willReturn($tableName); $this->adapter->expects($this->once())->method('renameTablesBatch') ->with($toRename); $this->indexTableSwitcher->switch($this->indexName, $connectionName); } }