Merge pull request #11735 from mukeshcompucorp/CRM-21814-add-proper-container-to...
[civicrm-core.git] / tests / phpunit / api / v3 / DomainTest.php
index 34c1a41ccd9f45377b77c04f0122ffdbfaa7c4c7..80f5425f0894a1587faa587bf6a8c862e99d270d 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2016                                |
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -171,7 +171,44 @@ class api_v3_DomainTest extends CiviUnitTestCase {
     $this->assertEquals($result['count'], 1);
     $this->assertNotNull($result['id']);
     $this->assertEquals($result['values'][$result['id']]['name'], $this->params['name']);
-    $this->assertEquals($result['values'][$result['id']]['version'], $this->params['domain_version']);
+    $this->assertEquals($result['values'][$result['id']]['domain_version'], $this->params['domain_version']);
+  }
+
+  /**
+   * Test if Domain.create does not touch the version of the domain.
+   *
+   * See CRM-17430.
+   */
+  public function testUpdateDomainName() {
+    // First create a domain.
+    $domain_result = $this->callAPISuccess('domain', 'create', $this->params);
+    $domain_before = $this->callAPISuccess('Domain', 'getsingle', array('id' => $domain_result['id']));
+
+    // Change domain name.
+    $this->callAPISuccess('Domain', 'create', array(
+      'id' => $domain_result['id'],
+      'name' => 'B-Team domain',
+    ));
+
+    // Get domain again.
+    $domain_after = $this->callAPISuccess('Domain', 'getsingle', array('id' => $domain_result['id']));
+
+    // Version should still be the same.
+    $this->assertEquals($domain_before['version'], $domain_after['version']);
+  }
+
+  /**
+   * Test whether Domain.create returns a correct value for domain_version.
+   *
+   * See CRM-17430.
+   */
+  public function testCreateDomainResult() {
+    // First create a domain.
+    $domain_result = $this->callAPISuccess('Domain', 'create', $this->params);
+    $result_value = CRM_Utils_Array::first($domain_result['values']);
+
+    // Check for domain_version in create result.
+    $this->assertEquals($this->params['domain_version'], $result_value['domain_version']);
   }
 
   /**