You are here

function CountriesFunctionsUnitTest::testCountriesSort in Countries 8

Same name and namespace in other branches
  1. 7.2 tests/countries.test \CountriesFunctionsUnitTest::testCountriesSort()

This test that the country sort works.

File

tests/countries.test, line 422
Tests for countries.module.

Class

CountriesFunctionsUnitTest
Test the general functions provided by the module.

Code

function testCountriesSort() {
  $strings = array(
    'AA' => 'Zzz',
    'AB' => 'Aaa',
    'AC' => 'Åbc',
    'AD' => 'Acd',
  );
  uasort($strings, 'countries_sort');
  $this
    ->assertEqual(implode('-', array_keys($strings)), 'AB-AC-AD-AA', 'Simple string sort');
  $objects = array(
    'AA' => country_create(array(
      'name' => 'Aec',
      'iso2' => 'aa',
    )),
    'AD' => country_create(array(
      'name' => 'Abd',
      'iso2' => 'ad',
    )),
    'AC' => country_create(array(
      'name' => 'Åbc',
      'iso2' => 'ac',
    )),
    'AB' => country_create(array(
      'name' => 'Aba',
      'iso2' => 'ab',
    )),
  );
  uasort($objects, 'countries_sort');
  $this
    ->assertEqual(implode('-', array_keys($objects)), 'AB-AC-AD-AA', 'Simple object sort');
}