Skip to content

Commit 37e5e15

Browse files
committed
Redirect to "Currency Option Path" more accurate
1 parent 3008324 commit 37e5e15

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

app/code/Magento/CurrencySymbol/Block/Adminhtml/System/Currency.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ protected function _prepareLayout()
4141
]
4242
);
4343

44-
$onClick = "setLocation('" . $this->getUrl('adminhtml/system_config/edit/section/currency') . "')";
44+
$currencyOptionPath = $this->getUrl(
45+
'adminhtml/system_config/edit',
46+
[
47+
'section' => 'currency',
48+
'_fragment' => 'currency_options-link'
49+
]
50+
);
51+
$onClick = "setLocation('" . $currencyOptionPath . "')";
4552

4653
$this->getToolbar()->addChild(
4754
'options_button',

app/code/Magento/CurrencySymbol/Test/Unit/Block/Adminhtml/System/CurrencyTest.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@
77

88
namespace Magento\CurrencySymbol\Test\Unit\Block\Adminhtml\System;
99

10+
use Magento\Backend\Block\Template\Context;
1011
use Magento\Backend\Block\Widget\Button;
1112
use Magento\CurrencySymbol\Block\Adminhtml\System\Currency;
1213
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1314
use Magento\Framework\View\Element\BlockInterface;
1415
use Magento\Framework\View\LayoutInterface;
1516
use PHPUnit\Framework\TestCase;
17+
use Magento\Framework\UrlInterface;
1618

1719
class CurrencyTest extends TestCase
1820
{
21+
/**
22+
* Stub currency option link url
23+
*/
24+
const STUB_OPTION_LINK_URL = 'https://localhost/admin/system_config/edit/section/currency#currency_options-link';
25+
1926
/**
2027
* Object manager helper
2128
*
@@ -70,12 +77,25 @@ public function testPrepareLayout()
7077
]
7178
);
7279

80+
$contextMock = $this->createMock(Context::class);
81+
$urlBuilderMock = $this->createMock(UrlInterface::class);
82+
83+
$contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilderMock);
84+
85+
$urlBuilderMock->expects($this->once())->method('getUrl')->with(
86+
'adminhtml/system_config/edit',
87+
[
88+
'section' => 'currency',
89+
'_fragment' => 'currency_options-link'
90+
]
91+
)->willReturn(self::STUB_OPTION_LINK_URL);
92+
7393
$childBlockMock->expects($this->at(1))
7494
->method('addChild')
7595
->with(
7696
'options_button',
7797
Button::class,
78-
['label' => __('Options'), 'onclick' => 'setLocation(\'\')']
98+
['label' => __('Options'), 'onclick' => 'setLocation(\''.self::STUB_OPTION_LINK_URL.'\')']
7999
);
80100

81101
$childBlockMock->expects($this->at(2))
@@ -90,7 +110,8 @@ public function testPrepareLayout()
90110
$block = $this->objectManagerHelper->getObject(
91111
Currency::class,
92112
[
93-
'layout' => $layoutMock
113+
'layout' => $layoutMock,
114+
'context' => $contextMock
94115
]
95116
);
96117
$block->setLayout($layoutMock);

0 commit comments

Comments
 (0)