@@ -68,23 +68,17 @@ public function setUp() {
6868 ->disableOriginalConstructor ()->getMock ();
6969 $ this ->dateTimeFormatter = $ this ->getMock ('\\OCP \\IDateTimeFormatter ' );
7070
71- $ this ->adminController = $ this ->getMockBuilder ('\OCA\UpdateNotification\Controller\AdminController ' )
72- ->setConstructorArgs (
73- [
74- 'updatenotification ' ,
75- $ this ->request ,
76- $ this ->jobList ,
77- $ this ->secureRandom ,
78- $ this ->config ,
79- $ this ->timeFactory ,
80- $ this ->l10n ,
81- $ this ->updateChecker ,
82- $ this ->dateTimeFormatter ,
83- ]
84- )
85- ->setMethods (['isCompatibleWithUpdater ' ])
86- ->getMock ()
87- ;
71+ $ this ->adminController = new AdminController (
72+ 'updatenotification ' ,
73+ $ this ->request ,
74+ $ this ->jobList ,
75+ $ this ->secureRandom ,
76+ $ this ->config ,
77+ $ this ->timeFactory ,
78+ $ this ->l10n ,
79+ $ this ->updateChecker ,
80+ $ this ->dateTimeFormatter
81+ );
8882 }
8983
9084 public function testDisplayPanelWithUpdate () {
@@ -115,69 +109,13 @@ public function testDisplayPanelWithUpdate() {
115109 ->expects ($ this ->once ())
116110 ->method ('getUpdateState ' )
117111 ->willReturn (['updateVersion ' => '8.1.2 ' ]);
118- $ this ->adminController
119- ->expects ($ this ->once ())
120- ->method ('isCompatibleWithUpdater ' )
121- ->willReturn (true );
122-
123- $ params = [
124- 'isNewVersionAvailable ' => true ,
125- 'lastChecked ' => 'LastCheckedReturnValue ' ,
126- 'currentChannel ' => \OCP \Util::getChannel (),
127- 'channels ' => $ channels ,
128- 'newVersionString ' => '8.1.2 ' ,
129- 'updaterRequirementsFulfilled ' => true ,
130- 'downloadLink ' => '' ,
131- ];
132-
133- $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
134- $ this ->assertEquals ($ expected , $ this ->adminController ->displayPanel ());
135- }
136-
137- public function testDisplayPanelWithUpdateAndIncompatibleUpdaterApp () {
138- $ channels = [
139- 'daily ' ,
140- 'beta ' ,
141- 'stable ' ,
142- 'production ' ,
143- ];
144- $ currentChannel = \OCP \Util::getChannel ();
145-
146- // Remove the currently used channel from the channels list
147- if (($ key = array_search ($ currentChannel , $ channels )) !== false ) {
148- unset($ channels [$ key ]);
149- }
150-
151- $ this ->config
152- ->expects ($ this ->once ())
153- ->method ('getAppValue ' )
154- ->with ('core ' , 'lastupdatedat ' )
155- ->willReturn ('12345 ' );
156- $ this ->dateTimeFormatter
157- ->expects ($ this ->once ())
158- ->method ('formatDateTime ' )
159- ->with ('12345 ' )
160- ->willReturn ('LastCheckedReturnValue ' );
161- $ this ->updateChecker
162- ->expects ($ this ->once ())
163- ->method ('getUpdateState ' )
164- ->willReturn ([
165- 'updateVersion ' => '8.1.2 ' ,
166- 'downloadLink ' => 'https://downloads.nextcloud.org/server ' ,
167- ]);
168- $ this ->adminController
169- ->expects ($ this ->once ())
170- ->method ('isCompatibleWithUpdater ' )
171- ->willReturn (false );
172112
173113 $ params = [
174114 'isNewVersionAvailable ' => true ,
175115 'lastChecked ' => 'LastCheckedReturnValue ' ,
176116 'currentChannel ' => \OCP \Util::getChannel (),
177117 'channels ' => $ channels ,
178118 'newVersionString ' => '8.1.2 ' ,
179- 'updaterRequirementsFulfilled ' => false ,
180- 'downloadLink ' => 'https://downloads.nextcloud.org/server ' ,
181119 ];
182120
183121 $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
@@ -212,19 +150,13 @@ public function testDisplayPanelWithoutUpdate() {
212150 ->expects ($ this ->once ())
213151 ->method ('getUpdateState ' )
214152 ->willReturn ([]);
215- $ this ->adminController
216- ->expects ($ this ->once ())
217- ->method ('isCompatibleWithUpdater ' )
218- ->willReturn (true );
219153
220154 $ params = [
221155 'isNewVersionAvailable ' => false ,
222156 'lastChecked ' => 'LastCheckedReturnValue ' ,
223157 'currentChannel ' => \OCP \Util::getChannel (),
224158 'channels ' => $ channels ,
225159 'newVersionString ' => '' ,
226- 'updaterRequirementsFulfilled ' => true ,
227- 'downloadLink ' => '' ,
228160 ];
229161
230162 $ expected = new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
0 commit comments