public function adapter($v = null) { if (empty($v)) { return $this->_adapter; } $this->_adapter = $v; foreach ($this->nsps as $nsp) { $nsp . initAdapter(); } return $this; }
$t->ok(!in_array('DELETE FROM test_child_c WHERE id = ?', $adapter->getAll()), 'The child C is not removed.'); $t->ok(!in_array('UPDATE test_child_b SET test_parent_id = ? WHERE id = ?', $adapter->getAll()), 'The child D doesn\'t unlink to parent.'); initAdapter($adapter); $record->getTable()->createQuery()->delete()->execute(); $t->ok(in_array('DELETE FROM test_parent', $adapter->getAll()), 'TestParents are removed by DELETE query.'); $t->ok(!in_array('DELETE FROM test_child_a WHERE test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2)', $adapter->getAll()), 'TestChlildrenA are not removed.'); $t->ok(!in_array('UPDATE test_child_b SET test_parent_id = ? WHERE test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2)', $adapter->getAll()), 'TestChlildrenB don\'t unlink to parent.'); $t->ok(!in_array('DELETE FROM test_child_c WHERE test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2)', $adapter->getAll()), 'TestChlildrenC are not removed.'); $t->ok(!in_array('UPDATE test_child_d SET test_parent_id = ? WHERE test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2)', $adapter->getAll()), 'TestChlildrenD don\'t unlink to parent.'); Doctrine_Manager::getInstance()->closeConnection($conn); // --------------- list($conn, $adapter) = getConnection(true); $t->comment('Doctrine::ATTR_EXPORT doesn\'t have Doctrine::EXPORT_CONSTRAINTS, so opApplicationLevelCascadingListener is enabled.'); $record = getRecord(); initAdapter($adapter); $t->ok($record->getListener() instanceof Doctrine_Record_Listener_Chain, 'The record has listener.'); $record->delete(); $t->ok(in_array('DELETE FROM test_parent WHERE id = ?', $adapter->getAll()), 'The record is removed by DELETE query.'); $t->ok(in_array('DELETE FROM test_child_a WHERE id = ?', $adapter->getAll()), 'The child A is removed.'); $t->ok(in_array('UPDATE test_child_b SET test_parent_id = ? WHERE id = ?', $adapter->getAll()), 'The child B unlinks to parent.'); $t->ok(in_array('DELETE FROM test_child_c WHERE id = ?', $adapter->getAll()), 'The child C is removed.'); $t->ok(in_array('UPDATE test_child_b SET test_parent_id = ? WHERE id = ?', $adapter->getAll()), 'The child D unlinks to parent.'); initAdapter($adapter); $record->getTable()->createQuery()->delete()->execute(); $t->ok(in_array('DELETE FROM test_parent', $adapter->getAll()), 'TestParents are removed by DELETE query.'); $t->ok(in_array('DELETE FROM test_child_a WHERE (test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2))', $adapter->getAll()), 'TestChlildrenA are removed.'); $t->ok(in_array('UPDATE test_child_b SET test_parent_id = ? WHERE (test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2))', $adapter->getAll()), 'TestChlildrenB unlink to parent.'); $t->ok(in_array('DELETE FROM test_child_c WHERE (test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2))', $adapter->getAll()), 'TestChlildrenC are removed.'); $t->ok(in_array('UPDATE test_child_d SET test_parent_id = ? WHERE (test_parent_id IN (SELECT t2.id AS t2__id FROM test_parent t2))', $adapter->getAll()), 'TestChlildrenD unlink to parent.'); Doctrine_Manager::getInstance()->closeConnection($conn); // ---------------