2011-11-14 12:26:51 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2011-11-14 12:26:51 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class URLSegmentFilterTest extends SapphireTest {
|
|
|
|
|
|
|
|
function testReplacesCommonEnglishSymbols() {
|
|
|
|
$f = new URLSegmentFilter();
|
|
|
|
$f->setAllowMultibyte(false);
|
|
|
|
$this->assertEquals(
|
|
|
|
'john-and-spencer',
|
|
|
|
$f->filter('John & Spencer')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testTransliteratesNonAsciiUrls() {
|
|
|
|
$f = new URLSegmentFilter();
|
|
|
|
$f->setAllowMultibyte(false);
|
|
|
|
$this->assertEquals(
|
|
|
|
'broetchen',
|
|
|
|
$f->filter('Brötchen')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRetainsNonAsciiUrlsWithAllowMultiByteOption() {
|
|
|
|
$f = new URLSegmentFilter();
|
|
|
|
$f->setAllowMultibyte(true);
|
|
|
|
$this->assertEquals(
|
|
|
|
'brötchen',
|
|
|
|
$f->filter('Brötchen')
|
|
|
|
);
|
|
|
|
}
|
2011-12-17 01:13:27 +01:00
|
|
|
|
|
|
|
function testReplacements() {
|
|
|
|
$f = new URLSegmentFilter();
|
|
|
|
$this->assertEquals(
|
|
|
|
'tim-and-struppi',
|
|
|
|
$f->filter('Tim&Struppi')
|
|
|
|
);
|
|
|
|
|
|
|
|
// Customize replacements
|
|
|
|
$rs = $f->getReplacements();
|
|
|
|
$rs['/&/u'] = '-und-';
|
|
|
|
$f->setReplacements($rs);
|
|
|
|
$this->assertEquals(
|
|
|
|
'tim-und-struppi',
|
|
|
|
$f->filter('Tim&Struppi')
|
|
|
|
);
|
|
|
|
}
|
2011-11-14 12:26:51 +01:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|