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

Added lines

This commit is contained in:
Daniel St. Jules
2015-07-25 22:19:36 -07:00
parent cce314f4a5
commit b9cf4b6ae3
3 changed files with 63 additions and 0 deletions

View File

@@ -259,6 +259,43 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
);
}
/**
* @dataProvider linesProvider()
*/
public function testLines($expected, $str, $encoding = null)
{
$result = S::create($str, $encoding)->lines();
$this->assertInternalType('array', $result);
foreach ($result as $line) {
$this->assertStringy($line);
}
for ($i = 0; $i < count($expected); $i++) {
$this->assertEquals($expected[$i], $result[$i]);
}
}
public function linesProvider()
{
return array(
array(array(), ""),
array(array(''), "\r\n"),
array(array('foo', 'bar'), "foo\nbar"),
array(array('foo', 'bar'), "foo\rbar"),
array(array('foo', 'bar'), "foo\r\nbar"),
array(array('foo', '', 'bar'), "foo\r\n\r\nbar"),
array(array('foo', 'bar', ''), "foo\r\nbar\r\n"),
array(array('', 'foo', 'bar'), "\r\nfoo\r\nbar"),
array(array('fòô', 'bàř'), "fòô\nbàř", 'UTF-8'),
array(array('fòô', 'bàř'), "fòô\rbàř", 'UTF-8'),
array(array('fòô', 'bàř'), "fòô\n\rbàř", 'UTF-8'),
array(array('fòô', 'bàř'), "fòô\r\nbàř", 'UTF-8'),
array(array('fòô', '', 'bàř'), "fòô\r\n\r\nbàř", 'UTF-8'),
array(array('fòô', 'bàř', ''), "fòô\r\nbàř\r\n", 'UTF-8'),
array(array('', 'fòô', 'bàř'), "\r\nfòô\r\nbàř", 'UTF-8'),
);
}
/**
* @dataProvider upperCaseFirstProvider()
*/