Skip to content

Commit 3e513d0

Browse files
unitTest covered for changes
1 parent 6ea86bb commit 3e513d0

File tree

1 file changed

+69
-0
lines changed
  • app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type

1 file changed

+69
-0
lines changed

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/OptionTest.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,75 @@ public function testValidateAmbiguousData(
776776
$this->assertEquals($errors, $resultErrors);
777777
}
778778

779+
/**
780+
* Test for row without store view code field
781+
* @param array $rowData
782+
* @param array $responseData
783+
*
784+
* @covers \Magento\CatalogImportExport\Model\Import\Product\Option::_parseCustomOptions
785+
* @dataProvider validateRowStoreViewCodeFieldDataProvider
786+
*/
787+
public function testValidateRowDataForStoreViewCodeField($rowData, $responseData)
788+
{
789+
$reflection = new \ReflectionClass(\Magento\CatalogImportExport\Model\Import\Product\Option::class);
790+
$reflectionMethod = $reflection->getMethod('_parseCustomOptions');
791+
$reflectionMethod->setAccessible(true);
792+
$result = $reflectionMethod->invoke($this->model, $rowData);
793+
$this->assertEquals($responseData, $result);
794+
}
795+
796+
/**
797+
* Data provider for test of method _parseCustomOptions
798+
*
799+
* @return array
800+
*/
801+
public function validateRowStoreViewCodeFieldDataProvider()
802+
{
803+
return [
804+
'with_store_view_code' => [
805+
'$rowData' => [
806+
'store_view_code' => '',
807+
'custom_options' => 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
808+
],
809+
'$responseData' => [
810+
'store_view_code' => '',
811+
'custom_options' => [
812+
'Test Field Title' => [
813+
[
814+
'name' => 'Test Field Title',
815+
'type' => 'field',
816+
'required' => '1',
817+
'sku' => '1-text',
818+
'price' => '0',
819+
'price_type' => 'fixed',
820+
'_custom_option_store' => ''
821+
]
822+
]
823+
]
824+
],
825+
],
826+
'without_store_view_code' => [
827+
'$rowData' => [
828+
'custom_options' => 'name=Test Field Title,type=field,required=1;sku=1-text,price=0,price_type=fixed'
829+
],
830+
'$responseData' => [
831+
'custom_options' => [
832+
'Test Field Title' => [
833+
[
834+
'name' => 'Test Field Title',
835+
'type' => 'field',
836+
'required' => '1',
837+
'sku' => '1-text',
838+
'price' => '0',
839+
'price_type' => 'fixed'
840+
]
841+
]
842+
]
843+
],
844+
]
845+
];
846+
}
847+
779848
/**
780849
* Data provider of row data and errors
781850
*

0 commit comments

Comments
 (0)