Repository navigation
Conversation
mjansenDatabay
approved these changes
Oct 5, 2026
thibsy
approved these changes
Oct 6, 2026
thibsy
left a comment
Contributor
There was a problem hiding this comment.
Thx a lot @chfsx for the PR!
Changes to UICore, Setup and Init look good. But I quickly ran the tests on your branch locally and there were two errors that stem from FileDelivery. Maybe you need to look into this:
1) ILIAS\Tests\FileDelivery\Delivery\StreamDeliveryIsolationTest::testValidTokenIsServedOnTheContentHost
InvalidArgumentException: The argument $resource must be of type resource but was "boolean"
trunk/components/ILIAS/Filesystem/src/Stream/Streams.php:67
trunk/components/ILIAS/FileDelivery/src/Delivery/StreamDelivery.php:185
trunk/components/ILIAS/FileDelivery/tests/Delivery/StreamDeliveryIsolationTest.php:124
trunk/components/ILIAS/FileDelivery/tests/Delivery/StreamDeliveryIsolationTest.php:168
2) ILIAS\Tests\FileDelivery\Delivery\StreamDeliveryIsolationTest::testValidTokenIsServedOnAnyHostWhenIsolationIsDisabled
InvalidArgumentException: The argument $resource must be of type resource but was "boolean"
trunk/components/ILIAS/Filesystem/src/Stream/Streams.php:67
trunk/components/ILIAS/FileDelivery/src/Delivery/StreamDelivery.php:185
trunk/components/ILIAS/FileDelivery/tests/Delivery/StreamDeliveryIsolationTest.php:124
trunk/components/ILIAS/FileDelivery/tests/Delivery/StreamDeliveryIsolationTest.php:184
There were also more warnings from FileDelivery tests which were caused because of some directory not being found.
Or am I missing something on my machine?
Best, @thibsy
Member
Author
|
Thanks, I forgot to rebase on trunk, those issues were fixed there |
chfsx
force-pushed
the
improvement/12/phpunit-14-mock-expects
branch
from
October 8, 2026 07:47
4a6442d to
c8d381b
Compare
Member
Author
|
@thibsy the branch is now rebased on trunk. The |
Contributor
|
LGTM, thx a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHPUnit 12.5 deprecates calling
with*()on a mock without an explicitexpects(), as well as theany()invocation count. Both will be removed in PHPUnit 14. This PR removes all PHPUnit deprecations from the unit tests of the components I am an authority of.Changes
with(),withParameterSetsInOrder()andwithParameterSetsInAnyOrder()on mocks now get an explicitexpects($this->atLeastOnce()).withAnyParameters()withoutexpects()has no effect and is removed.createStub()) instead ofcreateMock(). This also removes most of the "no expectations configured" notices.Making the invocation count explicit revealed two mock configurations which were never used:
ResourceStorageCollectionTest::testGetCollectionOfUser: the stub forgetResourceIdStrings()was never called and is removed.OrgUnitilOrgUnitOperationRegisteredObjectiveTest: for an unknown contextisApplicable()fails before the operation is looked up, sodoesOperationExistInContext()now expectsnever()in that case.In addition,
ilServicesGlobalScreenTestnow definesANONYMOUS_USER_IDitself. It only passed when another test had defined the constant before, and failed when the GlobalScreen tests were run on their own.Methodology
The changes were made with Rector 2.6.7 (including
rector-phpunit) and reviewed afterwards. The configuration:withComposerBased(phpunit: true)only applies therector-phpunitrules which match the installedphpunit/phpunitversion (13.1). Among others, this set turns mocks without expectations into stubs.ParentTestClassConstructorRectoris skipped. It adds a__construct()toTestCasedescendants such asilCtrlPathTestBase, but theTestCaseconstructor is final since PHPUnit 12.ExpectsForMockWithRectoris a small custom rule. It addsexpects($this->atLeastOnce())only tomethod()chains which usewith*(), replacesexpects($this->any())in such chains, and dropswithAnyParameters()withoutexpects().rector-phpunitshipsExplicitMockExpectsCallRector, but that rule only handles mocks in local variables of test methods and addsexpects()to everymethod()call. Most mocks here are properties set up insetUp().phpunitCodeQualityset was deliberately not used. Its broader refactorings, e.g. finalizing test classes or narrowingsetUp()properties, broke several tests.Affected components
Bibliographic, Cache, Component, EventHandling, File, FileDelivery, FileServices, Filesystem, GlobalScreen, HTTP, Init, MainMenu, OrgUnit, ResourceStorage, Setup, UICore
Only test code is changed. @thibsy, could you have a look at the changes in UICore, Setup, Component and Init? @mjansenDatabay for Init, @maalers / @mhomann-tf for OrgUnit and Bibliographic, in case you want to look at them.
Result
All tests of these components pass without PHPUnit deprecations. The remaining deprecations in the suite are in Test, TestQuestionPool, IndividualAssessment, LearningSequence and ILIASObject.