Skip to content

Commit

Permalink
ActionMappingTest - Update data-providers for phpunit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
totten committed Dec 19, 2024
1 parent a023e3d commit 725025c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/ActionMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/ActionMapping/ByTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down
45 changes: 38 additions & 7 deletions tests/phpunit/CRM/Event/ActionMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => ['[email protected]'],
'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', []);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------

Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/Civi/ActionSchedule/SavedSearchMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', '', []]];
}

}

0 comments on commit 725025c

Please sign in to comment.