aboutsummaryrefslogtreecommitdiff
path: root/tests/www
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-06-27 20:04:03 +0200
committerChristian Weiske <cweiske@cweiske.de>2011-06-27 20:04:03 +0200
commit57a5f6864d0241ab513b53a02c7e4ab9ebdeda0d (patch)
treeed01fa1e10640ee5d16987dfabf351073b3cf97d /tests/www
parent588d63a2c740335bb4ff7fbe7454fbe3876ea9c1 (diff)
downloadsemanticscuttle-57a5f6864d0241ab513b53a02c7e4ab9ebdeda0d.tar.gz
semanticscuttle-57a5f6864d0241ab513b53a02c7e4ab9ebdeda0d.tar.bz2
add own assertion to make it easier to switch to atom
Diffstat (limited to 'tests/www')
-rw-r--r--tests/www/rssTest.php33
1 files changed, 23 insertions, 10 deletions
diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php
index 63c2b3d..477e98c 100644
--- a/tests/www/rssTest.php
+++ b/tests/www/rssTest.php
@@ -6,6 +6,23 @@ class www_rssTest extends TestBaseApi
{
protected $urlPart = 'rss.php';
+
+ /**
+ * Verifies that the given number of feed items exist in the feed
+ * XML tree.
+ *
+ * @var SimpleXMLElement $simpleXml RSS feed root element
+ * @var integer $nCount Number of expected feed items
+ * @var string $msg Error message
+ */
+ protected function assertItemCount(
+ SimpleXMLElement $simpleXml, $nCount, $msg = null
+ ) {
+ $this->assertEquals($nCount, count($simpleXml->channel->item), $msg);
+ }
+
+
+
/**
* A private bookmark should not show up in an rss feed if the
* user is not logged in nor passes the private key
@@ -21,9 +38,7 @@ class www_rssTest extends TestBaseApi
$response_body = $req->send()->getBody();
$rss = simplexml_load_string($response_body);
- $items = $rss->channel->item;
-
- $this->assertEquals(0, count($items), 'I see a private bookmark');
+ $this->assertItemCount($rss, 0, 'I see a private bookmark');
}
@@ -46,10 +61,10 @@ class www_rssTest extends TestBaseApi
$response_body = $req->send()->getBody();
$rss = simplexml_load_string($response_body);
- $items = $rss->channel->item;
-
- $this->assertEquals(1, count($items), 'I miss the private bookmark');
- $this->assertEquals('private bookmark', (string)$items[0]->title);
+ $this->assertItemCount($rss, 1, 'I miss the private bookmark');
+ $this->assertEquals(
+ 'private bookmark', (string)$rss->channel->item[0]->title
+ );
}
@@ -83,9 +98,7 @@ class www_rssTest extends TestBaseApi
$req->setCookieJar($cookies);
$response_body = $req->send()->getBody();
$rss = simplexml_load_string($response_body);
- $items = $rss->channel->item;
-
- $this->assertEquals(0, count($items), 'I still see the private bookmark');
+ $this->assertItemCount($rss, 0, 'I still see the private bookmark');
}
}//end class www_rssTest