Commit baf09de8 authored by zYne's avatar zYne

added some new search tests and fixed hydration tests

parent 32a4639a
......@@ -60,7 +60,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase
public function testHydrateHooks()
{
$user = new User();
$user->getTable()->addListener(new HydrationListener);
$user->getTable()->addRecordListener(new HydrationListener);
$user->name = 'zYne';
$user->save();
......@@ -73,7 +73,7 @@ class Doctrine_Hydrate_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($user->password, 'DEFAULT PASS');
}
}
class HydrationListener extends Doctrine_EventListener
class HydrationListener extends Doctrine_Record_Listener
{
public function preHydrate(Doctrine_Event $event)
{
......
This diff is collapsed.
......@@ -34,12 +34,13 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables = array('SearchTest', 'SearchTestIndex');
$this->tables = array('SearchTest');
parent::prepareTables();
}
public function prepareData()
{ }
public function testBuildingOfSearchRecordDefinition()
{
$e = new SearchTest();
......@@ -49,7 +50,7 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
$rel = $e->getTable()->getRelation('SearchTestIndex');
$this->assertIdentical($rel->getLocal(), 'id');
$this->assertIdentical($rel->getForeign(), 'searchtest_id');
$this->assertIdentical($rel->getForeign(), 'id');
}
public function testSavingEntriesUpdatesIndex()
{
......@@ -116,4 +117,45 @@ class Doctrine_Search_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($array), 0);
}
public function testUpdateIndexInsertsNullValuesForBatchUpdatedEntries()
{
$e = new SearchTest();
$tpl = $e->getTable()->getTemplate('Doctrine_Template_Searchable');
$tpl->getPlugin()->setOption('batchUpdates', true);
$e->title = 'Some searchable title';
$e->content = 'Some searchable content';
$e->save();
$coll = Doctrine_Query::create()
->from('SearchTestIndex s')
->orderby('s.id DESC')
->limit(1)
->setHydrationMode(Doctrine::HYDRATE_ARRAY)
->fetchOne();
$this->assertEqual($coll['id'], 2);
$this->assertEqual($coll['keyword'], null);
$this->assertEqual($coll['field'], null);
$this->assertEqual($coll['position'], null);
}
public function testBatchUpdatesUpdateAllPendingEntries()
{
$e = new SearchTest();
$tpl = $e->getTable()->getTemplate('Doctrine_Template_Searchable');
$tpl->getPlugin()->processPending();
$coll = Doctrine_Query::create()
->from('SearchTestIndex s')
->setHydrationMode(Doctrine::HYDRATE_ARRAY)
->execute();
$coll = $this->conn->fetchAll('SELECT * FROM search_test_index');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment