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

Merge branch 'pr/20' after cleanup

This commit is contained in:
Daniel St. Jules
2014-03-18 23:36:24 -04:00
4 changed files with 38 additions and 138 deletions

View File

@@ -181,52 +181,15 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
);
}
public function padProvider()
{
return array(
// $length <= $str
array('foo bar', 'foo bar', -1),
array('foo bar', 'foo bar', 7),
array('fòô bàř', 'fòô bàř', 7, ' ', 'right', 'UTF-8'),
// right
array('foo bar ', 'foo bar', 9),
array('foo bar_*', 'foo bar', 9, '_*', 'right'),
array('foo bar_*_', 'foo bar', 10, '_*', 'right'),
array('fòô bàř ', 'fòô bàř', 9, ' ', 'right', 'UTF-8'),
array('fòô bàř¬ø', 'fòô bàř', 9, '¬ø', 'right', 'UTF-8'),
array('fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'right', 'UTF-8'),
array('fòô bàř¬ø¬ø', 'fòô bàř', 11, '¬ø', 'right', 'UTF-8'),
// left
array(' foo bar', 'foo bar', 9, ' ', 'left'),
array('_*foo bar', 'foo bar', 9, '_*', 'left'),
array('_*_foo bar', 'foo bar', 10, '_*', 'left'),
array(' fòô bàř', 'fòô bàř', 9, ' ', 'left', 'UTF-8'),
array('¬øfòô bàř', 'fòô bàř', 9, '¬ø', 'left', 'UTF-8'),
array('¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'left', 'UTF-8'),
array('¬ø¬øfòô bàř', 'fòô bàř', 11, '¬ø', 'left', 'UTF-8'),
// both
array('foo bar ', 'foo bar', 8, ' ', 'both'),
array(' foo bar ', 'foo bar', 9, ' ', 'both'),
array('fòô bàř ', 'fòô bàř', 8, ' ', 'both', 'UTF-8'),
array(' fòô bàř ', 'fòô bàř', 9, ' ', 'both', 'UTF-8'),
array('fòô bàř¬', 'fòô bàř', 8, '¬ø', 'both', 'UTF-8'),
array('¬fòô bàř¬', 'fòô bàř', 9, '¬ø', 'both', 'UTF-8'),
array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'both', 'UTF-8'),
array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬ø', 'both', 'UTF-8'),
array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬øÿ', 'both', 'UTF-8'),
array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬øÿ', 'both', 'UTF-8'),
array('¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'both', 'UTF-8')
);
}
public function padLeftProvider()
{
return array(
array(' foo bar', 'foo bar', 9),
array('_*foo bar', 'foo bar', 9, '_*'),
array('_*_foo bar', 'foo bar', 10, '_*'),
array(' fòô bàř', 'fòô bàř', 9, ' ', 'UTF-8'),
array('¬øfòô bàř', 'fòô bàř', 9, '¬ø', 'UTF-8'),
array('¬ø¬fòô bàř', 'fòô bàř', 10, '¬ø', 'UTF-8'),
array('¬ø¬øfòô bàř', 'fòô bàř', 11, '¬ø', 'UTF-8'),
);
}
@@ -235,7 +198,11 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
{
return array(
array('foo bar ', 'foo bar', 9),
array('foo bar_*', 'foo bar', 9, '_*'),
array('foo bar_*_', 'foo bar', 10, '_*'),
array('fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'),
array('fòô bàř¬ø', 'fòô bàř', 9, '¬ø', 'UTF-8'),
array('fòô bàř¬ø¬', 'fòô bàř', 10, '¬ø', 'UTF-8'),
array('fòô bàř¬ø¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'),
);
}
@@ -245,7 +212,14 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
return array(
array('foo bar ', 'foo bar', 8),
array(' foo bar ', 'foo bar', 9, ' '),
array('fòô bàř ', 'fòô bàř', 8, ' ', 'UTF-8'),
array(' fòô bàř ', 'fòô bàř', 9, ' ', 'UTF-8'),
array('fòô bàř¬', 'fòô bàř', 8, '¬ø', 'UTF-8'),
array('¬fòô bàř¬', 'fòô bàř', 9, '¬ø', 'UTF-8'),
array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬ø', 'UTF-8'),
array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬ø', 'UTF-8'),
array('¬fòô bàř¬ø', 'fòô bàř', 10, '¬øÿ', 'UTF-8'),
array('¬øfòô bàř¬ø', 'fòô bàř', 11, '¬øÿ', 'UTF-8'),
array('¬øfòô bàř¬øÿ', 'fòô bàř', 12, '¬øÿ', 'UTF-8')
);
}

View File

@@ -140,25 +140,6 @@ class StaticStringyTestCase extends CommonTest
$this->assertEquals($expected, $result);
}
/**
* @dataProvider padProvider()
*/
public function testPad($expected, $str, $length, $padStr = ' ',
$padType = 'right', $encoding = null)
{
$result = S::pad($str, $length, $padStr, $padType, $encoding);
$this->assertInternalType('string', $result);
$this->assertEquals($expected, $result);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPadException()
{
$result = S::pad('string', 5, 'foo', 'bar');
}
/**
* @dataProvider padLeftProvider()
*/

View File

@@ -309,28 +309,6 @@ class StringyTestCase extends CommonTest
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider padProvider()
*/
public function testPad($expected, $str, $length, $padStr = ' ',
$padType = 'right', $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->pad($length, $padStr, $padType);
$this->assertInstanceOf('Stringy\Stringy', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @expectedException \InvalidArgumentException
*/
public function testPadException()
{
$stringy = S::create('foo');
$result = $stringy->pad(5, 'foo', 'bar');
}
/**
* @dataProvider padLeftProvider()
*/