Skip to content

Commit

Permalink
Merge pull request #25356 from seamuslee001/dev_core_4081
Browse files Browse the repository at this point in the history
dev/core#4081 Ensure that if using the API to update an event templat…
  • Loading branch information
eileenmcnaughton authored Jan 16, 2023
2 parents 049e73e + 4bb246b commit d69cf75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 0 additions & 3 deletions CRM/Event/BAO/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public static function add(&$params) {
*/
public static function create(&$params) {
$transaction = new CRM_Core_Transaction();
if (empty($params['is_template'])) {
$params['is_template'] = 0;
}
// check if new event, if so set the created_id (if not set)
// and always set created_date to now
if (empty($params['id'])) {
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/api/v3/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,4 +935,28 @@ public function testGetListLeadingZero() {
$this->assertEquals(1, $result['count']);
}

/**
* Test that using the API to update an Event template keeps the is_template parameter the same
* @dataProvider versionThreeAndFour
*/
public function testUpdateEventTemplate($version): void {
$this->_apiversion = $version;
$templateParams = [
'summary' => 'Sign up now to learn the results of this unit test',
'description' => 'This event is created from a template, so all the values should be the same as the original ones.',
'event_type_id' => 1,
'is_public' => 1,
'end_date' => '2018-06-25 17:00:00',
'is_online_registration' => 1,
'registration_start_date' => '2017-06-25 17:00:00',
'registration_end_date' => '2018-06-25 17:00:00',
'max_participants' => 100,
'event_full_text' => 'Sorry! We are already full',
];
$template = $this->callAPISuccess('Event', 'create', ['is_template' => 1, 'template_title' => 'Test tpl'] + $templateParams);
$this->callAPISuccess('Event', 'create', ['id' => $template['id'], 'is_public' => 0]);
$template = $this->callAPISuccess('Event', 'get', ['id' => $template['id']])['values'][$template['id']];
$this->assertEquals(1, $template['is_template']);
}

}

0 comments on commit d69cf75

Please sign in to comment.