public function testFilledFeed()
 {
     $time = time();
     $messages = array($this->createMessage('message1', 'Eerste bericht', 1, $time), $this->createMessage('message2', 'Tweede bericht', 2, $time), $this->createMessage('message3', 'Derde bericht', 3, $time));
     $this->server->expects($this->any())->method('search')->will($this->returnValue($messages));
     $this->obj->createFeed('/tmp', 'feed.xml', 'http://www.example.com', 3);
     $files = array('feed.xml', '1.html', '2.html', '3.html');
     foreach ($files as $file) {
         $this->assertFileEquals(__DIR__ . '/' . $file, '/tmp/' . $file);
         @unlink('/tmp/' . $file);
     }
 }
Пример #2
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);
 }