mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUG Fix issue with SapphireTest::assertDOSEquals incorrectly passing on empty set
This commit is contained in:
parent
29c5eff433
commit
c69e55c49c
@ -670,29 +670,36 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
* @param mixed $dataObjectSet The {@link SS_List} to test.
|
* @param mixed $dataObjectSet The {@link SS_List} to test.
|
||||||
*/
|
*/
|
||||||
public function assertDOSEquals($matches, $dataObjectSet) {
|
public function assertDOSEquals($matches, $dataObjectSet) {
|
||||||
if(!$dataObjectSet) return;
|
// Extract dataobjects
|
||||||
|
|
||||||
$extracted = array();
|
$extracted = array();
|
||||||
foreach($dataObjectSet as $item) $extracted[] = $item->toMap();
|
if($dataObjectSet) {
|
||||||
|
foreach ($dataObjectSet as $item) {
|
||||||
foreach($matches as $match) {
|
/** @var DataObject $item */
|
||||||
$matched = false;
|
$extracted[] = $item->toMap();
|
||||||
foreach($extracted as $i => $item) {
|
|
||||||
if($this->dataObjectArrayMatch($item, $match)) {
|
|
||||||
// Remove it from $extracted so that we don't get duplicate mapping.
|
|
||||||
unset($extracted[$i]);
|
|
||||||
$matched = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We couldn't find a match - assertion failed
|
// Check all matches
|
||||||
$this->assertTrue(
|
if($matches) {
|
||||||
$matched,
|
foreach ($matches as $match) {
|
||||||
"Failed asserting that the SS_List contains an item matching "
|
$matched = false;
|
||||||
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
foreach ($extracted as $i => $item) {
|
||||||
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
if ($this->dataObjectArrayMatch($item, $match)) {
|
||||||
);
|
// Remove it from $extracted so that we don't get duplicate mapping.
|
||||||
|
unset($extracted[$i]);
|
||||||
|
$matched = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We couldn't find a match - assertion failed
|
||||||
|
$this->assertTrue(
|
||||||
|
$matched,
|
||||||
|
"Failed asserting that the SS_List contains an item matching "
|
||||||
|
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
||||||
|
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have leftovers than the DOS has extra data that shouldn't be there
|
// If we have leftovers than the DOS has extra data that shouldn't be there
|
||||||
|
Loading…
x
Reference in New Issue
Block a user