1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-27 06:54:44 +02:00

Add toSpaces() and toTabs()

This commit is contained in:
Daniel St. Jules
2013-07-18 23:42:38 -04:00
parent 493a194612
commit 031e9e68b2
3 changed files with 95 additions and 4 deletions

View File

@@ -444,6 +444,47 @@ class StringyTestCase extends PHPUnit_Framework_TestCase {
return $testData;
}
/**
* @dataProvider stringsForToSpaces
*/
public function testToSpaces($expected, $string, $tabLength = 4) {
$result = S::toSpaces($string, $tabLength);
$this->assertEquals($expected, $result);
}
public function stringsForToSpaces() {
$testData = array(
array(' foo bar ', ' foo bar '),
array(' foo bar ', ' foo bar ', 5),
array(' foo bar ', ' foo bar ', 2),
array('foobar', ' foo bar ', 0),
array(" foo\n bar", " foo\n bar"),
array(" fòô\n bàř", " fòô\n bàř")
);
return $testData;
}
/**
* @dataProvider stringsForToTabs
*/
public function testToTabs($expected, $string, $tabLength = 4) {
$result = S::toTabs($string, $tabLength);
$this->assertEquals($expected, $result);
}
public function stringsForToTabs() {
$testData = array(
array(' foo bar ', ' foo bar '),
array(' foo bar ', ' foo bar ', 5),
array(' foo bar ', ' foo bar ', 2),
array(" foo\n bar", " foo\n bar"),
array(" fòô\n bàř", " fòô\n bàř")
);
return $testData;
}
}
?>