Exemplo n.º 1
0
 public function testSetPath()
 {
     $path = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $storage = new DirectoryStorage();
     $storage->setPath($path);
     $this->assertTrue(file_exists($path));
 }
Exemplo n.º 2
0
 public function testSetType()
 {
     $storage = new DirectoryStorage();
     $storage->setType('test1');
     $this->assertEquals('test1', $storage->getType());
     $storage->setType('test2');
     $this->assertEquals('test2', $storage->getType());
 }
Exemplo n.º 3
0
 public function testSelect()
 {
     $path1 = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $log = new Logger('test_application');
     #$log->pushHandler(new StreamHandler('php://stdout', Logger::DEBUG));
     $server = new Server('', 0);
     $server->setLog($log);
     $server->init();
     $storage1 = new DirectoryStorage();
     $storage1->setPath($path1);
     $server->addStorage($storage1);
     $server->addFolder('test_dir1');
     $server->addFolder('test_dir2');
     $client1 = new Client();
     $client1->setServer($server);
     $client1->setId(1);
     $client2 = new Client();
     $client2->setServer($server);
     $client2->setId(2);
     $client1->select('test_dir1');
     $this->assertEquals('test_dir1', $client1->getSelectedFolder());
     $this->assertEquals(null, $client2->getSelectedFolder());
     $client1->select('test_dir2');
     $this->assertEquals('test_dir2', $client1->getSelectedFolder());
     $this->assertEquals(null, $client2->getSelectedFolder());
     $client2->select('test_dir1');
     $this->assertEquals('test_dir2', $client1->getSelectedFolder());
     $this->assertEquals('test_dir1', $client2->getSelectedFolder());
 }
Exemplo n.º 4
0
 public function testShutdownStorages()
 {
     $path1 = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $path2 = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $path3 = './test_data/test_mailbox_' . date('Ymd_His') . '_' . uniqid('', true);
     $server = new Server('', 0);
     $server->setLog(new Logger('test_application'));
     $server->init();
     $storage1 = new DirectoryStorage();
     $storage1->setPath($path1);
     $server->addStorage($storage1);
     $storage2db = new MsgDb();
     $storage2 = new TestStorage();
     $storage2->setPath($path2);
     $storage2->setType('temp');
     $storage2->setDb($storage2db);
     $storage2->setDbPath($path2 . '/msgdb.yml');
     $server->addStorage($storage2);
     $storage3 = new TestStorage();
     $storage3->setPath($path3);
     $server->addStorage($storage3);
     $this->assertEquals('normal', $storage1->getType());
     $this->assertEquals('temp', $storage2->getType());
     $this->assertEquals('normal', $storage3->getType());
     $this->assertTrue($server->getDefaultStorage() instanceof DirectoryStorage);
     $server->addFolder('test_dir1');
     #$server->shutdownStorages();
     $server->shutdown();
     $this->assertTrue(file_exists($path1));
     $this->assertFalse(file_exists($path2));
     $this->assertTrue(file_exists($path3));
     $filesystem = new Filesystem();
     $filesystem->remove($storage1->getPath());
     $filesystem->remove($storage2->getPath());
     $filesystem->remove($storage3->getPath());
 }
Exemplo n.º 5
0
 public function getDefaultStorage()
 {
     if (!$this->defaultStorage) {
         $storage = new DirectoryStorage();
         $storage->setPath($this->defaultStoragePath);
         $this->addStorage($storage);
     }
     return $this->defaultStorage;
 }