public function testTicket1132() { Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, true); $test = new SoftDeleteTest(); $test->name = 'test1'; $test->something = 'test2'; $test->save(); $q = Doctrine_Query::create()->from('SoftDeleteTest s')->addWhere('s.name = ?')->addWhere('s.something = ?'); $results = $q->execute(array('test1', 'test2')); $this->assertEqual($q->getSqlQuery(), 'SELECT s.name AS s__name, s.something AS s__something, s.deleted_at AS s__deleted_at FROM soft_delete_test s WHERE s.name = ? AND s.something = ? AND (s.deleted_at IS NULL)'); $this->assertEqual($q->getFlattenedParams(array('test1', 'test2')), array('test1', 'test2')); $this->assertEqual($results->count(), 1); Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_USE_DQL_CALLBACKS, false); }
public function testSoftDelete() { $r = new SoftDeleteTest(); $r->name = 'something'; $r->something = 'something'; $r->save(); $this->assertEqual($r->name, 'something'); $this->assertEqual($r->something, 'something'); $this->assertEqual($r->deleted_at, null); $this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN); try { $r->delete(); $this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN); $this->assertTrue(strtotime($r->deleted_at) > 0); } catch (Doctrine_Exception $e) { $this->fail(); } }
public function testTicket1132() { Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', true); $test = new SoftDeleteTest(); $test->name = 'test1'; $test->something = 'test2'; $test->save(); $q = Doctrine_Query::create() ->from('SoftDeleteTest s') ->addWhere('s.name = ?') ->addWhere('s.something = ?'); $results = $q->execute(array('test1', 'test2')); $this->assertEqual($q->getSql(), 'SELECT s.name AS s__name, s.something AS s__something, s.deleted AS s__deleted FROM soft_delete_test s WHERE s.name = ? AND s.something = ? AND s.deleted = ?'); $this->assertEqual($q->getParams(array('test1', 'test2')), array('test1', 'test2', false)); $this->assertEqual($results->count(), 1); Doctrine_Manager::getInstance()->setAttribute('use_dql_callbacks', false); }