RssHelperTest.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. <?php
  2. /**
  3. * RssHelperTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  8. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice
  12. *
  13. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  14. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  15. * @package Cake.Test.Case.View.Helper
  16. * @since CakePHP(tm) v 1.2.0.4206
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('View', 'View');
  20. App::uses('RssHelper', 'View/Helper');
  21. App::uses('TimeHelper', 'View/Helper');
  22. App::uses('File', 'Utility');
  23. /**
  24. * RssHelperTest class
  25. *
  26. * @package Cake.Test.Case.View.Helper
  27. */
  28. class RssHelperTest extends CakeTestCase {
  29. /**
  30. * setUp method
  31. *
  32. * @return void
  33. */
  34. public function setUp() {
  35. parent::setUp();
  36. $controller = null;
  37. $this->View = new View($controller);
  38. $this->Rss = new RssHelper($this->View);
  39. }
  40. /**
  41. * tearDown method
  42. *
  43. * @return void
  44. */
  45. public function tearDown() {
  46. parent::tearDown();
  47. unset($this->Rss);
  48. }
  49. /**
  50. * testDocument method
  51. *
  52. * @return void
  53. */
  54. public function testDocument() {
  55. $result = $this->Rss->document();
  56. $expected = array(
  57. 'rss' => array(
  58. 'version' => '2.0'
  59. )
  60. );
  61. $this->assertTags($result, $expected);
  62. $result = $this->Rss->document(null, 'content');
  63. $expected = array(
  64. 'rss' => array(
  65. 'version' => '2.0'
  66. ),
  67. 'content'
  68. );
  69. $this->assertTags($result, $expected);
  70. $result = $this->Rss->document(array('contrived' => 'parameter'), 'content');
  71. $expected = array(
  72. 'rss' => array(
  73. 'contrived' => 'parameter',
  74. 'version' => '2.0'
  75. ),
  76. 'content'
  77. );
  78. $this->assertTags($result, $expected);
  79. }
  80. /**
  81. * testChannel method
  82. *
  83. * @return void
  84. */
  85. public function testChannel() {
  86. $attrib = array('a' => '1', 'b' => '2');
  87. $elements = array('title' => 'title');
  88. $content = 'content';
  89. $result = $this->Rss->channel($attrib, $elements, $content);
  90. $expected = array(
  91. 'channel' => array(
  92. 'a' => '1',
  93. 'b' => '2'
  94. ),
  95. '<title',
  96. 'title',
  97. '/title',
  98. '<link',
  99. $this->Rss->url('/', true),
  100. '/link',
  101. '<description',
  102. 'content',
  103. '/channel'
  104. );
  105. $this->assertTags($result, $expected);
  106. $this->View->pageTitle = 'title';
  107. $attrib = array('a' => '1', 'b' => '2');
  108. $elements = array();
  109. $content = 'content';
  110. $result = $this->Rss->channel($attrib, $elements, $content);
  111. $expected = array(
  112. 'channel' => array(
  113. 'a' => '1',
  114. 'b' => '2'
  115. ),
  116. '<title',
  117. 'title',
  118. '/title',
  119. '<link',
  120. $this->Rss->url('/', true),
  121. '/link',
  122. '<description',
  123. 'content',
  124. '/channel'
  125. );
  126. $this->assertTags($result, $expected);
  127. }
  128. /**
  129. * test correct creation of channel sub elements.
  130. *
  131. * @return void
  132. */
  133. public function testChannelElements() {
  134. $attrib = array();
  135. $elements = array(
  136. 'title' => 'Title of RSS Feed',
  137. 'link' => 'http://example.com',
  138. 'description' => 'Description of RSS Feed',
  139. 'image' => array(
  140. 'title' => 'Title of image',
  141. 'url' => 'http://example.com/example.png',
  142. 'link' => 'http://example.com'
  143. ),
  144. 'cloud' => array(
  145. 'domain' => "rpc.sys.com",
  146. 'port' => "80",
  147. 'path' => "/RPC2",
  148. 'registerProcedure' => "myCloud.rssPleaseNotify",
  149. 'protocol' => "xml-rpc"
  150. )
  151. );
  152. $content = 'content-here';
  153. $result = $this->Rss->channel($attrib, $elements, $content);
  154. $expected = array(
  155. '<channel',
  156. '<title', 'Title of RSS Feed', '/title',
  157. '<link', 'http://example.com', '/link',
  158. '<description', 'Description of RSS Feed', '/description',
  159. '<image',
  160. '<title', 'Title of image', '/title',
  161. '<url', 'http://example.com/example.png', '/url',
  162. '<link', 'http://example.com', '/link',
  163. '/image',
  164. 'cloud' => array(
  165. 'domain' => "rpc.sys.com",
  166. 'port' => "80",
  167. 'path' => "/RPC2",
  168. 'registerProcedure' => "myCloud.rssPleaseNotify",
  169. 'protocol' => "xml-rpc"
  170. ),
  171. 'content-here',
  172. '/channel',
  173. );
  174. $this->assertTags($result, $expected);
  175. }
  176. public function testChannelElementAttributes() {
  177. $attrib = array();
  178. $elements = array(
  179. 'title' => 'Title of RSS Feed',
  180. 'link' => 'http://example.com',
  181. 'description' => 'Description of RSS Feed',
  182. 'image' => array(
  183. 'title' => 'Title of image',
  184. 'url' => 'http://example.com/example.png',
  185. 'link' => 'http://example.com'
  186. ),
  187. 'atom:link' => array(
  188. 'attrib' => array(
  189. 'href' => 'http://www.example.com/rss.xml',
  190. 'rel' => 'self',
  191. 'type' => 'application/rss+xml')
  192. )
  193. );
  194. $content = 'content-here';
  195. $result = $this->Rss->channel($attrib, $elements, $content);
  196. $expected = array(
  197. '<channel',
  198. '<title', 'Title of RSS Feed', '/title',
  199. '<link', 'http://example.com', '/link',
  200. '<description', 'Description of RSS Feed', '/description',
  201. '<image',
  202. '<title', 'Title of image', '/title',
  203. '<url', 'http://example.com/example.png', '/url',
  204. '<link', 'http://example.com', '/link',
  205. '/image',
  206. 'atom:link' => array(
  207. 'xmlns:atom' => 'http://www.w3.org/2005/Atom',
  208. 'href' => "http://www.example.com/rss.xml",
  209. 'rel' => "self",
  210. 'type' => "application/rss+xml"
  211. ),
  212. 'content-here',
  213. '/channel',
  214. );
  215. $this->assertTags($result, $expected);
  216. }
  217. /**
  218. * testItems method
  219. *
  220. * @return void
  221. */
  222. public function testItems() {
  223. $items = array(
  224. array('title' => 'title1', 'guid' => 'http://www.example.com/guid1', 'link' => 'http://www.example.com/link1', 'description' => 'description1'),
  225. array('title' => 'title2', 'guid' => 'http://www.example.com/guid2', 'link' => 'http://www.example.com/link2', 'description' => 'description2'),
  226. array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3')
  227. );
  228. $result = $this->Rss->items($items);
  229. $expected = array(
  230. '<item',
  231. '<title', 'title1', '/title',
  232. '<guid', 'http://www.example.com/guid1', '/guid',
  233. '<link', 'http://www.example.com/link1', '/link',
  234. '<description', 'description1', '/description',
  235. '/item',
  236. '<item',
  237. '<title', 'title2', '/title',
  238. '<guid', 'http://www.example.com/guid2', '/guid',
  239. '<link', 'http://www.example.com/link2', '/link',
  240. '<description', 'description2', '/description',
  241. '/item',
  242. '<item',
  243. '<title', 'title3', '/title',
  244. '<guid', 'http://www.example.com/guid3', '/guid',
  245. '<link', 'http://www.example.com/link3', '/link',
  246. '<description', 'description3', '/description',
  247. '/item'
  248. );
  249. $this->assertTags($result, $expected);
  250. $items = array(
  251. array('title' => 'title1', 'guid' => 'http://www.example.com/guid1', 'link' => 'http://www.example.com/link1', 'description' => 'description1'),
  252. array('title' => 'title2', 'guid' => 'http://www.example.com/guid2', 'link' => 'http://www.example.com/link2', 'description' => 'description2'),
  253. array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3')
  254. );
  255. $result = $this->Rss->items($items, create_function('$v', '$v[\'title\'] = $v[\'title\'] . \'-transformed\'; return $v;'));
  256. $expected = array(
  257. '<item',
  258. '<title', 'title1-transformed', '/title',
  259. '<guid', 'http://www.example.com/guid1', '/guid',
  260. '<link', 'http://www.example.com/link1', '/link',
  261. '<description', 'description1', '/description',
  262. '/item',
  263. '<item',
  264. '<title', 'title2-transformed', '/title',
  265. '<guid', 'http://www.example.com/guid2', '/guid',
  266. '<link', 'http://www.example.com/link2', '/link',
  267. '<description', 'description2', '/description',
  268. '/item',
  269. '<item',
  270. '<title', 'title3-transformed', '/title',
  271. '<guid', 'http://www.example.com/guid3', '/guid',
  272. '<link', 'http://www.example.com/link3', '/link',
  273. '<description', 'description3', '/description',
  274. '/item'
  275. );
  276. $this->assertTags($result, $expected);
  277. $result = $this->Rss->items(array());
  278. $expected = '';
  279. $this->assertEquals($expected, $result);
  280. }
  281. /**
  282. * testItem method
  283. *
  284. * @return void
  285. */
  286. public function testItem() {
  287. $item = array(
  288. 'title' => 'My title',
  289. 'description' => 'My description',
  290. 'link' => 'http://www.google.com/'
  291. );
  292. $result = $this->Rss->item(null, $item);
  293. $expected = array(
  294. '<item',
  295. '<title',
  296. 'My title',
  297. '/title',
  298. '<description',
  299. 'My description',
  300. '/description',
  301. '<link',
  302. 'http://www.google.com/',
  303. '/link',
  304. '<guid',
  305. 'http://www.google.com/',
  306. '/guid',
  307. '/item'
  308. );
  309. $this->assertTags($result, $expected);
  310. $item = array(
  311. 'title' => 'My Title',
  312. 'link' => 'http://www.example.com/1',
  313. 'description' => 'descriptive words',
  314. 'pubDate' => '2008-05-31 12:00:00',
  315. 'source' => array('http://www.google.com/', 'Google'),
  316. 'guid' => 'http://www.example.com/1'
  317. );
  318. $result = $this->Rss->item(null, $item);
  319. $expected = array(
  320. '<item',
  321. '<title',
  322. 'My Title',
  323. '/title',
  324. '<link',
  325. 'http://www.example.com/1',
  326. '/link',
  327. '<description',
  328. 'descriptive words',
  329. '/description',
  330. '<pubDate',
  331. date('r', strtotime('2008-05-31 12:00:00')),
  332. '/pubDate',
  333. 'source' => array('url' => 'http://www.google.com/'),
  334. 'Google',
  335. '/source',
  336. '<guid',
  337. 'http://www.example.com/1',
  338. '/guid',
  339. '/item'
  340. );
  341. $this->assertTags($result, $expected);
  342. $item = array(
  343. 'title' => 'My Title & more'
  344. );
  345. $result = $this->Rss->item(null, $item);
  346. $expected = array(
  347. '<item',
  348. '<title', 'My Title &amp; more', '/title',
  349. '/item'
  350. );
  351. $this->assertTags($result, $expected);
  352. $item = array(
  353. 'title' => 'Foo bar',
  354. 'link' => array(
  355. 'url' => 'http://example.com/foo?a=1&b=2',
  356. 'convertEntities' => false
  357. ),
  358. 'description' => array(
  359. 'value' => 'descriptive words',
  360. 'cdata' => true,
  361. ),
  362. 'pubDate' => '2008-05-31 12:00:00',
  363. 'source' => 'http://www.google.com/'
  364. );
  365. $result = $this->Rss->item(null, $item);
  366. $expected = array(
  367. '<item',
  368. '<title',
  369. 'Foo bar',
  370. '/title',
  371. '<link',
  372. 'http://example.com/foo?a=1&amp;b=2',
  373. '/link',
  374. '<description',
  375. '<![CDATA[descriptive words]]',
  376. '/description',
  377. '<pubDate',
  378. date('r', strtotime('2008-05-31 12:00:00')),
  379. '/pubDate',
  380. '<source',
  381. 'http://www.google.com/',
  382. '/source',
  383. '<guid',
  384. 'http://example.com/foo?a=1&amp;b=2',
  385. '/guid',
  386. '/item'
  387. );
  388. $this->assertTags($result, $expected);
  389. $item = array(
  390. 'title' => 'My title',
  391. 'description' => 'My description',
  392. 'link' => 'http://www.google.com/',
  393. 'source' => array('url' => 'http://www.example.com/', 'title' => 'Example website')
  394. );
  395. $result = $this->Rss->item(null, $item);
  396. $expected = array(
  397. '<item',
  398. '<title',
  399. 'My title',
  400. '/title',
  401. '<description',
  402. 'My description',
  403. '/description',
  404. '<link',
  405. 'http://www.google.com/',
  406. '/link',
  407. 'source' => array('url' => 'http://www.example.com/'),
  408. 'Example website',
  409. '/source',
  410. '<guid',
  411. 'http://www.google.com/',
  412. '/guid',
  413. '/item'
  414. );
  415. $this->assertTags($result, $expected);
  416. $item = array(
  417. 'title' => 'My title',
  418. 'description' => 'My description',
  419. 'link' => 'http://www.google.com/',
  420. 'category' => array('Category One', 'Category Two')
  421. );
  422. $result = $this->Rss->item(null, $item);
  423. $expected = array(
  424. '<item',
  425. '<title',
  426. 'My title',
  427. '/title',
  428. '<description',
  429. 'My description',
  430. '/description',
  431. '<link',
  432. 'http://www.google.com/',
  433. '/link',
  434. '<category',
  435. 'Category One',
  436. '/category',
  437. '<category',
  438. 'Category Two',
  439. '/category',
  440. '<guid',
  441. 'http://www.google.com/',
  442. '/guid',
  443. '/item'
  444. );
  445. $this->assertTags($result, $expected);
  446. }
  447. /**
  448. * test item() with cdata blocks.
  449. *
  450. * @return void
  451. */
  452. public function testItemCdata() {
  453. $item = array(
  454. 'title' => array(
  455. 'value' => 'My Title & more',
  456. 'cdata' => true,
  457. 'convertEntities' => false,
  458. )
  459. );
  460. $result = $this->Rss->item(null, $item);
  461. $expected = array(
  462. '<item',
  463. '<title',
  464. '<![CDATA[My Title & more]]',
  465. '/title',
  466. '/item'
  467. );
  468. $this->assertTags($result, $expected);
  469. $item = array(
  470. 'category' => array(
  471. 'value' => 'CakePHP',
  472. 'cdata' => true,
  473. 'domain' => 'http://www.cakephp.org',
  474. )
  475. );
  476. $result = $this->Rss->item(null, $item);
  477. $expected = array(
  478. '<item',
  479. 'category' => array('domain' => 'http://www.cakephp.org'),
  480. '<![CDATA[CakePHP]]',
  481. '/category',
  482. '/item'
  483. );
  484. $this->assertTags($result, $expected);
  485. $item = array(
  486. 'category' => array(
  487. array(
  488. 'value' => 'CakePHP',
  489. 'cdata' => true,
  490. 'domain' => 'http://www.cakephp.org'
  491. ),
  492. array(
  493. 'value' => 'Bakery',
  494. 'cdata' => true
  495. )
  496. )
  497. );
  498. $result = $this->Rss->item(null, $item);
  499. $expected = array(
  500. '<item',
  501. 'category' => array('domain' => 'http://www.cakephp.org'),
  502. '<![CDATA[CakePHP]]',
  503. '/category',
  504. '<category',
  505. '<![CDATA[Bakery]]',
  506. '/category',
  507. '/item'
  508. );
  509. $this->assertTags($result, $expected);
  510. $item = array(
  511. 'title' => array(
  512. 'value' => 'My Title',
  513. 'cdata' => true,
  514. ),
  515. 'link' => 'http://www.example.com/1',
  516. 'description' => array(
  517. 'value' => 'descriptive words',
  518. 'cdata' => true,
  519. ),
  520. 'enclosure' => array(
  521. 'url' => '/test.flv'
  522. ),
  523. 'pubDate' => '2008-05-31 12:00:00',
  524. 'guid' => 'http://www.example.com/1',
  525. 'category' => array(
  526. array(
  527. 'value' => 'CakePHP',
  528. 'cdata' => true,
  529. 'domain' => 'http://www.cakephp.org'
  530. ),
  531. array(
  532. 'value' => 'Bakery',
  533. 'cdata' => true
  534. )
  535. )
  536. );
  537. $result = $this->Rss->item(null, $item);
  538. $expected = array(
  539. '<item',
  540. '<title',
  541. '<![CDATA[My Title]]',
  542. '/title',
  543. '<link',
  544. 'http://www.example.com/1',
  545. '/link',
  546. '<description',
  547. '<![CDATA[descriptive words]]',
  548. '/description',
  549. 'enclosure' => array('url' => $this->Rss->url('/test.flv', true)),
  550. '<pubDate',
  551. date('r', strtotime('2008-05-31 12:00:00')),
  552. '/pubDate',
  553. '<guid',
  554. 'http://www.example.com/1',
  555. '/guid',
  556. 'category' => array('domain' => 'http://www.cakephp.org'),
  557. '<![CDATA[CakePHP]]',
  558. '/category',
  559. '<category',
  560. '<![CDATA[Bakery]]',
  561. '/category',
  562. '/item'
  563. );
  564. $this->assertTags($result, $expected);
  565. }
  566. /**
  567. * test item() with enclosure data.
  568. *
  569. * @return void
  570. */
  571. public function testItemEnclosureLength() {
  572. if (!is_writable(WWW_ROOT)) {
  573. $this->markTestSkipped(__d('cake_dev', 'Webroot is not writable.'));
  574. }
  575. $testExists = is_dir(WWW_ROOT . 'tests');
  576. $tmpFile = WWW_ROOT . 'tests' . DS . 'cakephp.file.test.tmp';
  577. $File = new File($tmpFile, true);
  578. $this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile);
  579. if (50300 <= PHP_VERSION_ID) {
  580. clearstatcache(true, $tmpFile);
  581. } else {
  582. clearstatcache();
  583. }
  584. $item = array(
  585. 'title' => array(
  586. 'value' => 'My Title',
  587. 'cdata' => true,
  588. ),
  589. 'link' => 'http://www.example.com/1',
  590. 'description' => array(
  591. 'value' => 'descriptive words',
  592. 'cdata' => true,
  593. ),
  594. 'enclosure' => array(
  595. 'url' => '/tests/cakephp.file.test.tmp'
  596. ),
  597. 'pubDate' => '2008-05-31 12:00:00',
  598. 'guid' => 'http://www.example.com/1',
  599. 'category' => array(
  600. array(
  601. 'value' => 'CakePHP',
  602. 'cdata' => true,
  603. 'domain' => 'http://www.cakephp.org'
  604. ),
  605. array(
  606. 'value' => 'Bakery',
  607. 'cdata' => true
  608. )
  609. )
  610. );
  611. $result = $this->Rss->item(null, $item);
  612. if (!function_exists('mime_content_type')) {
  613. $type = null;
  614. } else {
  615. $type = mime_content_type($tmpFile);
  616. }
  617. $expected = array(
  618. '<item',
  619. '<title',
  620. '<![CDATA[My Title]]',
  621. '/title',
  622. '<link',
  623. 'http://www.example.com/1',
  624. '/link',
  625. '<description',
  626. '<![CDATA[descriptive words]]',
  627. '/description',
  628. 'enclosure' => array(
  629. 'url' => $this->Rss->url('/tests/cakephp.file.test.tmp', true),
  630. 'length' => filesize($tmpFile),
  631. 'type' => $type
  632. ),
  633. '<pubDate',
  634. date('r', strtotime('2008-05-31 12:00:00')),
  635. '/pubDate',
  636. '<guid',
  637. 'http://www.example.com/1',
  638. '/guid',
  639. 'category' => array('domain' => 'http://www.cakephp.org'),
  640. '<![CDATA[CakePHP]]',
  641. '/category',
  642. '<category',
  643. '<![CDATA[Bakery]]',
  644. '/category',
  645. '/item'
  646. );
  647. if ($type === null) {
  648. unset($expected['enclosure']['type']);
  649. }
  650. $this->assertTags($result, $expected);
  651. $File->delete();
  652. if (!$testExists) {
  653. $Folder = new Folder(WWW_ROOT . 'tests');
  654. $Folder->delete();
  655. }
  656. }
  657. /**
  658. * testElementAttrNotInParent method
  659. *
  660. * @return void
  661. */
  662. public function testElementAttrNotInParent() {
  663. $attributes = array(
  664. 'title' => 'Some Title',
  665. 'link' => 'http://link.com',
  666. 'description' => 'description'
  667. );
  668. $elements = array('enclosure' => array('url' => 'http://test.com'));
  669. $result = $this->Rss->item($attributes, $elements);
  670. $expected = array(
  671. 'item' => array(
  672. 'title' => 'Some Title',
  673. 'link' => 'http://link.com',
  674. 'description' => 'description'
  675. ),
  676. 'enclosure' => array(
  677. 'url' => 'http://test.com'
  678. ),
  679. '/item'
  680. );
  681. $this->assertTags($result, $expected);
  682. }
  683. public function testElementNamespaceWithoutPrefix() {
  684. $item = array(
  685. 'creator' => 'Alex',
  686. );
  687. $attributes = array(
  688. 'namespace' => 'http://link.com'
  689. );
  690. $result = $this->Rss->item($attributes, $item);
  691. $expected = array(
  692. 'item' => array(
  693. 'xmlns' => 'http://link.com'
  694. ),
  695. 'creator' => array(
  696. 'xmlns' => 'http://link.com'
  697. ),
  698. 'Alex',
  699. '/creator',
  700. '/item'
  701. );
  702. $this->assertTags($result, $expected, true);
  703. }
  704. public function testElementNamespaceWithPrefix() {
  705. $item = array(
  706. 'title' => 'Title',
  707. 'dc:creator' => 'Alex',
  708. 'xy:description' => 'descriptive words'
  709. );
  710. $attributes = array(
  711. 'namespace' => array(
  712. 'prefix' => 'dc',
  713. 'url' => 'http://link.com'
  714. )
  715. );
  716. $result = $this->Rss->item($attributes, $item);
  717. $expected = array(
  718. 'item' => array(
  719. 'xmlns:dc' => 'http://link.com'
  720. ),
  721. 'title' => array(
  722. 'xmlns:dc' => 'http://link.com'
  723. ),
  724. 'Title',
  725. '/title',
  726. 'dc:creator' => array(
  727. 'xmlns:dc' => 'http://link.com'
  728. ),
  729. 'Alex',
  730. '/dc:creator',
  731. 'description' => array(
  732. 'xmlns:dc' => 'http://link.com'
  733. ),
  734. 'descriptive words',
  735. '/description',
  736. '/item'
  737. );
  738. $this->assertTags($result, $expected, true);
  739. }
  740. }