Update Tests to supports namespaces
This commit is contained in:
172
Tests/FtsTest.php
Normal file
172
Tests/FtsTest.php
Normal file
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
/** Test the FTS */
|
||||
class ftsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_tokenizerSearch0 ()
|
||||
{
|
||||
// Empty
|
||||
$fts = new fts ();
|
||||
$fts->search ("");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array (),
|
||||
"minuses"=>array ()));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch1 ()
|
||||
{
|
||||
// Too small
|
||||
$fts = new fts ();
|
||||
$fts->search ("X");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array (),
|
||||
"minuses"=>array ()));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch2 ()
|
||||
{
|
||||
// One word
|
||||
$fts = new fts ();
|
||||
$fts->search ("XYZ");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ"),
|
||||
"minuses"=>array ("")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch3 ()
|
||||
{
|
||||
// Two word
|
||||
$fts = new fts ();
|
||||
$fts->search ("XYZ 123");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123"),
|
||||
"minuses"=>array ("", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch4 ()
|
||||
{
|
||||
// Three word
|
||||
$fts = new fts ();
|
||||
$fts->search ("XYZ 123 ABC");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123", "ABC"),
|
||||
"minuses"=>array ("", "", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch5 ()
|
||||
{
|
||||
// Three word
|
||||
$fts = new fts ();
|
||||
$fts->search ("XYZ 123 ABC KLM");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "123",
|
||||
"ABC", "KLM"),
|
||||
"minuses"=>array ("", "", "", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSearch6 ()
|
||||
{
|
||||
// Three word
|
||||
$fts = new fts ();
|
||||
$fts->search ("Louis-XYZ 123 -AéBCé KLM");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("Louis-XYZ", "123",
|
||||
"AéBCé", "KLM"),
|
||||
"minuses"=>array ("", "", "-", "")));
|
||||
}
|
||||
|
||||
|
||||
public function test_tokenizerSentence0 ()
|
||||
{
|
||||
// Empty sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array (),
|
||||
"minuses"=>array ()));
|
||||
}
|
||||
|
||||
public function test_tokenizerSentence1 ()
|
||||
{
|
||||
// One sentence only
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"XYZ 123\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123"),
|
||||
"minuses"=>array ("")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSentence2 ()
|
||||
{
|
||||
// Two sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"XYZ 123\" \"ABC KLM\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM"),
|
||||
"minuses"=>array ("", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerSentence3 ()
|
||||
{
|
||||
// Three sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"XYZ 123\" -\"ABC KLM\" \"RPO YUI\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ 123", "ABC KLM",
|
||||
"RPO YUI"),
|
||||
"minuses"=>array ("", "-", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerMixed1 ()
|
||||
{
|
||||
// One word and one sentence, starting by word
|
||||
$fts = new fts ();
|
||||
$fts->search ("XYZ \"ABC KLM\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("XYZ", "ABC KLM"),
|
||||
"minuses"=>array ("", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerMixed2 ()
|
||||
{
|
||||
// One word and one sentence, starting by sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"ABC KLM\" XYZ");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ"),
|
||||
"minuses"=>array ("", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerMixed3 ()
|
||||
{
|
||||
// One word and two sentences, starting by sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
||||
"RPO YUI"),
|
||||
"minuses"=>array ("", "", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerMixed4 ()
|
||||
{
|
||||
// Two words and two sentences, starting by sentence
|
||||
$fts = new fts ();
|
||||
$fts->search ("\"ABC KLM\" XYZ \"RPO YUI\" 123");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("ABC KLM", "XYZ",
|
||||
"RPO YUI", "123"),
|
||||
"minuses"=>array ("", "", "", "")));
|
||||
}
|
||||
|
||||
public function test_tokenizerMixed5 ()
|
||||
{
|
||||
// Two words and two sentences, starting by a word
|
||||
$fts = new fts ();
|
||||
$fts->search ("123 \"ABC KLM\" XYZ \"RPO YUI\"");
|
||||
$res = $fts->getTokensMin ();
|
||||
$this->assertSame ($res, array ("tokens"=>array ("123", "ABC KLM",
|
||||
"XYZ", "RPO YUI"),
|
||||
"minuses"=>array ("", "", "", "")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user