This commit is contained in:
parent
07c5c92e73
commit
13941a6b86
@ -40,7 +40,7 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
|
|||||||
{
|
{
|
||||||
public function prepareTables()
|
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();
|
parent::prepareTables();
|
||||||
}
|
}
|
||||||
@ -58,8 +58,13 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
|
|||||||
$coll[]->name = 'new user';
|
$coll[]->name = 'new user';
|
||||||
|
|
||||||
$this->assertEqual($coll->count(), 7);
|
$this->assertEqual($coll->count(), 7);
|
||||||
|
$this->assertEqual(count($coll->getSnapshot()), 8);
|
||||||
|
|
||||||
|
$count = $this->conn->count();
|
||||||
|
|
||||||
$coll->save();
|
$coll->save();
|
||||||
|
print $this->conn->count();
|
||||||
|
print $count;
|
||||||
|
|
||||||
$this->connection->clear();
|
$this->connection->clear();
|
||||||
$coll = Doctrine_Query::create()->from('User u')->execute();
|
$coll = Doctrine_Query::create()->from('User u')->execute();
|
||||||
@ -113,17 +118,27 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
|
|||||||
|
|
||||||
$this->assertEqual($users[0]->Group[0]->name, 'PHP');
|
$this->assertEqual($users[0]->Group[0]->name, 'PHP');
|
||||||
$this->assertEqual($users[0]->Group[1]->name, 'Web');
|
$this->assertEqual($users[0]->Group[1]->name, 'Web');
|
||||||
|
$this->assertEqual(count($user->Group->getSnapshot()), 2);
|
||||||
unset($user->Group[0]);
|
unset($user->Group[0]);
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
|
$this->assertEqual(count($user->Group), 1);
|
||||||
|
|
||||||
$this->assertEqual(count($user->Group->getSnapshot()), 1);
|
$this->assertEqual(count($user->Group->getSnapshot()), 1);
|
||||||
unset($user->Group[1]);
|
unset($user->Group[1]);
|
||||||
$this->assertEqual(count($user->Group->getSnapshot()), 1);
|
$this->assertEqual(count($user->Group->getSnapshot()), 1);
|
||||||
|
|
||||||
|
$count = count($this->conn);
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$this->assertEqual(count($user->Group->getSnapshot()), 0);
|
$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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
public function prepareTables()
|
public function prepareTables()
|
||||||
{
|
{
|
||||||
$this->tables = array('RecordHookTest', 'SoftDeleteTest');
|
$this->tables = array('RecordHookTest', 'SoftDeleteTest');
|
||||||
|
|
||||||
parent::prepareTables();
|
parent::prepareTables();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
public function testInsertHooksGetInvoked()
|
public function testInsertHooksGetInvoked()
|
||||||
{
|
{
|
||||||
$r = new RecordHookTest();
|
$r = new RecordHookTest();
|
||||||
@ -67,7 +67,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($r->pop(), 'preUpdate');
|
$this->assertEqual($r->pop(), 'preUpdate');
|
||||||
$this->assertEqual($r->pop(), 'preSave');
|
$this->assertEqual($r->pop(), 'preSave');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDeleteHooksGetInvoked()
|
public function testDeleteHooksGetInvoked()
|
||||||
{
|
{
|
||||||
$records = Doctrine_Query::create()->from('RecordHookTest t')->where("t.name = 'record 2'")->execute();
|
$records = Doctrine_Query::create()->from('RecordHookTest t')->where("t.name = 'record 2'")->execute();
|
||||||
@ -78,7 +78,7 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($r->pop(), 'postDelete');
|
$this->assertEqual($r->pop(), 'postDelete');
|
||||||
$this->assertEqual($r->pop(), 'preDelete');
|
$this->assertEqual($r->pop(), 'preDelete');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testSoftDelete()
|
public function testSoftDelete()
|
||||||
{
|
{
|
||||||
$r = new SoftDeleteTest();
|
$r = new SoftDeleteTest();
|
||||||
@ -92,14 +92,15 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
|
|||||||
$this->assertEqual($r->deleted, null);
|
$this->assertEqual($r->deleted, null);
|
||||||
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
||||||
|
|
||||||
try{
|
try {
|
||||||
$r->delete();
|
$r->delete();
|
||||||
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
$this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
|
||||||
$this->assertEqual($r->deleted, true);
|
$this->assertEqual($r->deleted, true);
|
||||||
}catch(Doctrine_Exception $e){
|
} catch(Doctrine_Exception $e) {
|
||||||
$this->fail();
|
$this->fail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
class SoftDeleteTest extends Doctrine_Record
|
class SoftDeleteTest extends Doctrine_Record
|
||||||
{
|
{
|
||||||
@ -116,6 +117,7 @@ class SoftDeleteTest extends Doctrine_Record
|
|||||||
public function postDelete($event)
|
public function postDelete($event)
|
||||||
{
|
{
|
||||||
$this->deleted = true;
|
$this->deleted = true;
|
||||||
|
|
||||||
$this->save();
|
$this->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user