<?php
require_once 'rss.php';
require_once 
'PHPUnit.php';

class 
RssTest extends PHPUnit_TestCase
{
  function 
RssTest($name) {
    
$this->PHPUnit_TestCase($name);
  }

  function 
setUp() {
    
$this->movietickets = new Rss("MovieTickets.xml");
    
$this->fleasnemo = new Rss("FleasNemo.xml");
  }

  function 
tearDown() {
  }

  function 
testGetFeedsCount() {
    
$this->assertEquals(1$this->movietickets->count());
    
$this->assertEquals(2$this->fleasnemo->count());
  }

  function 
testGetFeedTitle() {
    
$feeds $this->movietickets->getFeeds();
    
$this->assertEquals("인 굿 컴퍼니"$feeds[0]->title());
  }

  function 
testGetChannelTitle() {
    
$info $this->movietickets->getChannelInfo();
    
$this->assertEquals("MovieTickets"$info['title']);

    
$info $this->fleasnemo->getChannelInfo();
    
$this->assertEquals("Flea's Nemo Ver.3"$info['title']);
  }

  function 
testFeedFormatting() {
    
$feeds $this->movietickets->getFeeds();
    
$this->assertEquals("[MovieTickets] 인 굿 컴퍼니"$feeds[0]->toString());
  }

  function 
testFeedLinkFormatting() {
    
$feeds $this->movietickets->getFeeds();
    
$title "[<a href='http://php.chol.com/~vvs740/tt/index.php'>MovieTickets</a>] <a href='http://php.chol.com/~vvs740/tt/index.php?pl=254'>인 굿 컴퍼니</a>";
    
$this->assertEquals($title$feeds[0]->toHtml());
  }

  function 
testCompositedFeedCount() {
    
$composited = new CompositedRss();
    
$composited->add("MovieTickets.xml");
    
$composited->add("FleasNemo.xml");
    
$this->assertEquals(3$composited->count());
  }

  function 
testCompositedFeeds() {
    
$composited = new CompositedRss();
    
$composited->add("MovieTickets.xml");
    
$composited->add("FleasNemo.xml");
    
$this->assertEquals(3sizeof($composited->getFeeds()));
  }

  function 
testGetFeedDate() {
    
$feeds $this->movietickets->getFeeds();
    
$this->assertEquals(strtotime("2005-08-27T09:40:00+09:00"), $feeds[0]->date());
  }
}
?>