Add in test from previous PR
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 19 Aug 2016 21:08:10 +0000 (07:08 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 19 Aug 2016 21:08:10 +0000 (07:08 +1000)
CRM/Utils/Address.php
tests/phpunit/CRM/Utils/AddressTest.php [new file with mode: 0644]

index 878390fb09234b1abd0f54911ee76a623d2666a4..01429fb4f3ae6d90495965e7637734eb74aacfa4 100644 (file)
@@ -94,6 +94,7 @@ class CRM_Utils_Address {
       }
     }
 
+    //CRM-16876 Display countries in all caps when in mailing mode.
     if ($mailing && !empty($fields['country'])) {
       if (Civi::settings()->get('hideCountryMailingLabels')) {
         $domain = CRM_Core_BAO_Domain::getDomain();
diff --git a/tests/phpunit/CRM/Utils/AddressTest.php b/tests/phpunit/CRM/Utils/AddressTest.php
new file mode 100644 (file)
index 0000000..df22b6d
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Class CRM_Utils_AddressTest
+ * @group headless
+ */
+class CRM_Utils_AddressTest extends CiviUnitTestCase {
+
+  public function setUp() {
+    parent::setUp();
+  }
+
+  public function testAddressFormat() {
+    $contact = $this->callAPISuccess('contact', 'create', array(
+      'first_name' => 'Micky',
+      'last_name' => 'mouse',
+      'contact_type' => 'Individual',
+    ));
+    $address = $this->callAPISuccess('address', 'create', array(
+      'street_address' => '1 Happy Place',
+      'city' => 'Miami',
+      'state_province' => 'Flordia',
+      'country' => 'United States',
+      'postal_code' => 33101,
+      'contact_id' => $contact['id'],
+      'location_type_id' => 5,
+      'is_primary' => 1,
+    ));
+    $addressDetails = $address['values'][$address['id']];
+    $countries = CRM_Core_PseudoConstant::country();
+    $addressDetails['country'] = $countries[$addressDetails['country_id']];
+    $formatted_address = CRM_Utils_Address::format($addressDetails, 'mailing_format', FALSE, TRUE);
+    $this->assertTrue((bool) strstr($formatted_address, 'UNITED STATES'));
+  }
+
+}