/** * @return void */ public function testBackupDocument() { $documentName = 'document_name'; $backupDocumentName = 'migration_backup_document_name'; $table = $this->getMockBuilder('Magento\\Framework\\DB\\Ddl\\Table')->disableOriginalConstructor()->setMethods(['getName'])->getMock(); $table->expects($this->any())->method('getName')->will($this->returnValue('migration_backup_document_name')); $select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from'])->getMock(); $select->expects($this->once())->method('from')->with($documentName)->willReturn($select); $this->pdoMysql->expects($this->once())->method('createTableByDdl')->with($documentName, $backupDocumentName)->will($this->returnValue($table)); $this->pdoMysql->expects($this->once())->method('isTableExists')->willReturn(false); $this->pdoMysql->expects($this->once())->method('dropTable')->with($backupDocumentName); $this->pdoMysql->expects($this->once())->method('createTable')->with($table); $this->pdoMysql->expects($this->once())->method('resetDdlCache')->with($backupDocumentName); $this->pdoMysql->expects($this->once())->method('select')->willReturn($select); $this->pdoMysql->expects($this->once())->method('insertFromSelect')->with($select, $backupDocumentName)->willReturn('select query'); $this->pdoMysql->expects($this->once())->method('query')->with('select query'); $this->adapterMysql->backupDocument($documentName); }