There might be slight behaviour differences, particularly in case of
offsets that are > 14 or < -12, but I don't think it's really worth
special-casing that, since other parts of the code already limits
offsets to values in that interval.
Also fix a bug in UserTimeCorrection where ctype_digit wouldn't
recognize negative offsets specified only as an integer.
Also add a lot of tests for userAdjust, actually testing the parsing
logic, and not just the fallback to the local offset (which is what
**all** the previous test cases were doing). Ideally, this test would be
a unit test and be moved elsewhere, but I don't think it's worth doing
that now, since I assume the Language class will be refactored anyway at
some point.
Finally, use DateTime::modify instead of mktime. It's more readable, it
works the same, but is much more compact. It also means we don't have to
suppress any errors (which I think was already unnecessary, but still).
Bug: T322352
Change-Id: Ie0ccdb0c16aaa6ac888ca1e13008a8b214ac8994
The files in `tests/phpunit/includes/` directory are now all
covered. Will do sub-directories of `/includes/` next.
Change-Id: I8d5655ce267b6d32cf3c7ee40dc5d2992631b5a6
- Added/removed spaces around parenthesis
- Added space after switch/if/foreach
- changed else if to elseif
Change-Id: I99cda543e0e077320091addd75c188cb6e3a42c2
Will technically still take an int (it's parsed around anyway), but
should be passed as a string
Mostly for HipHop stuffs
Change-Id: Id940028d581e34ca2e37a0730ca5766a08fc10e2
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.
This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:
"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"
Follow-up of I2987db68 (2b0edc8).
Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.
Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...
Either way they won't have to anymore with setMwGlobals.
Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)
(Matching the function signature with PHPUnit/Framework/TestCase.php)
Replaces:
* public function (setUp|tearDown)\(
* protected function $1(
* \tfunction (setUp|tearDown)\(
* \tprotected function $1(
* \tfunction (data|provide)\(
* \tpublic static function $1\(
Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.
Fixes:
TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).
MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...
FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"
HttpTest
* Added comment about:
"PHP Fatal: Call to protected MWHttpRequest::__construct()"
(too much unrelated code to fix in this commit)
ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
because regardless of whether wgExternalStores is true or false
it only uses it if it is an array.
Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
Had been resulting in fatal errors when running TimeAdjustTest, due to trying to use an old $wgContLang value that had never gotten saved properly because the parent class setUp() was not called.