From 45100b8ae0b376c7acf37073d17ca2ec1c9c0aed Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Sun, 27 Oct 2024 18:45:00 +0100 Subject: [PATCH] cleanup --- app/code/core/Mage/Catalog/Model/Url.php | 15 ++++----------- tests/unit/Mage/Catalog/Model/UrlTest.php | 18 ++++++------------ 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/app/code/core/Mage/Catalog/Model/Url.php b/app/code/core/Mage/Catalog/Model/Url.php index 20cf0daf437..eaa6a5a2462 100644 --- a/app/code/core/Mage/Catalog/Model/Url.php +++ b/app/code/core/Mage/Catalog/Model/Url.php @@ -1060,26 +1060,19 @@ public function getSlugger(): AsciiSlugger final public function getSluggerConfig(?string $locale): array { - $config = [ - '@' => 'at', - '\u00a9' => 'c', - '\u00ae' => 'r', - '\u2122' => 'tm' - ]; - - $config += Mage::helper('catalog/product_url')->getConvertTable(); + $config = Mage::helper('catalog/product_url')->getConvertTable(); if ($locale) { $convertNode = Mage::getConfig()->getNode('default/url/convert/' . $locale); if ($convertNode instanceof Mage_Core_Model_Config_Element) { - $custom = []; + $localeConfig = []; /** @var Mage_Core_Model_Config_Element $node */ foreach ($convertNode->children() as $node) { if (property_exists($node, 'from') && property_exists($node, 'to')) { - $custom[(string) $node->from] = (string) $node->to; + $localeConfig[(string) $node->from] = (string) $node->to; } } - $config = [$locale => $config + $custom]; + $config = [$locale => $config + $localeConfig]; } } diff --git a/tests/unit/Mage/Catalog/Model/UrlTest.php b/tests/unit/Mage/Catalog/Model/UrlTest.php index ca8e699e571..46f969d4721 100644 --- a/tests/unit/Mage/Catalog/Model/UrlTest.php +++ b/tests/unit/Mage/Catalog/Model/UrlTest.php @@ -87,9 +87,15 @@ public function testGetSlugger(): void public function testGetSluggerConfig($expectedResult, string $locale): void { $result = $this->subject->getSluggerConfig($locale); + $this->assertArrayHasKey($locale, $result); + $this->assertArrayHasKey('%', $result[$locale]); $this->assertArrayHasKey('&', $result[$locale]); + + $this->assertSame($expectedResult[$locale]['%'], $result[$locale]['%']); + $this->assertSame($expectedResult[$locale]['&'], $result[$locale]['&']); + $this->assertSame('at', $result[$locale]['@']); } @@ -97,10 +103,6 @@ public function provideGetSluggerConfig(): Generator { yield 'de_DE' => [ ['de_DE' => [ - '@' => 'at', - '\u00a9' => 'c', - '\u00ae' => 'r', - '\u2122' => 'tm', '%' => 'prozent', '&' => 'und', ]], @@ -108,10 +110,6 @@ public function provideGetSluggerConfig(): Generator ]; yield 'en_US' => [ ['en_US' => [ - '@' => 'at', - '\u00a9' => 'c', - '\u00ae' => 'r', - '\u2122' => 'tm', '%' => 'percent', '&' => 'and', ]], @@ -119,10 +117,6 @@ public function provideGetSluggerConfig(): Generator ]; yield 'fr_FR' => [ ['fr_FR' => [ - '@' => 'at', - '\u00a9' => 'c', - '\u00ae' => 'r', - '\u2122' => 'tm', '%' => 'pour cent', '&' => 'et', ]],