1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-12 16:24:00 +02:00

StaticStringy should return strings and not Stringy objects, add tests for trim

This commit is contained in:
Daniel St. Jules
2013-07-26 20:37:06 -04:00
parent 8063276578
commit cfeadbfacc
4 changed files with 63 additions and 26 deletions

View File

@@ -447,6 +447,22 @@ class CommonTest extends PHPUnit_Framework_TestCase
return $testData;
}
public function stringsForTrim()
{
$testData = array(
array('foo bar', ' foo bar '),
array('foo bar', ' foo bar'),
array('foo bar', 'foo bar '),
array('foo bar', "\n\t foo bar \n\t"),
array('fòô bàř', ' fòô bàř '),
array('fòô bàř', ' fòô bàř'),
array('fòô bàř', 'fòô bàř '),
array('fòô bàř', "\n\t fòô bàř \n\t")
);
return $testData;
}
// A test is required so as not to throw an error
// This is a lot cleaner than using PHPUnit's mocks to spy
public function test() {

View File

@@ -259,4 +259,13 @@ class StaticStringyTestCase extends CommonTest
$result = S::shuffle($str, $encoding);
$this->assertEquals(count_chars($str), count_chars($result));
}
/**
* @dataProvider stringsForTrim
*/
public function testTrim($expected, $str)
{
$result = S::trim($str);
$this->assertEquals($expected, $result);
}
}

View File

@@ -259,4 +259,13 @@ class StringyTestCase extends CommonTest
$result = S::create($str, $encoding)->shuffle();
$this->assertEquals(count_chars($str), count_chars($result));
}
/**
* @dataProvider stringsForTrim
*/
public function testTrim($expected, $str)
{
$result = S::create($str)->trim();
$this->assertEquals($expected, $result);
}
}