Commit 1ae37563 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '264-metager-testen' into 'development'

Resolve "MetaGer testen"



See merge request !505
parents 51256296 6fa9d6e2
......@@ -443,7 +443,7 @@ class MetaGer
*/
foreach ($sumas as $suma) {
if (($this->sumaIsSelected($suma, $request)
|| ($this->isBildersuche()
|| (!$this->isBildersuche()
&& $this->sumaIsAdsuche($suma, $overtureEnabled)))
&& (!$this->sumaIsDisabled($suma))) {
if ($this->sumaIsOverture($suma)) {
......@@ -586,7 +586,7 @@ class MetaGer
public function isBildersuche()
{
return $this->fokus !== "bilder";
return $this->fokus === "bilder";
}
public function sumaIsAdsuche($suma, $overtureEnabled)
......@@ -928,8 +928,8 @@ class MetaGer
$this->searchCheckSitesearch($site);
$this->searchCheckHostBlacklist();
$this->searchCheckDomainBlacklist();
$this->searchCheckStopwords();
$this->searchCheckPhrase();
$this->searchCheckStopwords();
}
public function searchCheckSitesearch($site)
......@@ -1023,7 +1023,7 @@ class MetaGer
public function rankAll()
{
foreach ($this->engines as $engine) {
$engine->rank($this);
$engine->rank($this->getQ());
}
}
......
......@@ -69,12 +69,10 @@ class Result
* + 0.02 * Sourcerank (20 - Position in Ergebnisliste des Suchanbieters)
* * Engine-Boost
*/
public function rank(\App\MetaGer $metager)
public function rank($eingabe)
{
$rank = 0;
$eingabe = $metager->getQ();
# Boost für Source Ranking
$rank += ($this->sourceRank * 0.02);
......@@ -130,7 +128,7 @@ class Result
$tmpLink = str_replace(urlencode($char), "", $tmpLink);
}
}
if (strlen($this->descr) > 80 && strlen($link) > 0) {
if (strlen($this->descr) > 0/*80*/ && strlen($link) > 0) {
return $count / ((strlen($link)) * 60); # ???
} else {
return 0;
......@@ -245,15 +243,10 @@ class Result
* "http://www.foo.bar.de/test?ja=1" -> "foo.bar.de"
* gebracht.
*/
private function getStrippedHost($link)
public function getStrippedHost($link)
{
if (strpos($link, "http") !== 0) {
$link = "http://" . $link;
}
$link = @parse_url($link, PHP_URL_HOST);
$link = preg_replace("/^www\./si", "", $link);
return $link;
$match = $this->getUrlElements($link);
return $match['host'];
}
/* Entfernt "http://", "www" und Parameter von einem Link
......@@ -261,15 +254,10 @@ class Result
* "http://www.foo.bar.de/test?ja=1" -> "foo.bar.de/test"
* gebracht.
*/
private function getStrippedLink($link)
public function getStrippedLink($link)
{
if (strpos($link, "http") !== 0) {
$link = "http://" . $link;
}
$host = $this->strippedHost;
$path = @parse_url($link, PHP_URL_PATH);
return $host . $path;
$match = $this->getUrlElements($link);
return $match['host'] . $match['path'];
}
/* Liest aus einem Link die Domain.
......@@ -277,17 +265,14 @@ class Result
* "http://www.foo.bar.de/test?ja=1" -> "bar.de"
* gebracht.
*/
private function getStrippedDomain($link)
public function getStrippedDomain($link)
{
if (preg_match("/([^\.]*\.[^\.]*)$/si", $link, $match)) {
return $match[1];
} else {
return $link;
}
$match = $this->getUrlElements($link);
return $match['domain'];
}
# Erstellt aus einem Link einen Proxy-Link für unseren Proxy-Service
private function generateProxyLink($link)
public function generateProxyLink($link)
{
if (!$link) {
return "";
......@@ -300,6 +285,37 @@ class Result
}
/* Liest aus einer URL alle Informationen aus
* https://max:muster@www.example.site.page.com:8080/index/indexer/list.html?p1=A&p2=B#ressource
* (?:((?:http)|(?:https))(?::\/\/))? - https:// => [1] = http / https
* (?:(\w+):(\w+)@)? - username:password@ => [2] = username, [3] = password
* (?:(www)(?:\.))? - www. => [4] = www
* ((?:(?:\w+\.)+)?(\w+\.\w+)) - example.site.page.com => [5] = example.site.page.com, [6] = page.com
* (?:(?::)(\d+))? - :8080 => [7] = 8080
* ((?:(?:\/\w+)+)(?:\.\w+)?)? - /index/indexer/list.html => [8] = /index/indexer/list.html
* (\?\w+=\w+(?:&\w+=\w+)*)? - ?p1=A&p2=B => [9] = ?p1=A&p2=B
* (?:(?:#)(\w+))? - #ressource => [10] = ressource
*/
public function getUrlElements($url)
{
if (!preg_match("/(?:((?:http)|(?:https))(?::\/\/))?(?:(\w+):(\w+)@)?(?:(www)(?:\.))?((?:(?:\w+\.)+)?(\w+\.\w+))(?:(?::)(\d+))?((?:(?:\/\w+)+)(?:\.\w+)?)?(\?\w+=\w+(?:&\w+=\w+)*)?(?:(?:#)(\w+))?/", $url, $match)) {
return;
} else {
$re = [];
if (isset($match[1])) {$re['schema'] = $match[1];} else { $re['schema'] = "";};
if (isset($match[2])) {$re['username'] = $match[2];} else { $re['username'] = "";};
if (isset($match[3])) {$re['password'] = $match[3];} else { $re['password'] = "";};
if (isset($match[4])) {$re['web'] = $match[4];} else { $re['web'] = "";};
if (isset($match[5])) {$re['host'] = $match[5];} else { $re['host'] = "";};
if (isset($match[6])) {$re['domain'] = $match[6];} else { $re['domain'] = "";};
if (isset($match[7])) {$re['port'] = $match[7];} else { $re['port'] = "";};
if (isset($match[8])) {$re['path'] = $match[8];} else { $re['path'] = "";};
if (isset($match[9])) {$re['query'] = $match[9];} else { $re['query'] = "";};
if (isset($match[10])) {$re['fragment'] = $match[10];} else { $re['fragment'] = "";};
return $re;
}
}
# Getter
public function getRank()
......
......@@ -13,9 +13,9 @@ abstract class Searchengine
{
use DispatchesJobs;
protected $ch; # Curl Handle zum erhalten der Ergebnisse
protected $getString = ""; # Der String für die Get-Anfrage
protected $engine; # Die ursprüngliche Engine XML
public $ch; # Curl Handle zum erhalten der Ergebnisse
public $getString = ""; # Der String für die Get-Anfrage
public $engine; # Die ursprüngliche Engine XML
public $enabled = true; # true, wenn die Suchmaschine nicht explizit disabled ist
public $results = []; # Die geladenen Ergebnisse
public $ads = []; # Die geladenen Werbungen
......@@ -34,8 +34,8 @@ abstract class Searchengine
public $hash; # Der Hash-Wert dieser Suchmaschine
public $fp; # Wird für Artefakte benötigt
protected $socketNumber = null; # Wird für Artefakte benötigt
protected $counter = 0; # Wird eventuell für Artefakte benötigt
public $socketNumber = null; # Wird für Artefakte benötigt
public $counter = 0; # Wird eventuell für Artefakte benötigt
public $write_time = 0; # Wird eventuell für Artefakte benötigt
public $connection_time = 0; # Wird eventuell für Artefakte benötigt
......@@ -59,6 +59,8 @@ abstract class Searchengine
$this->cacheDuration = 60;
}
$this->enabled = true;
# Eine Suchmaschine kann automatisch temporär deaktiviert werden, wenn es Verbindungsprobleme gab:
if (isset($this->disabled) && strtotime($this->disabled) <= time()) {
# In diesem Fall ist der Timeout der Suchmaschine abgelaufen.
......@@ -118,10 +120,10 @@ abstract class Searchengine
}
# Ruft die Ranking-Funktion aller Ergebnisse auf.
public function rank(\App\MetaGer $metager)
public function rank($eingabe)
{
foreach ($this->results as $result) {
$result->rank($metager);
$result->rank($eingabe);
}
}
......@@ -142,6 +144,7 @@ abstract class Searchengine
$xml = simplexml_load_file($sumaFile);
unset($xml->xpath("//sumas/suma[@name='" . $this->name . "']")['0']['disabled']);
$xml->saveXML($sumaFile);
$this->enabled = true;
}
public function closeFp()
......
......@@ -5,7 +5,7 @@
name="suchmaschine"
host="www.suchmaschine.de"
skript="/suche/"
formData="sprache=de&amp;sortieren=true&amp;&amp;queue=&lt;&lt;QUERY&gt;&gt;"
formData="sprache=de&amp;sortieren=true&amp;queue=&lt;&lt;QUERY&gt;&gt;"
package="suchmaschine"
displayName="Meine Suchmaschine"
homepage="www.suchmaschine.de/welcome"
......
......@@ -9,15 +9,28 @@
| you a convenient way to create models for testing and seeding your
| database. Just tell the factory how a default model should look.
|
*/
$factory->define(App\User::class, function (Faker\Generator $faker) {
static $password;
*/
$factory->define(app\Models\parserSkripte\Base::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
"provider" => null,
"titel" => "Hotels in L'Alpe-d'Huez",
"link" => "http://r.search.yahoo.com/cbclk/dWU9QUIxMzdDQTVGRUE1NDk4QiZ1dD0xNDc2NDMwMTM0MDY3JnVvPTUzNjEzNzI2OTYmbHQ9MiZlcz01LmtfeFdJR1BTOWpkdU95/RV=2/RE=1476458934/RO=10/RU=http%3a%2f%2f1616540.r.msn.com%2f%3fld%3dd3L21YyadK5JKikZbdYGL_WTVUCUwdKsA4ixeD_Iy-fyOol49ZUDwtvNaQrgo9_hrBZE29ZA8_kcVZvUh8zA3VBZsCAZK8rx10IhFt_RT45dthIWzATMhQpwXLvlSEiWjbX3oR-mghf0LQjcyYIqYSxSurjZ0%26u%3dhttp%253a%252f%252fwww.booking.com%252fcity%252ffr%252fl-alpe-d-huez.de.html%253faid%253d349014%2526label%253dmsn-w0pcQaojEix%2al5%2ajWskE5Q-5361372696%2526utm_campaign%253dFrance%2526utm_medium%253dcpc%2526utm_source%253dbing%2526utm_term%253dw0pcQaojEix%2al5%2ajWskE5Q/RK=0/RS=OWBpMcIG_XjwGHTMqrfc7GScvPg-",
"anzeigeLink" => "www.booking.com",
"descr" => "Schnell und sicher ein Hotel buchen. Alle Hotels mit Spezial-Angeboten.",
"gefVon" => "Yahoo",
"sourceRank" => 0,
"partnershop" => false,
"image" => "",
"proxyLink" => "https://proxy.suma-ev.de/cgi-bin/nph-proxy.cgi/en/I0/http/r.search.yahoo.com/cbclk/dWU9QUIxMzdDQTVGRUE1NDk4QiZ1dD0xNDc2NDMwMTM0MDY3JnVvPTUzNjEzNzI2OTYmbHQ9MiZlcz01LmtfeFdJR1BTOWpkdU95/RV=2/RE=1476458934/RO=10/RU=http%3a%2f%2f1616540.r.msn.com%2f%3fld%3dd3L21YyadK5JKikZbdYGL_WTVUCUwdKsA4ixeD_Iy-fyOol49ZUDwtvNaQrgo9_hrBZE29ZA8_kcVZvUh8zA3VBZsCAZK8rx10IhFt_RT45dthIWzATMhQpwXLvlSEiWjbX3oR-mghf0LQjcyYIqYSxSurjZ0%26u%3dhttp%253a%252f%252fwww.booking.com%252fcity%252ffr%252fl-alpe-d-huez.de.html%253faid%253d349014%2526label%253dmsn-w0pcQaojEix%2al5%2ajWskE5Q-5361372696%2526utm_campaign%253dFrance%2526utm_medium%253dcpc%2526utm_source%253dbing%2526utm_term%253dw0pcQaojEix%2al5%2ajWskE5Q/RK=0/RS=OWBpMcIG_XjwGHTMqrfc7GScvPg-",
"engineBoost" => 1.2,
"valid" => true,
"host" => "r.search.yahoo.com",
"strippedHost" => "booking.com",
"strippedDomain" => "booking.com",
"strippedLink" => "booking.com",
"rank" => 0,
"price" => 0,
"additionalInformation" => [],
];
});
......@@ -5,21 +5,23 @@ use Illuminate\Http\Request;
class MetaGerPhpTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function test()
{
$this->fullRunTest();
$this->specialSearchTest();
$this->createSearchEnginesTest();
$this->specialSumaTest();
$this->linkGeneratorTest();
#$this->getHostCountTest();
$this->addLinkTest();
$this->adjustFocusTest();
$this->checkCanNotSitesearchTest();
$this->isBildersucheTest();
$this->loadMiniSucherTest();
$this->getImageProxyLinkTest();
$this->showQuicktipsTest();
# Brauchen Engine Dummy
#$this->popAdTest();
#$this->productsTest();
}
public function fullRunTest()
......@@ -71,15 +73,33 @@ class MetaGerPhpTest extends TestCase
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$this->assertEquals("wantsite", $metager->getSite());
$this->assertEquals("blackhost", $metager->getUserHostBlacklist()[0]);
$this->assertEquals("blackdomain", $metager->getUserDomainBlacklist()[0]);
$this->assertEquals("blackword", $metager->getStopWords()[0]);
$this->assertEquals("i want phrase", $metager->getPhrases()[0]);
}
$this->assertContains("blackhost", $metager->getUserHostBlacklist());
$this->assertContains("blackdomain", $metager->getUserDomainBlacklist());
$this->assertContains("blackword", $metager->getStopWords());
$this->assertContains("i want phrase", $metager->getPhrases());
public function createSearchEnginesTest()
{
$this->specialSumaTest();
$metager = new MetaGer();
$request = new Request(['eingabe' => '-site:peter:test -blackword-test -host:blackhost-test.de.nz/test ich suche nach -host:blackhost:blackhost2.cote/t?p=5 "peter ist obst-garten und -bauern"']);
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$this->assertEquals("peter:test", $metager->getSite());
$this->assertContains("blackhost:blackhost2.cote/t?p=5", $metager->getUserHostBlacklist());
$this->assertContains("blackhost-test.de.nz/test", $metager->getUserHostBlacklist());
$this->assertContains("blackword-test", $metager->getStopWords());
$this->assertNotContains("bauern", $metager->getStopWords());
$this->assertContains("peter ist obst-garten und -bauern", $metager->getPhrases());
$metager = new MetaGer();
$request = new Request(['eingabe' => '-host:-domain:test']);
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$this->assertContains("-domain:test", $metager->getUserHostBlacklist());
$metager = new MetaGer();
$request = new Request(['eingabe' => '"-host:-domain:test"']);
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$this->assertContains("-host:-domain:test", $metager->getPhrases());
}
public function addLinkTest()
......@@ -109,22 +129,22 @@ class MetaGerPhpTest extends TestCase
$metager = new Metager();
$request = new Request(['eingabe' => 'test']);
$metager->parseFormData($request);
$this->linkCallbackTester($metager, "generateSearchLink", ["news"],
'/^.*?eingabe=test&focus=news&out=results$/');
$this->linkCallbackTester($metager, "generateQuicktipLink", [],
'/\/qt/');
$this->linkCallbackTester($metager, "generateSiteSearchLink", ["wolf.de"],
'/^.*?eingabe=test\+site%3Awolf.de&focus=web$/');
$this->linkCallbackTester($metager, "generateRemovedHostLink", ["wolf.de"],
'/^.*?eingabe=test\+-host%3Awolf.de$/');
$this->linkCallbackTester($metager, "generateRemovedDomainLink", ["wolf.de"],
'/^.*?eingabe=test\+-domain%3Awolf.de$/');
$this->containCallbackTester($metager, "generateSearchLink", ["news"],
'focus=news');
$this->containCallbackTester($metager, "generateQuicktipLink", [],
'/qt');
$this->containCallbackTester($metager, "generateSiteSearchLink", ["wolf.de"],
'site%3Awolf.de');
$this->containCallbackTester($metager, "generateRemovedHostLink", ["wolf.de"],
'-host%3Awolf.de');
$this->containCallbackTester($metager, "generateRemovedDomainLink", ["wolf.de"],
'-domain%3Awolf.de');
}
public function linkCallbackTester($metager, $funcName, $input, $expectedOutput)
public function containCallbackTester($object, $funcName, $input, $expectedInOutput)
{
$output = call_user_func_array(array($metager, $funcName), $input);
$this->assertRegExp($expectedOutput, $output);
$output = call_user_func_array(array($object, $funcName), $input);
$this->assertContains($expectedInOutput, $output);
}
public function getHostCountTest()
......@@ -150,6 +170,15 @@ class MetaGerPhpTest extends TestCase
$enabledSearchengines = $sumas;
$metager->adjustFocus($sumas, $enabledSearchengines);
$this->assertEquals("bilder", $metager->getFokus());
$metager = new MetaGer();
$request = new Request(["focus" => "web"]);
$metager->parseFormData($request);
$this->assertEquals("web", $metager->getFokus());
$sumas = simplexml_load_file("tests/testSumas2.xml")->xpath("suma"); # Eine spezielle test sumas.xml
$enabledSearchengines = array_slice($sumas, 0, 1);
$metager->adjustFocus($sumas, $enabledSearchengines);
$this->assertEquals("bilder", $metager->getFokus());
}
public function checkCanNotSitesearchTest()
......@@ -157,5 +186,63 @@ class MetaGerPhpTest extends TestCase
$metager = new MetaGer();
$enabledSearchengines = simplexml_load_file("tests/testSumas.xml")->xpath("suma"); # Eine spezielle test sumas.xml
$this->assertFalse($metager->checkCanNotSitesearch($enabledSearchengines));
$metager = new MetaGer();
$request = $this->createDummyRequest();
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$this->assertEquals("wantsite", $metager->getSite());
$enabledSearchengines = simplexml_load_file("tests/testSumas2.xml")->xpath("suma"); # Eine spezielle test sumas.xml
$this->assertTrue($metager->checkCanNotSitesearch($enabledSearchengines));
}
public function isBildersucheTest()
{
$metager = new MetaGer();
$request = new Request(["focus" => "bilder"]);
$metager->parseFormData($request);
$this->assertTrue($metager->isBildersuche());
}
public function loadMiniSucherTest()
{
$metager = new MetaGer();
$sumas = simplexml_load_file("tests/testSumas.xml");
$subcollections = ["minism1", "minism2"];
$minisucher = $metager->loadMiniSucher($sumas, $subcollections);
$this->assertContains("rows=10", $minisucher["formData"]->__toString());
$this->assertContains("fq=subcollection:%28minism1+OR+minism2%29", $minisucher["formData"]->__toString());
}
public function getImageProxyLinkTest()
{
$metager = new MetaGer();
$this->containCallbackTester($metager, "getImageProxyLink", ["www.bilder.de/bild1.png"], "url=www.bilder.de%2Fbild1.png");
}
public function showQuicktipsTest()
{
$metager = new MetaGer();
$request = new Request(["quicktips" => "yo"]);
$metager->parseFormData($request);
$this->assertFalse($metager->showQuicktips());
}
public function popAdTest()
{
$metager = new MetaGer();
$this->assertNull($metager->popAd());
$engines = [];
$engines[] = factory(app\Models\parserSkripte\Base::class)->make([], null);
$metager->combineResults($engines);
$ad = $metager->popAd();
$this->assertNull($metager->popAd());
}
public function productsTest()
{
$metager = new MetaGer();
$metager->hasProducts();
$metager->getProducts();
}
}
<?php
use App\MetaGer;
use App\Models\Result;
use Illuminate\Http\Request;
class ResultPhpTest extends TestCase
{
public function test()
{
$this->rankingTest();
$this->isValidTest();
$this->linkGeneratorsTest();
}
public function getDummyResult()
{
$provider = file_get_contents("tests/testSumas.xml");
$titel = "Titel";
$link = "link.de";
$anzeigeLink = "link.de/anzeige";
$descr = "Beschreibung: i want phrase";
$gefVon = "";
$sourceRank = 1;
return new Result($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $sourceRank);
}
public function getDummyMetaGer()
{
$metager = new MetaGer();
$request = $this->createDummyRequest();
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
return $metager;
}
public function createDummyRequest()
{
$query = [];
$query["eingabe"] = 'suchwort -blackword -host:blackhost -domain:blackdomain site:wantsite "i want phrase"';
$query["focus"] = "angepasst";
$query["encoding"] = "utf8";
$query["lang"] = "all";
$query["time"] = "1000";
$query["sprueche"] = "on";
$query["resultCount"] = "20";
$query["tab"] = "on";
$query["onenewspage"] = "on";
return new Request($query);
}
public function rankingTest()
{
$result = $this->getDummyResult();
$result->rank("link"); # 0.38, 0.38512820512820511 mit url-boost auch bei description länge > 0 statt > 80
$this->assertEquals(0.4, $result->getRank(), "Not within Range of Actual Value", 0.1);
$result->rank("titel"); # 0.38419999999999999
$this->assertEquals(0.4, $result->getRank(), "Not within Range of Actual Value", 0.1);
$result->rank("beschreibung"); # 0.38280000000000003
$this->assertEquals(0.4, $result->getRank(), "Not within Range of Actual Value", 0.1);
$result->rank("baum"); # 0.38
$this->assertEquals(0.4, $result->getRank(), "Not within Range of Actual Value", 0.1);
}
public function isValidTest()
{
$result = $this->getDummyResult();
$metager = $this->getDummyMetaGer();
$this->assertTrue($result->isValid($metager));
$metager = new MetaGer();
$request = new Request(['eingabe' => 'test -host:host.domain.de -domain:domain.de']);
$metager->parseFormData($request);
$metager->checkSpecialSearches($request);
$provider = file_get_contents("tests/testSumas.xml");
$titel = "Titel";
$link = "host.domain.de";
$anzeigeLink = "host.domain.de/ergebnis/1?p=2";
$descr = "Beschreibung: i want phrase";
$gefVon = "";
$sourceRank = 1;
$result = new Result($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $sourceRank);
$this->assertFalse($result->isValid($metager));
$link = "domain.de/ergebnis/1?p=2";
$result = new Result($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $sourceRank);
$this->assertFalse($result->isValid($metager));
}
public function linkGeneratorsTest()
{
$result = $this->getDummyResult();
$this->equalCallbackTester($result, "getStrippedHost", ["http://www.foo.bar.de/test?ja=1"],
'foo.bar.de');
$this->equalCallbackTester($result, "getStrippedLink", ["http://www.foo.bar.de/test?ja=1"],
'foo.bar.de/test');
$this->equalCallbackTester($result, "getStrippedDomain", ["http://www.foo.bar.de/test?ja=1"],
'bar.de');
$this->equalCallbackTester($result, "generateProxyLink", ["http://www.foo.bar.de/test?ja=1"],
'https://proxy.suma-ev.de/cgi-bin/nph-proxy.cgi/en/I0/http/www.foo.bar.de/test?ja=1');
$url = "https://leya:organa@www.han.solo.de/unterseite/document.htm?param1=2&param2=1#siebzehn";
$this->equalCallbackTester($result, "getStrippedHost", [$url],
'han.solo.de');
$this->equalCallbackTester($result, "getStrippedDomain", [$url],
'solo.de');
$this->equalCallbackTester($result, "getStrippedLink", [$url],
'han.solo.de/unterseite/document.htm');
}
public function equalCallbackTester($object, $funcName, $input, $expectedInOutput)
{
$output = call_user_func_array(array($object, $funcName), $input);
$this->assertEquals($expectedInOutput, $output);
}
}
<?php
use App\MetaGer;
use App\models\parserSkripte\Bing;
use Illuminate\Http\Request;
class SearchenginePhpTest extends TestCase
{
public function test()
{
$this->constructionTest();
$this->enablingTest();
}
public function constructionTest()
{
$engines = simplexml_load_file("tests/testSumas.xml")->xpath("suma");
$metager = new MetaGer();
$request = new Request(["focus" => "web"]);
$metager->parseFormData($request);
$searchengine = new Bing($engines[0], $metager);
$this->assertEquals('<suma name="minism" host="www.suchmaschine.de" skript="/suche/" formData="sprache=de&amp;sortieren=true&amp;queue=&lt;&lt;QUERY&gt;&gt;&amp;rows=&lt;&lt;COUNT&gt;&gt;&amp;fq=subcollection:&lt;&lt;SUBCOLLECTIONS&gt;&gt;" package="suchmaschine" displayName="Meine Suchmaschine" homepage="www.suchmaschine.de/welcome" port="443" inputEncoding="Latin1" userSelectable="1" type="bilder" engineBoost="1.2" additionalHeaders="$#!#$" hasSiteSearch="1" cacheDuration="60"/>',
$searchengine->engine);
$this->assertEquals(true,
$searchengine->enabled);
$this->assertEquals('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1',
$searchengine->useragent);
$this->assertEquals(null,
$searchengine->ip);
$this->assertEquals('<a href="www.suchmaschine.de/welcome" target="_blank">Meine Suchmaschine</a>',
$searchengine->gefVon);
#$this->assertEquals('0.68813000 1476867147', $searchengine->startTime);
$this->assertEquals('/suche/?sprache=de&sortieren=true&queue=&rows=<<COUNT>>&fq=subcollection:<<SUBCOLLECTIONS>>',
$searchengine->getString); # Enthält auch Testen von generateGetString(), urlEncode() und getOvertureAffilData() (nicht in der aktuellen Version)
$this->assertEquals('b1ac991618a8ffc0dab6b9bbb913841e',
$searchengine->hash);
$this->assertEquals('86a9106ae65537651a8e456835b316ab',
$searchengine->resultHash);
$this->assertEquals(true,
$searchengine->canCache);
$this->assertEquals('minism',
$searchengine->name);
$this->assertEquals('www.suchmaschine.de',
$searchengine->host);
$this->assertEquals('/suche/',