aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/mail
Commit message (Collapse)AuthorAgeFilesLines
* enotif: Retrieve performer and title from RecentChangePiotr Miazga2025-03-211-4/+5
| | | | | | | | | | | | | | | | This is the second step to refactor EmailNotification notifyOnPageChange() method to use single RecentChange object instead multiple arguments. Previously we had to feed $editor, $title and some attributes. Instead we can just pass the entire RecentChange and let EmailNotification decide which properties to use. In the future, this will allow EmailNotification to listen to RecentChange domain events to trigger Notifications. Bug: T388665 Change-Id: I5882531e91cd84c4683522f06d829149fdfc534e
* Pass the RecentChange to NotificationsPiotr Miazga2025-03-211-4/+14
| | | | | | | | | | | | | | | | | | | | | | To evolve Watchlist notifications and provide a unified approach system has to pass the RecentChange object to EmailNotification. Which later will pass to the RecentChange notification. This is required to fulfill Echo needs that requires more information from RecentChange. At current state, Echo requires properties like `rc_logid` which is not available in MediaWiki ENotif job. Furthermore this change will simplify the system, as * instead of passing multiple params (and adding more of them with time) we can just pass one RecentChange object that contains all required information. When passing RecentChange via Job we can use the `rc_id` to recreate the RecentChange when job gets processed. * later Notifications system will be able to listen on RecentChange domain event and trigger notifications via listener pattern which will simplify the system even more. Bug: T388665 Change-Id: I2d17bd3743e590e06298efaac387fc6d64e3609d
* tests: Add missing documentation to class propertiesUmherirrender2024-09-181-0/+1
| | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: Ifc27750207edc09e94af030d882b6f1a5369cf98
* mail: Improve docs, fix file headers, widen `@covers`Timo Tijhof2024-05-102-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add missing `ingroup` to class blocks (and remove from any file blocks) as otherwise the file is indexed twice (e.g. in Doxygen) which makes navigation on doc.wikimedia.org rather messy. Remove duplicate descriptions from file blocks in favour of class doc blocks. This reduces needless duplication and was often incorrect or outdated, and helps make file headers more consistently (visually) ignorable. Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged * Widen `@covers` tags in phpunit tests Given all called methods are de-facto and liberally claimed, and that we keep the coverage limited to the subject class, it maintains the spirit and intent by listing the class explicitly instead. PHPUnit offers a more precise tool when you need it (i.e. when testing legacy monster/god classes), but for well-written code, the class-wide tag is exactly what you want. We lose useful coverage and waste valuable time on keeping tags accurate through refactors (or worse, forget to do so). Tracking tiny per-method details wastes time in realizing (and fixing) when people inevitably don't keep them in sync, and time lost in finding uncovered code to write tests to realize it was already covered but "not yet claimed". Ref https://gerrit.wikimedia.org/r/q/owner:Krinkle+is:merged+message:Widen While at it, improve purposes and explainations of several mail-related classes, and set `@since`: - EmailNotification introduced in r22110 (1.11.0), git a6f6e04841, later moved to a separate file in bf8810d6bc (Ic435bbdbb6). - MailAddress introduced in r12082 (1.6.0, 1.5.7), git 5cfddf9a82. - UserMailer converted to class with ::send in r26357 (1.12.0), git 353f203ce2. Change-Id: I1216781240bcfabdebf109cef8f995355db0f659
* Remove meaningless constructor teststhiemowmde2024-05-061-7/+0
| | | | | | | | | These tests do effectively only one thing: Test if the constructor succeeds without throwing an exception. But these constructors are all trivial and can't even do that. They are still covered by all the other tests that also involve the constructor. Change-Id: I206da47fd93a8ecbb08271390ecc1307ffe9df4e
* tests: Fix @covers and @coversDefaultClass to have leading \Reedy2024-02-162-6/+6
| | | | Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
* Follow-up 71ff05267: Stop writing to tablesUsed in tests, now unnecessaryJames D. Forrester2023-11-211-5/+0
| | | | | Bug: T342301 Change-Id: I5ea01f7ee103570165261bde0965c5b65e04c369
* EmailNotificationTest: Expand coverage to be more accurateJames D. Forrester2023-10-301-3/+1
| | | | | | | PHPUnit won't spot the private method coverage if we only cover the public methods directly, rather than the class. Change-Id: I08fabab1eca5bfca1653a366ab9c439ea2eb8f53
* Namespace User under \MediaWiki\UserJames D. Forrester2023-09-191-0/+1
| | | | | Bug: T166010 Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
* tests: Make some PHPUnit data providers staticUmherirrender2023-05-201-1/+1
| | | | | | | | | Initally used a new sniff with autofix (T333745), but some provide are defined non-static in TestBase class and need more work to make them static in a compatible way Bug: T332865 Change-Id: I889d33424f0c01fb26f2d86f8d4fc3de3e568843
* mail: Round 2 of EmailUser refactoringDaimona Eaytoy2023-05-171-0/+17
| | | | | | | | | | | | | | | | | | | | - Strengthen types - Use StatusValue instead of Status - Extract duplicated code to a new private method - Add MailAddress::equals to compare addresses, instead of relying on the weak '!=' comparison. There might be a question of whether having the same address should be enough for two MailAddress objects to be equal, but the implementation in this patch preserves the status quo. - Make the new validateTarget accept a User object directly. This is better than passing strings around just to have the "validator" create a user for you. - Avoid returning false if there's a hook error in submit(). Accepting 5 different error formats in the same hook is simply unreasonable, and this should eventually be standardized to use StatusValue. The old methods in SpecialEmailUser retain BC. Bug: T265541 Change-Id: Ia0ba27fe634e328dff1a6c06fb9979cb8ce4f7e7
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* tests: Add missing @group DatabaseUmherirrender2022-08-061-0/+3
| | | | | | | $tablesUsed does not let the test run in the correct group in CI Fix casing and remove duplicate as well Change-Id: Id9e092865464de4900965840834d946925c728e5
* Migrate usage of `setMwGlobals()` to `overrideConfigValue(s)`Derick Alangi2022-08-011-3/+3
| | | | Change-Id: I49d97864d8f9d8cadf01b0c0dc653fbac4ca9e94
* tests: Use Title::makeTitle instead of Title::newFromTextUmherirrender2022-07-061-1/+1
| | | | | | Avoid parsing known titles in tests to improve performance Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
* Remove access to config globals from more classesdaniel2022-04-281-0/+83
| | | | | | Bug: T294739 Depends-On: I84056024b0d3a9dcddb1ab4dc8596118bb3fe8ea Change-Id: If005958c76bbfabba74def4215c48fe94f297797
* phpunit: use ->getServiceContainer() in integration testsAlexander Vorwerk2022-01-271-3/+1
| | | | Change-Id: I38299cb65eeaadfdc0eb05db4e8c0b0119cfb37d
* Make MailAddressTest a unit testDannyS7122021-07-231-73/+0
| | | | | | | Requires a bit of manual manipulation of globals, but other than than no reason to make an integration test. Change-Id: I56342770f856092992660e104e06aa65a24e0e20
* Use UserIdentityValue in tests where possibleThiemo Kreuz2021-04-221-9/+3
| | | | | | | … instead of PHPUnit mocks. The tiny value class is made for this. Change-Id: Ie04cde57126fcafabf8906f9644c6e80345d8a48
* Convert mail namespace to Authority/UserIdentityPetr Pchelko2021-04-011-2/+4
| | | | Change-Id: I1e1ea72f94735ddaf66eab29aad1296e1abffb9b
* Convert or split some tests to MediaWikiUnitTestCaseDannyS7122021-01-071-14/+0
| | | | | | Don't require any integration Change-Id: I293a84ce8fe87fc6932f8a6400d6ca443ccc6235
* MediaWikiTestCase to MediaWikiIntegrationTestCaseaddshore2020-06-302-2/+2
| | | | | | | | | | | | | The name change happened some time ago, and I think its about time to start using the name name! (Done with a find and replace) My personal motivation for doing this is that I have started trying out vscode as an IDE for mediawiki development, and right now it doesn't appear to handle php aliases very well or at all. Change-Id: I412235d91ae26e4c1c6a62e0dbb7e7cf3c5ed4a6
* Filter out expired watched items when sending email notificationsMusikAnimal2020-06-241-0/+59
| | | | | Bug: T253035 Change-Id: I9ebfee4042b6ac40726162fa8c887f757d7528b8
* mail: Always quote uncoded names in MailAddressAlexia E. Smith2018-04-241-6/+11
| | | | | | | | | | | | | | | | | | | | | Otherwise, names that contain whitespace (but no special characters that need Q-encoding) will be sent as-is in an email header. While that's valid by RFC 1036, RFC 5322 and others, some mail programs fail to correctly process spaces. Avoid these problems by simply quoting the name always - except for cases which are Q-encoded, which must remain unquoted to be valid (and also cannot contain spaces, thus unaffected). Before: > From: Foo Bar <fb@example.org> After: > From "Foo Bar" <fb@example.org> Update test to work with the new criteria. Bug: T191931 Change-Id: I4b2a0a80e8b43ecc943939fc5ebaa356a4f840e0
* Use ::class to resolve class names in testsUmherirrender2018-01-261-3/+3
| | | | | | | This helps to find renamed or misspelled classes earlier. Phan will check the class names Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
* phpunit: Avoid use of deprecated getMock for PHPUnit 5 compatTimo Tijhof2017-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | The default will remain PHPUnit 4.x due to PHP 5.5 support. But, we should allow developers to run tests with newer PHPUnit versions which are noticably faster (especially for code coverage reports). * <https://github.com/sebastianbergmann/phpunit/wiki/Release-Announcement-for-PHPUnit-5.4.0> PHPUnit 5 deprecates the getMock() shortcut for getMockBuilder()->getMock(). It instead introduces the shortcut createMock() which has better defaults than getMockBuilder(). For example, it sets 'disableArgumentCloning' and other things by default. Going forward, code should either use getMockBuilder directly and configure it using the setter methods (instead of the confusing variadic arguments of getMock) or simply use the new minimalistic createMock method. This patch backports the createMock method to MediaWikiTestCase so that we can start using it. Change-Id: I091c0289b21d2b1c876adba89529dc3e72b99af2
* Convert all array() syntax to []Kunal Mehta2016-02-171-10/+10
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* Fix Generic.Files.LineLength phpcs check in files under phpunit/includesAmir E. Aharoni2015-10-031-3/+9
| | | | | Bug: T102614 Change-Id: Iee3df5f064f595ecebe8210cc936bc3d20a122c9
* Merge "Skip MailAddressTest::testNewFromUser on windows"jenkins-bot2014-09-301-0/+3
|\
| * Skip MailAddressTest::testNewFromUser on windowsumherirrender2014-09-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 1) MailAddressTest::testNewFromUser Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'Real name <foo@bar.baz>' +'foo@bar.baz' Change-Id: I0c9724130730c39a355c22d06b2c0f0629c1d0e3
* | Fixed spacingumherirrender2014-09-291-2/+1
|/ | | | | | | | | | - Added newline at end of file - Removed double spaces/newlines - Added space after if/function and parentheses/brackets - Removed space before comma/cast - Fixed indent of some lines Change-Id: I29867ffdffdfb7d2b56997e9393497c7dc12f7d3
* Improve coverage of MailAddress::toString()Kunal Mehta2014-09-211-0/+1
| | | | Change-Id: I8d5a1e8f293afa03d94167b722d3078f467cf59e
* Add MailAddress::newFromUser()Kunal Mehta2014-09-141-0/+25
| | | | | | And tests! Change-Id: I5214c50855f6bc756f6d748e435ae2124b2264c1
* Add tests for MailAddressKunal Mehta2014-09-141-0/+38
| | | | Change-Id: Ia192919322743854096aceb24be0fcf9b1aa32b4
* Split UserMailer.php into includes/mail/Kunal Mehta2014-09-141-0/+14
Change-Id: Ic435bbdbb690028a5d34e8176522fcf4aa44fa92