From bd02e70293755d98b4f4020ddaae65cb2c8c4c14 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 3 Aug 2015 15:38:57 -0400 Subject: [PATCH] CRM-14055 - Add unit test for creating event from template --- tests/phpunit/api/v3/EventTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index a024995d8b..aa9e2e91cd 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -559,4 +559,29 @@ class api_v3_EventTest extends CiviUnitTestCase { $this->assertEquals(1, $result['values']['id']['api.required']); } + public function testCreateFromTemplate() { + $templateParams = array( + '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', + ); + $templateResult = $this->callAPISuccess('Event', 'create', array('is_template' => 1, 'template_title' => 'Test tpl') + $templateParams); + $eventResult = $this->callAPISuccess('Event', 'create', array( + 'template_id' => $templateResult['id'], + 'title' => 'Clone1', + 'start_date' => '2018-06-25 16:00:00', + )); + $eventResult = $this->callAPISuccess('Event', 'getsingle', array('id' => $eventResult['id'])); + foreach ($templateParams as $param => $value) { + $this->assertEquals($value, $eventResult[$param]); + } + } + } -- 2.25.1