Skip to content

Commit

Permalink
MAGETWO-59244: Make Bamboo tests green
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-v-rad committed Oct 10, 2016
1 parent 5a25661 commit bda928c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 10 deletions.
4 changes: 2 additions & 2 deletions etc/config.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<xs:element name="progress_bar_format" type="xs:string" maxOccurs="1"/>
<xs:element name="upgrade_customer_password_hash" type="xs:string" maxOccurs="1"/>
<xs:element name="crypt_key" type="xs:string" maxOccurs="1"/>
<xs:element name="edition_migrate" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="init_statements_source" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="edition_migrate" type="xs:string" maxOccurs="1"/>
<xs:element name="init_statements_source" type="xs:string" maxOccurs="1"/>
<xs:element name="init_statements_destination" type="xs:string" maxOccurs="1"/>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>
</xs:choice>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function testGetRecords()
*/
public function testGetAdapter()
{
$this->config->expects($this->once())->method('getOption')->with('edition_migrate')->willReturn('ce-to-ee');
$this->config->expects($this->any())->method('getOption')->willReturnMap([['edition_migrate', 'ce-to-ee']]);
$this->assertSame($this->adapter, $this->resourceDestination->getAdapter());
}
}
76 changes: 69 additions & 7 deletions tests/unit/testsuite/Migration/Step/Eav/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ class HelperTest extends \PHPUnit_Framework_TestCase
*/
protected $readerAttributes;

/**
* @var \Migration\ResourceModel\Adapter\Mysql|\PHPUnit_Framework_MockObject_MockObject
*/
protected $adapter;

/**
* @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject
*/
protected $pdoMysql;

/**
* @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
*/
protected $select;

/**
* @return void
*/
Expand All @@ -65,7 +80,7 @@ public function setUp()
$mapFactory->expects($this->any())->method('create')->with('eav_map_file')->willReturn($this->map);

$this->source = $this->getMockBuilder('Migration\ResourceModel\Source')->disableOriginalConstructor()
->setMethods(['getRecordsCount', 'getRecords'])
->setMethods(['getRecordsCount', 'getRecords', 'getAdapter', 'addDocumentPrefix'])
->getMock();
$this->destination = $this->getMockBuilder('Migration\ResourceModel\Destination')->disableOriginalConstructor()
->setMethods(['getRecordsCount', 'getRecords', 'deleteDocumentBackup'])
Expand Down Expand Up @@ -94,6 +109,21 @@ public function setUp()
['eav_attribute_groups_file', $this->readerAttributes]
]
);
$this->adapter = $this->getMock(
'Migration\ResourceModel\Adapter\Mysql',
['getSelect'],
[],
'',
false
);
$this->pdoMysql = $this->getMock(
'Magento\Framework\DB\Adapter\Pdo\Mysql',
['fetchPairs'],
[],
'',
false
);
$this->select = $this->getMock('Magento\Framework\DB\Select', ['from', 'getAdapter'], [], '', false);
$this->helper = new Helper($mapFactory, $this->source, $this->destination, $this->factory, $groupsFactory);
}

Expand Down Expand Up @@ -234,25 +264,57 @@ public function testClearIgnoredAttributes()
{
$allSourceRecords = [
0 => [
'attribute_code' => 'ignored_attribute'
'attribute_code' => 'ignored_attribute',
'entity_type_id' => 111,
],
1 => [
'attribute_code' => 'attribute_1'
'attribute_code' => 'attribute_1',
'entity_type_id' => 1,
],
2 => [
'attribute_code' => 'attribute_2'
'attribute_code' => 'attribute_2',
'entity_type_id' => 2,
]
];
$clearedSourceRecords = [
1 => [
'attribute_code' => 'attribute_1'
'attribute_code' => 'attribute_1',
'entity_type_id' => 1,
],
2 => [
'attribute_code' => 'attribute_2'
'attribute_code' => 'attribute_2',
'entity_type_id' => 2,
]
];
$entityTypesCodeToId = [
'ignored_attribute_type' => 111,
'attribute_type_1' => 1,
'attribute_type_2' => 2,
];
$eavEntityTypeTable = 'eav_entity_type';
$this->readerAttributes->expects($this->once())->method('getGroup')->with('ignore')
->willReturn(['ignored_attribute' => 0]);
->willReturn(['ignored_attribute' => ['ignored_attribute_type']]);
$this->source->expects($this->once())->method('getAdapter')->willReturn($this->adapter);
$this->source
->expects($this->once())
->method('addDocumentPrefix')
->with($eavEntityTypeTable)
->willReturn($eavEntityTypeTable);
$this->adapter->expects($this->once())->method('getSelect')->willReturn($this->select);
$this->select
->expects($this->once())
->method('from')
->with($eavEntityTypeTable, ['entity_type_code', 'entity_type_id'])
->will($this->returnSelf());
$this->select
->expects($this->once())
->method('getAdapter')
->will($this->returnValue($this->pdoMysql));
$this->pdoMysql
->expects($this->once())
->method('fetchPairs')
->with($this->select)
->will($this->returnValue($entityTypesCodeToId));
$this->assertEquals($clearedSourceRecords, $this->helper->clearIgnoredAttributes($allSourceRecords));
}
}

0 comments on commit bda928c

Please sign in to comment.