Exemplo n.º 1
0
 /**
  * Tests the static asort_objects_by_method method
  * @return void
  */
 public function test_asort_objects_by_method()
 {
     $objects = array('b' => new string_test_class('ab'), 1 => new string_test_class('aa'), 0 => new string_test_class('cc'));
     $result = collatorlib::asort_objects_by_method($objects, 'get_protected_name');
     $this->assertSame(array_keys($objects), array(1, 'b', 0));
     $this->assertSame($this->get_ordered_names($objects, 'get_protected_name'), array('aa', 'ab', 'cc'));
     $this->assertTrue($result);
     $objects = array('b' => new string_test_class('a20'), 1 => new string_test_class('a1'), 0 => new string_test_class('a100'));
     $result = collatorlib::asort_objects_by_method($objects, 'get_protected_name', collatorlib::SORT_NATURAL);
     $this->assertSame(array_keys($objects), array(1, 'b', 0));
     $this->assertSame($this->get_ordered_names($objects, 'get_protected_name'), array('a1', 'a20', 'a100'));
     $this->assertTrue($result);
 }
Exemplo n.º 2
0
/**
 * Returns a list of valid and compatible themes
 *
 * @return array
 */
function get_list_of_themes()
{
    global $CFG;
    $themes = array();
    if (!empty($CFG->themelist)) {
        // use admin's list of themes
        $themelist = explode(',', $CFG->themelist);
    } else {
        $themelist = array_keys(get_plugin_list("theme"));
    }
    foreach ($themelist as $key => $themename) {
        $theme = theme_config::load($themename);
        $themes[$themename] = $theme;
    }
    collatorlib::asort_objects_by_method($themes, 'get_theme_name');
    return $themes;
}
Exemplo n.º 3
0
 function test_asort_objects_by_method()
 {
     $objects = array('b' => new string_test_class('ab'), 1 => new string_test_class('aa'), 0 => new string_test_class('cc'));
     collatorlib::asort_objects_by_method($objects, 'get_protected_name');
     $this->assertIdentical(array_keys($objects), array(1, 'b', 0));
     $this->assertIdentical($this->get_ordered_names($objects, 'get_protected_name'), array('aa', 'ab', 'cc'));
     $objects = array('a' => new string_test_class('áb'), 'b' => new string_test_class('ab'), 1 => new string_test_class('aa'), 0 => new string_test_class('cc'));
     collatorlib::asort_objects_by_method($objects, 'get_private_name');
     $this->assertIdentical(array_keys($objects), array(1, 'b', 'a', 0), $this->error);
     $this->assertIdentical($this->get_ordered_names($objects, 'get_private_name'), array('aa', 'ab', 'áb', 'cc'), $this->error);
 }