From 74c0c50443b26fe6747fca8e267b335d6858c783 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 9 Aug 2006 18:02:09 +0200 Subject: cleanID unit tests + fix missing utf8 deaccent character mapping + set utf-8 charset for HTMLReporter (unit tests) darcs-hash:20060809160209-9b6ab-26c80a4830643b9790536f6d3a4adee0f451e4f0.gz --- _test/cases/inc/pageutils_clean_id.test.php | 137 ++++++++++++++++++++++++++++ _test/index.php | 2 +- 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 _test/cases/inc/pageutils_clean_id.test.php (limited to '_test') diff --git a/_test/cases/inc/pageutils_clean_id.test.php b/_test/cases/inc/pageutils_clean_id.test.php new file mode 100644 index 000000000..0b4f51571 --- /dev/null +++ b/_test/cases/inc/pageutils_clean_id.test.php @@ -0,0 +1,137 @@ +assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + + $conf['useslash'] = 1; + $tests = array(); + $tests[] = array('page/page',false,'page:page'); + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + } + + function test_sepchar(){ + // we test multiple cases here + // format: $id, $ascii, $correct_output + $tests = array(); + + global $conf; + $conf['sepchar'] = '-'; + $conf['deaccent'] = 1; + + $tests[] = array('pa-ge',false,'pa-ge'); + $tests[] = array('pa%ge',false,'pa-ge'); + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + } + + function test_deaccent_keep(){ + // we test multiple cases here + // format: $id, $ascii, $correct_output + $tests = array(); + + global $conf; + $conf['sepchar'] = '_'; + $conf['deaccent'] = 0; + + $tests[] = array('pàge',false,'pàge'); + $tests[] = array('pagĖ',false,'pagė'); + $tests[] = array('pagĒēĔĕĖėĘęĚě',false,'pagēēĕĕėėęęěě'); + $tests[] = array('ښ',false,'ښ'); + $tests[] = array('ښ侧化并곦ঝഈβ',false,'ښ侧化并곦ঝഈ'); + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + } + + function test_deaccent_romanize(){ + // we test multiple cases here + // format: $id, $ascii, $correct_output + $tests = array(); + + global $conf; + $conf['sepchar'] = '_'; + $conf['deaccent'] = 2; + + $tests[] = array('pàge',false,'page'); + $tests[] = array('pagĖ',false,'page'); + $tests[] = array('pagĒēĔĕĖėĘęĚě',false,'pageeeeeeeeee'); + $tests[] = array('ښ',false,'ښ'); + $tests[] = array('ښ侧化并곦ঝഈβ',false,'ښ侧化并곦ঝഈ'); + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + } + + function test_deaccent_ascii(){ + // we test multiple cases here + // format: $id, $ascii, $correct_output + $tests = array(); + + global $conf; + $conf['sepchar'] = '_'; + $conf['deaccent'] = 0; + + $tests[] = array('pàge',true,'page'); + $tests[] = array('pagĖ',true,'page'); + $tests[] = array('pagĒēĔĕĖėĘęĚě',true,'pageeeeeeeeee'); + $tests[] = array('ښ',true,''); + $tests[] = array('ښ侧化并곦ঝഈβ',true,''); + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + + $conf['deaccent'] = 1; + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + + $conf['deaccent'] = 2; + + foreach($tests as $test){ + $this->assertEqual(cleanID($test[0],$test[1]),$test[2]); + } + } + +} +//Setup VIM: ex: et ts=4 enc=utf-8 : diff --git a/_test/index.php b/_test/index.php index 99fae4b95..87cc10a35 100644 --- a/_test/index.php +++ b/_test/index.php @@ -49,7 +49,7 @@ function & DW_TESTS_GetReporter() { break; case DW_TESTS_OUTPUT_HTML: default: - $Reporter = new HTMLReporter(); + $Reporter = new HTMLReporter('utf-8'); break; } } -- cgit v1.2.3