@@ -10,10 +10,15 @@ class HtmlTargetDecoratorTest extends TestCase
1010 /**
1111 * @dataProvider dataProviderTestUrl
1212 */
13- public function testUrl (string $ target , string $ context , string $ urlJson , string $ expected ): void
13+ public function testUrl (bool $ hasOption , string $ target , string $ context , string $ urlJson , string $ expected ): void
1414 {
1515 $ input = $ this ->getMockBuilder (InputInterface::class)->getMockForAbstractClass ();
16- $ input ->expects ($ this ->once ())->method ('getOption ' )->with ('report-html-target-url ' )->willReturn ($ urlJson );
16+ $ input ->expects ($ this ->once ())->method ('hasOption ' )->with ('report-html-target-url ' )->willReturn ($ hasOption );
17+ if ($ hasOption ) {
18+ $ input ->expects ($ this ->once ())->method ('getOption ' )->with ('report-html-target-url ' )->willReturn ($ urlJson );
19+ } else {
20+ $ input ->expects ($ this ->never ())->method ('getOption ' );
21+ }
1722 $ result = HtmlTargetDecorator::url ($ target , $ context , $ input );
1823 $ this ->assertEquals ($ expected , $ result );
1924 }
@@ -22,35 +27,47 @@ public function dataProviderTestUrl()
2227 {
2328 return [
2429 'target-context-class ' => [
30+ true ,
2531 'Magento\Framework\Registry ' ,
2632 'class ' ,
2733 '[{"reportTypes": ["interface", "class"], "url": "https://localhost/?target=%s"}] ' ,
2834 '<a href="https://localhost/?target=TWFnZW50b1xGcmFtZXdvcmtcUmVnaXN0cnk=" target="_blank">Magento\Framework\Registry</a> '
2935 ],
3036 'target-context-class-array ' => [
37+ true ,
3138 'Magento\Framework\Registry ' ,
3239 'class ' ,
3340 '[{"reportTypes": ["mftf"], "url": "https://localhost/?target=%s"}, {"reportTypes": ["class"], "url": "https://localhost/?target=%s"}] ' ,
3441 '<a href="https://localhost/?target=TWFnZW50b1xGcmFtZXdvcmtcUmVnaXN0cnk=" target="_blank">Magento\Framework\Registry</a> '
3542 ],
3643 'target-context-mftf ' => [
44+ true ,
3745 'Magento\Framework\Registry ' ,
3846 'mftf ' ,
3947 '[{"reportTypes": ["interface", "class"], "url": "https://localhost/?target=%s"}] ' ,
4048 'Magento\Framework\Registry '
4149 ],
4250 'empty-json ' => [
43- 'Magento\Framework\Registry ' ,
51+ true ,
52+ 'Magento\Framework\Registry::$someProperty ' ,
4453 'class ' ,
4554 '' ,
46- 'Magento\Framework\Registry '
55+ 'Magento\Framework\Registry::$someProperty '
4756 ],
4857 'broken-json ' => [
58+ true ,
4959 'Magento\Framework\Registry ' ,
5060 'class ' ,
5161 '[{"reportTypes": ["interface", "class"] ' ,
5262 'Magento\Framework\Registry '
5363 ],
64+ 'has-no-option ' => [
65+ false ,
66+ 'Magento\Framework\Registry ' ,
67+ 'class ' ,
68+ '' ,
69+ 'Magento\Framework\Registry '
70+ ],
5471 ];
5572 }
5673}
0 commit comments