CRM-16876 Change country name to uppercase
[civicrm-core.git] / tests / phpunit / CRM / Core / BAO / CustomFieldTest.php
index 055401a2e57c316c476b54549d242834567f97f6..54bc605697176a15ba3c9ebdb65428b6dfcc72ed 100644 (file)
@@ -40,7 +40,7 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
     $dbFieldName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'name', 'id', 'Database check for edited CustomField.');
     $dbColumnName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'column_name', 'id', 'Database check for edited CustomField.');
     $this->assertEquals(strtolower("{$dbFieldName}_{$customFieldID}"), $dbColumnName,
-        "Column name ends in ID");
+      "Column name ends in ID");
 
     Custom::deleteGroup($customGroup);
   }
@@ -60,7 +60,7 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
     );
     $dbColumnName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'column_name', 'id', 'Database check for edited CustomField.');
     $this->assertEquals($fields['column_name'], $dbColumnName,
-        "Column name set as specified");
+      "Column name set as specified");
 
     Custom::deleteGroup($customGroup);
   }
@@ -169,66 +169,66 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
    */
   public function testMoveField() {
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
-    $this->assertTrue($countriesByName['Andorra'] > 0);
+    $this->assertTrue($countriesByName['ANDORRA'] > 0);
     $groups = array(
       'A' => Custom::createGroup(array(
-          'title' => 'Test_Group A',
-          'name' => 'test_group_a',
-          'extends' => array('Individual'),
-          'style' => 'Inline',
-          'is_multiple' => 0,
-          'is_active' => 1,
-          'version' => 3,
-        )),
+        'title' => 'Test_Group A',
+        'name' => 'test_group_a',
+        'extends' => array('Individual'),
+        'style' => 'Inline',
+        'is_multiple' => 0,
+        'is_active' => 1,
+        'version' => 3,
+      )),
       'B' => Custom::createGroup(array(
-          'title' => 'Test_Group B',
-          'name' => 'test_group_b',
-          'extends' => array('Individual'),
-          'style' => 'Inline',
-          'is_multiple' => 0,
-          'is_active' => 1,
-          'version' => 3,
-        )),
+        'title' => 'Test_Group B',
+        'name' => 'test_group_b',
+        'extends' => array('Individual'),
+        'style' => 'Inline',
+        'is_multiple' => 0,
+        'is_active' => 1,
+        'version' => 3,
+      )),
     );
     $fields = array(
       'countryA' => Custom::createField(array(), array(
-          'groupId' => $groups['A']->id,
-          'label' => 'Country A',
-          'dataType' => 'Country',
-          'htmlType' => 'Select Country',
-        )),
+        'groupId' => $groups['A']->id,
+        'label' => 'Country A',
+        'dataType' => 'Country',
+        'htmlType' => 'Select Country',
+      )),
       'countryB' => Custom::createField(array(), array(
-          'groupId' => $groups['A']->id,
-          'label' => 'Country B',
-          'dataType' => 'Country',
-          'htmlType' => 'Select Country',
-        )),
+        'groupId' => $groups['A']->id,
+        'label' => 'Country B',
+        'dataType' => 'Country',
+        'htmlType' => 'Select Country',
+      )),
       'countryC' => Custom::createField(array(), array(
-          'groupId' => $groups['B']->id,
-          'label' => 'Country C',
-          'dataType' => 'Country',
-          'htmlType' => 'Select Country',
-        )),
+        'groupId' => $groups['B']->id,
+        'label' => 'Country C',
+        'dataType' => 'Country',
+        'htmlType' => 'Select Country',
+      )),
     );
     $contacts = array(
       'alice' => Contact::createIndividual(array(
-          'first_name' => 'Alice',
-          'last_name' => 'Albertson',
-          'custom_' . $fields['countryA']->id => $countriesByName['Andorra'],
-          'custom_' . $fields['countryB']->id => $countriesByName['Barbados'],
-        )),
+        'first_name' => 'Alice',
+        'last_name' => 'Albertson',
+        'custom_' . $fields['countryA']->id => $countriesByName['ANDORRA'],
+        'custom_' . $fields['countryB']->id => $countriesByName['BARBADOS'],
+      )),
       'bob' => Contact::createIndividual(array(
-          'first_name' => 'Bob',
-          'last_name' => 'Roberts',
-          'custom_' . $fields['countryA']->id => $countriesByName['Austria'],
-          'custom_' . $fields['countryB']->id => $countriesByName['Bermuda'],
-          'custom_' . $fields['countryC']->id => $countriesByName['Chad'],
-        )),
+        'first_name' => 'Bob',
+        'last_name' => 'Roberts',
+        'custom_' . $fields['countryA']->id => $countriesByName['AUSTRIA'],
+        'custom_' . $fields['countryB']->id => $countriesByName['BERMUDA'],
+        'custom_' . $fields['countryC']->id => $countriesByName['CHAD'],
+      )),
       'carol' => Contact::createIndividual(array(
-          'first_name' => 'Carol',
-          'last_name' => 'Carolson',
-          'custom_' . $fields['countryC']->id => $countriesByName['Cambodia'],
-        )),
+        'first_name' => 'Carol',
+        'last_name' => 'Carolson',
+        'custom_' . $fields['countryC']->id => $countriesByName['CAMBODIA'],
+      )),
     );
 
     // Move!
@@ -240,7 +240,8 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
       $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}");
       $this->fail('Expected exception when querying column on wrong table');
     }
-    catch(PEAR_Exception$e) {}
+    catch (PEAR_Exception$e) {
+    }
     $errorScope = NULL;
 
     // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before
@@ -251,7 +252,7 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
             AND {$fields['countryC']->column_name} is null",
       array(
         1 => array($contacts['alice'], 'Integer'),
-        3 => array($countriesByName['Barbados'], 'Integer'),
+        3 => array($countriesByName['BARBADOS'], 'Integer'),
       )
     );
 
@@ -263,8 +264,8 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
             AND {$fields['countryC']->column_name} = %4",
       array(
         1 => array($contacts['bob'], 'Integer'),
-        3 => array($countriesByName['Bermuda'], 'Integer'),
-        4 => array($countriesByName['Chad'], 'Integer'),
+        3 => array($countriesByName['BERMUDA'], 'Integer'),
+        4 => array($countriesByName['CHAD'], 'Integer'),
       )
     );
 
@@ -276,11 +277,12 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase {
             AND {$fields['countryC']->column_name} = %4",
       array(
         1 => array($contacts['carol'], 'Integer'),
-        4 => array($countriesByName['Cambodia'], 'Integer'),
+        4 => array($countriesByName['CAMBODIA'], 'Integer'),
       )
     );
 
     Custom::deleteGroup($groups['A']);
     Custom::deleteGroup($groups['B']);
   }
+
 }