1
0
mirror of synced 2025-01-17 22:11:41 +03:00
This commit is contained in:
zYne 2007-09-01 17:28:49 +00:00
parent 07c5c92e73
commit 13941a6b86
2 changed files with 25 additions and 8 deletions

View File

@ -40,7 +40,7 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
{
public function prepareTables()
{
$this->tables = array('Entity', 'User', 'Group', 'Phonenumber', 'Email', 'Book');
$this->tables = array('Entity', 'User', 'Group', 'GroupUser', 'Account', 'Album', 'Phonenumber', 'Email', 'Book');
parent::prepareTables();
}
@ -58,8 +58,13 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$coll[]->name = 'new user';
$this->assertEqual($coll->count(), 7);
$this->assertEqual(count($coll->getSnapshot()), 8);
$count = $this->conn->count();
$coll->save();
print $this->conn->count();
print $count;
$this->connection->clear();
$coll = Doctrine_Query::create()->from('User u')->execute();
@ -113,18 +118,28 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($users[0]->Group[0]->name, 'PHP');
$this->assertEqual($users[0]->Group[1]->name, 'Web');
$this->assertEqual(count($user->Group->getSnapshot()), 2);
unset($user->Group[0]);
$user->save();
$this->assertEqual(count($user->Group), 1);
$this->assertEqual(count($user->Group->getSnapshot()), 1);
unset($user->Group[1]);
$this->assertEqual(count($user->Group->getSnapshot()), 1);
$count = count($this->conn);
$user->save();
$this->assertEqual(count($user->Group->getSnapshot()), 0);
$this->conn->clear();
$users = Doctrine_Query::create()->from('User u LEFT JOIN u.Group g')
->where('u.id = ' . $user->id)->execute();
$this->assertEqual(count($user->Group), 0);
}
}

View File

@ -40,7 +40,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
parent::prepareTables();
}
/**
public function testInsertHooksGetInvoked()
{
$r = new RecordHookTest();
@ -78,7 +78,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($r->pop(), 'postDelete');
$this->assertEqual($r->pop(), 'preDelete');
}
*/
public function testSoftDelete()
{
$r = new SoftDeleteTest();
@ -92,14 +92,15 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($r->deleted, null);
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
try{
try {
$r->delete();
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
$this->assertEqual($r->deleted, true);
}catch(Doctrine_Exception $e){
} catch(Doctrine_Exception $e) {
$this->fail();
}
}
}
class SoftDeleteTest extends Doctrine_Record
{
@ -116,6 +117,7 @@ class SoftDeleteTest extends Doctrine_Record
public function postDelete($event)
{
$this->deleted = true;
$this->save();
}
}