39 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
1093256560
MDL-81522 phpunit: Add missing void return type to all tests
While this change is not 100% required now, it's good habit
and we are checking for it since Moodle 4.4.

All the changes in this commit have been applied automatically
using the moodle.PHPUnit.TestReturnType sniff and are, exclusively
adding the ": void" return types when missing.
2024-06-11 12:18:04 +02:00
Eloy Lafuente (stronk7)
4003e31983 MDL-73785 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- When belonging to other components and being valid api:
  - analytics related tests have been moved to tests/analytics subdir.
  - backup & restore related tests have been moved to tests/backup subdir.
  - events related tests have been moved to tests/event subdir.
  - privacy related tests have been moved to tests/privacy.
  - task related tests have been moved to tests/task subdir.
- Some simple renames, not including the component part anymore (not
  needed now that they are namespaced):
  - some xxxlib_test.php have been renamed lib_test.php
    (when they where testing the corresponding lib.php).
  - cache stores tests have been all renamed store_test, originally
    each one had its own name (file_test, apcu_test, redis_test...)
  - assign feedback tests have been all renamed feedback_test, originally
    each one had its own name (file_test, editpdf_test...)
2022-03-03 12:19:30 +01:00
Pau Ferrer Ocaña
b4c75986ad MDL-67853 message: Adapt tests removing online/offline settings 2022-01-27 15:22:15 +01:00
cescobedo
084833acbe MDL-71919 core_message: Fix tests in message_send 2021-07-08 23:30:35 +02:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
David Monllaó
b63c0b9079 Merge branch 'MDL-60680-master' of git://github.com/jleyva/moodle 2019-04-25 18:55:45 +02:00
Juan Leyva
333d11c9fc MDL-60680 notifications: New customdata field
New field to store custom data for message processors.
2019-04-23 13:15:24 +02:00
Adrian Greeve
8c67db30a6 Merge branch 'MDL-64017_master' of git://github.com/markn86/moodle 2019-04-18 16:18:22 +08:00
Mark Nelson
168d782ff8 MDL-64017 message_email: task to send messages as a digest 2019-04-18 16:03:27 +08:00
Mark Nelson
c210455a4c MDL-64017 core: remove group conversation check for processors
We now want to allow processors to process group messages.
2019-04-18 14:28:09 +08:00
Sara Arjona
734b198fd3 MDL-64715 message: add support for self conversations
Added new MESSAGE_CONVERSATION_TYPE_SELF type for self-conversations
and upgraded legacy self-conversations to the new type, removing
repeated members in the message_conversation_members table.
Besides, from now, a self-conversation will be created by default for
all the existing users.

All the self-conversations have been also starred and a default message
will be displayed always to explain how to use them.
2019-04-15 20:17:54 +02:00
Mark Nelson
5e600f7ce2 MDL-64773 core_message: do not process muted conversations 2019-03-13 09:08:46 +08:00
Jake Dallimore
267b4f03e7 MDL-63283 core_message: skip processors in non-individual conversations
Disable the processor for messages being sent to conversation types
other than individual.
2018-11-15 10:37:33 +08:00
Jake Dallimore
52f9cf205e MDL-63724 core_message: add send_message_to_conversation() to api 2018-11-12 10:09:27 +08:00
Jake Dallimore
b30f4d6d58 MDL-63724 core_message: buffering support for conv messages in manager
We need to be able to delay calling all member processors with localised
event data if a DB transaction is taking place. This code treats a
conversation message as a single item of work to be buffered, and stores
all localised eventdata, and processorlists for later reference. When
processing the buffer, we pass off all localised eventdata items to
their respective member's processors, before firing a single event.
2018-11-12 10:09:27 +08:00
Jake Dallimore
0eddf920be MDL-63724 core_message: add conversation support to message_send()
Added a test confirming that processors are called for each member
and that a single event is fired.
2018-11-12 10:09:27 +08:00
David Mudrák
39d2c68856 MDL-61742 messaging: Do not send messages from inactive providers
Before this patch, we only checked that the given provider has been
configured in the user or system preferences. However, if the provider's
component is disabled, it does not even appear in these preferences.
Additionally, there was no check that the message / notification
provider is among providers allowed to be consumed by the recipient.

The patch checks that the message origin is among providers returned by
the message_get_providers_for_user() so disabled plugins can't act as
sources of messages and users can't receive messages from providers they
do not have capability for. This mitigates the risk of abusing a plugin
as a source of spam, for example.

Unit test is fixed and extended. When the $CFG->messaging is disabled,
no messages between users should be sent (I can't understand why the
unit test was written in an opposite way). Added assertions for the
raised debugging message.
2018-08-31 12:15:30 +02:00
Mark Nelson
0d657cc9b7 MDL-36941 core: removed 'message_working' table 2018-03-23 12:30:29 +08:00
Mark Nelson
376a79c242 MDL-36941 core: added events for notifications 2018-03-23 12:30:27 +08:00
Mark Nelson
883ce42127 MDL-36941 core: convert existing api to use new table structure
Also deprecated the following functions -

1. message_move_userfrom_unread2read - It is not necessary
   for us to mark a message as read on user deletion.
2. message_get_blocked_users - Horrible logic used to
   determine if a user is blocked via reference on some
   randomly chosen 'isblocked' variable.
3. message_get_contacts - The same as above. This can be
   done in a much nicer way.
4. message_mark_message_read - We want two functions to do
   this to avoid confusing messages and notifications.
5. message_can_delete_message - This assumed the variable
   $message contained the 'useridto' property, which
   was present in the old table structure. We do not want
   future usages where a query is done on the new table
   and is simply passed as this won't contain this property.
6. message_delete_message - Same as above.
2018-03-23 12:30:27 +08:00
Mark Nelson
685daf1aed MDL-58650 core_message: always use 'popup' processor for messages 2017-05-02 15:46:48 +08:00
Andrew Nicols
bc378b50ec Merge branch 'wip-MDL-44467-master' of git://github.com/abgreeve/moodle 2016-11-03 14:08:21 +08:00
Adrian Greeve
e0789335ee MDL-44467 lib: Unit test updates. 2016-10-28 13:27:00 +08:00
Simey Lameze
253ae23058 MDL-44467 core: always send email from noreplyaddress 2016-10-28 13:04:09 +08:00
Amanda Doughty
cc350fd9c8 MDL-47162 core_message: Add course id to message eventdata 2016-10-27 18:11:27 +02:00
rajesh Taneja
5ecf8e8f21 MDL-51266 unittest: replaced low level phpunit_util calls 2015-09-23 15:42:48 +08:00
Andrew Nicols
fc05c1b8e5 MDL-48197 testing: Normalise uses of noemailever and phpmailer sink 2014-11-19 09:09:50 +08:00
Petr Skoda
5cf50f96e7 MDL-48083 dml: Empty buffers on forced rollback 2014-11-06 15:52:37 +13:00
Simey Lameze
9a2c52571e MDL-44257 message: added test to make sure the stored file still exists 2014-09-16 10:07:17 +08:00
Petr Skoda
349f98ad3e MDL-45941 implement support for message sending from DB transactions and fix other problems
This patch includes following fixes:
 - messages may be now sent when database transactions active
 - consistent return status on failure from message_send(), false is
   returned only when message not created in message(_read)? table,
   processor failure results in debugging message only and messages
   are not marked as read
 - message_sent is triggered always with id from message table
 - logic for marking messages as viewed was standardised
 - message_viewed event is triggered consistently
 - improved performance when fetching user preferences
 - full unit tests coverage for send_message() function
 - fixed multiple other smaller issues discovered by unit tests
2014-06-17 16:09:43 +12:00
Juan Leyva
5e12b369af MDL-44954 messages: Fixed save notifications with the notification flag 2014-04-07 12:19:52 +02:00
Michael Aherne
780cf0a728 MDL-43440 unit tests Use correct cm identifier in unit tests 2014-01-25 08:56:43 +11:00
Rajesh Taneja
fd0f7ac5c2 MDL-33618 Messages: Added support to disable message provider 2013-11-21 09:40:34 +08:00
Petr Škoda
f007e89961 MDL-42224 clean up message and email redirection testing 2013-10-12 13:59:07 +02:00
Yuliya Bozhko
56b9a02eea MDL-41956 messages: Accept attachments in send_message() in email message provider 2013-10-01 15:38:02 +13:00
Petr Škoda
2988b725bc MDL-39915 cleanup core_messagelib_testcase 2013-07-27 19:39:47 +02:00
Andrew Davis (andyjdavis)
6ba8a4bee2 MDL-30545 messaging prefs: add Andy's extra unit tests. 2012-10-23 18:41:43 +08:00
Tim Hunt
2cf5ab1028 MDL-30545 messaging prefs: show all relevant message providers.
Some message providers have an associated capability. For example
the mod/quiz:emailconfirmsubmission capability. At the moment,
we only show the preferences for the capabilities that the user
has in the system context.

That does not work for the example capability above. Typically
the capability will be overridden in one quiz, to allow for
Students, and the user will have the Student role in the course
context. Therefore, this message type does not appear on the
preferences page.

This fix corrects the logic, so that all message types that are
to the current user are displayed.
2012-10-23 18:41:43 +08:00