Merge branch 'MDL-69206-master' of git://github.com/mihailges/moodle
authorJake Dallimore <jake@moodle.com>
Wed, 15 Jul 2020 02:29:03 +0000 (10:29 +0800)
committerJake Dallimore <jake@moodle.com>
Wed, 15 Jul 2020 02:29:03 +0000 (10:29 +0800)
course/tests/behat/search_recommended_activities.feature
course/tests/services_content_item_service_test.php

index 202839d..414e62c 100644 (file)
@@ -8,7 +8,7 @@ Feature: Search recommended activities
     And I navigate to "Courses > Activity chooser > Recommended activities" in site administration
     When I set the field "search" to "assign"
     And I click on "Submit search" "button"
-    Then I should see "Search results: 1"
+    Then I should see "Search results"
     And "Assignment" "table_row" should exist
     And "Book" "table_row" should not exist
 
index 51d2183..f1924fb 100644 (file)
@@ -153,9 +153,12 @@ class services_content_item_service_testcase extends \advanced_testcase {
         $matchingcontentitems1 = $cis->get_content_items_by_name_pattern($user, $pattern1);
         $matchingcontentitems2 = $cis->get_content_items_by_name_pattern($user, $pattern2);
 
-        // The pattern "assign" should return 1 content item ("Assignment").
-        $this->assertCount(1, $matchingcontentitems1);
-        $this->assertEquals("Assignment", $matchingcontentitems1[0]->title);
+        // The pattern "assign" should return at least 1 content item (ex. "Assignment").
+        $this->assertGreaterThanOrEqual(1, count($matchingcontentitems1));
+        // Verify the pattern "assign" can be found in the title of each returned content item.
+        foreach ($matchingcontentitems1 as $contentitem) {
+            $this->assertEquals(1, preg_match("/$pattern1/i", $contentitem->title));
+        }
         // The pattern "random string" should not return any content items.
         $this->assertEmpty($matchingcontentitems2);
     }