Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Oct 27, 2024
1 parent 7a2ae70 commit 45100b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
15 changes: 4 additions & 11 deletions app/code/core/Mage/Catalog/Model/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down
18 changes: 6 additions & 12 deletions tests/unit/Mage/Catalog/Model/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,42 +87,36 @@ 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]['@']);
}

public function provideGetSluggerConfig(): Generator
{
yield 'de_DE' => [
['de_DE' => [
'@' => 'at',
'\u00a9' => 'c',
'\u00ae' => 'r',
'\u2122' => 'tm',
'%' => 'prozent',
'&' => 'und',
]],
'de_DE',
];
yield 'en_US' => [
['en_US' => [
'@' => 'at',
'\u00a9' => 'c',
'\u00ae' => 'r',
'\u2122' => 'tm',
'%' => 'percent',
'&' => 'and',
]],
'en_US',
];
yield 'fr_FR' => [
['fr_FR' => [
'@' => 'at',
'\u00a9' => 'c',
'\u00ae' => 'r',
'\u2122' => 'tm',
'%' => 'pour cent',
'&' => 'et',
]],
Expand Down

0 comments on commit 45100b8

Please sign in to comment.