diff --git a/lib/aws-sns-message-validator/src/MessageValidator.php b/lib/aws-sns-message-validator/src/MessageValidator.php index 474aec8..4697a31 100644 --- a/lib/aws-sns-message-validator/src/MessageValidator.php +++ b/lib/aws-sns-message-validator/src/MessageValidator.php @@ -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) { diff --git a/tests/bounce_threshold_block_test.php b/tests/bounce_threshold_block_test.php index ea56781..06905c5 100644 --- a/tests/bounce_threshold_block_test.php +++ b/tests/bounce_threshold_block_test.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . namespace tool_emailutils; +use PHPUnit\Framework\Attributes\CoversMethod; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -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; diff --git a/tests/sns_client_test.php b/tests/sns_client_test.php index 4dbd973..3b4e34e 100644 --- a/tests/sns_client_test.php +++ b/tests/sns_client_test.php @@ -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. @@ -30,6 +32,10 @@ * @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 */ @@ -37,8 +43,6 @@ final class sns_client_test extends \advanced_testcase { /** * 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. @@ -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, @@ -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; diff --git a/tests/suffix_test.php b/tests/suffix_test.php index a0d69a3..f048018 100644 --- a/tests/suffix_test.php +++ b/tests/suffix_test.php @@ -16,6 +16,9 @@ namespace tool_emailutils; +use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\DataProvider; + /** * Tests for DKIM default suffix. * @@ -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. @@ -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()) diff --git a/tests/suppressionlist_test.php b/tests/suppressionlist_test.php index abc1700..75abd6a 100644 --- a/tests/suppressionlist_test.php +++ b/tests/suppressionlist_test.php @@ -15,6 +15,9 @@ // along with Moodle. If not, see . namespace tool_emailutils; +use PHPUnit\Framework\Attributes\CoversMethod; +use tool_emailutils\task\update_suppression_list; + defined('MOODLE_INTERNAL') || die(); global $CFG; @@ -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. @@ -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 */ @@ -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; diff --git a/version.php b/version.php index 36a3fb3..f92de8e 100644 --- a/version.php +++ b/version.php @@ -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];