Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/aws-sns-message-validator/src/MessageValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static function convertLambdaMessage(Message $lambdaMessage)
* @param string $hostNamePattern
*/
public function __construct(
callable $certClient = null,
?callable $certClient = null,
$hostNamePattern = ''
) {
$this->certClient = $certClient ?: function($certUrl) {
Expand Down
4 changes: 3 additions & 1 deletion tests/bounce_threshold_block_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_emailutils;
use PHPUnit\Framework\Attributes\CoversMethod;

defined('MOODLE_INTERNAL') || die();

global $CFG;
Expand All @@ -26,10 +28,10 @@
* @copyright 2024 onwards Catalyst IT {@link http://www.catalyst-eu.net/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[CoversMethod(hook_callbacks::class, 'before_email_to_user')]
final class bounce_threshold_block_test extends \advanced_testcase {
/**
* Test that emails over the bounce threshold are blocked.
* @covers \tool_emailutils\hook_callbacks::before_email_to_user
*/
public function test_bounce_threshold_block_test(): void {
global $CFG;
Expand Down
13 changes: 7 additions & 6 deletions tests/sns_client_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
require_once(__DIR__ . '/../lib/aws-sns-message-validator/src/Message.php');

use Aws\Sns\Message;
use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Tests for SNS client.
Expand All @@ -30,15 +32,17 @@
* @copyright Catalyst IT 2024
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[
CoversMethod(sns_client::class, '__construct'),
CoversMethod(sns_notification::class, 'process_notification'),
]
final class sns_client_test extends \advanced_testcase {
/**
* Test email for user in unit test */
const TEST_EMAIL = 'user@example.com';

/**
* Test required libs are installed.
*
* @covers \tool_emailutils\sns_client::__construct
*/
public function test_lib(): void {
// Use process message to ensure no errors from missing libs are produced.
Expand Down Expand Up @@ -199,15 +203,14 @@ public static function bounce_processing_provider(): array {
/**
* Tests the email bounce thresholds
*
* @dataProvider bounce_processing_provider
* @param string $type bounce type
* @param string $subtype bounce subtype
* @param int $notifications the number of notifications to process
* @param int $sendcount the email send count
* @param int $expectedbounces expected bounce conut
* @param bool $overthreshold expected to be over the threshold
* @covers \tool_emailutils\sns_notification::process_notification()
**/
#[DataProvider('bounce_processing_provider')]
public function test_bounce_processing(
string $type,
string $subtype,
Expand Down Expand Up @@ -257,8 +260,6 @@ public function test_bounce_processing(

/**
* Tests the email delivery processing
*
* @covers \tool_emailutils\sns_notification::process_notification()
**/
public function test_delivery_processing(): void {
global $CFG, $DB;
Expand Down
15 changes: 10 additions & 5 deletions tests/suffix_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

namespace tool_emailutils;

use PHPUnit\Framework\Attributes\CoversMethod;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Tests for DKIM default suffix.
*
Expand All @@ -24,6 +27,11 @@
* @copyright Catalyst IT 2024
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[
CoversMethod(dns_util::class, 'get_selector_suffix'),
CoversMethod(dns_util::class, 'get_primary_domain'),
CoversMethod(dns_util::class, 'get_noreply_domain'),
]
final class suffix_test extends \advanced_testcase {
/**
* Test suffix.
Expand All @@ -32,15 +40,12 @@ final class suffix_test extends \advanced_testcase {
* @param string $noreplydomain noreply domain
* @param string $primarydomain primary domain
* @param string $selectorsuffix selector suffix
* @dataProvider dns_comparisons
* @covers \tool_emailutils\dns_util::get_selector_suffix
* @covers \tool_emailutils\dns_util::get_primary_domain
* @covers \tool_emailutils\dns_util::get_noreply_domain
*/
#[DataProvider('dns_comparisons')]
public function test_suffix(string $lmsdomain, string $noreplydomain, string $primarydomain, string $selectorsuffix): void {
$this->resetAfterTest();
$mock = $this->getMockBuilder('\tool_emailutils\dns_util')
->setMethods(['get_primary_domain', 'get_noreply_domain'])
->onlyMethods(['get_primary_domain', 'get_noreply_domain'])
->getMock();

$mock->expects($this->any())
Expand Down
7 changes: 4 additions & 3 deletions tests/suppressionlist_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_emailutils;
use PHPUnit\Framework\Attributes\CoversMethod;
use tool_emailutils\task\update_suppression_list;

defined('MOODLE_INTERNAL') || die();

global $CFG;
Expand All @@ -26,6 +29,7 @@
* @copyright 2024 onwards Catalyst IT {@link http://www.catalyst-eu.net/}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[CoversMethod(update_suppression_list::class, 'execute')]
final class suppressionlist_test extends \advanced_testcase {
/**
* Set up the test environment and return a configured task.
Expand Down Expand Up @@ -81,8 +85,6 @@ protected function prepare_test_environment(bool $enablefeature): \tool_emailuti
* 3. Each record has the correct email and reason as per the mock data.
* 4. A CSV file is generated with the correct headers and content matching the database.
*
* @covers \tool_emailutils\task\update_suppression_list::execute
*
* @return void
* @throws \dml_exception
*/
Expand Down Expand Up @@ -128,7 +130,6 @@ public function test_suppression_list_update_and_export(): void {
*
* @return void
* @throws \dml_exception
* @covers \tool_emailutils\task\update_suppression_list::execute
*/
public function test_suppression_list_update_when_disabled(): void {
global $DB;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2024112901;
$plugin->version = 2025021900;
$plugin->release = 2024112901;
$plugin->requires = 2024042200;
$plugin->component = 'tool_emailutils';
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [404, 405];
$plugin->supported = [500, 501];
Loading