public function testSaveLoad() { $db1 = new MsgDb('test_data/msgdb1.yml'); $db1->addMsg('test_data/email1.eml', array(Storage::FLAG_SEEN), true); $db1->addMsg('test_data/email2.eml', array(Storage::FLAG_SEEN), true); $db1->save(); $finder = new Finder(); $files = $finder->in('test_data')->name('msgdb1.yml'); $this->assertEquals(1, count($files)); $db2 = new MsgDb('test_data/msgdb1.yml'); $this->assertTrue($db2->load()); $msg = $db2->getMsgById(100002); $this->assertEquals(100002, $msg['id']); $this->assertEquals('test_data/email2.eml', $msg['path']); $this->assertEquals(array(Storage::FLAG_SEEN), $msg['flags']); $this->assertEquals(true, $msg['recent']); $db3 = new MsgDb('test_data/msgdb2.yml'); $this->assertFalse($db3->load()); #\Doctrine\Common\Util\Debug::dump($db3); }
public function addStorage(AbstractStorage $storage) { #fwrite(STDOUT, 'add: '.$storage->getType().' '.get_class($storage)."\n"); if (!$this->defaultStorage) { $this->defaultStorage = $storage; $dbPath = $storage->getPath(); if (substr($dbPath, -1) == '/') { $dbPath = substr($dbPath, 0, -1); } $dbPath .= '.yml'; $storage->setDbPath($dbPath); $db = new MsgDb($dbPath); $db->load(); $storage->setDb($db); } else { $this->storages[] = $storage; } #\Doctrine\Common\Util\Debug::dump($this->defaultStorage); #\Doctrine\Common\Util\Debug::dump($this->storages); }