|
9 | 9 | namespace Magento\CatalogImportExport\Model\Export;
|
10 | 10 |
|
11 | 11 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
| 12 | +use Magento\Catalog\Api\CategoryRepositoryInterface; |
12 | 13 | use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as ProductAttributeCollection;
|
13 | 14 | use Magento\Catalog\Observer\SwitchPriceAttributeScopeOnConfigChange;
|
| 15 | +use Magento\Catalog\Test\Fixture\Category as CategoryFixture; |
| 16 | +use Magento\Catalog\Test\Fixture\Product as ProductFixture; |
14 | 17 | use Magento\CatalogImportExport\Model\Export\Product\Type\Simple as SimpleProductType;
|
15 | 18 | use Magento\CatalogInventory\Api\StockConfigurationInterface;
|
16 | 19 | use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
|
17 | 20 | use Magento\CatalogInventory\Model\Stock\Item;
|
18 | 21 | use Magento\Framework\App\Config\ReinitableConfigInterface;
|
| 22 | +use Magento\Store\Model\StoreManagerInterface; |
| 23 | +use Magento\Store\Test\Fixture\Store as StoreFixture; |
| 24 | +use Magento\TestFramework\Fixture\DataFixture; |
| 25 | +use Magento\TestFramework\Fixture\DataFixtureStorage; |
| 26 | +use Magento\TestFramework\Fixture\DataFixtureStorageManager; |
| 27 | +use Magento\TestFramework\Fixture\DbIsolation; |
19 | 28 |
|
20 | 29 | /**
|
21 | 30 | * @magentoDataFixtureBeforeTransaction Magento/Catalog/_files/enable_reindex_schedule.php
|
@@ -46,6 +55,21 @@ class ProductTest extends \PHPUnit\Framework\TestCase
|
46 | 55 | */
|
47 | 56 | private $productRepository;
|
48 | 57 |
|
| 58 | + /** |
| 59 | + * @var CategoryRepositoryInterface |
| 60 | + */ |
| 61 | + private $categoryRepository; |
| 62 | + |
| 63 | + /** |
| 64 | + * @var StoreManagerInterface |
| 65 | + */ |
| 66 | + private $storeManager; |
| 67 | + |
| 68 | + /** |
| 69 | + * @var DataFixtureStorage |
| 70 | + */ |
| 71 | + private $fixtures; |
| 72 | + |
49 | 73 | /**
|
50 | 74 | * @var array
|
51 | 75 | */
|
@@ -82,6 +106,9 @@ protected function setUp(): void
|
82 | 106 | \Magento\CatalogImportExport\Model\Export\Product::class
|
83 | 107 | );
|
84 | 108 | $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
|
| 109 | + $this->categoryRepository = $this->objectManager->create(CategoryRepositoryInterface::class); |
| 110 | + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); |
| 111 | + $this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage(); |
85 | 112 | }
|
86 | 113 |
|
87 | 114 | /**
|
@@ -789,4 +816,29 @@ private function doExport(array $filters = []): string
|
789 | 816 | );
|
790 | 817 | return $this->model->export();
|
791 | 818 | }
|
| 819 | + |
| 820 | + #[ |
| 821 | + DbIsolation(true), |
| 822 | + DataFixture(StoreFixture::class, as: 'store2'), |
| 823 | + DataFixture(CategoryFixture::class, as: 'c1'), |
| 824 | + DataFixture(ProductFixture::class, ['category_ids' => ['$c1.id$']], 'p1'), |
| 825 | + ] |
| 826 | + public function testExportCategoryPathHasAdminScopeNames(): void |
| 827 | + { |
| 828 | + $secondStoreId = $this->fixtures->get('store2')->getId(); |
| 829 | + $categoryId = $this->fixtures->get('c1')->getId(); |
| 830 | + $oldStoreId = $this->storeManager->getStore()->getId(); |
| 831 | + $this->storeManager->setCurrentStore($secondStoreId); |
| 832 | + $category = $this->categoryRepository->get($categoryId, $secondStoreId); |
| 833 | + $category->setName('NewCategoryName'); |
| 834 | + $this->categoryRepository->save($category); |
| 835 | + $this->storeManager->setCurrentStore($oldStoreId); |
| 836 | + $this->model->setWriter( |
| 837 | + $this->objectManager->create( |
| 838 | + \Magento\ImportExport\Model\Export\Adapter\Csv::class |
| 839 | + ) |
| 840 | + ); |
| 841 | + $exportData = $this->model->export(); |
| 842 | + $this->assertStringNotContainsString('NewCategoryName', $exportData); |
| 843 | + } |
792 | 844 | }
|
0 commit comments