mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Adding tests for RssHelper::items
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6124 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d6c918ec95
commit
7d8bf76744
1 changed files with 24 additions and 1 deletions
|
@ -40,7 +40,7 @@ uses('view'.DS.'helpers'.DS.'app_helper', 'controller'.DS.'controller', 'model'.
|
||||||
class RssTest extends UnitTestCase {
|
class RssTest extends UnitTestCase {
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
$this->Rss = new RssHelper();
|
$this->Rss =& new RssHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
@ -92,6 +92,29 @@ class RssTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItems() {
|
function testItems() {
|
||||||
|
$items = array(
|
||||||
|
array('title' => 'title1', 'guid' => 'http://www.example.com/guid1', 'link' => 'http://www.example.com/link1', 'description' => 'description1'),
|
||||||
|
array('title' => 'title2', 'guid' => 'http://www.example.com/guid2', 'link' => 'http://www.example.com/link2', 'description' => 'description2'),
|
||||||
|
array('title' => 'title3', 'guid' => 'http://www.example.com/guid3', 'link' => 'http://www.example.com/link3', 'description' => 'description3')
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $this->Rss->items($items);
|
||||||
|
$this->assertPattern('/^<item>.*<\/item><item>.*<\/item><item>.*<\/item>$/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<title>title1<\/title>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<guid>' . str_replace('/', '\/', 'http://www.example.com/guid1') . '<\/guid>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<link>' . str_replace('/', '\/', 'http://www.example.com/link1') . '<\/link>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<description>description1<\/description>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<title>title2<\/title>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<guid>' . str_replace('/', '\/', 'http://www.example.com/guid2') . '<\/guid>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<link>' . str_replace('/', '\/', 'http://www.example.com/link2') . '<\/link>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<description>description2<\/description>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<title>title3<\/title>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<guid>' . str_replace('/', '\/', 'http://www.example.com/guid3') . '<\/guid>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<link>' . str_replace('/', '\/', 'http://www.example.com/link3') . '<\/link>.*<\/item>/', $result);
|
||||||
|
$this->assertPattern('/<item>.*<description>description3<\/description>.*<\/item>/', $result);
|
||||||
|
|
||||||
|
$result = $this->Rss->items(array());
|
||||||
|
$this->assertEqual($result, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItem() {
|
function testItem() {
|
||||||
|
|
Loading…
Reference in a new issue