mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11174] Move assertion definition to base class.
PHPBB3-11174
This commit is contained in:
parent
d308ee8a25
commit
3ed4fc437e
2 changed files with 16 additions and 16 deletions
|
@ -175,20 +175,4 @@ class phpbb_search_native_test extends phpbb_database_test_case
|
||||||
}
|
}
|
||||||
$this->assert_array_content_equals($common, $this->search->get_common_words());
|
$this->assert_array_content_equals($common, $this->search->get_common_words());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assert_array_content_equals($one, $two)
|
|
||||||
{
|
|
||||||
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
|
|
||||||
// but one array_diff is not enough!
|
|
||||||
if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
|
|
||||||
{
|
|
||||||
// get a nice error message
|
|
||||||
$this->assertEquals($one, $two);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// increase assertion count
|
|
||||||
$this->assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,4 +141,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||||
{
|
{
|
||||||
return $matches[1] . strtoupper($matches[2]) . $matches[3];
|
return $matches[1] . strtoupper($matches[2]) . $matches[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function assert_array_content_equals($one, $two)
|
||||||
|
{
|
||||||
|
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
|
||||||
|
// but one array_diff is not enough!
|
||||||
|
if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
|
||||||
|
{
|
||||||
|
// get a nice error message
|
||||||
|
$this->assertEquals($one, $two);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// increase assertion count
|
||||||
|
$this->assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue