Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)

This commit is contained in:
2023-04-13 22:22:46 +02:00
parent b017700d0a
commit 273db5f183
51 changed files with 3926 additions and 3637 deletions

View File

@@ -1,182 +1,185 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
/**
* DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
use Domframework\Fts;
/** Test the FTS */
/**
* Test the FTS
*/
class FtsTest extends \PHPUnit_Framework_TestCase
{
public function testTokenizerSearch0()
{
// Empty
// Empty
$fts = new Fts();
$fts->search("");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array (),
"minuses" => array ()));
$this->assertSame($res, ["tokens" => [],
"minuses" => []]);
}
public function testTokenizerSearch1()
{
// Too small
// Too small
$fts = new Fts();
$fts->search("X");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array (),
"minuses" => array ()));
$this->assertSame($res, ["tokens" => [],
"minuses" => []]);
}
public function testTokenizerSearch2()
{
// One word
// One word
$fts = new Fts();
$fts->search("XYZ");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array ("XYZ"),
"minuses" => array ("")));
$this->assertSame($res, ["tokens" => ["XYZ"],
"minuses" => [""]]);
}
public function testTokenizerSearch3()
{
// Two word
// Two word
$fts = new Fts();
$fts->search("XYZ 123");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array ("XYZ", "123"),
"minuses" => array ("", "")));
$this->assertSame($res, ["tokens" => ["XYZ", "123"],
"minuses" => ["", ""]]);
}
public function testTokenizerSearch4()
{
// Three word
// Three word
$fts = new Fts();
$fts->search("XYZ 123 ABC");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array ("XYZ", "123", "ABC"),
"minuses" => array ("", "", "")));
$this->assertSame($res, ["tokens" => ["XYZ", "123", "ABC"],
"minuses" => ["", "", ""]]);
}
public function testTokenizerSearch5()
{
// Three word
// 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 ("", "", "", "")));
$this->assertSame($res, ["tokens" => ["XYZ", "123",
"ABC", "KLM"],
"minuses" => ["", "", "", ""]]);
}
public function testTokenizerSearch6()
{
// Three word
// 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 ("", "", "-", "")));
$this->assertSame($res, ["tokens" => ["Louis-XYZ", "123",
"AéBCé", "KLM"],
"minuses" => ["", "", "-", ""]]);
}
public function testTokenizerSentence0()
{
// Empty sentence
// Empty sentence
$fts = new Fts();
$fts->search("\"\"");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array (),
"minuses" => array ()));
$this->assertSame($res, ["tokens" => [],
"minuses" => []]);
}
public function testTokenizerSentence1()
{
// One sentence only
// One sentence only
$fts = new Fts();
$fts->search("\"XYZ 123\"");
$res = $fts->getTokensMin();
$this->assertSame($res, array ("tokens" => array ("XYZ 123"),
"minuses" => array ("")));
$this->assertSame($res, ["tokens" => ["XYZ 123"],
"minuses" => [""]]);
}
public function testTokenizerSentence2()
{
// Two sentence
// 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 ("", "")));
$this->assertSame($res, ["tokens" => ["XYZ 123", "ABC KLM"],
"minuses" => ["", ""]]);
}
public function testTokenizerSentence3()
{
// Three sentence
// 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 ("", "-", "")));
$this->assertSame($res, ["tokens" => ["XYZ 123", "ABC KLM",
"RPO YUI"],
"minuses" => ["", "-", ""]]);
}
public function testTokenizerMixed1()
{
// One word and one sentence, starting by word
// 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 ("", "")));
$this->assertSame($res, ["tokens" => ["XYZ", "ABC KLM"],
"minuses" => ["", ""]]);
}
public function testTokenizerMixed2()
{
// One word and one sentence, starting by sentence
// 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 ("", "")));
$this->assertSame($res, ["tokens" => ["ABC KLM", "XYZ"],
"minuses" => ["", ""]]);
}
public function testTokenizerMixed3()
{
// One word and two sentences, starting by sentence
// 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 ("", "", "")));
$this->assertSame($res, ["tokens" => ["ABC KLM", "XYZ",
"RPO YUI"],
"minuses" => ["", "", ""]]);
}
public function testTokenizerMixed4()
{
// Two words and two sentences, starting by sentence
// 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 ("", "", "", "")));
$this->assertSame($res, ["tokens" => ["ABC KLM", "XYZ",
"RPO YUI", "123"],
"minuses" => ["", "", "", ""]]);
}
public function testTokenizerMixed5()
{
// Two words and two sentences, starting by a word
// 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 ("", "", "", "")));
$this->assertSame($res, ["tokens" => ["123", "ABC KLM",
"XYZ", "RPO YUI"],
"minuses" => ["", "", "", ""]]);
}
}