Asserts the results as expected regardless of order between and in rows.
array $expected: An array of the expected results.
protected function assertResults($expected, $sorted = FALSE) {
$found = TRUE;
$expected_keys = array_keys($expected);
foreach ($this->queryResult as $key => $row) {
$keys = $sorted ? array(
$key,
) : $expected_keys;
foreach ($keys as $key) {
$expected_row = $expected[$key];
if (!array_diff_assoc($row, $expected_row) && !array_diff_assoc($expected_row, $row)) {
continue 2;
}
}
$found = FALSE;
break;
}
return $this
->assertTrue($found, strtr('!expected expected, !found found', array(
'!expected' => print_r($expected, TRUE),
'!found' => print_r($this->queryResult, TRUE),
)));
}