public function setUp()
 {
     $config = (include 'config.php');
     $this->user = new User();
     $this->user->id = 1;
     $this->user->email = $config['email'];
     $this->user->name = 'CMB Test';
     $this->imap = new \Fetch\Server($config['server_path'], $config['port']);
     $this->imap->setAuthentication($config['login'], $config['password']);
     $this->imap->setMailBox($config['mailbox']);
     $this->conn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'user' => 'root', 'password' => 'root', 'memory' => true));
     $data_provider = new DataProviderDoctrine($this->conn);
     $purchase_service = new \shina\controlmybudget\PurchaseService($data_provider);
     $this->mail_importer = $this->makeImporter($this->imap, $purchase_service);
 }
Пример #2
0
 /**
  * Test opening connection.
  */
 public function testGetImapStream()
 {
     $imap = $this->getMock('Fetch\\Imap', array('open'));
     $imap->expects($this->once())->method('open')->with($this->equalTo('{imap.example.com:143/novalidate-cert}'), $this->equalTo('username'), $this->equalTo('password'), $this->equalTo(0), $this->equalTo(1), $this->equalTo(array()))->will($this->returnValue('SUCCESS'));
     $server = new Server('imap.example.com');
     $server->setImap($imap);
     $server->setAuthentication('username', 'password');
     $this->assertEquals('SUCCESS', $server->getImapStream());
 }
Пример #3
0
 /**
  * @throws ParameterException
  */
 public function init()
 {
     $this->checkConfiguration();
     $this->initCalled = true;
     if ($this->fetchServer === null) {
         $this->fetchServer = $this->createServer($this->server, $this->port);
         $this->fetchServer->setAuthentication($this->email, $this->password);
     }
     $serverCustom = new ServerCustom($this->fetchServer);
     if ($this->filename) {
         $this->lastUidPersist = new LastUidPersistFile($this->filename);
     }
     $this->processor = new Processor($serverCustom, $this->newEmailWatcher, $this->lastUidPersist);
 }
Пример #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dir = $input->getOption('dir');
     $limit = '- ' . $input->getOption('limit') . ' day';
     if (!is_dir($dir)) {
         throw new RuntimeException('Dir does not exist');
     }
     $url = rtrim($input->getOption('url'), '/') . '/';
     $filename = $input->getOption('filename');
     $feedFile = $dir . '/' . $filename;
     $server = new Server($input->getOption('hostname'), $input->getOption('port'), $input->getOption('type'));
     $server->setAuthentication($input->getOption('username'), $input->getOption('password'));
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($input->getOption('title'))->description($input->getOption('description'))->url($url . $filename)->appendTo($feed);
     $generator = new EmailFeedGenerator($server, $feed, $channel);
     $generator->createFeed($dir, $filename, $url, $limit);
     $output->writeln('Succesfully generated ' . $feedFile);
 }
 public function import()
 {
     $imap = new Server($this->server, $this->port);
     $imap->setAuthentication($this->username, $this->password);
     $imap->setMailBox($this->mailbox);
     $dataProvider = new DataProvider();
     $purchaseService = new PurchaseService($dataProvider);
     $user_service = new UserService($dataProvider, new Client());
     $user = $user_service->getById($this->backend_users_id);
     $importer = new ImporterService();
     $importer->addImporter(new MailItauCardImport($imap, $purchaseService));
     $importer->addImporter(new MailItauDebitImport($imap, $purchaseService));
     $importer->addImporter(new MailItauWithdrawImport($imap, $purchaseService));
     $importer->addImporter(new MailItauUniclassDebitImport($imap, $purchaseService));
     if ($this->is_first_time) {
         $importer->import(null, $user);
         $this->is_first_time = false;
         $this->save();
     } else {
         $importer->import(10, $user);
     }
 }
Пример #6
0
 public static function getServer()
 {
     $server = new Server(TESTING_SERVER_HOST, 143);
     $server->setAuthentication(TEST_USER, TEST_PASSWORD);
     return $server;
 }