Skip to content

Commit 7e6d2c5

Browse files
committed
MAGETWO-31764: Function _underscore didn't work with keys like SKeyName ('s_key_name')
1 parent 6e74547 commit 7e6d2c5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

dev/tests/unit/testsuite/Magento/Framework/ObjectTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,11 @@ public function underscoreDataProvider()
453453
return [
454454
'Test 1' => ['Stone1Color', 'stone_1_color'],
455455
'Test 2' => ['StoneColor', 'stone_color'],
456-
'Test 3' => ['StoneToXML', 'stone_to_xml'],
456+
'Test 3' => ['StoneToXml', 'stone_to_xml'],
457457
'Test 4' => ['1StoneColor', '1_stone_color'],
458458
'Test 5' => ['getCcLast4', 'get_cc_last_4'],
459-
'Test 6' => ['99Bottles', '99_bottles']
459+
'Test 6' => ['99Bottles', '99_bottles'],
460+
'Test 7' => ['XApiLogin', 'x_api_login']
460461
];
461462
}
462463
}

lib/internal/Magento/Framework/Object.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ protected function _underscore($name)
544544
if (isset(self::$_underscoreCache[$name])) {
545545
return self::$_underscoreCache[$name];
546546
}
547-
$result = strtolower(trim(preg_replace('/([A-Z]+|[0-9]+)/', "_$1", $name), '_'));
547+
$result = strtolower(trim(preg_replace('/([A-Z]|[0-9]+)/', "_$1", $name), '_'));
548548
self::$_underscoreCache[$name] = $result;
549549
return $result;
550550
}

0 commit comments

Comments
 (0)