Skip to content
Snippets Groups Projects
Commit c1967607 authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT
Browse files

hotline#183443 : RSS : Fixing Atom Feed import

parent d44f961e
Branches
Tags
1 merge request!4799hotline#183443 : RSS : Fixing Atom Feed import
Pipeline #24722 passed with stage
in 28 minutes and 31 seconds
- correctif #183443 : RSS : Intégration des flux au format Atom et support de la balise content
\ No newline at end of file
......@@ -30,7 +30,7 @@ class Class_RssItem {
protected string $_first_image_url;
protected string $_date;
public function __construct(Zend_Feed_Entry_Rss $item) {
public function __construct(Zend_Feed_Entry_Abstract $item) {
$this->_link = $item->link();
$this->_title = $item->title();
$this->_pub_date = trim($item->pubDate());
......@@ -62,7 +62,7 @@ class Class_RssItem {
}
protected function _extractDate(Zend_Feed_Entry_Rss $item) : string {
protected function _extractDate(Zend_Feed_Entry_Abstract $item) : string {
$date = '';
if ($item_date = trim($item->pubDate())) {
$locale = Zend_Registry::get('locale');
......@@ -90,8 +90,10 @@ class Class_RssItem {
}
protected function _getRawDescription(Zend_Feed_Entry_Rss $item) : string{
$description = $item->description();
protected function _getRawDescription(Zend_Feed_Entry_Abstract $item) : string{
$description = $item->description() ?? $item->content();
if (!$description)
return '';
if (is_array($description)) {
$description = reset($description);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,8 +19,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class RssItemDescriptionTest extends PHPUnit_Framework_TestCase {
/** @var Class_RssItem */
protected $_item;
protected Class_RssItem $_item;
......@@ -48,3 +47,30 @@ class RssItemDescriptionTest extends PHPUnit_Framework_TestCase {
$this->assertNotContains('<a class=', $this->_item->getDescription());
}
}
class RssItemFromAtomFeedTest extends PHPUnit_Framework_TestCase {
protected Class_RssItem $_item;
protected function setUp() {
parent::setUp();
$feed = Zend_Feed::importString(file_get_contents(ROOT_PATH . 'tests/fixtures/php.atom'));
$this->_item = $item = new Class_RssItem($feed->current());
}
/** @test */
public function itemShouldReturnFirstDescription() {
$this->assertContains('wallabag est une application', $this->_item->getDescription());
}
/** @test */
public function descriptionShouldBeStripTagged() {
$this->assertNotContains('<a class=', $this->_item->getDescription());
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment