From 125918ddedae97ab5d638bc8c97269d941afc354 Mon Sep 17 00:00:00 2001 From: Matthew Wire Date: Sat, 28 Apr 2018 20:56:02 +0100 Subject: [PATCH] Unit test for Job.clone --- tests/phpunit/api/v3/JobTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index c42d29017f..9795dfb0f0 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -121,6 +121,22 @@ class api_v3_JobTest extends CiviUnitTestCase { $this->assertDBState('CRM_Core_DAO_Job', $result['id'], $this->_params); } + /** + * Clone job + */ + public function testClone() { + $createResult = $this->callAPISuccess('job', 'create', $this->_params); + $params = array('id' => $createResult['id']); + $cloneResult = $this->callAPIAndDocument('job', 'clone', $params, __FUNCTION__, __FILE__); + $clonedJob = $cloneResult['values'][$cloneResult['id']]; + $this->assertEquals($this->_params['name'] . ' - Copy', $clonedJob['name']); + $this->assertEquals($this->_params['description'], $clonedJob['description']); + $this->assertEquals($this->_params['parameters'], $clonedJob['parameters']); + $this->assertEquals($this->_params['is_active'], $clonedJob['is_active']); + $this->assertArrayNotHasKey('last_run', $clonedJob); + $this->assertArrayNotHasKey('scheduled_run_date', $clonedJob); + } + /** * Check if required fields are not passed. */ -- 2.25.1