Added additional Set test for Xml class.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7559 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
TommyO 2008-09-05 17:48:51 +00:00
parent a83a0f099f
commit f96f7f0926

View file

@ -633,7 +633,7 @@ class SetTest extends CakeTestCase {
$expected = array(array('Comment' => $common[1]['Comment'][0]));
$r = Set::extract('/Comment[addition=]', $common);
$this->assertEqual($r, $expected);
$habtm = array(
array(
'Post' => array(
@ -1972,7 +1972,7 @@ class SetTest extends CakeTestCase {
)
)
);
$this->assertIdentical($result, $expected);
$this->assertIdentical($result, $expected);
$xml = new Xml('<example attr="ex_attr"><item attr="123"><titles>list</titles>textforitems</item></example>');
$result = Set::reverse($xml);
@ -2055,6 +2055,72 @@ class SetTest extends CakeTestCase {
)
));
$this->assertEqual($result, $expected);
$text = '<?xml version="1.0" encoding="UTF-8"?>
<XRDS xmlns="xri://$xrds">
<XRD xml:id="oauth" xmlns="xri://$XRD*($v*2.0)" version="2.0">
<Type>xri://$xrds*simple</Type>
<Expires>2008-04-13T07:34:58Z</Expires>
<Service>
<Type>http://oauth.net/core/1.0/endpoint/authorize</Type>
<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>
<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>
<URI priority="10">https://ma.gnolia.com/oauth/authorize</URI>
<URI priority="20">http://ma.gnolia.com/oauth/authorize</URI>
</Service>
</XRD>
<XRD xmlns="xri://$XRD*($v*2.0)" version="2.0">
<Type>xri://$xrds*simple</Type>
<Service priority="10">
<Type>http://oauth.net/discovery/1.0</Type>
<URI>#oauth</URI>
</Service>
</XRD>
</XRDS>';
$xml = new Xml($text);
$result = Set::reverse($xml);
$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);
}
/**
* testStrictKeyCheck method