Changeset 1868

Show
Ignore:
Timestamp:
09/27/08 15:59:57 (3 months ago)
Author:
mikey
Message:

add proper toString() handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • framework/trunk/src/main/php/net/stubbles/lang/types/stubDate.php

    r1860 r1868  
    9393     * returns internal date/time handle 
    9494     * 
    95      * @return  DateTimeZone 
     95     * @return  DateTime 
    9696     */ 
    9797    public function getHandle() 
     
    254254 
    255255    /** 
     256     * returns a string representation of the class 
     257     * 
     258     * @return  string 
     259     */ 
     260    public function __toString() 
     261    { 
     262        return self::getStringRepresentationOf($this, array('dateTime' => $this->format('Y-m-d H:i:sO'))); 
     263    } 
     264 
     265    /** 
    256266     * make sure handle is cloned as well 
    257267     */ 
  • framework/trunk/src/main/php/net/stubbles/lang/types/stubTimeZone.php

    r1858 r1868  
    147147        return false; 
    148148    } 
     149 
     150    /** 
     151     * returns a string representation of the class 
     152     * 
     153     * @return  string 
     154     */ 
     155    public function __toString() 
     156    { 
     157        return self::getStringRepresentationOf($this, array('timeZone' => $this->timeZone->getName())); 
     158    } 
    149159} 
    150160?> 
  • framework/trunk/src/test/php/net/stubbles/lang/types/stubDateTestCase.php

    r1860 r1868  
    424424        $date = new stubDate('invalid'); 
    425425    } 
     426 
     427    /** 
     428     * ensure a readable string representation is created 
     429     * 
     430     * @test 
     431     */ 
     432    public function toStringConvertsDateTimePropertyIntoReadableDateRepresentation() 
     433    { 
     434        $date = new stubDate('31.12.1969 00:00 GMT'); 
     435        $this->assertEquals("net::stubbles::lang::types::stubDate {\n    dateTime(string): 1969-12-31 00:00:00+0000\n}\n", (string) $date); 
     436    } 
    426437} 
    427438?> 
  • framework/trunk/src/test/php/net/stubbles/lang/types/stubTimeZoneTestCase.php

    r1858 r1868  
    156156        $timeZone = new stubTimeZone('Europe/Karlsruhe'); 
    157157    } 
     158 
     159    /** 
     160     * time zone instance can be transformed into a readable representation 
     161     * 
     162     * @test 
     163     */ 
     164    public function toStringConversionCreatesReadableRepresentation() 
     165    { 
     166        $this->assertEquals("net::stubbles::lang::types::stubTimeZone {\n    timeZone(string): Europe/Berlin\n}\n", (string) $this->timeZone); 
     167    } 
    158168} 
    159169?>