Fix test had no assertions

This commit is contained in:
nathangray 2017-10-17 13:29:17 +02:00
parent 8b1a8d38f5
commit 6fad74c710

View File

@ -164,16 +164,31 @@ class SecurityTest extends TestCase {
* @param boolean $result If we expect the string to fail or not
*
* @dataProvider unserializeProvider
* @requires PHP < 7
*/
public function testUnserialize($str, $result)
public function testObjectsCannotBeUnserializedInPhp5($str, $result)
{
$r=@php_safe_unserialize($str);
$this->assertSame($result, $r, 'Save unserialize failed');
}
/**
* Test safe unserialization
*
* @param String $str Serialized string to be checked
* @param boolean $result If we expect the string to fail or not
*
* @dataProvider unserializeProvider
* @requires PHP 7
*/
public function testObjectsCannotBeUnserializedInPhp7($str, $result)
{
$r=@php_safe_unserialize($str);
if((bool)($r) !== $result)
{
if (!$result)
{
if (PHP_VERSION >= 7)
{
$matches = null;
if (preg_match_all('/([^ ]+) Object\(/', array2string($r), $matches))
@ -188,15 +203,13 @@ class SecurityTest extends TestCase {
}
}
else
{
$this->fail($str);
}
}
else
{
$this->fail("false positive: $str");
}
}
// Avoid this test getting reported as no assertions, we do the testing
// in the foreach loop
$this->assertTrue(true);
}
/**