Array( [0] => Array(",
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
'author' => 'bmil...@gmail.com(bpscrugs)',
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
),
array(
'title' => 'Re: share views between actions?',
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
'description' => 'Then perhaps you might do us all a favour and refrain from replying to things you do not understand. That goes especially for asinine comments. Indeed. To sum up: No comment. In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any further responses from you. You (and I) were referring to the *online documentation*, not other',
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
)
)
)
));
$this->assertEqual($result, $expected);
$string ='';
$xml = new Xml($string);
$result = $xml->toArray();
$expected = array('Data' => array('Post' => array('title' => 'Title of this post', 'description' => 'cool')));
$this->assertEqual($result, $expected);
$xml = new Xml('An example of a correctly reversed XMLNode');
$result = Set::reverse($xml);
$expected = array(
'Example' => array(
'Item' => array(
'title' => 'An example of a correctly reversed XMLNode',
'desc' => array(),
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('title1title2');
$result = $xml->toArray();
$expected = array(
'Example' => array(
'Item' => array(
'attr' => '123',
'Titles' => array(
'Title' => array('title1', 'title2')
)
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('listtextforitems');
$result = $xml->toArray();
$expected = array(
'Example' => array(
'attr' => 'ex_attr',
'Item' => array(
'attr' => '123',
'titles' => 'list',
'value' => 'textforitems'
)
)
);
$this->assertIdentical($result, $expected);
$xml = new Xml('listtextforitems');
$example = $xml->child('example');
$item = $example->child('item');
$result = $item->toArray();
$expected = array(
'attr' => '123',
'titles' => 'list',
'value' => 'textforitems'
);
$this->assertIdentical($result, $expected);
$string = '
Cake PHP Google Group
http://groups.google.com/group/cake-php
Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.enconstructng result array when using findall
http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f
i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(cakephphttp://groups.google.com/group/cake-php/msg/49bc00f3bc651b4fbmil...@gmail.com(bpscrugs)Fri, 28 Dec 2007 00:44:14 UTRe: share views between actions?
http://groups.google.com/group/cake-php/msg/8b350d898707dad8
Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I'll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not othercakephphttp://groups.google.com/group/cake-php/msg/8b350d898707dad8subtropolis.z...@gmail.com(subtropolis zijn)Fri, 28 Dec 2007 00:45:01 UT';
$xml = new Xml($string);
$result = $xml->toArray();
$expected = array('Rss' => array(
'version' => '2.0',
'Channel' => array(
'title' => 'Cake PHP Google Group',
'link' => 'http://groups.google.com/group/cake-php',
'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.',
'language' => 'en',
'Item' => array(
array(
'title' => 'constructng result array when using findall',
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
'description' => "i'm using cakephp to construct a logical data model array that will be passed to a flex app. I have the following model association: ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what the current output from my findall is something like this example:
Array( [0] => Array(",
'creator' => 'cakephp',
'Category' => array('cakephp', 'model'),
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
'author' => 'bmil...@gmail.com(bpscrugs)',
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
),
array(
'title' => 'Re: share views between actions?',
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
'description' => 'Then perhaps you might do us all a favour and refrain from replying to things you do not understand. That goes especially for asinine comments. Indeed. To sum up: No comment. In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any further responses from you. You (and I) were referring to the *online documentation*, not other',
'creator' => 'cakephp',
'Category' => array('cakephp', 'model'),
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
)
)
)
));
$this->assertEqual($result, $expected);
$text = "
1234";
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array('Course' => array(
'Comps' => array(
'Comp' => array(
1, 2, 3, 4
)
)
));
$this->assertEqual($result, $expected);
$text = '
xri://$xrds*simple2008-04-13T07:34:58Zhttp://oauth.net/core/1.0/endpoint/authorizehttp://oauth.net/core/1.0/parameters/auth-headerhttp://oauth.net/core/1.0/parameters/uri-queryhttps://ma.gnolia.com/oauth/authorizehttp://ma.gnolia.com/oauth/authorizexri://$xrds*simplehttp://oauth.net/discovery/1.0#oauth';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array('XRDS' => array(
'xmlns' => 'xri://$xrds',
'XRD' => array(
array(
'xml:id' => 'oauth',
'xmlns' => 'xri://$XRD*($v*2.0)',
'version' => '2.0',
'Type' => 'xri://$xrds*simple',
'Expires' => '2008-04-13T07:34:58Z',
'Service' => array(
'Type' => array(
'http://oauth.net/core/1.0/endpoint/authorize',
'http://oauth.net/core/1.0/parameters/auth-header',
'http://oauth.net/core/1.0/parameters/uri-query'
),
'URI' => array(
array(
'value' => 'https://ma.gnolia.com/oauth/authorize',
'priority' => '10',
),
array(
'value' => 'http://ma.gnolia.com/oauth/authorize',
'priority' => '20'
)
)
)
),
array(
'xmlns' => 'xri://$XRD*($v*2.0)',
'version' => '2.0',
'Type' => 'xri://$xrds*simple',
'Service' => array(
'priority' => '10',
'Type' => 'http://oauth.net/discovery/1.0',
'URI' => '#oauth'
)
)
)
));
$this->assertEqual($result, $expected);
$text = '
';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Root' => array(
'Child' => array(
array('id' => 1, 'other' => 1),
array('id' => 2, 'other' => 1),
array('id' => 3, 'other' => 1),
array('id' => 4, 'other' => 1),
array('id' => 5, 'other' => 1)
)
)
);
$this->assertEqual($result, $expected);
$text = '';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Main' => array(
'First' => array(
array('label' => 'first type node 1'),
array('label' => 'first type node 2')
),
'Second' => array('label'=>'second type node')
)
);
$this->assertIdentical($result,$expected);
$text = '';
$xml = new Xml($text);
$result = $xml->toArray();
$expected = array(
'Main' => array(
'First' => array(
array('label' => 'first type node 1'),
array('label' => 'first type node 2')
),
'Second' => array('label'=>'second type node'),
'Collection' => array(
'Fifth' => array('label' => 'fifth type node'),
'Third' => array(
array('label' => 'third type node 1'),
array('label' => 'third type node 2'),
array('label' => 'third type node 3'),
),
'Fourth' => array('label' => 'fourth type node'),
)
)
);
$this->assertIdentical($result,$expected);
}
/**
* testAppend method
*
* @access public
* @return void
*/
function testAppend() {
$parentNode = new XmlNode('ourParentNode');
$parentNode->append( new XmlNode('ourChildNode'));
$first =& $parentNode->first();
$this->assertEqual($first->name, 'ourChildNode');
$string = 'ourChildNode';
$parentNode = new XmlNode('ourParentNode');
$parentNode->append($string);
$last =& $parentNode->last();
$this->assertEqual($last->name, 'ourChildNode');
$this->expectError();
$parentNode->append($parentNode);
}
/**
* testNamespacing method
*
* @access public
* @return void
*/
function testNamespacing() {
$node = new Xml('');
$node->addNamespace('cake', 'http://cakephp.org');
$this->assertEqual($node->toString(), '');
$this->assertTrue($node->removeNamespace('cake'));
$this->assertEqual($node->toString(), '');
$node = new Xml('');
$this->assertTrue($node->removeNamespace('cake'));
$this->assertEqual($node->toString(), '');
$node->addNamespace('cake', 'http://cakephp.org');
$this->assertEqual($node->toString(), '');
}
/**
* testCamelize method
*
* @access public
* @return void
*/
function testCamelize() {
$xmlString = 'examples.getStateName' .
'41';
$Xml = new Xml($xmlString);
$expected = array(
'methodCall' => array(
'methodName' => 'examples.getStateName',
'params' => array(
'param' => array('value' => array('i4' => 41)))));
$this->assertEqual($expected, $Xml->toArray(false));
$Xml = new Xml($xmlString);
$expected = array(
'MethodCall' => array(
'methodName' => 'examples.getStateName',
'Params' => array(
'Param' => array('Value' => array('i4' => 41)))));
$this->assertEqual($expected, $Xml->toArray());
}
/**
* testNumericDataHandling method
*
* @access public
* @return void
*/
function testNumericDataHandling() {
$data = '012345';
$node = new Xml();
$node->load($data);
$node->parse();
$result = $node->first();
$result = $result->children("data");
$result = $result[0]->first();
$this->assertEqual($result->value, '012345');
}
/**
* test that creating an xml object does not leak memory
*
* @return void
*/
function testMemoryLeakInConstructor() {
if ($this->skipIf(!function_exists('memory_get_usage'), 'Cannot test memory leaks without memory_get_usage')) {
return;
}
$data = 'TEST';
$start = memory_get_usage();
for ($i = 0; $i <= 300; $i++) {
$test =& new XML($data);
$test->__destruct();
unset($test);
}
$end = memory_get_usage();
$this->assertWithinMargin($start, $end, 3600, 'Memory leaked %s');
}
}