PSR12
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
@@ -12,170 +13,170 @@ use Domframework\Fts;
|
||||
/** 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 testTokenizerSearch0()
|
||||
{
|
||||
// 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 testTokenizerSearch1()
|
||||
{
|
||||
// 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 testTokenizerSearch2()
|
||||
{
|
||||
// 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 testTokenizerSearch3()
|
||||
{
|
||||
// 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 testTokenizerSearch4()
|
||||
{
|
||||
// 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",
|
||||
public function testTokenizerSearch5()
|
||||
{
|
||||
// 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 ("", "", "", "")));
|
||||
}
|
||||
"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",
|
||||
public function testTokenizerSearch6()
|
||||
{
|
||||
// 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 ("", "", "-", "")));
|
||||
}
|
||||
"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 testTokenizerSentence0()
|
||||
{
|
||||
// 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 testTokenizerSentence1()
|
||||
{
|
||||
// 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 testTokenizerSentence2()
|
||||
{
|
||||
// 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",
|
||||
public function testTokenizerSentence3()
|
||||
{
|
||||
// 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 ("", "-", "")));
|
||||
}
|
||||
"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 testTokenizerMixed1()
|
||||
{
|
||||
// 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 testTokenizerMixed2()
|
||||
{
|
||||
// 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",
|
||||
public function testTokenizerMixed3()
|
||||
{
|
||||
// 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 ("", "", "")));
|
||||
}
|
||||
"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",
|
||||
public function testTokenizerMixed4()
|
||||
{
|
||||
// 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 ("", "", "", "")));
|
||||
}
|
||||
"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",
|
||||
public function testTokenizerMixed5()
|
||||
{
|
||||
// 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 ("", "", "", "")));
|
||||
}
|
||||
"minuses" => array ("", "", "", "")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user