@@ -204,7 +204,7 @@ public function theCliUpdaterIsRun() {
204204 copy ($ this ->buildDir . 'updater.phar ' , $ this ->serverDir . 'nextcloud/updater/updater ' );
205205 chdir ($ this ->serverDir . 'nextcloud/updater ' );
206206 chmod ($ this ->serverDir . 'nextcloud/updater/updater ' , 0755 );
207- exec ('./updater -n ' , $ output , $ returnCode );
207+ exec ('./updater -n 2>&1 ' , $ output , $ returnCode );
208208
209209 // sleep to let the opcache do it's work and invalidate the status.php
210210 sleep (5 );
@@ -564,4 +564,54 @@ public function thereIsAConfigForASecondaryAppsDirectoryCalled($name) {
564564 public function phpIsAtLeastInVersion ($ version ) {
565565 $ this ->skipIt = in_array (version_compare ($ version , PHP_VERSION , '< ' ), [0 , false ], true );
566566 }
567+
568+ /**
569+ * @Given the update server returns HTTP status :statusCode
570+ */
571+ public function theUpdateServerReturnsHttpStatus (int $ statusCode ) {
572+ if ($ this ->skipIt ) {
573+ return ;
574+ }
575+
576+ $ this ->runUpdateServer ();
577+
578+ $ content = '<?php http_response_code( ' . $ statusCode . '); echo "Server Error"; ' ;
579+ file_put_contents ($ this ->updateServerDir . 'index.php ' , $ content );
580+ }
581+
582+ /**
583+ * @Given the update server returns invalid XML
584+ */
585+ public function theUpdateServerReturnsInvalidXml () {
586+ if ($ this ->skipIt ) {
587+ return ;
588+ }
589+
590+ $ this ->runUpdateServer ();
591+
592+ $ content = '<?php header("Content-Type: application/xml"); echo "this is not valid xml <><><"; ' ;
593+ file_put_contents ($ this ->updateServerDir . 'index.php ' , $ content );
594+ }
595+
596+ /**
597+ * @Given the update server is unreachable
598+ */
599+ public function theUpdateServerIsUnreachable () {
600+ if ($ this ->skipIt ) {
601+ return ;
602+ }
603+
604+ // Point updater.server.url at a port with nothing listening
605+ $ configFile = $ this ->serverDir . 'nextcloud/config/config.php ' ;
606+ $ content = file_get_contents ($ configFile );
607+ $ content = preg_replace (
608+ '!\$CONFIG\s*=\s*array\s*\(! ' ,
609+ "\$CONFIG = array( \n 'updater.server.url' => 'http://localhost:8871/', " ,
610+ $ content
611+ );
612+ file_put_contents ($ configFile , $ content );
613+
614+ // Intentionally do NOT start any server on port 8871
615+ }
567616}
617+
0 commit comments