Show
Ignore:
Timestamp:
02/27/08 22:52:17 (4 years ago)
Author:
nperriault
Message:

refs #40 - More tests + bug fixes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cleversvg/trunk/tests/csDocumentTest.php

    r325 r326  
    11<?php 
    2 // Call csDocumentTest::main() if this source file is executed directly. 
    3 if (!defined('PHPUnit_MAIN_METHOD')) { 
    4     define('PHPUnit_MAIN_METHOD', 'csDocumentTest::main'); 
    5 } 
    6  
    72require_once 'PHPUnit/Framework.php'; 
    83require_once dirname(__FILE__).'/../cleversvg.php'; 
     4require_once dirname(__FILE__).'/csBaseTestCase.class.php'; 
    95 
    106/** 
     
    128 * 
    139 */ 
    14 class csDocumentTest extends PHPUnit_Framework_TestCase 
     10class csDocumentTest extends csBaseTestCase 
    1511{ 
    1612 
    17   /** 
    18    * csDocument instance 
    19    * @var csDocument 
    20    */ 
    21   protected $doc; 
    22  
    23   public static function main() 
     13  public function testSetDescription() 
    2414  { 
    25     require_once 'PHPUnit/TextUI/TestRunner.php'; 
    26     $suite  = new PHPUnit_Framework_TestSuite('csDocumentTest'); 
    27     $result = PHPUnit_TextUI_TestRunner::run($suite); 
    28   } 
    29  
    30   public function setUp() 
    31   { 
    32     $doc = new csDocument(320, 240, 'SVG test document'); 
    33     $rect = new csRect(60, 60, 40, 40); 
    34     $rect->setFill('red'); 
    35     $rect->setStroke('yellow'); 
    36     $rect->setStrokeWidth('4'); 
    37     $doc->addElement($rect); 
    38     $this->doc = $doc; 
     15    $doc = $this->generateTestDoc(); 
     16    $doc->setDescription('Added description'); 
     17    $xml = $doc->toXML(); 
     18    $this->assertEquals(preg_match('#<desc>Added description</desc>#si', $xml), 1, $xml); 
    3919  } 
    4020 
    4121  public function testSetTitle() 
    4222  { 
    43     $this->doc->setTitle('Changed title'); 
    44     $xml = $this->doc->toXML(); 
     23    $doc = $this->generateTestDoc(); 
     24    $doc->setTitle('Changed title'); 
     25    $xml = $doc->toXML(); 
    4526    $this->assertEquals(preg_match('#<title>Changed title</title>#si', $xml), 1, $xml); 
    46   } 
    47  
    48   public function testSetDescription() 
    49   { 
    50     $this->doc->setDescription('Changed description'); 
    51     $xml = $this->doc->toXML(); 
    52     $this->assertEquals(preg_match('#<desc>Changed description</desc>#si', $xml), 1, $xml); 
    5327  } 
    5428 
    5529  public function testToXml() 
    5630  { 
    57     $xml = $this->doc->toXML(); 
     31    $doc = $this->generateTestDoc(); 
     32    $xml = $doc->toXML(); 
    5833    $this->assertEquals(preg_match('#<\?xml version="1.0" encoding="UTF-8".*?\?>#s', $xml), 1, $xml); 
    5934  } 
     35 
    6036} 
    61  
    62 // Call csDocumentTest::main() if this source file is executed directly. 
    63 if (PHPUnit_MAIN_METHOD == 'csDocumentTest::main') { 
    64     csDocumentTest::main(); 
    65 }