public function testIndexCreate() { $objSearchDocument = new class_module_search_document(); $objSearchDocument->setDocumentId(1); $objSearchContent = new class_module_search_content(); $objSearchContent->setFieldName('title'); $objSearchContent->setContent('bla'); $objSearchContent->setDocumentId(1); $objSearchDocument->addContentObj($objSearchContent); $objSearchContent = new class_module_search_content(); $objSearchContent->setFieldName('title'); $objSearchContent->setContent('blub'); $objSearchContent->setDocumentId(1); $objSearchDocument->addContentObj($objSearchContent); $this->assertEquals(count($objSearchDocument->getContent()), 2, "manual added test"); // test tokenizer $objSearchDocument->addContent("title", "hAha DUdub"); $this->assertEquals(count($objSearchDocument->getContent()), 4); // test lowerize $this->assertEquals($objSearchDocument->getContent()[2]->getContent(), 'haha'); $this->assertEquals($objSearchDocument->getContent()[3]->getContent(), 'dudub'); // test id management $this->assertEquals($objSearchDocument->getContent()[2]->getDocumentId(), $objSearchDocument->getDocumentId(), "id management test"); // test short entry ignoring $objSearchDocument->addContent("title", "in hIulk, It, fs fslong or."); $arrContent = $objSearchDocument->getContent(); $this->assertEquals(count($arrContent), 6); $this->assertEquals($arrContent[4]->getContent(), 'hiulk'); $this->assertEquals($arrContent[5]->getContent(), 'fslong'); //test blacklisting $objSearchDocument2 = new class_module_search_document(); $objSearchDocument2->setDocumentId(2); $objSearchDocument2->addContent("title", " this is allowed and this is not "); $arrContent = $objSearchDocument2->getContent(); $this->assertEquals(count($arrContent), 3); $this->assertEquals($arrContent[0]->getContent(), 'this'); $this->assertEquals($arrContent[0]->getScore(), 2); $this->assertEquals($arrContent[1]->getContent(), 'allowed'); $this->assertEquals($arrContent[2]->getContent(), 'not'); }