1
0
mirror of synced 2024-12-13 06:46:03 +03:00

fixed tests

This commit is contained in:
zYne 2006-09-24 19:54:55 +00:00
parent 96177e3e22
commit 617213b8ca
5 changed files with 14 additions and 31 deletions

View File

@ -29,7 +29,7 @@ Doctrine::autoload('Doctrine_EventListener_Interface');
* @url www.phpdoctrine.com
* @license LGPL
*/
abstract class Doctrine_EventListener implements Doctrine_EventListener_Interface {
class Doctrine_EventListener implements Doctrine_EventListener_Interface {
public function onLoad(Doctrine_Record $record) { }
public function onPreLoad(Doctrine_Record $record) { }
@ -79,4 +79,4 @@ abstract class Doctrine_EventListener implements Doctrine_EventListener_Interfac
public function onCollectionDelete(Doctrine_Collection $collection) { }
public function onPreCollectionDelete(Doctrine_Collection $collection) { }
}
}

View File

@ -24,28 +24,22 @@ class Doctrine_EventListener_TestB extends Doctrine_EventListener {
}
class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase {
public function testEvents() {
$connection = $this->manager->openConnection(Doctrine_DB::getConn("sqlite::memory:"));
$debug = $this->listener->getMessages();
$last = end($debug);
$this->assertTrue($last->getObject() instanceof Doctrine_Connection);
$this->assertTrue($last->getCode() == Doctrine_EventListener_Debugger::EVENT_OPEN);
}
public function testAccessorInvokerChain() {
$e = new EventListenerTest;
$e = new EventListenerChainTest;
$e->name = "something";
$this->assertEqual($e->get('name'), 'SOMETHING');
$this->assertEqual($e->get('name'), 'somethingTestATestB');
// test repeated calls
$this->assertEqual($e->get('name'), 'SOMETHING');
$this->assertEqual($e->get('name'), 'somethingTestATestB');
$this->assertEqual($e->id, null);
$this->assertEqual($e->rawGet('name'), 'something');
$e->save();
$this->assertEqual($e->id, 1);
$this->assertEqual($e->name, 'SOMETHING');
$this->assertEqual($e->name, 'somethingTestATestB');
$this->assertEqual($e->rawGet('name'), 'something');
$this->connection->clear();
@ -53,7 +47,7 @@ class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase {
$e->refresh();
$this->assertEqual($e->id, 1);
$this->assertEqual($e->name, 'SOMETHING');
$this->assertEqual($e->name, 'somethingTestATestB');
$this->assertEqual($e->rawGet('name'), 'something');
$this->connection->clear();
@ -61,7 +55,7 @@ class Doctrine_EventListener_Chain_TestCase extends Doctrine_UnitTestCase {
$e = $e->getTable()->find($e->id);
$this->assertEqual($e->id, 1);
$this->assertEqual($e->name, 'SOMETHING');
$this->assertEqual($e->name, 'somethingTestATestB');
$this->assertEqual($e->rawGet('name'), 'something');
}
public function prepareData() { }

View File

@ -195,8 +195,12 @@ class Doctrine_EventListenerTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($this->logger->pop(), 'onPreDelete');
$this->assertEqual($this->logger->pop(), 'onTransactionBegin');
$this->assertEqual($this->logger->pop(), 'onPreTransactionBegin');
$this->connection->setListener(new Doctrine_EventListener());
}
public function prepareData() { }
public function prepareTables() {
$this->tables = array('EventListenerTest');

View File

@ -690,21 +690,6 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this->assertEqual($user->getModified(), array());
$this->assertEqual($user->name, "Jack Daniels");
$debug = $this->listener->getMessages();
$p = array_pop($debug);
$this->assertTrue($p->getObject() instanceof Doctrine_Connection);
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_COMMIT);
$p = array_pop($debug);
$this->assertTrue($p->getObject() instanceof Doctrine_Record);
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_SAVE);
$p = array_pop($debug);
$this->assertTrue($p->getObject() instanceof Doctrine_Record);
$this->assertTrue($p->getCode() == Doctrine_EventListener_Debugger::EVENT_UPDATE);
}
public function testCopy() {
$user = $this->connection->getTable("User")->find(4);

View File

@ -82,7 +82,7 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$this->assertTrue($fk->getType() == Doctrine_Relation::MANY_COMPOSITE);
$this->assertTrue($fk->getLocal() == $this->objTable->getIdentifier());
$this->assertTrue($fk->getForeign() == "entity_id");
}
public function testGetComponentName() {