diff --git a/tests/unit/core/mock/menu.php b/tests/unit/core/mock/menu.php index 43626f5dd040f..9c5a502628de3 100644 --- a/tests/unit/core/mock/menu.php +++ b/tests/unit/core/mock/menu.php @@ -59,6 +59,10 @@ public static function create(PHPUnit_Framework_TestCase $test, $setDefault = tr ->method('getItem') ->will($test->returnValueMap(self::prepareGetItemData())); + $mockObject->expects($test->any()) + ->method('getItems') + ->will($test->returnCallback(array('TestMockMenu', 'getItems'))); + $mockObject->expects($test->any()) ->method('getMenu') ->will($test->returnValue(self::$data)); @@ -101,6 +105,46 @@ protected static function prepareDefaultData() return $return; } + public static function getItems($attributes, $values) + { + $items = array(); + $attributes = (array) $attributes; + $values = (array) $values; + TestMockMenu::createMenuSampleData(); + + foreach (TestMockMenu::$data as $item) + { + $test = true; + + for ($i = 0, $count = count($attributes); $i < $count; $i++) + { + if (is_array($values[$i])) + { + if (!in_array($item->{$attributes[$i]}, $values[$i])) + { + $test = false; + break; + } + } + else + { + if ($item->{$attributes[$i]} != $values[$i]) + { + $test = false; + break; + } + } + } + + if ($test) + { + $items[] = $item; + } + } + + return $items; + } + protected static function prepareGetItemsData() { // Why this is clear here?