From 725025cfec80fa2c363ea86c70c9207f52e3f987 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 18 Dec 2024 16:34:27 -0800 Subject: [PATCH] ActionMappingTest - Update data-providers for phpunit 10 --- .../CRM/Activity/ActionMappingTest.php | 2 +- .../Contribute/ActionMapping/ByTypeTest.php | 2 +- tests/phpunit/CRM/Event/ActionMappingTest.php | 45 ++++++++++++++++--- .../AbstractMappingTestCase.php | 5 ++- .../ActionSchedule/SavedSearchMappingTest.php | 4 +- 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/CRM/Activity/ActionMappingTest.php b/tests/phpunit/CRM/Activity/ActionMappingTest.php index 4f271b93db6..88446e84502 100644 --- a/tests/phpunit/CRM/Activity/ActionMappingTest.php +++ b/tests/phpunit/CRM/Activity/ActionMappingTest.php @@ -40,7 +40,7 @@ class CRM_Activity_ActionMappingTest extends \Civi\ActionSchedule\AbstractMappin * - recipients: array of emails * - subject: regex */ - public function createTestCases() { + public static function createTestCases(): array { $cs = []; $cs[] = [ diff --git a/tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php b/tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php index aaf69b3280e..5ec94ca3893 100644 --- a/tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php +++ b/tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php @@ -39,7 +39,7 @@ class CRM_Contribute_ActionMapping_ByTypeTest extends AbstractMappingTestCase { * - recipients: array of emails * - subject: regex */ - public function createTestCases(): array { + public static function createTestCases(): array { $cs = []; $cs[] = [ diff --git a/tests/phpunit/CRM/Event/ActionMappingTest.php b/tests/phpunit/CRM/Event/ActionMappingTest.php index 97915590563..bbd0fafe935 100644 --- a/tests/phpunit/CRM/Event/ActionMappingTest.php +++ b/tests/phpunit/CRM/Event/ActionMappingTest.php @@ -23,20 +23,51 @@ */ class CRM_Event_ActionMappingTest extends AbstractMappingTestCase { - public function createTestCases() { + public static function createTestCases(): array { + $cs = []; + + $cs[] = [ + '2015-02-01 00:00:00', + 'createReunion registerAliceDualRole scheduleForEventStart startWeekBefore targetByRole useHelloFirstName', + [ + [ + 'time' => '2015-01-25 00:00:00', + 'to' => ['alice@example.org'], + 'subject' => '/Hello, Alice/', + ], + ], + ]; + + return $cs; + } + + public function createReunion(array $params = [], string $identifier = 'event') { + $this->eventCreateUnpaid([ + 'title' => 'Roadie Reunion', + 'start_date' => '2015-02-01 00:00:00', + 'end_date' => '2015-02-03 05:00:00', + 'registration_start_date' => '2014-08-01 09:00:00', + 'registration_end_date' => '2015-01-15 23:59:59', + ]); } - public function testLimitByRoleID(): void { - $this->participantCreate(['role_id' => [1, 2], 'event_id' => $this->eventCreateUnpaid()['id']]); + public function registerAliceDualRole() { + $this->participantCreate([ + 'role_id' => [1, 2], + 'contact_id' => $this->contacts['alice']['id'], + 'event_id' => $this->getEventID(), + ]); + } + + public function scheduleForEventStart(): void { $this->schedule->mapping_id = CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID; $this->schedule->start_action_date = 'start_date'; $this->schedule->entity_value = $this->getEventID(); + } + + public function targetByRole(): void { $this->schedule->limit_to = 1; $this->schedule->recipient_listing = 1; - $this->startWeekBefore(); - $this->useHelloFirstName(); - $this->schedule->save(); - $this->callAPISuccess('Job', 'send_reminder', []); } } diff --git a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTestCase.php b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTestCase.php index 872f54cb32a..4196b882caf 100644 --- a/tests/phpunit/Civi/ActionSchedule/AbstractMappingTestCase.php +++ b/tests/phpunit/Civi/ActionSchedule/AbstractMappingTestCase.php @@ -95,7 +95,7 @@ abstract class AbstractMappingTestCase extends \CiviUnitTestCase { * - subject: regex * - message: regex */ - abstract public function createTestCases(); + abstract public static function createTestCases(): array; // ---------------------------------------- Setup Helpers ---------------------------------------- @@ -274,6 +274,9 @@ protected function setUp(): void { * @throws \Exception */ public function testDefault(string $targetDate, string $setupFuncs, array $expectMessages) { + if ($targetDate === 'INCOMPLETE') { + $this->markTestIncomplete(); + } $this->targetDate = $targetDate; foreach (explode(' ', $setupFuncs) as $setupFunc) { diff --git a/tests/phpunit/Civi/ActionSchedule/SavedSearchMappingTest.php b/tests/phpunit/Civi/ActionSchedule/SavedSearchMappingTest.php index 5acb1323dca..36bff1edcdd 100644 --- a/tests/phpunit/Civi/ActionSchedule/SavedSearchMappingTest.php +++ b/tests/phpunit/Civi/ActionSchedule/SavedSearchMappingTest.php @@ -159,8 +159,8 @@ protected function setDateField(string $fieldName): void { /** * Disable testDefault by returning no test cases */ - public function createTestCases() { - return []; + public static function createTestCases(): array { + return [['INCOMPLETE', '', []]]; } }