chregu          Mon Oct 27 12:51:56 2003 EDT

  Added files:                 
    /php-src/ext/dom/tests      dom006.phpt 
  Log:
  extending of domDocument class test
  

Index: php-src/ext/dom/tests/dom006.phpt
+++ php-src/ext/dom/tests/dom006.phpt
--TEST--
Test 6: Extends Test
--SKIPIF--
<?php  require_once('skipif.inc'); ?>
--FILE--
<?php

Class books extends domDocument {
    function __construct() {
        /* We must first call the constructor for the parent to create the document
        otherwise this class will not work */
        parent::__construct();
    }
    
    function addBook($title, $author) {
        $titleElement = $this->createElement("title");
        $titleElement->appendChild($this->createTextNode($title));
        $authorElement = $this->createElement("author");
        $authorElement->appendChild($this->createTextNode($author));

        $bookElement = $this->createElement("book");

        $bookElement->appendChild($titleElement);
        $bookElement->appendChild($authorElement);
        $this->documentElement->appendChild($bookElement);
    }
   
}

$dom = new books;

$dom->load(dirname(__FILE__)."/book.xml");
$dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker");
print $dom->saveXML();
--EXPECT--
<?xml version="1.0"?>
<books>
 <book>
  <title>The Grapes of Wrath</title>
  <author>John Steinbeck</author>
 </book>
 <book>
  <title>The Pearl</title>
  <author>John Steinbeck</author>
 </book>
<book><title>PHP de Luxe</title><author>Richard Samar, Christian 
Stocker</author></book></books>


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to