1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-13 00:34:11 +02:00

function isSerialized(), with tests

This commit is contained in:
Lucas
2013-08-23 15:19:24 +02:00
committed by Daniel St. Jules
parent 454e8e2f87
commit 0b76c56333
6 changed files with 73 additions and 0 deletions

View File

@@ -782,6 +782,21 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
return $testData;
}
public function stringsForIsSerialized()
{
$testData = array(
array(false, ''),
array(true, 'a:1:{s:3:"foo";s:3:"bar";}'),
array(false, 'a:1:{s:3:"foo";s:3:"bar"}'),
array(true, serialize(false)),
array(true, 'a:1:{s:3:"foo";s:3:"bar";}', 'UTF-8'),
array(false, 'a:1:{s:3:"foo";s:3:"bar"}', 'UTF-8'),
array(true, serialize(false), 'UTF-8'),
);
return $testData;
}
public function stringsForIsUpperCase()
{
$testData = array(

View File

@@ -472,6 +472,16 @@ class StaticStringyTestCase extends CommonTest
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForIsSerialized
*/
public function testIsSerialized($expected, $str, $encoding = null)
{
$result = S::isSerialized($str, $encoding);
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
}
/**
* @dataProvider stringsForIsUpperCase
*/

View File

@@ -550,6 +550,18 @@ class StringyTestCase extends CommonTest
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForIsSerialized
*/
public function testIsSerialized($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->isSerialized();
$this->assertInternalType('boolean', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
/**
* @dataProvider stringsForIsUpperCase
*/