9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\ImportExport\Test\Fixture\ImportData;
11 use Magento\Mtf\Client\BrowserInterface;
12 use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
14 use Magento\Mtf\Fixture\FixtureInterface;
84 $this->
import = $import;
86 $this->webApi = $webApi;
89 $products = $this->
import->getDataFieldConfig(
'import_file')[
'source']->getEntities();
93 $resultCsvData = $this->getResultCsv(
$product->getSku());
94 \PHPUnit\Framework\Assert::assertEquals(
97 'Products from page and csv are not match.' 125 $this->catalogProductEdit->open([
'id' =>
$productId]);
127 return $this->catalogProductEdit->getProductForm()->getData(
$product);
136 private function getResultCsv($productSku)
138 $csvData = $this->
import->getDataFieldConfig(
'import_file')[
'source']->getCsv();
140 $csvKeys = array_shift($csvData);
141 foreach ($csvData as
$data) {
143 if (
$data[
'sku'] === $productSku) {
144 return $this->deleteUnusedData(
$data);
170 $resultProductsData = [];
171 array_walk_recursive(
173 function (
$value, $key) use (&$resultProductsData) {
174 if (array_key_exists($key, array_flip($this->neededKeys)) !==
false) {
175 $resultProductsData[$key] =
$value;
180 return $resultProductsData;
189 private function deleteUnusedData(array $csvData)
192 foreach ($csvData as $key =>
$value) {
193 if (array_key_exists($key, array_flip($this->neededKeys)) !==
false) {
209 $url = $_ENV[
'app_frontend_url'] .
'rest/all/V1/products/' .
$product->getSku();
210 $this->webApi->write(
$url, [], WebapiDecorator::GET);
211 $response = json_decode($this->webApi->read(),
true);
212 $this->webApi->close();
223 return 'Products data from CSV import file and data from product edit page are correct and match.';
getResultProductsData(array $productsData)
getDisplayedOnProductPageData(FixtureInterface $product)
retrieveProductBySku(FixtureInterface $product)
getDisplayedProductData(FixtureInterface $product)
processAssert(BrowserInterface $browser, CatalogProductEdit $catalogProductEdit, WebapiDecorator $webApi, ImportData $import)