Esempio n. 1
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());
 }
Esempio n. 2
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());
 }