<?php
/*
* This file is part of the pwp package.
* (c) 2009-2010 Victor Rad' <victor.v.rad[at]gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Unit test of the search system
*/
// prepare data
require_once dirname(__FILE__).'/../bootstrap/unit.php';
new sfDatabaseManager($configuration);
$t = new lime_test(1, new lime_output_color());
$testStr = 'PWPUnitTestOfTheSearchSystem';
// save News record
$news = DFactory::get('News')->getRecord();
$news->news_providers_id = 1;
$news->title = 'Title: '.$testStr;
$news->description = 'Description: '.$testStr;
$news->hash = md5('Hash: '.$testStr);
$news->link = 'Link: '.$testStr;
$news->created_at = date('Y-m-d H:i:s');
$news->save();
// do search
$search = new Search_Composite(new Search_News());
$foundIds = $search->find($testStr);
// test found
$t->is($news->getId(), $foundIds[0][0]);
// test of delete news
$news->delete();
// search after deleted
$search = new Search_Composite(new Search_News());
$foundIds = $search->find($testStr);
$t->is($foundIds, array(array()));