1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-06 21:36:31 +02:00

Breaking change: Fix docs, force static methods to return strings

rather than Stringy instances
This commit is contained in:
Daniel St. Jules
2017-03-06 15:11:14 -05:00
parent 5303203a72
commit bf2a302aa1
4 changed files with 65 additions and 44 deletions

View File

@@ -15,25 +15,38 @@ class StaticStringyTestCase extends PHPUnit_Framework_TestCase
public function testEmptyArgsInvocation()
{
$result = S::toLowerCase();
$this->assertEquals('', (string) $result);
$this->assertEquals('', $result);
}
public function testInvocation()
{
$result = S::toLowerCase('FOOBAR');
$this->assertEquals('foobar', (string) $result);
$this->assertEquals('foobar', $result);
$this->assertInternalType('string', $result);
}
public function testPartialArgsInvocation()
{
$result = S::slice('foobar', 0, 3);
$this->assertEquals('foo', (string) $result);
$this->assertEquals('foo', $result);
$this->assertInternalType('string', $result);
}
public function testFullArgsInvocation()
{
$result = S::slice('fòôbàř', 0, 3, 'UTF-8');
$this->assertEquals('fòô', (string) $result);
$this->assertEquals('fòô', $result);
$this->assertInternalType('string', $result);
}
public function testArrayReturnValue()
{
$result = S::lines("a\nb");
$this->assertEquals(['a', 'b'], $result);
$this->assertInternalType('array', $result);
foreach ($result as $val) {
$this->assertInternalType('string', $val);
}
}
/**