From 30cede9ea4ec2cf891037d5e748394dab08b7717 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 5 Jul 2019 14:58:05 -0400 Subject: [PATCH] Make OPML parser protected --- lib/ImportExport/AbstractImportExport.php | 2 +- lib/ImportExport/OPML.php | 2 +- tests/cases/ImportExport/TestOPML.php | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ImportExport/AbstractImportExport.php b/lib/ImportExport/AbstractImportExport.php index 54452301..3a234438 100644 --- a/lib/ImportExport/AbstractImportExport.php +++ b/lib/ImportExport/AbstractImportExport.php @@ -141,7 +141,7 @@ abstract class AbstractImportExport { return true; } - abstract public function parse(string $data, bool $flat): array; + abstract protected function parse(string $data, bool $flat): array; abstract public function export(string $user, bool $flat = false): string; diff --git a/lib/ImportExport/OPML.php b/lib/ImportExport/OPML.php index 92252696..aa311f8a 100644 --- a/lib/ImportExport/OPML.php +++ b/lib/ImportExport/OPML.php @@ -10,7 +10,7 @@ use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\User\Exception as UserException; class OPML extends AbstractImportExport { - public function parse(string $opml, bool $flat): array { + protected function parse(string $opml, bool $flat): array { $d = new \DOMDocument; if (!@$d->loadXML($opml)) { // not a valid XML document diff --git a/tests/cases/ImportExport/TestOPML.php b/tests/cases/ImportExport/TestOPML.php index 0002f2c8..e4ef7b42 100644 --- a/tests/cases/ImportExport/TestOPML.php +++ b/tests/cases/ImportExport/TestOPML.php @@ -109,7 +109,8 @@ OPML_EXPORT_SERIALIZATION; /** @dataProvider provideParserData */ public function testParseOpmlForImport(string $file, bool $flat, $exp) { $data = file_get_contents(\JKingWeb\Arsse\DOCROOT."Import/OPML/$file"); - $parser = new OPML; + // set up a partial mock to make the ImportExport::parse() method visible + $parser = \Phake::makeVisible(\Phake::partialMock(OPML::class)); if ($exp instanceof \JKingWeb\Arsse\AbstractException) { $this->assertException($exp); $parser->parse($data, $flat);