Merge pull request #12236 from agileware/CIVICRM-874
[civicrm-core.git] / tests / phpunit / api / v3 / JobTest.php
index 4047f383508d69e2509009744a3623bb0221505b..9795dfb0f06d0586af21124871ab16c990fe72d8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
@@ -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.
    */