Project

General

Profile

Bug #19601 » 9779_tests.diff

Administrator Admin, 2009-03-02 12:36

View differences:

tests/t3lib/t3lib_div_testcase.php (working copy)
/**
* @test
*/
public function checkTrimExplodeLimitsResults() {
public function checkTrimExplodeLimitsResultsToFirstXElementsWithPositiveParameter() {
$testString = ' a , b , c , , d,, ,e ';
$expectedArray = array('a', 'b', 'c , , d,, ,e'); // limiting returns the rest of the string as the last element
$expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
$actualArray = t3lib_div::trimExplode(',', $testString, false, 3);
$this->assertEquals($expectedArray, $actualArray);
......
/**
* @test
*/
public function checkTrimExplodeLimitsResultsToLastXElementsWithNegativeParameter() {
$testString = ' a , b , c , d, ,e, f , , ';
$expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
$actualArray = t3lib_div::trimExplode(',', $testString, true, -3);
$this->assertEquals($expectedArray, $actualArray);
}
/**
* @test
*/
public function checkTrimExplodeKeepsZeroAsString() {
$testString = 'a , b , c , ,d ,, ,e,f, 0 ,';
$expectedArray = array('a', 'b', 'c', 'd', 'e', 'f', '0');
(2-2/3)