Skip to content

Commit f86d2d7

Browse files
committed
ACP2E-2481: Category Canonical URLs not working
1 parent 1b50085 commit f86d2d7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
use Magento\Catalog\Model\ResourceModel\Category\Collection;
1515
use Magento\Catalog\Model\ResourceModel\Category\Tree;
1616
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
17+
use Magento\Catalog\Test\Fixture\Category as CategoryFixture;
1718
use Magento\Eav\Model\Entity\Attribute\Exception as AttributeException;
19+
use Magento\Framework\Exception\LocalizedException;
1820
use Magento\Framework\Exception\NoSuchEntityException;
1921
use Magento\Framework\Math\Random;
2022
use Magento\Framework\Url;
2123
use Magento\Store\Api\StoreRepositoryInterface;
2224
use Magento\Store\Model\Store;
2325
use Magento\Store\Model\StoreManagerInterface;
26+
use Magento\TestFramework\Fixture\DataFixture;
27+
use Magento\TestFramework\Fixture\DataFixtureStorage;
28+
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
2429
use Magento\TestFramework\Helper\Bootstrap;
2530
use PHPUnit\Framework\TestCase;
2631

@@ -57,6 +62,11 @@ class CategoryTest extends TestCase
5762
/** @var CategoryRepositoryInterface */
5863
private $categoryRepository;
5964

65+
/**
66+
* @var DataFixtureStorage
67+
*/
68+
private DataFixtureStorage $dataFixtureStorage;
69+
6070
/**
6171
* @inheritdoc
6272
*/
@@ -69,6 +79,7 @@ protected function setUp(): void
6979
$this->_model = $this->objectManager->create(Category::class);
7080
$this->categoryResource = $this->objectManager->get(CategoryResource::class);
7181
$this->categoryRepository = $this->objectManager->get(CategoryRepositoryInterface::class);
82+
$this->dataFixtureStorage = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
7283
}
7384

7485
public function testGetUrlInstance(): void
@@ -509,4 +520,20 @@ protected function getCategoryByName($categoryName)
509520

510521
return $collection->getItemByColumnValue('name', $categoryName);
511522
}
523+
524+
/**
525+
* @return void
526+
* @throws LocalizedException|\Exception
527+
*/
528+
#[
529+
DataFixture(CategoryFixture::class, as: 'category'),
530+
]
531+
public function testGetUrlAfterUpdate() {
532+
$category = $this->dataFixtureStorage->get('category');
533+
$category->setUrlKey('new-url');
534+
$category->setSaveRewritesHistory(true);
535+
$this->categoryResource->save($category);
536+
537+
$this->assertStringEndsWith('new-url.html', $category->getUrl());
538+
}
512539
}

0 commit comments

Comments
 (0)