@@ -10,10 +10,15 @@ class HtmlTargetDecoratorTest extends TestCase
10
10
/**
11
11
* @dataProvider dataProviderTestUrl
12
12
*/
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
14
14
{
15
15
$ 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
+ }
17
22
$ result = HtmlTargetDecorator::url ($ target , $ context , $ input );
18
23
$ this ->assertEquals ($ expected , $ result );
19
24
}
@@ -22,35 +27,47 @@ public function dataProviderTestUrl()
22
27
{
23
28
return [
24
29
'target-context-class ' => [
30
+ true ,
25
31
'Magento\Framework\Registry ' ,
26
32
'class ' ,
27
33
'[{"reportTypes": ["interface", "class"], "url": "https://localhost/?target=%s"}] ' ,
28
34
'<a href="https://localhost/?target=TWFnZW50b1xGcmFtZXdvcmtcUmVnaXN0cnk=" target="_blank">Magento\Framework\Registry</a> '
29
35
],
30
36
'target-context-class-array ' => [
37
+ true ,
31
38
'Magento\Framework\Registry ' ,
32
39
'class ' ,
33
40
'[{"reportTypes": ["mftf"], "url": "https://localhost/?target=%s"}, {"reportTypes": ["class"], "url": "https://localhost/?target=%s"}] ' ,
34
41
'<a href="https://localhost/?target=TWFnZW50b1xGcmFtZXdvcmtcUmVnaXN0cnk=" target="_blank">Magento\Framework\Registry</a> '
35
42
],
36
43
'target-context-mftf ' => [
44
+ true ,
37
45
'Magento\Framework\Registry ' ,
38
46
'mftf ' ,
39
47
'[{"reportTypes": ["interface", "class"], "url": "https://localhost/?target=%s"}] ' ,
40
48
'Magento\Framework\Registry '
41
49
],
42
50
'empty-json ' => [
43
- 'Magento\Framework\Registry ' ,
51
+ true ,
52
+ 'Magento\Framework\Registry::$someProperty ' ,
44
53
'class ' ,
45
54
'' ,
46
- 'Magento\Framework\Registry '
55
+ 'Magento\Framework\Registry::$someProperty '
47
56
],
48
57
'broken-json ' => [
58
+ true ,
49
59
'Magento\Framework\Registry ' ,
50
60
'class ' ,
51
61
'[{"reportTypes": ["interface", "class"] ' ,
52
62
'Magento\Framework\Registry '
53
63
],
64
+ 'has-no-option ' => [
65
+ false ,
66
+ 'Magento\Framework\Registry ' ,
67
+ 'class ' ,
68
+ '' ,
69
+ 'Magento\Framework\Registry '
70
+ ],
54
71
];
55
72
}
56
73
}
0 commit comments