/** * Test that we can search and include related competencies. * * @return void */ public function test_search_competencies_including_related() { $this->setUser($this->creator); $lpg = $this->getDataGenerator()->get_plugin_generator('core_competency'); $framework = $lpg->create_framework(); $c1 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id())); $c2 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id())); $c3 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id())); $c4 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id())); $c5 = $lpg->create_competency(array('competencyframeworkid' => $framework->get_id())); // We have 1-2, 1-3, 2-4, and no relation between 2-3 nor 1-4 nor 5. $rc12 = $lpg->create_related_competency(array('competencyid' => $c1->get_id(), 'relatedcompetencyid' => $c2->get_id())); $rc13 = $lpg->create_related_competency(array('competencyid' => $c1->get_id(), 'relatedcompetencyid' => $c3->get_id())); $rc24 = $lpg->create_related_competency(array('competencyid' => $c2->get_id(), 'relatedcompetencyid' => $c4->get_id())); $result = external::search_competencies('comp', $framework->get_id(), true); $result = external_api::clean_returnvalue(external::search_competencies_returns(), $result); $this->assertCount(5, $result); }