X7ROOT File Manager
Current Path:
/home/cbholdings/pasukulu/lib/tests
home
/
cbholdings
/
pasukulu
/
lib
/
tests
/
๐
..
๐
accesslib_has_capability_test.php
(29.72 KB)
๐
accesslib_test.php
(240.86 KB)
๐
adminlib_test.php
(4.29 KB)
๐
admintree_test.php
(18.01 KB)
๐
ajaxlib_test.php
(4.4 KB)
๐
analysers_test.php
(12.79 KB)
๐
analytics
๐
antivirus_test.php
(11.81 KB)
๐
authlib_test.php
(19.04 KB)
๐
behat
๐
behat_lib_test.php
(3.25 KB)
๐
blocklib_test.php
(36.13 KB)
๐
check_test.php
(1.77 KB)
๐
client_test.php
(4.34 KB)
๐
collator_test.php
(12.06 KB)
๐
completionlib_test.php
(84.19 KB)
๐
component_test.php
(44.1 KB)
๐
componentlib_test.php
(6.91 KB)
๐
configonlylib_test.php
(5.93 KB)
๐
content
๐
content_test.php
(4.77 KB)
๐
context
๐
context_block_test.php
(4.14 KB)
๐
context_helper_test.php
(22.27 KB)
๐
context_test.php
(3.38 KB)
๐
core_media_player_native_test.php
(6.4 KB)
๐
core_renderer_template_exploit_test.php
(16.56 KB)
๐
coverage.php
(3.55 KB)
๐
cron_test.php
(6.86 KB)
๐
csslib_test.php
(1.56 KB)
๐
csvclass_test.php
(5.62 KB)
๐
curl_security_helper_test.php
(14.79 KB)
๐
customcontext_test.php
(4.66 KB)
๐
dataformat_test.php
(3.74 KB)
๐
datalib_test.php
(48.36 KB)
๐
datalib_update_with_unique_index_test.php
(6.06 KB)
๐
date_legacy_test.php
(13.62 KB)
๐
date_test.php
(25.77 KB)
๐
db
๐
editorlib_test.php
(1.95 KB)
๐
encryption_test.php
(8.68 KB)
๐
environment_test.php
(8.49 KB)
๐
event
๐
event_course_module_instance_list_viewed.php
(2.54 KB)
๐
event_course_module_viewed.php
(3.14 KB)
๐
exporter_test.php
(11.26 KB)
๐
external
๐
externallib_test.php
(2.02 KB)
๐
filelib_test.php
(77.16 KB)
๐
filestorage_zip_archive_test.php
(2.55 KB)
๐
filetypes_test.php
(10.06 KB)
๐
filter_manager_test.php
(3.31 KB)
๐
filterlib_test.php
(36.76 KB)
๐
fixtures
๐
formslib_test.php
(39.94 KB)
๐
gdlib_test.php
(5.68 KB)
๐
googlelib_test.php
(1.6 KB)
๐
gradelib_test.php
(11.96 KB)
๐
grades_external_test.php
(15.04 KB)
๐
grading_external_test.php
(26.33 KB)
๐
graphlib_test.php
(4.61 KB)
๐
grouplib_test.php
(109.11 KB)
๐
h5p_clean_orphaned_records_task_test.php
(3.16 KB)
๐
html2text_test.php
(7.54 KB)
๐
html_writer_test.php
(9.65 KB)
๐
htmlpurifier_test.php
(23.01 KB)
๐
http_client_test.php
(14.94 KB)
๐
hub
๐
ip_utils_test.php
(14.13 KB)
๐
jquery_test.php
(1.58 KB)
๐
ldaplib_test.php
(17.73 KB)
๐
licenselib_test.php
(11.58 KB)
๐
lock
๐
lock_config_test.php
(3.47 KB)
๐
lock_test.php
(5.3 KB)
๐
markdown_test.php
(2.24 KB)
๐
mathslib_test.php
(13.42 KB)
๐
medialib_test.php
(19.63 KB)
๐
message_test.php
(12.25 KB)
๐
messageinbound_test.php
(5.96 KB)
๐
messagelib_test.php
(56.36 KB)
๐
minify_test.php
(3.12 KB)
๐
modinfolib_test.php
(54.43 KB)
๐
moodle_page_test.php
(31.59 KB)
๐
moodle_url_test.php
(15.64 KB)
๐
moodlelib_current_language_test.php
(7.68 KB)
๐
moodlelib_test.php
(237.46 KB)
๐
moodlenet
๐
myprofilelib_test.php
(12.36 KB)
๐
navigation
๐
navigationlib_test.php
(31.79 KB)
๐
notification_test.php
(4.35 KB)
๐
oauth2
๐
oauth2_test.php
(23.06 KB)
๐
other
๐
output
๐
outputcomponents_test.php
(33.25 KB)
๐
outputfactories_test.php
(6.78 KB)
๐
outputrenderers_test.php
(1.62 KB)
๐
outputrequirementslib_test.php
(16.29 KB)
๐
pdflib_test.php
(3.18 KB)
๐
performance
๐
persistent_test.php
(30.53 KB)
๐
phpxmlrpc_test.php
(2.04 KB)
๐
plugin_manager_test.php
(27.4 KB)
๐
plugininfo
๐
portfoliolib_test.php
(8.4 KB)
๐
progress_display_test.php
(3.75 KB)
๐
progress_test.php
(14.48 KB)
๐
qrcode_test.php
(1.68 KB)
๐
questionlib_test.php
(100.67 KB)
๐
regex_test.php
(1.55 KB)
๐
report_helper_test.php
(2.62 KB)
๐
requirejs_test.php
(2.22 KB)
๐
rsslib_test.php
(7.35 KB)
๐
rtlcss_test.php
(56.86 KB)
๐
sample_questions.ser
(141.76 KB)
๐
sample_questions.xml
(102.62 KB)
๐
sample_questions_with_old_image_tag.ser
(4.85 KB)
๐
sample_questions_with_old_image_tag.xml
(4.08 KB)
๐
sample_questions_wrong.xml
(102.57 KB)
๐
scss_test.php
(4.26 KB)
๐
session_manager_test.php
(34.79 KB)
๐
session_redis_test.php
(13.56 KB)
๐
sessionlib_test.php
(12.32 KB)
๐
setuplib_test.php
(20.17 KB)
๐
statslib_test.php
(26.68 KB)
๐
string_manager_standard_test.php
(10.18 KB)
๐
tablelib_test.php
(25.12 KB)
๐
task
๐
text_test.php
(26.53 KB)
๐
theme_config_test.php
(9.94 KB)
๐
update_api_test.php
(6.62 KB)
๐
update_checker_test.php
(10.82 KB)
๐
update_code_manager_test.php
(8.88 KB)
๐
update_validator_test.php
(18.28 KB)
๐
upgrade_util_test.php
(5.32 KB)
๐
upgradelib_test.php
(69.6 KB)
๐
user_menu_test.php
(3.75 KB)
๐
user_test.php
(34.34 KB)
๐
useragent_test.php
(83.82 KB)
๐
weblib_format_text_test.php
(11.91 KB)
๐
weblib_test.php
(43.44 KB)
๐
xhprof_test.php
(3.14 KB)
๐
xhtml_container_stack_test.php
(4.05 KB)
๐
xmlize_test.php
(2.55 KB)
Editing: collator_test.php
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Unit tests for our utf-8 aware collator which is used for sorting. * * @package core * @category test * @copyright 2011 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace core; use core_collator; defined('MOODLE_INTERNAL') || die(); /** * Unit tests for our utf-8 aware collator which is used for sorting. * * @package core * @category test * @copyright 2011 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class collator_test extends \advanced_testcase { /** * @var string The initial lang, stored because we change it during testing */ protected $initiallang = null; /** * @var string The last error that has occurred */ protected $error = null; /** * Prepares things for this test case. */ protected function setUp(): void { global $SESSION; if (isset($SESSION->lang)) { $this->initiallang = $SESSION->lang; } $SESSION->lang = 'en'; // Make sure we test en language to get consistent results, hopefully all systems have this locale. if (extension_loaded('intl')) { $this->error = 'Collation aware sorting not supported'; } else { $this->error = 'Collation aware sorting not supported, PHP extension "intl" is not available.'; } parent::setUp(); } /** * Cleans things up after this test case has run. */ protected function tearDown(): void { global $SESSION; parent::tearDown(); if ($this->initiallang !== null) { $SESSION->lang = $this->initiallang; $this->initiallang = null; } else { unset($SESSION->lang); } } /** * Tests the static asort method. */ public function test_asort() { $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc'); $result = core_collator::asort($arr); $this->assertSame(array('aa', 'ab', 'cc'), array_values($arr)); $this->assertSame(array(1, 'b', 0), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc'); $result = core_collator::asort($arr, core_collator::SORT_STRING); $this->assertSame(array('aa', 'ab', 'cc'), array_values($arr)); $this->assertSame(array(1, 'b', 0), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => 'aac', 1 => 'Aac', 0 => 'cc'); $result = core_collator::asort($arr, (core_collator::SORT_STRING | core_collator::CASE_SENSITIVE)); $this->assertSame(array('Aac', 'aac', 'cc'), array_values($arr)); $this->assertSame(array(1, 'b', 0), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => 'a1', 1 => 'a10', 0 => 'a3b'); $result = core_collator::asort($arr); $this->assertSame(array('a1', 'a10', 'a3b'), array_values($arr)); $this->assertSame(array('b', 1, 0), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => 'a1', 1 => 'a10', 0 => 'a3b'); $result = core_collator::asort($arr, core_collator::SORT_NATURAL); $this->assertSame(array('a1', 'a3b', 'a10'), array_values($arr)); $this->assertSame(array('b', 0, 1), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => '1.1.1', 1 => '1.2', 0 => '1.20.2'); $result = core_collator::asort($arr, core_collator::SORT_NATURAL); $this->assertSame(array_values($arr), array('1.1.1', '1.2', '1.20.2')); $this->assertSame(array_keys($arr), array('b', 1, 0)); $this->assertTrue($result); $arr = array('b' => '-1', 1 => 1000, 0 => -1.2, 3 => 1, 4 => false); $result = core_collator::asort($arr, core_collator::SORT_NUMERIC); $this->assertSame(array(-1.2, '-1', false, 1, 1000), array_values($arr)); $this->assertSame(array(0, 'b', 4, 3, 1), array_keys($arr)); $this->assertTrue($result); $arr = array('b' => array(1), 1 => array(2, 3), 0 => 1); $result = core_collator::asort($arr, core_collator::SORT_REGULAR); $this->assertSame(array(1, array(1), array(2, 3)), array_values($arr)); $this->assertSame(array(0, 'b', 1), array_keys($arr)); $this->assertTrue($result); // Test sorting of array of arrays - first element should be used for actual comparison. $arr = array(0=>array('bb', 'z'), 1=>array('ab', 'a'), 2=>array('zz', 'x')); $result = core_collator::asort($arr, core_collator::SORT_REGULAR); $this->assertSame(array(1, 0, 2), array_keys($arr)); $this->assertTrue($result); $arr = array('a' => 'รกb', 'b' => 'ab', 1 => 'aa', 0=>'cc', 'x' => 'รb'); $result = core_collator::asort($arr); $this->assertSame(array('aa', 'ab', 'รกb', 'รb', 'cc'), array_values($arr), $this->error); $this->assertSame(array(1, 'b', 'a', 'x', 0), array_keys($arr), $this->error); $this->assertTrue($result); $a = array(2=>'b', 1=>'c'); $c =& $a; $b =& $a; core_collator::asort($b); $this->assertSame($a, $b); $this->assertSame($c, $b); } /** * Tests the static asort_objects_by_method method. */ 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 = core_collator::asort_objects_by_method($objects, 'get_protected_name'); $this->assertSame(array(1, 'b', 0), array_keys($objects)); $this->assertSame(array('aa', 'ab', 'cc'), $this->get_ordered_names($objects, 'get_protected_name')); $this->assertTrue($result); $objects = array( 'b' => new string_test_class('a20'), 1 => new string_test_class('a1'), 0 => new string_test_class('a100') ); $result = core_collator::asort_objects_by_method($objects, 'get_protected_name', core_collator::SORT_NATURAL); $this->assertSame(array(1, 'b', 0), array_keys($objects)); $this->assertSame(array('a1', 'a20', 'a100'), $this->get_ordered_names($objects, 'get_protected_name')); $this->assertTrue($result); } /** * Tests the static asort_objects_by_method method. */ public function test_asort_objects_by_property() { $objects = array( 'b' => new string_test_class('ab'), 1 => new string_test_class('aa'), 0 => new string_test_class('cc') ); $result = core_collator::asort_objects_by_property($objects, 'publicname'); $this->assertSame(array(1, 'b', 0), array_keys($objects)); $this->assertSame(array('aa', 'ab', 'cc'), $this->get_ordered_names($objects, 'publicname')); $this->assertTrue($result); $objects = array( 'b' => new string_test_class('a20'), 1 => new string_test_class('a1'), 0 => new string_test_class('a100') ); $result = core_collator::asort_objects_by_property($objects, 'publicname', core_collator::SORT_NATURAL); $this->assertSame(array(1, 'b', 0), array_keys($objects)); $this->assertSame(array('a1', 'a20', 'a100'), $this->get_ordered_names($objects, 'publicname')); $this->assertTrue($result); } /** * Tests the sorting of an array of arrays by key. */ public function test_asort_array_of_arrays_by_key() { $array = array( 'a' => array('name' => 'bravo'), 'b' => array('name' => 'charlie'), 'c' => array('name' => 'alpha') ); $this->assertSame(array('a', 'b', 'c'), array_keys($array)); $this->assertTrue(core_collator::asort_array_of_arrays_by_key($array, 'name')); $this->assertSame(array('c', 'a', 'b'), array_keys($array)); $array = array( 'a' => array('name' => 'b'), 'b' => array('name' => 1), 'c' => array('name' => 0) ); $this->assertSame(array('a', 'b', 'c'), array_keys($array)); $this->assertTrue(core_collator::asort_array_of_arrays_by_key($array, 'name')); $this->assertSame(array('c', 'b', 'a'), array_keys($array)); $array = array( 'a' => array('name' => 'รกb'), 'b' => array('name' => 'ab'), 1 => array('name' => 'aa'), 'd' => array('name' => 'cc'), 0 => array('name' => 'รb') ); $this->assertSame(array('a', 'b', 1, 'd', 0), array_keys($array)); $this->assertTrue(core_collator::asort_array_of_arrays_by_key($array, 'name')); $this->assertSame(array(1, 'b', 'a', 0, 'd'), array_keys($array)); $this->assertSame(array( 1 => array('name' => 'aa'), 'b' => array('name' => 'ab'), 'a' => array('name' => 'รกb'), 0 => array('name' => 'รb'), 'd' => array('name' => 'cc') ), $array); } /** * Returns an array of sorted names. * @param array $objects * @param string $methodproperty * @return array */ protected function get_ordered_names($objects, $methodproperty = 'get_protected_name') { $return = array(); foreach ($objects as $object) { if ($methodproperty == 'publicname') { $return[] = $object->publicname; } else { $return[] = $object->$methodproperty(); } } return $return; } /** * Tests the static ksort method. */ public function test_ksort() { $arr = array('b' => 'ab', 1 => 'aa', 0 => 'cc'); $result = core_collator::ksort($arr); $this->assertSame(array(0, 1, 'b'), array_keys($arr)); $this->assertSame(array('cc', 'aa', 'ab'), array_values($arr)); $this->assertTrue($result); $obj = new \stdClass(); $arr = array('1.1.1'=>array(), '1.2'=>$obj, '1.20.2'=>null); $result = core_collator::ksort($arr, core_collator::SORT_NATURAL); $this->assertSame(array('1.1.1', '1.2', '1.20.2'), array_keys($arr)); $this->assertSame(array(array(), $obj, null), array_values($arr)); $this->assertTrue($result); $a = array(2=>'b', 1=>'c'); $c =& $a; $b =& $a; core_collator::ksort($b); $this->assertSame($a, $b); $this->assertSame($c, $b); } } /** * Simple class used to work with the unit test. * * @package core * @category phpunit * @copyright 2011 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class string_test_class extends \stdClass { /** * @var string A public property */ public $publicname; /** * @var string A protected property */ protected $protectedname; /** * @var string A private property */ private $privatename; /** * Constructs the test instance. * @param string $name */ public function __construct($name) { $this->publicname = $name; $this->protectedname = $name; $this->privatename = $name; } /** * Returns the protected property. * @return string */ public function get_protected_name() { return $this->protectedname; } /** * Returns the protected property. * @return string */ public function get_private_name() { return $this->publicname; } }
Upload File
Create Folder