/**
  * Test the search function with a list of CMs. This was broken at one point.
  */
 public function test_search_with_cm_list()
 {
     global $DB;
     $this->resetAfterTest();
     // Turn on the system.
     set_config(year_tables::CONFIG_ENABLED, year_tables::ENABLED_ON, 'local_ousearch');
     // Create a test courses.
     $course1 = $this->getDataGenerator()->create_course(array('startdate' => strtotime('2013-01-04 10:00')));
     // Create imaginary CMs.
     $cm1 = (object) array('id' => 19, 'course' => $course1->id);
     $cm2 = (object) array('id' => 77, 'course' => $course1->id);
     $cm3 = (object) array('id' => 138, 'course' => $course1->id);
     // Add four documents, two to one CM and one to two others..
     self::add_test_document(1, $course1, 'Doc One', $cm1->id);
     self::add_test_document(2, $course1, 'Doc Two', $cm2->id);
     self::add_test_document(3, $course1, 'Doc Three', $cm2->id);
     self::add_test_document(4, $course1, 'Doc Four', $cm3->id);
     // Check search on whole course.
     $this->check_search($course1, 'Doc', array(1, 2, 3, 4));
     // Check search on cm1 and cm2.
     $search = new local_ousearch_search('Doc');
     $search->set_plugin('test_yeartablestest');
     $search->set_coursemodule_array(array($cm1, $cm2));
     $this->check_search_inner($search, array(1, 2, 3));
     // Check on cm1 and cm3.
     $search = new local_ousearch_search('Doc');
     $search->set_plugin('test_yeartablestest');
     $search->set_coursemodule_array(array($cm1, $cm3));
     $this->check_search_inner($search, array(1, 4));
 }