diff options
author | Timo Tijhof <krinkle@fastmail.com> | 2022-05-13 18:14:47 +0100 |
---|---|---|
committer | Tim Starling <tstarling@wikimedia.org> | 2022-05-16 14:10:31 +1000 |
commit | 4dd2b8d885d847ded34eabc2c05112d35c4ba929 (patch) | |
tree | 446a2a62b3406d7a418ec98a4368c6bb5df862d1 /includes/utils | |
parent | 363adf7df463e3ec2d0dc7ac9ea9d179f0382419 (diff) | |
download | mediawikicore-4dd2b8d885d847ded34eabc2c05112d35c4ba929.tar.gz mediawikicore-4dd2b8d885d847ded34eabc2c05112d35c4ba929.zip |
UrlUtils: Simplify and increase test coverage
Follows-up I31f1403ab40c79ab270c417.
* Make the test cases less dynamic. It was approaching the same
kind of complexity as the source code, thus reducing confidence
in the test.
* Make the test cases more explicit. A good test can be read without
executing it and show plainly what the expected output are.
Use little to no indirection, favouring small amounts of
duplication when in doubt.
* Increase coverage of the "non-standard HTTPS port" configuration,
by removing the two hardcoded assertions for it, in favour of
including it in the overal test matrix and applying the same set
of default cases to it as the other configurations under test.
* There are now 306 instead of 2355 generated test cases, but
the code coverage of UrlUtils.php remains identical
at 98.28% (171/174 lines).
Change-Id: I755c017964757b9aab5ebeabd80be5664be48798
Diffstat (limited to 'includes/utils')
-rw-r--r-- | includes/utils/UrlUtils.php | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/includes/utils/UrlUtils.php b/includes/utils/UrlUtils.php index 55b89e400ee1..f21b9e734d59 100644 --- a/includes/utils/UrlUtils.php +++ b/includes/utils/UrlUtils.php @@ -144,7 +144,8 @@ class UrlUtils { $defaultProto = $serverProto ?? PROTO_HTTP; } - $defaultProtoWithoutSlashes = $defaultProto === null ? '' : substr( $defaultProto, 0, -2 ); + // @phan-suppress-next-line PhanTypeMismatchArgumentNullableInternal T308355 + $defaultProtoWithoutSlashes = $defaultProto === PROTO_FALLBACK ? '' : substr( $defaultProto, 0, -2 ); if ( substr( $url, 0, 2 ) == '//' ) { $url = $defaultProtoWithoutSlashes . $url; |