/** * @dataProvider getDocumentDataSource() * @param string $prefix * @param string $optionName * @return void */ public function testGetDocument($prefix, $optionName) { $resourceName = 'core_config_data'; $structureData = ['id' => 'int']; $structure = $this->getMock('\\Migration\\ResourceModel\\Structure', [], [], '', false); $document = $this->getMock('\\Migration\\ResourceModel\\Document', [], [], '', false); $this->config->expects($this->any())->method('getOption')->with($optionName)->will($this->returnValue($prefix)); $this->documentFactory->expects($this->any())->method('create')->with($this->equalTo(['structure' => $structure, 'documentName' => $resourceName]))->will($this->returnValue($document)); $this->adapter->expects($this->any())->method('getDocumentStructure')->with($this->equalTo($prefix . $resourceName))->willReturn($structureData); $this->structureFactory->expects($this->any())->method('create')->with($this->equalTo(['documentName' => $resourceName, 'data' => $structureData]))->willReturn($structure); $this->adapter->expects($this->any())->method('getDocumentList')->willReturn([$prefix . $resourceName]); $resource = $prefix == MapInterface::TYPE_SOURCE ? $this->resourceSource : $this->resourceDestination; $this->assertSame($document, $resource->getDocument($resourceName)); }
/** * Returns document object * * @param string $documentName * @return \Migration\ResourceModel\Structure */ public function getStructure($documentName) { $data = $this->adapter->getDocumentStructure($this->addDocumentPrefix($documentName)); return $this->structureFactory->create(['documentName' => $documentName, 'data' => $data]); }