Commit graph

360 commits

Author SHA1 Message Date
ephemeralwaves 319808de5d Selenium: the first test for Special:Notifications
Open the notifications page and check that the notification heading is present.

Bug: T217051
Change-Id: I357e83eca9f6d6fe380ec6996fb557d578a76912
2019-03-25 15:47:38 +00:00
jenkins-bot dd3fc548bd Merge "Test that checks for alerts' flyout" 2019-03-05 13:28:02 +00:00
jenkins-bot a838836a23 Merge "Use explicit columns and avoid SELECT *" 2019-03-04 21:12:28 +00:00
ephemeralwaves 8212dfe2a3 Test that checks for alerts' flyout
Added a test that checks if the flyout window appears when the alerts badge is
clicked.

Bug: T217051
Change-Id: I5afbb6928a42ddf1c71dec13c4559189d7c31f28
2019-03-04 13:26:22 -05:00
jenkins-bot 8de5066b24 Merge "Convert caching to WANObjectCache" 2019-03-04 15:06:35 +00:00
Umherirrender 1b5308ba81 Use explicit columns and avoid SELECT *
Change-Id: Ibde033784aee5adc13fae6f1d395d9464f54fefd
2019-03-02 22:39:53 +01:00
Aaron Schulz bb0ca321df Convert caching to WANObjectCache
Change-Id: I6c0315aa6e24c573cf9a8410ff21471ed3da60d1
2019-02-28 21:56:38 -08:00
Thiemo Kreuz afdcce5059 Add type hints and remove unused code from tests
This patch contains a series of different clean-ups in test classes.
Some documentation is added as well as soft and hard type hints. Note
all this is exclusively done in tests. So if the CI is fine with it,
it can't be wrong. Right? ;-)

Change-Id: Ibcf1f65f48ac0fb41837c47672dddfd70302e9fd
2019-02-20 19:16:33 +00:00
Thiemo Kreuz 5941ef476c Replace @expectedException with $this->expectException()
The @expectedException annotation got deprecated in PHPUnit 7.5, and
removed in PHPUnit 8.0. This was done because the annotation does have
two disadvantages:
* The class name is encoded in string, where it is not easy to find for
  all IDEs and tools.
* it did not allow to say exactly *when* the exception is expected.

Change-Id: I96862a18874f36355e817accd64d8703c1965c86
2019-02-19 20:54:15 +00:00
Thiemo Kreuz c36d2bd0e8 Prefer the …::class feature over hard-coded strings in all tests
The codebase already used the …::class feature in many places. So this
is more for consistency than anything. The …::class feature makes it
much easier to do refactoring in the future.

Note this patch is exclusively touching tests. That should make it
relatively easy to review this. As long as the CI is fine with it, it
should be ok. Right? ;-)

Change-Id: I4d2adee76b4adbc83b2061161fd4e863ba833fcb
2019-02-19 14:35:14 +00:00
Ed Sanders 7ed027ddcf build: Update eslint-config-wikimedia to 0.10.1
Change-Id: I776585adab962c2b1d353d18d3a02b6662941b13
2019-02-06 01:42:53 +00:00
Ed Sanders 4d03a4856d Update eslint-config-wikimedia to 0.9.0
Change-Id: Icd7b0f4ca54275c31eb61a759e2c3c9ce0a18952
2018-11-27 22:48:32 +00:00
Ed Sanders 17126b2ab1 Remove obsolete aliases from closures
Bug: T208951
Change-Id: If51fc6d50b9755c779fd0bf1be7bb0fe276539ea
2018-11-12 13:56:38 +00:00
jenkins-bot f75d5d120f Merge "Add method scope visibility" 2018-11-02 23:55:06 +00:00
Umherirrender 81183a6d86 Add method scope visibility
Change-Id: Id4fe59155d6e0fa2ef1ccf4dc46ee1f109265246
2018-11-02 18:47:39 +01:00
jenkins-bot 92ed4e312c Merge "Make notifyAgent a per-type property rather than per-event" 2018-11-02 15:09:19 +00:00
Roan Kattouw de536d09d9 Make notifyAgent a per-type property rather than per-event
Specify which notification types allow notifying the event agent in
$wgEchoNotifications, and stop specifying it in the event_extra data.

Putting 'notifyAgent' => true in event_extra will still work, but is
discouraged.

Change-Id: I4f558654ec23757dd4ecd6986eb3e9a5593f5386
2018-10-29 15:41:51 -07:00
jenkins-bot 512a0904c5 Merge "Avoid use of IDatabase::insert() return value" 2018-10-28 21:42:07 +00:00
Aaron Schulz bbf0e1fade Avoid use of IDatabase::insert() return value
Change-Id: I36a18d9ff315928555bef7ab93283ec72aeef9f7
2018-10-26 15:44:57 -07:00
Aaron Schulz 9a0ce7d4d7 Avoid use of IDatabase::update return value
Change-Id: I0739c2dcd22aa0536257e534dd1eb0d44d3f016b
2018-10-26 13:56:30 -07:00
Aaron Schulz 9c26779852 Reload the test user instance before checking the edit count
These are updated in deferred updates and should not rely on the same
User instance being used in those updates. This also avoids convoluted
logic in User to set the new edit count for various cases.

Change-Id: I0ad3d17107efc7b0e59f1dd54d5733cd1572a2b7
2018-10-23 11:01:35 -07:00
jenkins-bot f6927d714f Merge "Add a test to validate $wgEchoNotifications" 2018-10-13 06:17:35 +00:00
Kunal Mehta dbf44b1be7 Don't call count() with a non-countable value
Triggers a warning in PHP 7.2.

Bug: T206541
Change-Id: I5c25b59cd91871fcdbbf73e01af5a61c05c5fffd
2018-10-12 20:49:42 -07:00
Max Semenik e5e8de1ba6 Add a test to validate $wgEchoNotifications
Change-Id: I7c9f76f4222f692a2babf47618b869f4c963499f
2018-10-10 19:07:04 -07:00
Max Semenik b82b54f0a6 Don't override checkmatrix defaults set elsewhere
Bug: T174220
Change-Id: I3c9bc06ff78040f88f7f870671c838dad4e3ad6d
2018-09-20 17:15:09 -07:00
Umherirrender 1345b056c2 Add @group Database to unit test
Used database by inserting pages

Change-Id: If97d9e6e525465ca3879003e71dd5e67fc0afdfd
2018-09-14 22:29:34 +02:00
Umherirrender 00fe420a1f Add @group Database to unit test
Follow-Up: I4cdc8130032340726c5d18d795cd2d6b6b58b307
Change-Id: Iac4458d24838198f530a5a0e738f6dc4db0f9b56
2018-09-12 22:38:23 +02:00
Ed Sanders 2c089e075d build: Update linters
Change-Id: I9747097fdf725992710f97d4ce4ea49fd611df1b
2018-09-11 23:46:52 +01:00
Umherirrender 8429547776 Fix phpunit @group annotation
Change-Id: Ic6c2c5bb7c6092d581e646358d836f55d5cf38b0
2018-09-09 20:41:59 +02:00
daniel c06ca6d111 Test data providers should never access the database.
Any database access in test providers is hitting the live
database, not the test mock!

Change-Id: I01d8c41ed30cfaf68642c218090147ac39757c5e
2018-09-07 01:24:52 +00:00
Umherirrender 2cd8d9d0eb Split long lines over 140 chars
This makes the code easier to read even on big screens

Change-Id: I14bfb97b2986f389ad11a6ddc97ba61468774782
2018-08-25 12:51:14 +02:00
Umherirrender a0ad95b63f Split long lines over 200 chars
This makes the code easier to read even on big screens

Change-Id: Iebc2ca785690abc6e7998c6f6078daf0bd01ccf8
2018-08-23 10:33:25 +02:00
Timo Tijhof 2142be10b0 cache: Reduce responsibility of subclass and remove unused parts
* Reduce responsibility of resolve() methods to only supplying
  the resolves values.
  Moved logic for populating the cache and clearing the queue
  to the base class, and made 'lookups' private.

* The second parameter to LocalCache::add() is unused, and never passed.
  Removed to avoid confusion.

* The getTargets() method is unused. Removed.

* The getLookups() method is unused. Removed.

* The internal 'lookups' member was being used both for its keys and its
  values, but never at the same time. This seemed risky, especially in
  EchoRevisionLocalCache::resolve() where the associative array was passed
  directly to the 'where' clause of IDatabase::select(), which shouldn't
  espect keys when creating the 'IN' clause.

  Using only values would keep value types flexible, but would require
  use of the less efficient in_array().
  Keeping both keys and values and calling array_values() would work.
  Using only keys also works and is simpler, so long only ints are used.

* The tests were swapping 'targets' MapCacheLRU with a HashBagOStuff.
  Following-up 4939bff7, this was forgotten, but works because the two
  called methods (get and set) exist in both, but still seems odd.

  Fixed by using TestingAccessWrapper to act on the existing object
  instead of swapping it out.

* Improved tests by asserting more of the observed behaviour and impact.

Change-Id: I530eeac8bf3b407b8c633e0e20c7d35cc49f7a9f
2018-08-17 03:28:02 +00:00
jenkins-bot af2b92856f Merge "Fix missing/mismatching type hints PHPDoc tags" 2018-08-16 08:39:29 +00:00
Thiemo Kreuz 2d7096bcff Fix missing/mismatching type hints PHPDoc tags
This fixes some issues I found while updating this code base, e.g.
this removes types a method really does not return.

Change-Id: I19457e7bf88945eec958bf53e0b76a7585715a45
2018-08-16 07:07:20 +00:00
jenkins-bot ef233becf5 Merge "Make "@… array" type hints more specific" 2018-08-16 00:57:12 +00:00
jenkins-bot e23cf162fe Merge "Migrate EchoLocalCache to MapCacheLRU" 2018-08-15 21:45:02 +00:00
Aaron Schulz 4939bff723 Migrate EchoLocalCache to MapCacheLRU
Change-Id: Ie007bc5ec1db4d9686ced724b87f9cbc328aa339
2018-08-15 12:30:51 -07:00
Thiemo Kreuz 63eee2b9a1 Remove two unused properties from AttributeManager
These two properties are protected. I used
https://codesearch.wmflabs.org/search/?q=EchoAttributeManager%5B%5ET%3A%5D
to make sure no subclass exists that might use them.

Change-Id: I37c71db55bc4832968a1812142588dddaa81724a
2018-08-15 09:29:54 +00:00
Alangi Derick 61301318a6 Fix common typos in Echo extension
Fixed typo from "seperate" to "separate" in DiffParserTest.php

Bug: T201491
Change-Id: I39027bfbede2bc5a7398b7fd623319d6f2257b59
2018-08-14 12:34:43 +01:00
Thiemo Kreuz fc59da2cca Add missing newlines before "use" sections
Change-Id: I15b4aaac007379370f832bc24e3cebfe54dda754
2018-08-13 09:29:32 +02:00
Thiemo Kreuz c1c3c7b672 Make "@… array" type hints more specific
There are about 200 of such generic "array" type hints in this code base,
the majority in @param tags. I started with what I found most relevant:
@var and @return tags. I might continue working on this later, but
wanted to stop for now to keep this patch moderately small.

Change-Id: Iff0d9590a794ae0f885466ef6bb336b0b42a6cd3
2018-08-13 09:27:37 +02:00
Roan Kattouw 06f0a7a6d5 NotifUser: Remove basically-unused talk notification cache
This cache was only used so that, if we're told to clear the newtalk
flag and we already know there are no edit-user-talk notifications, we
won't try to delete them. But that's not a good justification for such a
confusingly-written cache that would have been hard to convert to
getWithSetCallback(), and I'm concerned that using cached data to make
this decision could lead to inconsistencies.

Also remove the notifCountHasReachedMax() check, which made no sense: if
the user has >99 notifications, that is no justification for not marking
their user talk notifications as read when they visit their user talk
page. Whether the displayed notification count will change has no
bearing on whether these notifications should be marked as read (and now
that bundled notifications are counted individually, the displayed count
actually could change).

Bug: T164860
Change-Id: I3ff5c9b31307839b9336bd8856015db9baa52fad
2018-08-09 16:34:04 -07:00
Roan Kattouw fe17b49fcd NotificationMapper: Use batching in deleteByUserEventOffset()
Also test it more meaningfully by setting up a mock database and
asserting that the right DELETE queries are issued.

Change-Id: Id39723b92118e98d9c9f0cd7381e9396dce67c17
2018-08-08 14:57:58 -07:00
Aryeh Gregor 83be57fe01 Use setContentLang instead of setMwGlobals
This sets $wgLanguageCode appropriately.  It will also be necessary when
$wgContLang becomes a service, in which case setting the global directly
will not work correctly.

Bug: T200246
Change-Id: I4aaf1c641ec6abef214eb96c0e4b42a67488ac00
2018-07-25 19:12:09 +03:00
Max Semenik f8ef0cc7f5 Get rid of special casing for user blacklist
Makes so many things simpler and robust.

Bug: T198935
Change-Id: Ia836f8f497cae8599f85cf86a7f6b299cd012e81
Depends-On: Iff63da0d215585cfcf083e7f7ec8ed45d5b77301
2018-07-09 15:50:38 -07:00
jenkins-bot 7862759c53 Merge "Re-enable test coverage reporting, add @covers tags" 2018-06-28 17:02:18 +00:00
Kosta Harlan da2da90b48 Re-enable test coverage reporting, add @covers tags
Bug: T195136
Change-Id: I9203232e79f162aedb982b713f708cebfe9d1ae0
2018-06-28 08:32:57 -04:00
jenkins-bot 855497c3ba Merge "Avoid counting where not necessary" 2018-06-26 13:54:59 +00:00
Thiemo Kreuz cb282251a8 Avoid counting where not necessary
Change-Id: I0abbdced4474dabbdecd3bbfae194e79b7c29db1
2018-06-26 07:10:38 +00:00