Пример #1
0
	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');
	}
Пример #2
0
	public function testDelete()
	{
		// Look up the SIDS
		// Ok, we cant really test this, so we use implementation knowledge
		$q = DB::prepare('SELECT SID FROM SearchFooIndex
		                   WHERE title=:title AND someOtherPrimary=:primary');
		$q->execute(array(':title' => 'My Title', ':primary' => 'other-primary'));
		$SIDS = $q->fetchAll();
	
		$someFoo = SearchFoo::get('My Title', 'other-primary', '2010-01-01');
		$someFoo->delete();
		
		// See if it is completely removed
		// Ok, we cant really test this, so we use implementation knowledge
		$q = DB::prepare('SELECT * FROM SearchFooIndex
		                   WHERE title=:title AND someOtherPrimary=:primary');
		$q->execute(array(':title' => 'My Title', ':primary' => 'other-primary'));
		$this->assertFalse($q->fetch());
		
		$q = DB::prepare('SELECT * FROM SearchIndex
		                   WHERE SID=:SID');
		$q->execute(array(':SID' => $SIDS[0]['SID']));
		$this->assertFalse($q->fetch());
		
		$pager = SearchFoo::search('rainbow', 'en');
		$results = $pager->execute(1, 10);
		$this->assertEquals(0, count($results));
		
		$someFoo = new SearchFoo;
		$someFoo->title = 'My Title';
		$someFoo->someOtherPrimary = 'other-primary';
		$someFoo->datePrimary = '2010-01-01';
		$someFoo->body = 'Empty body';
		$someFoo->language = 'en';
		$someFoo->save();
		
		$pager = SearchFoo::search('body', 'en');
		$results = $pager->execute(1, 10);
		$this->assertEquals(1, count($results));
	}