20
20
21
21
namespace ILIAS \LegalDocuments \ConsumerToolbox \ConsumerSlots ;
22
22
23
+ use ILIAS \Data \URI ;
24
+ use ILIAS \Data \Result \Error ;
23
25
use ILIAS \UI \Component \Component ;
24
26
use ILIAS \LegalDocuments \Value \DocumentContent ;
25
27
use ilTemplate ;
32
34
use ILIAS \LegalDocuments \ConsumerToolbox \ConsumerSlots \ModifyFooter ;
33
35
use PHPUnit \Framework \TestCase ;
34
36
use Closure ;
37
+ use ILIAS \UI \Component \Modal \Modal ;
35
38
36
39
require_once __DIR__ . '/../../ContainerMock.php ' ;
37
40
@@ -46,41 +49,64 @@ public function testConstruct(): void
46
49
$ this ->mock (User::class),
47
50
$ this ->mock (Provide::class),
48
51
$ this ->fail (...),
49
- $ this ->fail (...)
52
+ $ this ->fail (...),
53
+ null ,
50
54
));
51
55
}
52
56
53
57
public function testInvoke (): void
54
58
{
55
- $ footer = $ this -> mock (Footer::class) ;
56
- $ footer-> expects ( self :: once ())-> method ( ' withAdditionalModalAndTrigger ' )-> willReturn ( $ footer ) ;
59
+ $ return = fn () => null ;
60
+ $ footer = fn () => $ return ;
57
61
58
62
$ instance = new ModifyFooter (
59
63
$ this ->mock (UI ::class),
60
64
$ this ->mockTree (User::class, ['acceptedVersion ' => new Ok ($ this ->mock (DocumentContent::class))]),
61
65
$ this ->mock (Provide::class),
62
66
fn () => 'rendered ' ,
63
- fn () => $ this ->mock (ilTemplate::class)
67
+ fn () => $ this ->mock (ilTemplate::class),
68
+ null ,
64
69
);
65
70
66
- $ this ->assertSame ($ footer , $ instance ($ footer ));
71
+ $ this ->assertSame ($ return , $ instance ($ footer ));
67
72
}
68
73
69
- public function testRenderModal (): void
74
+ public function testInvokeWithGotoLink (): void
70
75
{
71
- $ footer = $ this ->mock (Footer::class);
72
- $ footer ->expects (self ::once ())->method ('withAdditionalModalAndTrigger ' )->willReturn ($ footer );
76
+ $ dummy_uri = $ this ->mock (URI ::class);
77
+ $ return = fn () => null ;
78
+ $ footer = function ($ id , $ title , $ uri ) use ($ dummy_uri , $ return ) {
79
+ $ this ->assertSame ('foo ' , $ id );
80
+ $ this ->assertSame ('translated ' , $ title );
81
+ $ this ->assertSame ($ dummy_uri , $ uri );
82
+ return $ return ;
83
+ };
84
+
85
+ $ instance = new ModifyFooter (
86
+ $ this ->mockTree (UI ::class, ['txt ' => 'translated ' ]),
87
+ $ this ->mockTree (User::class, ['acceptedVersion ' => new Error ('Not found. ' ), 'isLoggedIn ' => false ]),
88
+ $ this ->mockTree (Provide::class, ['id ' => 'foo ' ]),
89
+ fn () => 'rendered ' ,
90
+ fn () => $ this ->mock (ilTemplate::class),
91
+ fn () => $ dummy_uri ,
92
+ );
93
+
94
+ $ this ->assertSame ($ return , $ instance ($ footer ));
95
+ }
73
96
97
+ public function testRenderModal (): void
98
+ {
74
99
$ instance = new ModifyFooter (
75
100
$ this ->mock (UI ::class),
76
101
$ this ->mock (User::class),
77
102
$ this ->mock (Provide::class),
78
103
fn () => 'rendered ' ,
79
- fn () => $ this ->mock (ilTemplate::class)
104
+ fn () => $ this ->mock (ilTemplate::class),
105
+ null
80
106
);
81
107
82
- $ proc = $ instance ->renderModal ($ footer );
83
- $ this ->assertSame ( $ footer , $ proc ( $ this -> mock (DocumentContent ::class)) );
108
+ $ modal = $ instance ->renderModal ($ this -> mock (DocumentContent::class) );
109
+ $ this ->assertInstanceOf (Modal ::class, $ modal );
84
110
}
85
111
86
112
public function testWithdrawalButton (): void
@@ -94,7 +120,8 @@ public function testWithdrawalButton(): void
94
120
$ this ->mock (User::class),
95
121
$ this ->mock (Provide::class),
96
122
fn () => 'rendered ' ,
97
- fn () => $ template
123
+ fn () => $ template ,
124
+ null
98
125
);
99
126
100
127
$ this ->assertInstanceOf (Component::class, $ instance ->withdrawalButton ());
0 commit comments