mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing incorrect implementation of RssHelper::channel(). Test cases added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7887 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
acb9e72355
commit
cfa2229689
2 changed files with 44 additions and 26 deletions
|
@ -138,9 +138,17 @@ class RssHelper extends XmlHelper {
|
|||
$elems = '';
|
||||
foreach ($elements as $elem => $data) {
|
||||
$attributes = array();
|
||||
if (is_array($data) && isset($data['attrib']) && is_array($data['attrib'])) {
|
||||
$attributes = $data['attrib'];
|
||||
unset($data['attrib']);
|
||||
if (is_array($data)) {
|
||||
if (strtolower($elem) == 'cloud') {
|
||||
$attributes = $data;
|
||||
$data = array();
|
||||
} else {
|
||||
$innerElements = '';
|
||||
foreach ($data as $subElement => $value) {
|
||||
$innerElements .= $this->elem($subElement, array(), $value);
|
||||
}
|
||||
$data = $innerElements;
|
||||
}
|
||||
}
|
||||
$elems .= $this->elem($elem, $attributes, $data);
|
||||
}
|
||||
|
|
|
@ -173,41 +173,51 @@ class RssTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testChannelElementLevelAttrib method
|
||||
* test correct creation of channel sub elements.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testChannelElementLevelAttrib() {
|
||||
function testChannelElements() {
|
||||
$attrib = array();
|
||||
$elements = array(
|
||||
'title' => 'title',
|
||||
'title' => 'Title of RSS Feed',
|
||||
'link' => 'http://example.com',
|
||||
'description' => 'Description of RSS Feed',
|
||||
'image' => array(
|
||||
'myImage',
|
||||
'attrib' => array(
|
||||
'href' => 'http://localhost'
|
||||
)
|
||||
'title' => 'Title of image',
|
||||
'url' => 'http://example.com/example.png',
|
||||
'link' => 'http://example.com'
|
||||
),
|
||||
'cloud' => array(
|
||||
'domain' => "rpc.sys.com",
|
||||
'port' => "80",
|
||||
'path' =>"/RPC2",
|
||||
'registerProcedure' => "myCloud.rssPleaseNotify",
|
||||
'protocol' => "xml-rpc"
|
||||
)
|
||||
);
|
||||
$content = 'content';
|
||||
|
||||
$content = 'content-here';
|
||||
$result = $this->Rss->channel($attrib, $elements, $content);
|
||||
$expected = array(
|
||||
'<channel',
|
||||
'<title',
|
||||
'title',
|
||||
'/title',
|
||||
'image' => array(
|
||||
'href' => 'http://localhost'
|
||||
),
|
||||
'<myImage',
|
||||
'/image',
|
||||
'<link',
|
||||
RssHelper::url('/', true),
|
||||
'/link',
|
||||
'<description',
|
||||
'content',
|
||||
'/channel'
|
||||
'<title', 'Title of RSS Feed', '/title',
|
||||
'<link', 'http://example.com', '/link',
|
||||
'<description', 'Description of RSS Feed', '/description',
|
||||
'<image',
|
||||
'<title', 'Title of image', '/title',
|
||||
'<url', 'http://example.com/example.png', '/url',
|
||||
'<link', 'http://example.com', '/link',
|
||||
'/image',
|
||||
'cloud' => array(
|
||||
'domain' => "rpc.sys.com",
|
||||
'port' => "80",
|
||||
'path' =>"/RPC2",
|
||||
'registerProcedure' => "myCloud.rssPleaseNotify",
|
||||
'protocol' => "xml-rpc"
|
||||
),
|
||||
'content-here',
|
||||
'/channel',
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue