public function setUp() { parent::setUp(); $bar = new SearchBar; $bar->title = 'Bar Title'; $bar->someOtherPrimary = 'The Primary'; $bar->body = 'Lorem Ipsum'; $bar->language = 'en'; $bar->save(); $foo = new SearchFoo; $foo->title = 'My Title'; $foo->someOtherPrimary = 'other-primary'; $foo->datePrimary = '2010-01-01'; $foo->body = 'Somewhere over the rainbow goes, tudeludoedoe <bold>This is some text that has to be searched</bold>'; $foo->barTitle = 'Bar Title'; $foo->barSomeOtherPrimary = 'The Primary'; $foo->identity = 'Keep Me As I am'; $foo->language = 'en'; $foo->save(); $tag = new Tagging; $tag->title = 'Some Title'; $tag->language = 'en'; $tag->body = 'Some Very Long body.'; $tag->save(); $tag->tag('Gamma'); $tag->tag('Alpha'); $tag->tag('Beta'); $tag = new Tagging; $tag->title = 'Some Other Title'; $tag->language = 'en'; $tag->body = 'Some Very short body.'; $tag->save(); $tag->tag('Aay'); $tag->tag('Bee'); $tag->tag('Cee'); }
public function testNormalSearch() { $pager = SearchBar::search('lorem latin', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(2, count($results)); $this->assertEquals('Other Bar Title', $results[0]->title); $this->assertEquals('The Primary', $results[0]->someOtherPrimary); $this->assertEquals('Bar Title', $results[1]->title); $this->assertEquals('The Primary', $results[1]->someOtherPrimary); $pager = SearchFoo::search('title', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(3, count($results)); $this->assertEquals('My Title', $results[0]->title); $this->assertEquals('primary', $results[0]->someOtherPrimary); $this->assertEquals('My Other Title', $results[1]->title); $this->assertEquals('primary', $results[1]->someOtherPrimary); $this->assertEquals('My Title', $results[2]->title); $this->assertEquals('other-primary', $results[2]->someOtherPrimary); $pager = SearchFoo::search('primary', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(0, count($results)); $pager = SearchFoo::search('important', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(1, count($results)); $this->assertEquals('My Title', $results[0]->title); $this->assertEquals('primary', $results[0]->someOtherPrimary); $pager = SearchFoo::search('rainbow', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(1, count($results)); $this->assertEquals('My Title', $results[0]->title); $this->assertEquals('other-primary', $results[0]->someOtherPrimary); $pager = SearchFoo::search('iacta aLeIA title', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(3, count($results)); $this->assertEquals('My Other Title', $results[0]->title); $this->assertEquals('primary', $results[0]->someOtherPrimary); $this->assertEquals('My Title', $results[1]->title); $this->assertEquals('primary', $results[1]->someOtherPrimary); $this->assertEquals('My Title', $results[2]->title); $this->assertEquals('other-primary', $results[2]->someOtherPrimary); $pager = SearchFoo::search('title', 'nl'); $results = $pager->execute(1, 10); $this->assertEquals(1, count($results)); $this->assertEquals('Mijn andere titel', $results[0]->title); $this->assertEquals('primary', $results[0]->someOtherPrimary); $pager = SearchFoo::search('tekst', 'nl'); $results = $pager->execute(1, 10); $this->assertEquals(1, count($results)); $this->assertEquals('Mijn andere titel', $results[0]->title); $this->assertEquals('primary', $results[0]->someOtherPrimary); $pager = SearchFoo::search('hola dit', 'nl'); // 'Dit' is filtered out $results = $pager->execute(1, 10); $this->assertEquals(0, count($results)); $pager = SearchFoo::search('sjeezel the', 'en'); // 'The' is filtered out $results = $pager->execute(1, 10); $this->assertEquals(0, count($results)); }