7
7
8
8
namespace Magento \CurrencySymbol \Test \Unit \Block \Adminhtml \System ;
9
9
10
+ use Magento \Backend \Block \Template \Context ;
10
11
use Magento \Backend \Block \Widget \Button ;
11
12
use Magento \CurrencySymbol \Block \Adminhtml \System \Currency ;
12
13
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
13
14
use Magento \Framework \View \Element \BlockInterface ;
14
15
use Magento \Framework \View \LayoutInterface ;
15
16
use PHPUnit \Framework \TestCase ;
17
+ use Magento \Framework \UrlInterface ;
16
18
17
19
class CurrencyTest extends TestCase
18
20
{
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
+
19
26
/**
20
27
* Object manager helper
21
28
*
@@ -70,12 +77,25 @@ public function testPrepareLayout()
70
77
]
71
78
);
72
79
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
+
73
93
$ childBlockMock ->expects ($ this ->at (1 ))
74
94
->method ('addChild ' )
75
95
->with (
76
96
'options_button ' ,
77
97
Button::class,
78
- ['label ' => __ ('Options ' ), 'onclick ' => 'setLocation( \'\') ' ]
98
+ ['label ' => __ ('Options ' ), 'onclick ' => 'setLocation( \'' . self :: STUB_OPTION_LINK_URL . ' \') ' ]
79
99
);
80
100
81
101
$ childBlockMock ->expects ($ this ->at (2 ))
@@ -90,7 +110,8 @@ public function testPrepareLayout()
90
110
$ block = $ this ->objectManagerHelper ->getObject (
91
111
Currency::class,
92
112
[
93
- 'layout ' => $ layoutMock
113
+ 'layout ' => $ layoutMock ,
114
+ 'context ' => $ contextMock
94
115
]
95
116
);
96
117
$ block ->setLayout ($ layoutMock );
0 commit comments