SearchExcerptTestCase cannot be a UnitTest because it tries to invoke preprocess handlers (via search_simplify_excerpt_match) that need a hit to the db on module_list.

Attached patch converts SearchExcerptTestCase to a DrupalWebTestCase and corrects the snippet test on $longtext.

While similar warnings (Illegal string offset 'filename' on module_list 74) occur on SearchExpressionInsertExtractTestCase the root cause there is a bug in how module_list handles its fixed_list parameter. This is being discussed in #1563620: All unit tests blow up with a fatal error.

CommentFileSizeAuthor
fix_search_excerpt_test.patch1.33 KBheine

Comments

heine’s picture

Status: Active » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

OK. This patch also has a fix that needs to get into the D8 excerpt test:

     $longtext = str_repeat($text . ' ', 10);
-    $result = preg_replace('| +|', ' ', search_excerpt('nothing', $text));
+    $result = preg_replace('| +|', ' ', search_excerpt('nothing', $longtext));
     $this->assertTrue(strpos($result, $expected) === 0, 'When keyword is not found in long string, return value starts as expected');

But in D8 the Excerpt test is a web test, so this issue as titled is D7 only.

I'll file a separate issue for that other fix, and let's take it out of this patch for D7.
#2083773: SearchExcerpt test has a small problem

jhodgdon’s picture

Status: Needs work » Reviewed & tested by the community

OK, that other issue got into 8, and this patch should be fine with 7, so let's just get it committed.

webchick’s picture

Title: SearchExcerptTestCase should be a WEBtestcase » SearchExcerptTestCase should be a DrupalWebTestCase

Sorry. :) Those caps were poking me in the eye. :D

webchick’s picture

Issue summary: View changes

Update cause

David_Rothstein’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.