Unit/System Tests PR-7.0-dev Pending

User tests: Successful: Unsuccessful:

avatar Llewellynvdm
Llewellynvdm
15 Oct 2026
  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

This PR removes getRouter() from CMSWebApplicationInterface and restricts the concrete application methods to compatibility mode.

The method has been deprecated since Joomla 4.3, but core still uses it. To allow Joomla 7 to run without the backward compatibility plugin, this PR:

  • Removes the interface declaration and its unused import.
  • Guards the implementations in CMSApplication and ConsoleApplication with COMPAT_JOOMLA_7, following the existing compatibility pattern.
  • Preserves the site and administrator default router names.
  • Emits a deprecation notice when the compatibility method is used.
  • Replaces the deprecated calls in the content, contact, and newsfeeds routers with access to the shared SiteRouter service.
  • Updates the base application routing method to retrieve its router from the container.
  • Retains the legacy fallback in Route::link() only when compatibility mode is enabled.
  • Removes the obsolete PHPStan suppressions and adds regression tests.

The retained compatibility methods are documented for removal in Joomla 8. The separate BeforeApiRouteEvent::getRouter() API is unaffected.

Testing Instructions

Apply the PR to 7.0-dev.

With Composer dependencies installed, run:

php libraries/vendor/bin/phpunit \
  --filter 'ApplicationRouterCompatibilityTest|RouteTest|ComponentRouterTaintTest|ConsoleApplicationTest'

Expected result: 25 tests and 94 assertions pass.

Actual result BEFORE applying this Pull Request

  • Removal of the interface requirement.
  • Rejection of application getRouter() calls without compatibility mode.
  • Preservation of default and explicitly selected routers with compatibility mode enabled.
  • Deprecation notices and the console application's required router name.
  • Container-based routing and the compatibility-only legacy fallback.
  • Tainted-route handling through the shared site router in all three affected components.

Expected result AFTER applying this Pull Request

  1. Enable Behaviour - Backward Compatibility 7.
  2. Check frontend navigation, administrator access, and links to articles, contacts, and newsfeeds.
  3. Disable the plugin and repeat these checks in fresh requests.
  4. With SEF enabled and IDs included in item URLs, change an item's alias segment while preserving its numeric ID. Confirm routing still works without a getRouter() compatibility exception.

Local validation completed successfully: the tests above, PHP syntax checks, project code-style checks, and PHPStan analysis of the changed production files.

Link to documentations

Please select:

  • Documentation link for guide.joomla.org:

  • No documentation changes for guide.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar Llewellynvdm Llewellynvdm - open - 15 Oct 2026
avatar Llewellynvdm Llewellynvdm - change - 15 Oct 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 15 Oct 2026
Category ⇒ Front End com_contact com_content com_newsfeeds Libraries Unit Tests
avatar Llewellynvdm Llewellynvdm - change - 15 Oct 2026
The description was changed
avatar Llewellynvdm Llewellynvdm - edited - 15 Oct 2026
avatar tecpromotion tecpromotion - change - 16 Oct 2026
Labels Added: Unit/System Tests PR-7.0-dev
avatar tecpromotion
tecpromotion - comment - 16 Oct 2026

I have tested this item successfully at runtime, but it needs changes: the new tests don't run under PHPUnit 12, so the unit test jobs fail in CI.

1. New tests fail: docblock annotations are ignored by PHPUnit 12

7.0-dev uses PHPUnit 12.5, which no longer reads @dataProvider, @runTestsInSeparateProcesses or @preserveGlobalState. Running the PR's own command:

Tests: 8, Assertions: 5, Errors: 5.
ArgumentCountError: Too few arguments to function ...::testRouterAccessRequiresCompatibility(), 0 passed ... exactly 1 expected

This is not the expected 25 tests, 94 assertions. Without process isolation, define('COMPAT_JOOMLA_7', true) would also leak into later tests. Fix: use attributes, as the other tests in tests/Unit do:

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

#[RunTestsInSeparateProcesses]
#[PreserveGlobalState(false)]
class RouteTest extends UnitTestCase
{
    #[DataProvider('compatibilityModes')]
    public function testLinkUsesTheContainerRouterWithoutALegacyApplication(bool $compatibility): void

With that change: 25 tests, 112 assertions, all pass, and the full Unit suite is green. One small cleanup: ComponentRouterTaintTest triggers 3 PHPUnit notices (No expectations were configured for the mock object for QueryInterface), so use createStub() for $query.

2. Manual entry missing

Neither manual.joomla.org checkbox is ticked. Removing getRouter() from CMSWebApplicationInterface and having it throw without the compat plugin needs an entry in the 6.x → 7.0 Removed and Backward Incompatibility page. The compat plugin is disabled on a fresh 7.0 install.

Tested (7.0-dev + PR, PHP 8.3, SEF on)

Check compat7 off compat7 on
Home, administrator login + dashboard, API (401 without token), CLI ✅ ✅
article / contact / newsfeed, correct URL 200 200
old id-alias URL (IDs removed) or wrong alias (IDs in URL) → tainted → 301 to the correct URL ✅ all 3 ✅ all 3
Factory::getApplication()->getRouter() in a template BadMethodCallException SiteRouter

One more thing: in the description, the content under Actual result BEFORE and Expected result AFTER is swapped.

avatar tecpromotion
tecpromotion - comment - 16 Oct 2026

I have tested this item successfully at runtime, but it needs changes: the new tests don't run under PHPUnit 12, so the unit test jobs fail in CI.

1. New tests fail: docblock annotations are ignored by PHPUnit 12

7.0-dev uses PHPUnit 12.5, which no longer reads @dataProvider, @runTestsInSeparateProcesses or @preserveGlobalState. Running the PR's own command:

Tests: 8, Assertions: 5, Errors: 5.
ArgumentCountError: Too few arguments to function ...::testRouterAccessRequiresCompatibility(), 0 passed ... exactly 1 expected

This is not the expected 25 tests, 94 assertions. Without process isolation, define('COMPAT_JOOMLA_7', true) would also leak into later tests. Fix: use attributes, as the other tests in tests/Unit do:

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

#[RunTestsInSeparateProcesses]
#[PreserveGlobalState(false)]
class RouteTest extends UnitTestCase
{
    #[DataProvider('compatibilityModes')]
    public function testLinkUsesTheContainerRouterWithoutALegacyApplication(bool $compatibility): void

With that change: 25 tests, 112 assertions, all pass, and the full Unit suite is green. One small cleanup: ComponentRouterTaintTest triggers 3 PHPUnit notices (No expectations were configured for the mock object for QueryInterface), so use createStub() for $query.

2. Manual entry missing

Neither manual.joomla.org checkbox is ticked. Removing getRouter() from CMSWebApplicationInterface and having it throw without the compat plugin needs an entry in the 6.x → 7.0 Removed and Backward Incompatibility page. The compat plugin is disabled on a fresh 7.0 install.

Tested (7.0-dev + PR, PHP 8.3, SEF on)

Check compat7 off compat7 on
Home, administrator login page ✅ ✅
Administrator dashboard, API (401 without token), CLI ✅ not tested
article / contact / newsfeed, correct URL 200 200
old id-alias URL (IDs removed) or wrong alias (IDs in URL) → tainted → 301 to the correct URL ✅ all 3 ✅ all 3
Factory::getApplication()->getRouter() in a template BadMethodCallException SiteRouter

One more thing: in the description, the content under Actual result BEFORE and Expected result AFTER is swapped.

avatar Llewellynvdm Llewellynvdm - change - 16 Oct 2026
The description was changed
avatar Llewellynvdm Llewellynvdm - edited - 16 Oct 2026

Add a Comment

Login with GitHub to post a comment