Merge pull request #12236 from agileware/CIVICRM-874
[civicrm-core.git] / tests / phpunit / api / v3 / JobTest.php
index c42d29017f7c06fd2e086ed4dc7d6be82855f8a0..9795dfb0f06d0586af21124871ab16c990fe72d8 100644 (file)
@@ -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.
    */