|
<?php
|
|
|
|
class tx_ourclienttestsuite_mbstring_testcase extends tx_phpunit_testcase {
|
|
|
|
/**
|
|
* Array with testdata and expected results.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function cropData(){
|
|
return array(
|
|
array('Hallo Welt', 'Hallo...',5),
|
|
array('Hallo Welt', '... Welt',-5),
|
|
array('塑造更紧密的客户关','塑造更...',3),
|
|
array('塑造更紧密的客户关','...客户关',-3),
|
|
array('塑造更紧密的客户关','塑造更紧密的客户关',50),
|
|
array('','',0),
|
|
array('塑造更紧密的客户关','塑造更紧密的客户关',0),
|
|
array('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.','Lorem ipsu...',10),
|
|
array('AAAaaaBBBCCC@@@&&&','AA...',2),
|
|
array('AAAaaaBBBCCC@@@&&&','...&&',-2),
|
|
array('리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다','리케이션을 제공합니다...',11),
|
|
array('리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다공합니다리케이션을 제공합니다','...리케이션을 제공합니다',-11),
|
|
array('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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|
}
|
|
|
|
/**
|
|
* Should test the functionallity of the patched TYPO3 core functionallity
|
|
*
|
|
* @param string $input text that should be cropped
|
|
* @param string $expectedOutput expected cropped output
|
|
* @param integer $len number of characters that should be kept
|
|
* @dataProvider cropData
|
|
* @test
|
|
*/
|
|
public function cropTextMBString($input,$expectedOutput,$len){
|
|
$oldSetting = $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'];
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'mbstring';
|
|
|
|
/* @var $t3lib_cs t3lib_cs */
|
|
$t3lib_cs = t3lib_div::makeInstance('t3lib_cs');
|
|
$crop = '...';
|
|
$charset = 'utf-8';
|
|
|
|
$result = $t3lib_cs->crop($charset,$input,$len,$crop);
|
|
|
|
$this->assertEquals($expectedOutput,$result);
|
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = $oldSetting;
|
|
}
|
|
|
|
/**
|
|
* Should test the core functionallity with the unpatched code and the same data
|
|
*
|
|
* @param string $input text that should be cropped
|
|
* @param string $expectedOutput expected cropped output
|
|
* @param integer $len number of characters that should be kept
|
|
* @dataProvider cropData
|
|
* @test
|
|
*/
|
|
public function cropTextCore($input,$expectedOutput,$len){
|
|
$oldSetting = $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'];
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = false;
|
|
|
|
/* @var $t3lib_cs t3lib_cs */
|
|
$t3lib_cs = t3lib_div::makeInstance('t3lib_cs');
|
|
$crop = '...';
|
|
$charset = 'utf-8';
|
|
|
|
$result = $t3lib_cs->crop($charset,$input,$len,$crop);
|
|
|
|
$this->assertEquals($expectedOutput,$result);
|
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = $oldSetting;
|
|
}
|
|
}
|
|
|
|
?>
|