/** * Test finding loops between two items referring to each other. * * @param array $categories * @param array $expected * @dataProvider provider_loop_categories */ public function test_tool_health_category_find_loops($categories, $expected) { $loops = tool_health_category_find_loops($categories); $this->assertEquals($expected, $loops); }
/** * Search for problems in the course categories. * * @uses $DB * @return array List of categories that contain missing parents or loops. */ public function find_problems() { global $DB; static $answer = null; if (is_null($answer)) { $categories = $DB->get_records('course_categories', array(), 'id'); // Look for missing parents. $missingparent = tool_health_category_find_missing_parents($categories); // Look for loops. $loops = tool_health_category_find_loops($categories); $answer = array($missingparent, $loops); } return $answer; }