Tests/Services/SearchServiceTest.php
changeset 77 021131fbe2c5
parent 75 ca2a145e67f3
equal deleted inserted replaced
76:bb7808e180c3 77:021131fbe2c5
    95     public function testCompletion()
    95     public function testCompletion()
    96     {
    96     {
    97         $search_service = $this->get("wiki_tag.search");
    97         $search_service = $this->get("wiki_tag.search");
    98     
    98     
    99         $result = $search_service->completion("tag");
    99         $result = $search_service->completion("tag");
       
   100         $completion_result = array(
       
   101         	'Tag1' => 2,
       
   102         	'Tag2' => 4,
       
   103         	'Tag3' => 5,
       
   104             'Tag4' => 6
       
   105         );
   100     
   106     
   101         $this->assertNotNull($result, "completion should not be null");
   107         $this->assertNotNull($result, "completion should not be null");
   102         $this->assertEquals(4, count($result));
   108         $this->assertEquals(4, count($result));
   103         
   109         
   104         foreach ($result as $tagname) {
   110         foreach ($result as $tagname) {
   105             $this->assertEquals(0,strpos($tagname,"tag"));
   111             $this->assertEquals(0,strpos($tagname['label'],"Tag"));
       
   112             $this->assertArrayHasKey($tagname['label'], $completion_result);
       
   113             $this->assertEquals($completion_result[$tagname['label']], $tagname['nb_docs']);
   106         }
   114         }
   107     }
   115     }
   108     
   116     
   109     public function testSearch() {
   117     public function testSearch() {
   110         
   118