/** * Tests the get_all_children() function. */ public function test_get_all_children() { // Create a tree with nothing in. $structure = tree::get_root_json(array(), tree::OP_OR); $tree1 = new tree($structure); // Create second tree with complex structure. $structure->c = array(tree::get_nested_json(array(self::mock(array('m' => '1')), self::mock(array('m' => '2'))), tree::OP_OR), self::mock(array('m' => 3))); $tree2 = new tree($structure); // Check list of conditions from both trees. $this->assertEquals(array(), $tree1->get_all_children('core_availability\\condition')); $result = $tree2->get_all_children('core_availability\\condition'); $this->assertEquals(3, count($result)); $this->assertEquals('{mock:n,1}', (string) $result[0]); $this->assertEquals('{mock:n,2}', (string) $result[1]); $this->assertEquals('{mock:n,3}', (string) $result[2]); // Check specific type, should give same results. $result2 = $tree2->get_all_children('availability_mock\\condition'); $this->assertEquals($result, $result2); }