Merge pull request #12236 from agileware/CIVICRM-874
[civicrm-core.git] / tests / phpunit / api / v3 / JobTest.php
index 17358a1cd3d2e8e1bafe4e83a2f0dbcbeb90281e..9795dfb0f06d0586af21124871ab16c990fe72d8 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
+ | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -31,7 +31,7 @@
  * @package CiviCRM_APIv3
  * @subpackage API_Job
  *
- * @copyright CiviCRM LLC (c) 2004-2017
+ * @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.
    */