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

Added toLowerCase() and toUpperCase()

This commit is contained in:
Daniel St. Jules
2013-09-14 11:22:52 -04:00
parent ea20aebc91
commit 61cd5f5f4d
6 changed files with 152 additions and 0 deletions

View File

@@ -338,6 +338,32 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
return $testData;
}
public function stringsForToLowerCase()
{
$testData = array(
array('foo bar', 'FOO BAR'),
array(' foo_bar ', ' FOO_bar '),
array('fòô bàř', 'FÒÔ BÀŘ', 'UTF-8'),
array(' fòô_bàř ', ' FÒÔ_bàř ', 'UTF-8'),
array('αυτοκίνητο', 'ΑΥΤΟΚΊΝΗΤΟ', 'UTF-8'),
);
return $testData;
}
public function stringsForToUpperCase()
{
$testData = array(
array('FOO BAR', 'foo bar'),
array(' FOO_BAR ', ' FOO_bar '),
array('FÒÔ BÀŘ', 'fòô bàř', 'UTF-8'),
array(' FÒÔ_BÀŘ ', ' FÒÔ_bàř ', 'UTF-8'),
array('ΑΥΤΟΚΊΝΗΤΟ', 'αυτοκίνητο', 'UTF-8'),
);
return $testData;
}
public function stringsForSlugify()
{
$testData = array(

View File

@@ -222,6 +222,26 @@ class StaticStringyTestCase extends CommonTest
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForToLowerCase
*/
public function testToLowerCase($expected, $str, $encoding = null)
{
$result = S::toLowerCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForToUpperCase
*/
public function testToUpperCase($expected, $str, $encoding = null)
{
$result = S::toUpperCase($str, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForSlugify
*/

View File

@@ -285,6 +285,30 @@ class StringyTestCase extends CommonTest
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForToLowerCase
*/
public function testToLowerCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->toLowerCase();
$this->assertInstanceOf('Stringy\Stringy', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForToUpperCase
*/
public function testToUpperCase($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->toUpperCase();
$this->assertInstanceOf('Stringy\Stringy', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForSlugify
*/