@@ -59,14 +59,85 @@ public function testExport()
59
59
60
60
$ csvfile = uniqid ('importexport_ ' ) . '.csv ' ;
61
61
62
+ $ this ->exportData ($ csvfile );
63
+ $ this ->importData ($ csvfile );
64
+
65
+ while ($ index > 0 ) {
66
+ $ index --;
67
+ $ newPricingData = $ this ->objectManager ->create (\Magento \Catalog \Model \Product::class)
68
+ ->load ($ ids [$ index ])
69
+ ->getTierPrices ();
70
+ $ this ->assertEquals (count ($ origPricingData [$ index ]), count ($ newPricingData ));
71
+ $ this ->assertEqualsOtherThanSkippedAttributes ($ origPricingData [$ index ], $ newPricingData , []);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @magentoAppArea adminhtml
77
+ * @magentoDbIsolation enabled
78
+ * @magentoAppIsolation enabled
79
+ * @magentoConfigFixture current_store catalog/price/scope 1
80
+ * @magentoDataFixture Magento/AdvancedPricingImportExport/_files/product_with_second_website.php
81
+ */
82
+ public function testExportMultipleWebsites ()
83
+ {
84
+ $ productRepository = $ this ->objectManager ->create (
85
+ \Magento \Catalog \Api \ProductRepositoryInterface::class
86
+ );
87
+ $ index = 0 ;
88
+ $ ids = [];
89
+ $ origPricingData = [];
90
+ $ skus = ['AdvancedPricingSimple 1 ' , 'AdvancedPricingSimple 2 ' ];
91
+ while (isset ($ skus [$ index ])) {
92
+ $ ids [$ index ] = $ productRepository ->get ($ skus [$ index ])->getId ();
93
+ $ origPricingData [$ index ] = $ this ->objectManager ->create (\Magento \Catalog \Model \Product::class)
94
+ ->load ($ ids [$ index ])
95
+ ->getTierPrices ();
96
+ $ index ++;
97
+ }
98
+
99
+ $ csvfile = uniqid ('importexport_ ' ) . '.csv ' ;
100
+
101
+ $ exportContent = $ this ->exportData ($ csvfile );
102
+ $ this ->assertContains (
103
+ '"AdvancedPricingSimple 2",test,"ALL GROUPS",3.0000,5.0000 ' ,
104
+ $ exportContent
105
+ );
106
+ $ this ->importData ($ csvfile );
107
+
108
+ while ($ index > 0 ) {
109
+ $ index --;
110
+ $ newPricingData = $ this ->objectManager ->create (\Magento \Catalog \Model \Product::class)
111
+ ->load ($ ids [$ index ])
112
+ ->getTierPrices ();
113
+ $ this ->assertEquals (count ($ origPricingData [$ index ]), count ($ newPricingData ));
114
+ $ this ->assertEqualsOtherThanSkippedAttributes ($ origPricingData [$ index ], $ newPricingData , []);
115
+ }
116
+ }
117
+
118
+ /**
119
+ * @param string $csvFile
120
+ * @return string
121
+ */
122
+ private function exportData ($ csvFile )
123
+ {
62
124
$ this ->model ->setWriter (
63
125
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
64
126
\Magento \ImportExport \Model \Export \Adapter \Csv::class,
65
- ['fileSystem ' => $ this ->fileSystem , 'destination ' => $ csvfile ]
127
+ ['fileSystem ' => $ this ->fileSystem , 'destination ' => $ csvFile ]
66
128
)
67
129
);
68
- $ this ->assertNotEmpty ($ this ->model ->export ());
130
+ $ exportContent = $ this ->model ->export ();
131
+ $ this ->assertNotEmpty ($ exportContent );
132
+
133
+ return $ exportContent ;
134
+ }
69
135
136
+ /**
137
+ * @param string $csvFile
138
+ */
139
+ private function importData ($ csvFile )
140
+ {
70
141
/** @var \Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing $importModel */
71
142
$ importModel = $ this ->objectManager ->create (
72
143
\Magento \AdvancedPricingImportExport \Model \Import \AdvancedPricing::class
@@ -75,7 +146,7 @@ public function testExport()
75
146
$ source = $ this ->objectManager ->create (
76
147
\Magento \ImportExport \Model \Import \Source \Csv::class,
77
148
[
78
- 'file ' => $ csvfile ,
149
+ 'file ' => $ csvFile ,
79
150
'directory ' => $ directory
80
151
]
81
152
);
@@ -90,18 +161,9 @@ public function testExport()
90
161
91
162
$ this ->assertTrue (
92
163
$ errors ->getErrorsCount () == 0 ,
93
- 'Advanced Pricing import error, imported from file: ' . $ csvfile
164
+ 'Advanced Pricing import error, imported from file: ' . $ csvFile
94
165
);
95
166
$ importModel ->importData ();
96
-
97
- while ($ index > 0 ) {
98
- $ index --;
99
- $ newPricingData = $ this ->objectManager ->create (\Magento \Catalog \Model \Product::class)
100
- ->load ($ ids [$ index ])
101
- ->getTierPrices ();
102
- $ this ->assertEquals (count ($ origPricingData [$ index ]), count ($ newPricingData ));
103
- $ this ->assertEqualsOtherThanSkippedAttributes ($ origPricingData [$ index ], $ newPricingData , []);
104
- }
105
167
}
106
168
107
169
private function assertEqualsOtherThanSkippedAttributes ($ expected , $ actual , $ skippedAttributes )
0 commit comments