mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-26 01:43:47 +01:00
Fix test had no assertions
This commit is contained in:
parent
8b1a8d38f5
commit
6fad74c710
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user