Skip to content

Commit

Permalink
MDL-64701 search: change category for customfield search area
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Mar 28, 2019
1 parent 0920f35 commit 23533bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions course/classes/search/customfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,16 @@ public function get_component_name() {
public function get_doc_icon(\core_search\document $doc) : \core_search\document_icon {
return new \core_search\document_icon('i/customfield');
}

/**
* Returns a list of category names associated with the area.
*
* @return array
*/
public function get_category_names() {
return [
\core_search\manager::SEARCH_AREA_CATEGORY_COURSE_CONTENT,
\core_search\manager::SEARCH_AREA_CATEGORY_COURSES
];
}
}
2 changes: 2 additions & 0 deletions course/tests/search_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,10 @@ public function test_get_doc_icon_for_section_area() {
public function test_get_category_names() {
$coursessearcharea = \core_search\manager::get_search_area($this->coursesareaid);
$sectionsearcharea = \core_search\manager::get_search_area($this->sectionareaid);
$customfieldssearcharea = \core_search\manager::get_search_area($this->customfieldareaid);

$this->assertEquals(['core-courses'], $coursessearcharea->get_category_names());
$this->assertEquals(['core-course-content'], $sectionsearcharea->get_category_names());
$this->assertEquals(['core-course-content', 'core-courses'], $customfieldssearcharea->get_category_names());
}
}

0 comments on commit 23533bc

Please sign in to comment.