Skip to content

Commit 2d15e91

Browse files
committed
#27044 Integration Test to cover described case (loading with $storeId) attribute
1 parent 24c2169 commit 2d15e91

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
use Magento\Catalog\Api\CategoryRepositoryInterface;
1111
use Magento\Catalog\Api\CategoryRepositoryInterfaceFactory;
12-
use Magento\Framework\Exception\LocalizedException;
13-
use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
1412
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
1513
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
14+
use Magento\Framework\Exception\LocalizedException;
15+
use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
1616
use Magento\TestFramework\Helper\Bootstrap;
1717
use PHPUnit\Framework\TestCase;
1818

@@ -21,6 +21,11 @@
2121
*/
2222
class CategoryRepositoryTest extends TestCase
2323
{
24+
private const FIXTURE_CATEGORY_ID = 333;
25+
private const FIXTURE_TWO_STORES_CATEGORY_ID = 555;
26+
private const FIXTURE_SECOND_STORE_CODE = 'fixturestore';
27+
private const FIXTURE_FIRST_STORE_CODE = 'default';
28+
2429
/**
2530
* @var CategoryLayoutUpdateManager
2631
*/
@@ -77,13 +82,13 @@ public function testCustomLayout(): void
7782
{
7883
//New valid value
7984
$repo = $this->createRepo();
80-
$category = $repo->get(333);
85+
$category = $repo->get(self::FIXTURE_CATEGORY_ID);
8186
$newFile = 'test';
82-
$this->layoutManager->setCategoryFakeFiles(333, [$newFile]);
87+
$this->layoutManager->setCategoryFakeFiles(self::FIXTURE_CATEGORY_ID, [$newFile]);
8388
$category->setCustomAttribute('custom_layout_update_file', $newFile);
8489
$repo->save($category);
8590
$repo = $this->createRepo();
86-
$category = $repo->get(333);
91+
$category = $repo->get(self::FIXTURE_CATEGORY_ID);
8792
$this->assertEquals($newFile, $category->getCustomAttribute('custom_layout_update_file')->getValue());
8893

8994
//Setting non-existent value
@@ -126,4 +131,30 @@ public function testCategoryBehaviourAfterDelete(): void
126131
'Wrong categories was deleted'
127132
);
128133
}
134+
135+
/**
136+
* Verifies whether `get()` method `$storeId` attribute works as expected.
137+
*
138+
* @magentoDbIsolation enabled
139+
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
140+
* @magentoDataFixture Magento/Catalog/_files/category_with_two_stores.php
141+
*/
142+
public function testGetCategoryForProvidedStore()
143+
{
144+
$categoryRepository = $this->repositoryFactory->create();
145+
146+
$categoryFirstStore = $categoryRepository->get(
147+
self::FIXTURE_TWO_STORES_CATEGORY_ID,
148+
self::FIXTURE_FIRST_STORE_CODE
149+
);
150+
151+
$this->assertSame('category-defaultstore', $categoryFirstStore->getUrlKey());
152+
153+
$categorySecondStore = $categoryRepository->get(
154+
self::FIXTURE_TWO_STORES_CATEGORY_ID,
155+
self::FIXTURE_SECOND_STORE_CODE
156+
);
157+
158+
$this->assertSame('category-fixturestore', $categorySecondStore->getUrlKey());
159+
}
129160
}

0 commit comments

Comments
 (0)