Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / search / ferret / __tests__ / PhabricatorFerretEngineTestCase.php
blobf9481d79c0454c947b6ba87ce30c7ee0dca04b47
1 <?php
3 final class PhabricatorFerretEngineTestCase
4 extends PhabricatorTestCase {
6 public function testTermsCorpus() {
7 $map = array(
8 'Hear ye, hear ye!' => ' Hear ye hear ye ',
9 "Thou whom'st've art worthy." => " Thou whom'st've art worthy ",
10 'Guaranteed to contain "food".' => ' Guaranteed to contain food ',
11 'http://example.org/path/to/file.jpg' =>
12 ' http example org path to file jpg ',
15 $engine = new ManiphestTaskFerretEngine();
17 foreach ($map as $input => $expect) {
18 $actual = $engine->newTermsCorpus($input);
20 $this->assertEqual(
21 $expect,
22 $actual,
23 pht('Terms corpus for: %s', $input));
27 public function testTermNgramExtraction() {
28 $snowman = "\xE2\x98\x83";
30 $map = array(
31 'a' => array(' a '),
32 'ab' => array(' ab', 'ab '),
33 'abcdef' => array(' ab', 'abc', 'bcd', 'cde', 'def', 'ef '),
34 "{$snowman}" => array(" {$snowman} "),
35 "x{$snowman}y" => array(
36 " x{$snowman}",
37 "x{$snowman}y",
38 "{$snowman}y ",
40 "{$snowman}{$snowman}" => array(
41 " {$snowman}{$snowman}",
42 "{$snowman}{$snowman} ",
46 $ngram_engine = new PhabricatorSearchNgramEngine();
48 foreach ($map as $input => $expect) {
49 $actual = $ngram_engine->getTermNgramsFromString($input);
50 $this->assertEqual(
51 $actual,
52 $expect,
53 pht('Term ngrams for: %s.', $input));