1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-05 08:07:33 +02:00

refactor: deprecate FeedItem constructor (#4201)

* fix: bug in prior commit

* refactor: deprecate FeedItem constructor

* test: fix
This commit is contained in:
Dag
2024-08-08 03:43:26 +02:00
committed by GitHub
parent 2a96bf19b5
commit 6afd13eb06
11 changed files with 78 additions and 114 deletions

View File

@@ -4,45 +4,16 @@ declare(strict_types=1);
namespace RssBridge\Tests;
use FeedItem;
use PHPUnit\Framework\TestCase;
class FeedItemTest extends TestCase
{
public function test()
{
$item = new FeedItem();
$item->setTitle('hello');
$this->assertSame('hello', $item->getTitle());
$item = FeedItem::fromArray(['title' => 'hello2']);
$this->assertSame('hello2', $item->getTitle());
$item = new FeedItem();
$item->setAuthor('123');
$this->assertSame('123', $item->getAuthor());
$item = new FeedItem();
$item->title = 'aa';
$this->assertSame('aa', $item->title);
$this->assertSame('aa', $item->getTitle());
}
public function testTimestamp()
{
$item = new FeedItem();
$item->setTimestamp(5);
$this->assertSame(5, $item->getTimestamp());
$item->setTimestamp('5');
$this->assertSame(5, $item->getTimestamp());
$item->setTimestamp('1970-01-01 18:00:00');
$this->assertSame(64800, $item->getTimestamp());
$item->setTimestamp('1st jan last year');
// This will fail at 2025-01-01 hehe
$this->assertSame(1672531200, $item->getTimestamp());
$item = [
'title' => 'kek',
];
$feedItem = \FeedItem::fromArray($item);
$this->assertSame('kek', $feedItem->getTitle());
}
}

View File

@@ -39,7 +39,7 @@ abstract class BaseFormatTest extends TestCase
$items = [];
foreach ($data['items'] as $item) {
$items[] = \FeedItem::fromArray($item);
$items[] = ($item);
}
return (object)[