summaryrefslogtreecommitdiffstats
path: root/tests/OpmlTest.php
diff options
context:
space:
mode:
authorRomain d'Alverny <rdalverny@gmail.com>2022-01-16 17:01:53 +0100
committerRomain d'Alverny <rdalverny@gmail.com>2022-01-16 17:01:53 +0100
commit58ce95a255c04e1b6ecac0d794bc4dbeb23871de (patch)
tree4205d2da15a4e92dfb8ad59a112ef3d2e1c2c143 /tests/OpmlTest.php
parent9d3f003ba2ab29ef6a790535cc586ca20d555d15 (diff)
downloadplanet-58ce95a255c04e1b6ecac0d794bc4dbeb23871de.tar
planet-58ce95a255c04e1b6ecac0d794bc4dbeb23871de.tar.gz
planet-58ce95a255c04e1b6ecac0d794bc4dbeb23871de.tar.bz2
planet-58ce95a255c04e1b6ecac0d794bc4dbeb23871de.tar.xz
planet-58ce95a255c04e1b6ecac0d794bc4dbeb23871de.zip
Add test coverage, add tests, refactor OPML code
Diffstat (limited to 'tests/OpmlTest.php')
-rw-r--r--tests/OpmlTest.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/OpmlTest.php b/tests/OpmlTest.php
new file mode 100644
index 0000000..571fdaf
--- /dev/null
+++ b/tests/OpmlTest.php
@@ -0,0 +1,53 @@
+<?php
+
+use PHPUnit\Framework\TestCase;
+
+class OpmlManagerTest extends TestCase
+{
+ public function setUp() : void
+ {
+ $this->fixtures = [
+ [file_get_contents('./tests/opml/test-empty.opml'), [], '', '', '', ''],
+ [
+ file_get_contents('./tests/opml/test-valid.opml'),
+ [
+ [
+ 'website' => 'https://blog.example.com/',
+ 'name' => 'text 1',
+ 'feed' => 'https://some.other.example.com/feed/path',
+ 'isDown' => '',
+ ],
+ [
+ 'website' => 'https://blog2.example.com',
+ 'name' => 'text 2',
+ 'feed' => 'https://blog2.example.com/rss.xml',
+ 'isDown' => '',
+ ]
+ ],
+ 'Test OPML',
+ 'user name',
+ 'user@example.com',
+ 'http://user.example.com/'
+ ]
+ ];
+ }
+
+ public function testParse()
+ {
+ foreach ($this->fixtures as $data) {
+ $given = $data[0];
+ $entries = $data[1];
+
+ $opml = new Opml();
+ $entries = $opml->parse($given);
+
+ $this->assertEquals($data[1], $entries);
+ $this->assertEquals($data[1], $opml->entries);
+ $this->assertEquals($data[1], $opml->getPeople());
+ $this->assertEquals($data[2], $opml->getTitle());
+ $this->assertEquals($data[3], $opml->ownerName);
+ $this->assertEquals($data[4], $opml->ownerEmail);
+ $this->assertEquals($data[5], $opml->ownerId);
+ }
+ }
+}