Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
61bbde66
Commit
61bbde66
authored
Jan 22, 2009
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#308277
by robertDouglass: Tests for multiple search engine types.
parent
a8c0d79f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
modules/search/search.test
modules/search/search.test
+37
-1
No files found.
modules/search/search.test
View file @
61bbde66
<?php
// $Id$
// The search index can contain different types of content. Typically the type is 'node'.
// Here we test with _test_ and _test2_ as the type.
define
(
'SEARCH_TYPE'
,
'_test_'
);
define
(
'SEARCH_TYPE_2'
,
'_test2_'
);
class
SearchMatchTestCase
extends
DrupalWebTestCase
{
function
getInfo
()
{
...
...
@@ -36,11 +39,14 @@ class SearchMatchTestCase extends DrupalWebTestCase {
for
(
$i
=
1
;
$i
<=
7
;
++
$i
)
{
search_index
(
$i
,
SEARCH_TYPE
,
$this
->
getText
(
$i
));
}
for
(
$i
=
1
;
$i
<=
5
;
++
$i
)
{
search_index
(
$i
+
7
,
SEARCH_TYPE_2
,
$this
->
getText2
(
$i
));
}
search_update_totals
();
}
/**
* Helper method for generating snippets of content.
*
_test_:
Helper method for generating snippets of content.
*
* Generated items to test against:
* 1 ipsum
...
...
@@ -56,6 +62,21 @@ class SearchMatchTestCase extends DrupalWebTestCase {
return
implode
(
' '
,
array_slice
(
$words
,
$n
-
1
,
$n
));
}
/**
* _test2_: Helper method for generating snippets of content.
*
* Generated items to test against:
* 8 dear
* 9 king philip
* 10 philip came over
* 11 came over from germany
* 12 over from germany swimming
*/
function
getText2
(
$n
)
{
$words
=
explode
(
' '
,
"Dear King Philip came over from Germany swimming."
);
return
implode
(
' '
,
array_slice
(
$words
,
$n
-
1
,
$n
));
}
/**
* Run predefine queries looking for indexed terms.
*/
...
...
@@ -116,6 +137,21 @@ class SearchMatchTestCase extends DrupalWebTestCase {
$this
->
_testQueryMatching
(
$query
,
$set
,
$results
);
$this
->
_testQueryScores
(
$query
,
$set
,
$results
);
}
// These queries are run against the second index type, SEARCH_TYPE_2.
$queries
=
array
(
// Simple AND queries.
'ipsum'
=>
array
(),
'enim'
=>
array
(),
'enim minim'
=>
array
(),
'dear'
=>
array
(
8
),
'germany'
=>
array
(
11
,
12
),
);
foreach
(
$queries
as
$query
=>
$results
)
{
$set
=
do_search
(
$query
,
SEARCH_TYPE_2
);
$this
->
_testQueryMatching
(
$query
,
$set
,
$results
);
$this
->
_testQueryScores
(
$query
,
$set
,
$results
);
}
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment