diff --git a/cake/libs/view/helpers/rss.php b/cake/libs/view/helpers/rss.php index 8a25a992b..f9b361a19 100644 --- a/cake/libs/view/helpers/rss.php +++ b/cake/libs/view/helpers/rss.php @@ -111,6 +111,7 @@ class RssHelper extends XmlHelper { if (!isset($attrib['version']) || empty($attrib['version'])) { $attrib['version'] = $this->version; } + return $this->elem('rss', $attrib, $content); } /** diff --git a/cake/libs/view/helpers/xml.php b/cake/libs/view/helpers/xml.php index d2b8bbb92..772091029 100644 --- a/cake/libs/view/helpers/xml.php +++ b/cake/libs/view/helpers/xml.php @@ -43,6 +43,15 @@ class XmlHelper extends AppHelper { * @var string */ var $encoding = 'UTF-8'; +/** + * Constructor + * @return void + */ + function __construct() { + parent::__construct(); + $this->Xml =& new Xml(); + $this->Xml->options(array('verifyNs' => false)); + } /** * Returns an XML document header * @@ -114,6 +123,7 @@ class XmlHelper extends AppHelper { $children = $content; $content = null; } + $elem =& $this->Xml->createElement($name, $content, $attrib, $namespace); foreach ($children as $child) { $elem->createElement($child); @@ -125,6 +135,11 @@ class XmlHelper extends AppHelper { } return $this->output($out); } +/** + * Create closing tag for current element + * + * @return string + */ function closeElem() { $name = $this->Xml->name(); if ($parent =& $this->Xml->parent()) { @@ -140,14 +155,8 @@ class XmlHelper extends AppHelper { * @return string A copy of $data in XML format */ function serialize($data, $options = array()) { - $data = new Xml($data, array_merge(array('attributes' => false, 'format' => 'attributes'), $options)); + $data =& new Xml($data, array_merge(array('attributes' => false, 'format' => 'attributes'), $options)); return $data->toString(array_merge(array('header' => false), $options)); } - - function beforeRender() { - $this->Xml =& new Xml(); - $this->Xml->options(array('verifyNs' => false)); - } } - ?> \ No newline at end of file diff --git a/cake/libs/xml.php b/cake/libs/xml.php index 82b1e1ffb..b8108d61e 100644 --- a/cake/libs/xml.php +++ b/cake/libs/xml.php @@ -114,7 +114,7 @@ class XmlNode extends Object { $this->createTextNode($value); } } - + /** * Adds a namespace to the current node * @@ -129,7 +129,7 @@ class XmlNode extends Object { } return false; } - + /** * Creates an XmlNode object that can be appended to this document or a node in it * @@ -196,7 +196,7 @@ class XmlNode extends Object { if ($tagOpts === false) { return; } - + if (isset($tagOpts['name'])) { $name = $tagOpts['name']; } elseif ($name != strtolower($name)) { @@ -572,13 +572,23 @@ class XmlNode extends Object { if ($options['whitespace']) { $d .= str_repeat("\t", $depth); } + $d .= '<' . $this->name(); - if (is_array($this->namespaces) && count($this->namespaces) > 0) { + if (count($this->namespaces) > 0) { foreach ($this->namespaces as $key => $val) { $val = str_replace('"', '\"', $val); $d .= ' xmlns:' . $key . '="' . $val . '"'; } } + + $parent =& $this->parent(); + if ($parent->name === '#document' && count($parent->namespaces) > 0) { + foreach ($parent->namespaces as $key => $val) { + $val = str_replace('"', '\"', $val); + $d .= ' xmlns:' . $key . '="' . $val . '"'; + } + } + if (is_array($this->attributes) && count($this->attributes) > 0) { foreach ($this->attributes as $key => $val) { $val = str_replace('"', '\"', $val); @@ -621,6 +631,7 @@ class XmlNode extends Object { } } } + return $d; } /** @@ -918,6 +929,7 @@ class Xml extends XmlNode { if (is_bool($options)) { $options = array('header' => $options); } + $defaults = array('header' => false, 'encoding' => $this->encoding); $options = array_merge($defaults, Xml::options(), $options); $data = parent::toString($options, 0); @@ -928,14 +940,21 @@ class Xml extends XmlNode { } return $this->header() . "\n" . $data; } + return $data; } - +/** + * Return a header used on the first line of the xml file + * + * @param mixed $attrib attributes of the header element + * @return string formated header + */ function header($attrib = array()) { $header = 'xml'; if (is_string($attrib)) { $header = $attrib; } else { + $attrib = array_merge(array('version' => $this->version, 'encoding' => $this->encoding), $attrib); foreach ($attrib as $key=>$val) { $header .= ' ' . $key . '="' . $val . '"'; @@ -966,21 +985,20 @@ class Xml extends XmlNode { */ function addGlobalNs($name, $url = null) { $_this =& XmlManager::getInstance(); - if ($ns = Xml::__resolveNamespace($name, $url)) { + if ($ns = Xml::resolveNamespace($name, $url)) { $_this->namespaces = array_merge($_this->namespaces, $ns); return $ns; } return false; } /** - * Private method + * Resolves current namespace * * @param string $name * @param string $url * @return array - * @access private */ - function __resolveNamespace($name, $url) { + function resolveNamespace($name, $url) { $_this =& XmlManager::getInstance(); if ($url == null && in_array($name, array_keys($_this->defaultNamespaceMap))) { $url = $_this->defaultNamespaceMap[$name]; @@ -1013,15 +1031,16 @@ class Xml extends XmlNode { */ function removeGlobalNs($name) { $_this =& XmlManager::getInstance(); - if (in_array($name, array_keys($_this->namespaces))) { unset($_this->namespaces[$name]); + unset($this->namespaces[$name]); } elseif (in_array($name, $_this->namespaces)) { $keys = array_keys($_this->namespaces); $count = count($keys); for ($i = 0; $i < $count; $i++) { if ($_this->namespaces[$keys[$i]] == $name) { unset($_this->namespaces[$keys[$i]]); + unset($this->namespaces[$keys[$i]]); return; } } @@ -1050,18 +1069,39 @@ class Xml extends XmlNode { return $_this->options; } } - +/** + * The XML Element + * + */ class XmlElement extends XmlNode { - +/** + * Construct an Xml element + * + * @param string $name name of the node + * @param string $value value of the node + * @param array $attributes + * @param string $namespace + * @return string A copy of $data in XML format + */ function __construct($name = null, $value = null, $attributes = array(), $namespace = false) { parent::__construct($name, $value, $namespace); $this->addAttribute($attributes); } - +/** + * Get all the attributes for this element + * + * @return array + */ function attributes() { return $this->attributes; } - +/** + * Add attributes to this element + * + * @param string $name name of the node + * @param string $value value of the node + * @return boolean + */ function addAttribute($name, $val = null) { if (is_object($name)) { $name = get_object_vars($name); @@ -1091,7 +1131,12 @@ class XmlElement extends XmlNode { } return false; } - +/** + * Remove attributes to this element + * + * @param string $name name of the node + * @return boolean + */ function removeAttribute($attr) { if ($this->attributes[$attr]) { unset($this->attributes[$attr]); @@ -1182,8 +1227,6 @@ class XmlTextNode extends XmlNode { return $val; } } - - /** * Manages application-wide namespaces and XML parsing/generation settings. * Private class, used exclusively within scope of XML class. @@ -1239,5 +1282,4 @@ class XmlManager { return $instance[0]; } } - ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/helpers/rss.test.php b/cake/tests/cases/libs/view/helpers/rss.test.php index c45f46871..1e3b2efeb 100644 --- a/cake/tests/cases/libs/view/helpers/rss.test.php +++ b/cake/tests/cases/libs/view/helpers/rss.test.php @@ -40,7 +40,7 @@ App::import('Helper', array('Rss', 'Time')); class RssTest extends CakeTestCase { /** * setUp method - * + * * @access public * @return void */ @@ -51,7 +51,7 @@ class RssTest extends CakeTestCase { } /** * tearDown method - * + * * @access public * @return void */ @@ -60,7 +60,7 @@ class RssTest extends CakeTestCase { } /** * testAddNamespace method - * + * * @access public * @return void */ @@ -70,10 +70,18 @@ class RssTest extends CakeTestCase { $expected = array('custom' => 'http://example.com/dtd.xml'); $this->assertEqual($manager->namespaces, $expected); + + $this->Rss->removeNs('custom'); + + $this->Rss->addNs('dummy', 'http://dummy.com/1.0/'); + $res = $this->Rss->document(); + $this->assertPattern('/^$/', $res); + + $this->Rss->removeNs('dummy'); } /** * testRemoveNamespace method - * + * * @access public * @return void */ @@ -91,7 +99,7 @@ class RssTest extends CakeTestCase { } /** * testDocument method - * + * * @access public * @return void */ @@ -112,7 +120,7 @@ class RssTest extends CakeTestCase { } /** * testChannel method - * + * * @access public * @return void */ @@ -131,7 +139,7 @@ class RssTest extends CakeTestCase { } /** * testChannelElementLevelAttrib method - * + * * @access public * @return void */ @@ -150,7 +158,7 @@ class RssTest extends CakeTestCase { } /** * testItems method - * + * * @access public * @return void */ @@ -181,7 +189,7 @@ class RssTest extends CakeTestCase { } /** * testItem method - * + * * @access public * @return void */ @@ -189,7 +197,7 @@ class RssTest extends CakeTestCase { $result = $this->Rss->item(null, array("title"=>"My title","description"=>"My description","link"=>"http://www.google.com/")); $expecting = 'My titleMy descriptionhttp://www.google.com/http://www.google.com/'; $this->assertEqual($result, $expecting); - + $item = array( 'title' => array( 'value' => 'My Title', @@ -224,7 +232,7 @@ class RssTest extends CakeTestCase { '/item' ); $this->assertTags($result, $expected); - + $item = array( 'title' => array( 'value' => 'My Title & more', @@ -240,7 +248,7 @@ class RssTest extends CakeTestCase { '/item' ); $this->assertTags($result, $expected); - + $item = array( 'title' => array( 'value' => 'My Title & more', @@ -256,7 +264,7 @@ class RssTest extends CakeTestCase { '/item' ); $this->assertTags($result, $expected); - + $item = array( 'title' => array( 'value' => 'My Title & more', @@ -276,7 +284,7 @@ class RssTest extends CakeTestCase { } /** * testTime method - * + * * @access public * @return void */ @@ -284,7 +292,7 @@ class RssTest extends CakeTestCase { } /** * testElementAttrNotInParent method - * + * * @access public * @return void */ @@ -301,4 +309,4 @@ class RssTest extends CakeTestCase { $this->assertTags($result, $expected); } } -?> +?> \ No newline at end of file diff --git a/cake/tests/cases/libs/view/helpers/xml.test.php b/cake/tests/cases/libs/view/helpers/xml.test.php index 03831f680..ea6906fc0 100644 --- a/cake/tests/cases/libs/view/helpers/xml.test.php +++ b/cake/tests/cases/libs/view/helpers/xml.test.php @@ -33,22 +33,22 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) { uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.DS.'model', 'view'.DS.'helper', 'view'.DS.'helpers'.DS.'xml'); /** * TestXml class - * + * * @package cake * @subpackage cake.tests.cases.libs.view.helpers */ class TestXml extends Object { /** * content property - * + * * @var string '' * @access public */ var $content = ''; /** * construct method - * - * @param mixed $content + * + * @param mixed $content * @access private * @return void */ @@ -57,7 +57,7 @@ class TestXml extends Object { } /** * toString method - * + * * @access public * @return void */ @@ -74,7 +74,7 @@ class TestXml extends Object { class XmlHelperTest extends UnitTestCase { /** * setUp method - * + * * @access public * @return void */ @@ -86,7 +86,7 @@ class XmlHelperTest extends UnitTestCase { } /** * testAddNamespace method - * + * * @access public * @return void */ @@ -99,7 +99,7 @@ class XmlHelperTest extends UnitTestCase { } /** * testRemoveNamespace method - * + * * @access public * @return void */ @@ -117,7 +117,7 @@ class XmlHelperTest extends UnitTestCase { } /** * testRenderZeroElement method - * + * * @access public * @return void */ @@ -128,7 +128,7 @@ class XmlHelperTest extends UnitTestCase { } /** * testRenderElementWithNamespace method - * + * * @access public * @return void */ @@ -140,14 +140,14 @@ class XmlHelperTest extends UnitTestCase { $result = $this->Xml->elem('count', array('namespace' => 'myNameSpace'), 'content', false); $expected = 'content'; $this->assertEqual($result, $expected); - + $expected .= ''; $result .= $this->Xml->closeElem(); $this->assertEqual($result, $expected); } /** * testRenderElementWithComplexContent method - * + * * @access public * @return void */ @@ -162,7 +162,7 @@ class XmlHelperTest extends UnitTestCase { } /** * testSerialize method - * + * * @access public * @return void */ @@ -182,10 +182,24 @@ class XmlHelperTest extends UnitTestCase { $result = $this->Xml->serialize($data); $expected = ''; $this->assertIdentical($result, $expected); + + $data = array( + 'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2'))) + ); + $result = $this->Xml->serialize($data); + $expected = ''; + $this->assertIdentical($result, $expected); + + $data = array( + 'ServiceDay' => array('ServiceTime' => array('ServiceTimePrice' => array('dollar' => 1, 'cents' => '2'))) + ); + $result = $this->Xml->serialize($data, array('format' => 'tags')); + $expected = '12'; + $this->assertIdentical($result, $expected); } /** * testHeader method - * + * * @access public * @return void */ @@ -194,9 +208,9 @@ class XmlHelperTest extends UnitTestCase { if (empty($expectedDefaultEncoding)) { $expectedDefaultEncoding = 'UTF-8'; } - $attrib = array(); - $result = $this->Xml->header($attrib); - $expected = ''; + $attrib = array(); + $result = $this->Xml->header($attrib); + $expected = ''; $this->assertIdentical($result, $expected); $attrib = array( @@ -223,7 +237,7 @@ class XmlHelperTest extends UnitTestCase { } /** * tearDown method - * + * * @access public * @return void */ @@ -232,4 +246,4 @@ class XmlHelperTest extends UnitTestCase { } } -?> +?> \ No newline at end of file diff --git a/cake/tests/cases/libs/xml.test.php b/cake/tests/cases/libs/xml.test.php index 38eb5dc5a..163292e51 100644 --- a/cake/tests/cases/libs/xml.test.php +++ b/cake/tests/cases/libs/xml.test.php @@ -35,6 +35,10 @@ App::import('Core', 'Xml'); * @subpackage cake.tests.cases.libs */ class XmlTest extends UnitTestCase { + + function KgetTests() { + return array('testRootTagParsing'); + } /** * testRootTagParsing method * @@ -42,7 +46,11 @@ class XmlTest extends UnitTestCase { * @return void */ function testRootTagParsing() { - $input = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . "\n" . ''; + $input = '<' . '?xml version="1.0" encoding="UTF-8" ?' . '>' . "\n" . + '' + .'' + .'' + .''; $xml = new Xml($input); $this->assertEqual($xml->children[0]->name, 'plugin'); $this->assertEqual($xml->children[0]->children[0]->name, 'current'); @@ -72,7 +80,7 @@ class XmlTest extends UnitTestCase { $xml = new Xml($input); $result = preg_replace("/\n/",'', $xml->toString(false)); - $expected = '1Touch Screen Kiosk1Financial2<client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>'; + $expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>'; $xml = new Xml($input, array('format' => 'tags')); $result = $xml->toString(array('header' => false, 'cdata' => false)); @@ -224,7 +232,7 @@ class XmlTest extends UnitTestCase { ) ) ); - $expected = '<project><id>1</id><title/><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>15</id><name>Print</name></media_type><media_type><id>7</id><name>Web Demo</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry><business_solution><id>4</id><name>Build Relationship</name></business_solution><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>17</id><name>Web</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project>'; + $expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>15</id><name>Print</name></media_type><media_type><id>7</id><name>Web Demo</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry><business_solution><id>4</id><name>Build Relationship</name></business_solution><business_solution><id>6</id><name>Convert Sales</name></business_solution><media_type><id>17</id><name>Web</name></media_type><media_type><id>6</id><name>CD-ROM</name></media_type></project>'; $xml = new Xml($input, array('format' => 'tags')); $result = $xml->toString(array('header' => false, 'cdata' => false)); @@ -391,7 +399,7 @@ class XmlTest extends UnitTestCase { 'Industry' => array('id' => 2, 'name' => 'Education'), ) ); - $expected = '<project><id>1</id><title/><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1.89</job_type_id><industry_id>1.56</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name><![CDATA[Touch Screen Kiosk]]></name></job_type><industry><id>1</id><name><![CDATA[Financial]]></name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2.2</job_type_id><industry_id>2.2</industry_id><modified><![CDATA[2007-11-26 14:48:36]]></modified><created /><style><id /><name /></style><job_type><id>2</id><name><![CDATA[Awareness Campaign]]></name></job_type><industry><id>2</id><name><![CDATA[Education]]></name></industry></project>'; + $expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1.89</job_type_id><industry_id>1.56</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name><![CDATA[Touch Screen Kiosk]]></name></job_type><industry><id>1</id><name><![CDATA[Financial]]></name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2.2</job_type_id><industry_id>2.2</industry_id><modified><![CDATA[2007-11-26 14:48:36]]></modified><created /><style><id /><name /></style><job_type><id>2</id><name><![CDATA[Awareness Campaign]]></name></job_type><industry><id>2</id><name><![CDATA[Education]]></name></industry></project>'; $xml = new Xml($input, array('format' => 'tags')); $result = $xml->toString(array('header' => false, 'cdata' => true)); $this->assertEqual($expected, $result); @@ -429,7 +437,7 @@ class XmlTest extends UnitTestCase { 'Industry' => array('id' => 2, 'name' => 'Education'), ) ); - $expected = "\n\t<project>\n\t\t<id>\n\t\t\t1\n\t\t</id>\n\t\t<title/>\n\t\t<client_id>\n\t\t\t1\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t1\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t1\n\t\t</industry_id>\n\t\t<modified />\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tTouch Screen Kiosk\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tFinancial\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n\t<project>\n\t\t<id>\n\t\t\t2\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t2\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t2\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t2\n\t\t</industry_id>\n\t\t<modified>\n\t\t\t2007-11-26 14:48:36\n\t\t</modified>\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tAwareness Campaign\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tEducation\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n"; + $expected = "\n\t<project>\n\t\t<id>\n\t\t\t1\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t1\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t1\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t1\n\t\t</industry_id>\n\t\t<modified />\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tTouch Screen Kiosk\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t1\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tFinancial\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n\t<project>\n\t\t<id>\n\t\t\t2\n\t\t</id>\n\t\t<title />\n\t\t<client_id>\n\t\t\t2\n\t\t</client_id>\n\t\t<show>\n\t\t\t1\n\t\t</show>\n\t\t<is_spotlight />\n\t\t<style_id>\n\t\t\t0\n\t\t</style_id>\n\t\t<job_type_id>\n\t\t\t2\n\t\t</job_type_id>\n\t\t<industry_id>\n\t\t\t2\n\t\t</industry_id>\n\t\t<modified>\n\t\t\t2007-11-26 14:48:36\n\t\t</modified>\n\t\t<created />\n\t\t<style>\n\t\t\t<id />\n\t\t\t<name />\n\t\t</style>\n\t\t<job_type>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tAwareness Campaign\n\t\t\t</name>\n\t\t</job_type>\n\t\t<industry>\n\t\t\t<id>\n\t\t\t\t2\n\t\t\t</id>\n\t\t\t<name>\n\t\t\t\tEducation\n\t\t\t</name>\n\t\t</industry>\n\t</project>\n"; $xml = new Xml($input, array('format' => 'tags')); $result = $xml->toString(array('header' => false, 'cdata' => false, 'whitespace' => true)); @@ -456,7 +464,7 @@ class XmlTest extends UnitTestCase { 'Industry' => array('id' => 2, 'name' => 'Education'), ) ); - $expected = '<project><id>1</id><title/><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>'; + $expected = '<project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project>'; $xml = new Xml(Set::map($input), array('format' => 'tags')); $result = $xml->toString(array('header' => false, 'cdata' => false)); @@ -464,7 +472,7 @@ class XmlTest extends UnitTestCase { } /** * testSimpleParsing method - * + * * @access public * @return void */ @@ -476,7 +484,7 @@ class XmlTest extends UnitTestCase { } /** * testMixedParsing method - * + * * @access public * @return void */ @@ -488,19 +496,19 @@ class XmlTest extends UnitTestCase { } /** * testComplexParsing method - * + * * @access public * @return void */ function testComplexParsing() { - $source = '<projects><project><id>1</id><title/><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project></projects>'; + $source = '<projects><project><id>1</id><title /><client_id>1</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>1</job_type_id><industry_id>1</industry_id><modified /><created /><style><id /><name /></style><job_type><id>1</id><name>Touch Screen Kiosk</name></job_type><industry><id>1</id><name>Financial</name></industry></project><project><id>2</id><title /><client_id>2</client_id><show>1</show><is_spotlight /><style_id>0</style_id><job_type_id>2</job_type_id><industry_id>2</industry_id><modified>2007-11-26 14:48:36</modified><created /><style><id /><name /></style><job_type><id>2</id><name>Awareness Campaign</name></job_type><industry><id>2</id><name>Education</name></industry></project></projects>'; $xml = new Xml($source); $result = $xml->toString(array('cdata' => false)); $this->assertEqual($source, $result); } /** * testNamespaceParsing method - * + * * @access public * @return void */ @@ -519,7 +527,7 @@ class XmlTest extends UnitTestCase { } /** * testNamespaces method - * + * * @access public * @return void */ @@ -535,10 +543,6 @@ class XmlTest extends UnitTestCase { $this->assertEqual($expects, $result); } -/* - * @todo Add test for default namespaces - */ - } -?> +?> \ No newline at end of file