Permalink
Browse files

Added unit tests (phpunit) for FeedService.

  • Loading branch information...
cbenard committed Aug 1, 2015
1 parent 7016de2 commit b767b3b9ccab69752c06ec904f02d6f679011c29
View
@@ -1,5 +1,5 @@
application: comicfeeds-1022
version: 6
version: 7
runtime: php55
api_version: 1
threadsafe: no
View
@@ -45,7 +45,15 @@ public function fetchPageContents($url) {
}
public function getLinkFromEntry(SimpleXMLElement $entry) {
$url = $entry->link['href'];
if (!isset($entry->link)) {
throw new Exception("Link element was not present");
}
$url = $entry->link['href'] ? $entry->link['href'] : (string)$entry->link;
if (!$url) {
throw new Exception("Unable to detect link URL.");
}
return $url;
}
@@ -73,14 +73,7 @@ protected function fetch() {
}
private function getEntryContents(SimpleXMLElement $entry) {
if (!isset($entry->link)) {
throw new Exception("Link element was not present");
}
$url = $entry->link['href'] ? $entry->link['href'] : (string)$entry->link;
if (!$url) {
throw new Exception("Unable to detect link URL.");
}
$url = $this->feedService->getLinkFromEntry($entry);
$this->log->log("\tFetching URL: $url");
$contents = $this->feedService->fetchPageContents($url);
View
@@ -1,5 +1,8 @@
<?php
spl_autoload_register(function ($class) {
include __DIR__ . '/../classes/' . $class . '.php';
$filename = __DIR__ . '/../classes/' . $class . '.php';
if (file_exists($filename)) {
include(__DIR__ . '/../classes/' . $class . '.php');
}
});
View
@@ -1,5 +1,6 @@
{
"require": {
"pimple/pimple": "~3.0"
"pimple/pimple": "~3.0",
"phpunit/phpunit": "4.7.*"
}
}
Oops, something went wrong.

0 comments on commit b767b3b

Please sign in to comment.