@@ -12,31 +12,31 @@ |
||
| 12 | 12 | |
| 13 | 13 | class CRSSFeed { |
| 14 | 14 | |
| 15 | - // constructor - initialize SimplePie. |
|
| 16 | - public function __construct($feedArr, $duration = 3600) { |
|
| 17 | - $this->object = new SimplePie(); |
|
| 18 | - $this->object->set_cache_location(CACHE); |
|
| 19 | - $this->object->set_cache_duration($duration); |
|
| 20 | - $this->object->set_feed_url($feedArr); |
|
| 21 | - $this->object->init(); |
|
| 22 | - } |
|
| 15 | + // constructor - initialize SimplePie. |
|
| 16 | + public function __construct($feedArr, $duration = 3600) { |
|
| 17 | + $this->object = new SimplePie(); |
|
| 18 | + $this->object->set_cache_location(CACHE); |
|
| 19 | + $this->object->set_cache_duration($duration); |
|
| 20 | + $this->object->set_feed_url($feedArr); |
|
| 21 | + $this->object->init(); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - // return content. |
|
| 25 | - public function getFeed() { |
|
| 26 | - $feedItems = $this->object->get_items(); |
|
| 27 | - $html = '<article>'; |
|
| 28 | - $html .= "<h1>Senaste nytt fran IDG</h1>"; |
|
| 29 | - foreach($feedItems as $content) { |
|
| 30 | - $html .= '<div class="feed-content">'; |
|
| 31 | - $html .= "<h2>" . $content->get_title() . "</h2>" ; |
|
| 32 | - $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
|
| 33 | - $html .= "<p>{$content->get_content()}</p>"; |
|
| 34 | - $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
|
| 35 | - $html .= '</div>'; |
|
| 36 | - } |
|
| 37 | - $html .= "</article>"; |
|
| 38 | - return $html; |
|
| 39 | - } |
|
| 24 | + // return content. |
|
| 25 | + public function getFeed() { |
|
| 26 | + $feedItems = $this->object->get_items(); |
|
| 27 | + $html = '<article>'; |
|
| 28 | + $html .= "<h1>Senaste nytt fran IDG</h1>"; |
|
| 29 | + foreach($feedItems as $content) { |
|
| 30 | + $html .= '<div class="feed-content">'; |
|
| 31 | + $html .= "<h2>" . $content->get_title() . "</h2>" ; |
|
| 32 | + $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
|
| 33 | + $html .= "<p>{$content->get_content()}</p>"; |
|
| 34 | + $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
|
| 35 | + $html .= '</div>'; |
|
| 36 | + } |
|
| 37 | + $html .= "</article>"; |
|
| 38 | + return $html; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /*$rss = new SimplePie(); |
@@ -26,12 +26,12 @@ |
||
| 26 | 26 | $feedItems = $this->object->get_items(); |
| 27 | 27 | $html = '<article>'; |
| 28 | 28 | $html .= "<h1>Senaste nytt fran IDG</h1>"; |
| 29 | - foreach($feedItems as $content) { |
|
| 29 | + foreach ($feedItems as $content) { |
|
| 30 | 30 | $html .= '<div class="feed-content">'; |
| 31 | - $html .= "<h2>" . $content->get_title() . "</h2>" ; |
|
| 32 | - $html .= "<small>Postad ". $content->get_date('Y-m-d | H:i:s')."</small>"; |
|
| 31 | + $html .= "<h2>".$content->get_title()."</h2>"; |
|
| 32 | + $html .= "<small>Postad ".$content->get_date('Y-m-d | H:i:s')."</small>"; |
|
| 33 | 33 | $html .= "<p>{$content->get_content()}</p>"; |
| 34 | - $html .= "<p><a href='" . $content->get_permalink() . "'>Läs mer</a>"; |
|
| 34 | + $html .= "<p><a href='".$content->get_permalink()."'>Läs mer</a>"; |
|
| 35 | 35 | $html .= '</div>'; |
| 36 | 36 | } |
| 37 | 37 | $html .= "</article>"; |
@@ -14,38 +14,38 @@ |
||
| 14 | 14 | class CRSSFeedTest extends \PHPUnit_Framework_TestCase { |
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** ------------------------------------------------------- |
|
| 17 | + /** ------------------------------------------------------- |
|
| 18 | 18 | * Test 1a |
| 19 | - * |
|
| 19 | + * |
|
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | |
| 23 | - private $feed; |
|
| 23 | + private $feed; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - public function setUp(){ |
|
| 27 | - $rss = new SimplePie(); |
|
| 28 | - $rss->get_items(1,1); |
|
| 29 | - $this->feed = new CRSSFeed($rss); |
|
| 30 | - } |
|
| 26 | + public function setUp(){ |
|
| 27 | + $rss = new SimplePie(); |
|
| 28 | + $rss->get_items(1,1); |
|
| 29 | + $this->feed = new CRSSFeed($rss); |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - public function testAssertTags(){ |
|
| 34 | - $matcher = array( |
|
| 35 | - 'tag' => 'h1', 'content' => 'regexp:/<h1>.*<\/h1>/', |
|
| 36 | - 'parent' => array('tag' => 'article') |
|
| 37 | - ); |
|
| 33 | + public function testAssertTags(){ |
|
| 34 | + $matcher = array( |
|
| 35 | + 'tag' => 'h1', 'content' => 'regexp:/<h1>.*<\/h1>/', |
|
| 36 | + 'parent' => array('tag' => 'article') |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - $matchFeed = array( |
|
| 40 | - 'tag'=> 'h2', 'content' => 'regexp:/<h2>.*<\/h2>/', |
|
| 41 | - 'tag'=> 'small', 'content' => 'regexp:/<small>.*<\/small>/', |
|
| 42 | - 'tag'=> 'p', 'content' => 'regexp:/<p>.*<\/p>/', |
|
| 43 | - 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'feed-content')) |
|
| 44 | - ); |
|
| 45 | - } |
|
| 39 | + $matchFeed = array( |
|
| 40 | + 'tag'=> 'h2', 'content' => 'regexp:/<h2>.*<\/h2>/', |
|
| 41 | + 'tag'=> 'small', 'content' => 'regexp:/<small>.*<\/small>/', |
|
| 42 | + 'tag'=> 'p', 'content' => 'regexp:/<p>.*<\/p>/', |
|
| 43 | + 'parent' => array('tag' => 'div', 'attributes' => array('class' => 'feed-content')) |
|
| 44 | + ); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - public function testGetFeed(){ |
|
| 49 | - $this->assertInternalType('string', 'regexp:/<article>.*<\/article>/'); |
|
| 50 | - } |
|
| 48 | + public function testGetFeed(){ |
|
| 49 | + $this->assertInternalType('string', 'regexp:/<article>.*<\/article>/'); |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | private $feed; |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - public function setUp(){ |
|
| 26 | + public function setUp() { |
|
| 27 | 27 | $rss = new SimplePie(); |
| 28 | - $rss->get_items(1,1); |
|
| 28 | + $rss->get_items(1, 1); |
|
| 29 | 29 | $this->feed = new CRSSFeed($rss); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - public function testAssertTags(){ |
|
| 33 | + public function testAssertTags() { |
|
| 34 | 34 | $matcher = array( |
| 35 | 35 | 'tag' => 'h1', 'content' => 'regexp:/<h1>.*<\/h1>/', |
| 36 | 36 | 'parent' => array('tag' => 'article') |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
| 48 | - public function testGetFeed(){ |
|
| 48 | + public function testGetFeed() { |
|
| 49 | 49 | $this->assertInternalType('string', 'regexp:/<article>.*<\/article>/'); |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |