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:
@@ -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() {
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user