[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Test runner was exiting before finishing tests

Benoit GrĂ©goire (@benoitg) via TikiWiki-cvs <[email protected]> Wed, 08 Jul 2026 21:14:48 +0000
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a4ebdc8984b1_3919ba90596a@gitlab-sidekiq-low-urgency-cpu-bound-v2-5bcd6ccdbf-b4lt5.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
2201cbb4 by Luis Fagundes at 2026-07-08T20:56:33+00:00
[FIX] Test runner was exiting before finishing tests
---
* [FIX] tests: stop ServicesUserControllerTest from exiting the PHPUnit process

testTimezoneSwitchAction/testTimezoneTemporaryAction plant a fake
HTTP_REFERER in setUp() so the controller's redirect path can be
exercised, but actionLocalTimezoneSync() -> redirectAndReturn() ->
TikiAccessLib::redirect() ends with exit(), silently killing the whole
PHPUnit run (exit code 0) at whatever test happens to run next.

Use TikiAccessLib::preventRedirect(), the same guard already used by
Services/Tracker/Controller.php and searchlib-unified.php, so redirect()
becomes a no-op in setUp()/tearDown() and the controller's return value
can still be asserted.

Also adds the missing `use TikiLib;` import needed to call
TikiLib::lib('access') from this namespaced test class.

See merge request tikiwiki/tiki!10654

- - - - -


1 changed file:

- lib/test/Core/Services/User/ControllerTest.php


Changes:

=====================================
lib/test/Core/Services/User/ControllerTest.php
=====================================
@@ -10,6 +10,7 @@ namespace Tiki\Test\Core\Services\User;
 use JitFilter;
 use PHPUnit\Framework\TestCase;
 use Services_User_Controller as ServicesUserController;
+use TikiLib;
 
 class ServicesUserControllerTest extends TestCase
 {
@@ -31,6 +32,12 @@ class ServicesUserControllerTest extends TestCase
         // Fake referer used by controller redirects
         $_SERVER['HTTP_REFERER'] = 'http://example.com/some/page';
 
+        // redirectAndReturn() calls TikiAccessLib::redirect(), which ends the
+        // request with exit(); preventRedirect() makes it a no-op so the
+        // controller's return value can still be asserted (same pattern used
+        // by lib/core/Services/Tracker/Controller.php and searchlib-unified.php).
+        TikiLib::lib('access')->preventRedirect(true);
+
         self::$originalTimezone = $prefs['display_timezone'];
         $this->originalUserSyncPref = $prefs['user_localtimezonesync'];
     }
@@ -42,6 +49,8 @@ class ServicesUserControllerTest extends TestCase
         $prefs['display_timezone'] = self::$originalTimezone;
         $prefs['user_localtimezonesync'] = $this->originalUserSyncPref;
 
+        TikiLib::lib('access')->preventRedirect(false);
+
         unset($_SESSION['temp_timezone']);
         unset($_SERVER['HTTP_REFERER']);
         unset($GLOBALS['user']);



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2201cbb466bc0cd166f4d1f8f2cce947b79238f3

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2201cbb466bc0cd166f4d1f8f2cce947b79238f3
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs