Changeset 326 for cleversvg/trunk/tests/csDocumentTest.php
- Timestamp:
- 02/27/08 22:52:17 (4 years ago)
- Files:
-
- 1 modified
-
cleversvg/trunk/tests/csDocumentTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cleversvg/trunk/tests/csDocumentTest.php
r325 r326 1 1 <?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 7 2 require_once 'PHPUnit/Framework.php'; 8 3 require_once dirname(__FILE__).'/../cleversvg.php'; 4 require_once dirname(__FILE__).'/csBaseTestCase.class.php'; 9 5 10 6 /** … … 12 8 * 13 9 */ 14 class csDocumentTest extends PHPUnit_Framework_TestCase10 class csDocumentTest extends csBaseTestCase 15 11 { 16 12 17 /** 18 * csDocument instance 19 * @var csDocument 20 */ 21 protected $doc; 22 23 public static function main() 13 public function testSetDescription() 24 14 { 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); 39 19 } 40 20 41 21 public function testSetTitle() 42 22 { 43 $this->doc->setTitle('Changed title'); 44 $xml = $this->doc->toXML(); 23 $doc = $this->generateTestDoc(); 24 $doc->setTitle('Changed title'); 25 $xml = $doc->toXML(); 45 26 $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);53 27 } 54 28 55 29 public function testToXml() 56 30 { 57 $xml = $this->doc->toXML(); 31 $doc = $this->generateTestDoc(); 32 $xml = $doc->toXML(); 58 33 $this->assertEquals(preg_match('#<\?xml version="1.0" encoding="UTF-8".*?\?>#s', $xml), 1, $xml); 59 34 } 35 60 36 } 61 62 // Call csDocumentTest::main() if this source file is executed directly.63 if (PHPUnit_MAIN_METHOD == 'csDocumentTest::main') {64 csDocumentTest::main();65 }
