Changeset 1900

Show
Ignore:
Timestamp:
10/24/08 15:02:24 (2 months ago)
Author:
mikey
Message:

allow date instances as argument for stubRSSFeedItem::publishedOn()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework/trunk/src/main/php/net/stubbles/xml/rss/stubRSSFeedItem.php

    r1839 r1900  
    99 */ 
    1010stubClassLoader::load('net::stubbles::lang::exceptions::stubIllegalArgumentException', 
     11                      'net::stubbles::lang::types::stubDate', 
    1112                      'net::stubbles::xml::stubXMLStreamWriter', 
    1213                      'net::stubbles::xml::rss::stubRSSFeedItemAnnotation' 
     
    297298     * set the date when the item was published 
    298299     * 
    299      * @param   string|int       $pubDate  publishing date of rss feed item 
     300     * @param   string|int|stubDate  $pubDate  publishing date of rss feed item 
    300301     * @return  stubRSSFeedItem 
    301302     * @throws  stubIllegalArgumentException 
     
    303304    public function publishedOn($pubDate) 
    304305    { 
    305         if (is_int($pubDate) === false) { 
     306        if ($pubDate instanceof stubDate) { 
     307            $pubDate = $pubDate->getTimestamp(); 
     308        } elseif (is_int($pubDate) === false) { 
    306309            $pubDate = strtotime($pubDate); 
    307310            if (false === $pubDate) { 
    308                 throw new stubIllegalArgumentException('Argument must be a unix timestamp or a valid string representation of a time.'); 
     311                throw new stubIllegalArgumentException('Argument must be a unix timestamp, a valid string representation of a time or an instance of net::stubbles::lang::types::stubDate.'); 
    309312            } 
    310313        } 
  • framework/trunk/src/test/php/net/stubbles/xml/rss/stubRSSFeedItemTestCase.php

    r1763 r1900  
    66 * @package     stubbles 
    77 * @subpackage  xml_rss_test 
     8 * @version     $Id$ 
    89 */ 
    910stubClassLoader::load('net::stubbles::xml::rss::stubRSSFeedItem'); 
     
    147148     * @test 
    148149     */ 
     150    public function publishingDateAsInstance() 
     151    { 
     152        $date = new stubDate('2008-05-24'); 
     153        $this->assertSame($this->rssFeedItem1, $this->rssFeedItem1->publishedOn($date)); 
     154        $this->assertEquals('Sat 24 May 2008 00:00:00 +0200', $this->rssFeedItem1->getPubDate()); 
     155    } 
     156 
     157    /** 
     158     * alternate publishing date should be valid as well 
     159     * 
     160     * @test 
     161     */ 
    149162    public function alternativePublishingDate() 
    150163    {