@@ -67,17 +67,23 @@ public function setUp() {
6767 ->disableOriginalConstructor ()->getMock ();
6868 $ this ->dateTimeFormatter = $ this ->getMock ('\\OCP \\IDateTimeFormatter ' );
6969
70- $ this ->adminController = new AdminController (
71- 'updatenotification ' ,
72- $ this ->request ,
73- $ this ->jobList ,
74- $ this ->secureRandom ,
75- $ this ->config ,
76- $ this ->timeFactory ,
77- $ this ->l10n ,
78- $ this ->updateChecker ,
79- $ this ->dateTimeFormatter
80- );
70+ $ this ->adminController = $ this ->getMockBuilder ('\OCA\UpdateNotification\Controller\AdminController ' )
71+ ->setConstructorArgs (
72+ [
73+ 'updatenotification ' ,
74+ $ this ->request ,
75+ $ this ->jobList ,
76+ $ this ->secureRandom ,
77+ $ this ->config ,
78+ $ this ->timeFactory ,
79+ $ this ->l10n ,
80+ $ this ->updateChecker ,
81+ $ this ->dateTimeFormatter ,
82+ ]
83+ )
84+ ->setMethods (['isCompatibleWithUpdater ' ])
85+ ->getMock ()
86+ ;
8187 }
8288
8389 public function testDisplayPanelWithUpdate () {
@@ -108,13 +114,64 @@ public function testDisplayPanelWithUpdate() {
108114 ->expects ($ this ->once ())
109115 ->method ('getUpdateState ' )
110116 ->willReturn (['updateVersion ' => '8.1.2 ' ]);
117+ $ this ->adminController
118+ ->expects ($ this ->once ())
119+ ->method ('isCompatibleWithUpdater ' )
120+ ->willReturn (true );
111121
112122 $ params = [
113123 'isNewVersionAvailable ' => true ,
114124 'lastChecked ' => 'LastCheckedReturnValue ' ,
115125 'currentChannel ' => \OCP \Util::getChannel (),
116126 'channels ' => $ channels ,
117127 'newVersionString ' => '8.1.2 ' ,
128+ 'updaterRequirementsFulfilled ' => true ,
129+ ];
130+
131+ $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
132+ $ this ->assertEquals ($ expected , $ this ->adminController ->displayPanel ());
133+ }
134+
135+ public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp () {
136+ $ channels = [
137+ 'daily ' ,
138+ 'beta ' ,
139+ 'stable ' ,
140+ 'production ' ,
141+ ];
142+ $ currentChannel = \OCP \Util::getChannel ();
143+
144+ // Remove the currently used channel from the channels list
145+ if (($ key = array_search ($ currentChannel , $ channels )) !== false ) {
146+ unset($ channels [$ key ]);
147+ }
148+
149+ $ this ->config
150+ ->expects ($ this ->once ())
151+ ->method ('getAppValue ' )
152+ ->with ('core ' , 'lastupdatedat ' )
153+ ->willReturn ('12345 ' );
154+ $ this ->dateTimeFormatter
155+ ->expects ($ this ->once ())
156+ ->method ('formatDateTime ' )
157+ ->with ('12345 ' )
158+ ->willReturn ('LastCheckedReturnValue ' );
159+ $ this ->updateChecker
160+ ->expects ($ this ->once ())
161+ ->method ('getUpdateState ' )
162+ ->willReturn (['updateVersion ' => '8.1.2 ' ]);
163+ $ this ->adminController
164+ ->expects ($ this ->once ())
165+ ->method ('isCompatibleWithUpdater ' )
166+ ->willReturn (false );
167+
168+ $ params = [
169+ 'isNewVersionAvailable ' => true ,
170+ 'lastChecked ' => 'LastCheckedReturnValue ' ,
171+ 'currentChannel ' => \OCP \Util::getChannel (),
172+ 'channels ' => $ channels ,
173+ 'newVersionString ' => '8.1.2 ' ,
174+ 'updaterRequirementsFulfilled ' => false ,
118175 ];
119176
120177 $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
@@ -149,13 +206,18 @@ public function testDisplayPanelWithoutUpdate() {
149206 ->expects ($ this ->once ())
150207 ->method ('getUpdateState ' )
151208 ->willReturn ([]);
209+ $ this ->adminController
210+ ->expects ($ this ->once ())
211+ ->method ('isCompatibleWithUpdater ' )
212+ ->willReturn (true );
152213
153214 $ params = [
154215 'isNewVersionAvailable ' => false ,
155216 'lastChecked ' => 'LastCheckedReturnValue ' ,
156217 'currentChannel ' => \OCP \Util::getChannel (),
157218 'channels ' => $ channels ,
158219 'newVersionString ' => '' ,
220+ 'updaterRequirementsFulfilled ' => true ,
159221 ];
160222
161223 $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
0 commit comments