public function testUndoAll() { $post = $this->TPost->find('first', array('recursive' => -1, 'conditions' => array('id' => 1), 'activeRecord' => true)); $orgMessage = $post->message; $post->message = 'TestUndoAll'; $newWriter = $this->TWriter->find('first', array('recursive' => -1, 'conditions' => array('id' => 2), 'activeRecord' => true)); $orgWriterName = $post->Writer->name; $this->assertNotEquals($orgWriterName, $newWriter->name); $post->Writer = $newWriter; $orgCommentsCount = count($post->Comments); $post->Comments->add(new ARTComment(array('message' => 'TestMessage'))); $orgTagsCount = count($post->Tags); $this->assertGreaterThan(0, $orgTagsCount); $post->Tags = null; ActiveRecordManager::undoAll(); $this->assertEquals($orgMessage, $post->message); $this->assertEquals($orgWriterName, $post->Writer->name); $this->assertEquals($orgCommentsCount, count($post->Comments)); $this->assertEquals($orgTagsCount, count($post->Tags)); ActiveRecordManager::saveAll(); $this->assertEquals($orgMessage, $post->message); $this->assertEquals($orgWriterName, $post->Writer->name); $this->assertEquals($orgCommentsCount, count($post->Comments)); $this->assertEquals($orgTagsCount, count($post->Tags)); }
public function undoAll() { return ActiveRecordManager::undoAll(); }