From c5daf112bed9d958f70073fd1cb199beff322334 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Wed, 28 Oct 2020 23:06:49 +0100 Subject: Command: Add unittests Signed-off-by: Sean Molenaar --- AUTHORS.md | 3 +- CHANGELOG.md | 1 + composer.lock | 276 ++++++++++++++++++++++------ lib/Command/Config/FeedAdd.php | 16 +- lib/Command/Config/FeedDelete.php | 8 +- lib/Command/Config/FeedList.php | 4 +- lib/Command/Config/FolderAdd.php | 6 +- lib/Command/Config/FolderDelete.php | 8 +- lib/Command/Config/FolderList.php | 4 +- lib/Command/Config/OpmlExport.php | 4 +- lib/Command/ShowFeed.php | 21 +-- lib/Command/Updater/AfterUpdate.php | 2 +- lib/Command/Updater/AllFeeds.php | 6 + lib/Command/Updater/UpdateFeed.php | 7 +- lib/Service/FolderServiceV2.php | 5 +- tests/Unit/Command/AfterUpdateTest.php | 80 ++++++++ tests/Unit/Command/BeforeUpdateTest.php | 67 +++++++ tests/Unit/Command/ExploreGeneratorTest.php | 3 +- tests/Unit/Command/FeedAddTest.php | 93 ++++++++++ tests/Unit/Command/FeedDeleteTest.php | 77 ++++++++ tests/Unit/Command/FeedListTest.php | 123 +++++++++++++ tests/Unit/Command/FolderAddTest.php | 83 +++++++++ tests/Unit/Command/FolderDeleteTest.php | 101 ++++++++++ tests/Unit/Command/FolderListTest.php | 120 ++++++++++++ tests/Unit/Command/OpmlExportTest.php | 78 ++++++++ tests/Unit/Command/ShowFeedTest.php | 122 ++++++++++++ tests/Unit/Command/UpdateFeedTest.php | 110 +++++++++++ tests/Unit/Utility/TimeTest.php | 50 +++++ 28 files changed, 1370 insertions(+), 108 deletions(-) create mode 100644 tests/Unit/Command/AfterUpdateTest.php create mode 100644 tests/Unit/Command/BeforeUpdateTest.php create mode 100644 tests/Unit/Command/FeedAddTest.php create mode 100644 tests/Unit/Command/FeedDeleteTest.php create mode 100644 tests/Unit/Command/FeedListTest.php create mode 100644 tests/Unit/Command/FolderAddTest.php create mode 100644 tests/Unit/Command/FolderDeleteTest.php create mode 100644 tests/Unit/Command/FolderListTest.php create mode 100644 tests/Unit/Command/OpmlExportTest.php create mode 100644 tests/Unit/Command/ShowFeedTest.php create mode 100644 tests/Unit/Command/UpdateFeedTest.php create mode 100644 tests/Unit/Utility/TimeTest.php diff --git a/AUTHORS.md b/AUTHORS.md index fab6e9c07..65abd3e7d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,8 +1,8 @@ # Authors * [Bernhard Posselt](mailto:dev@bernhard-posselt.com) * [Alessandro Cosentino](mailto:cosenal@gmail.com) -* [Robin Appelman](mailto:icewind@owncloud.com) * [Benjamin Brahmer](mailto:info@b-brahmer.de) +* [Robin Appelman](mailto:icewind@owncloud.com) * [Gregor Tätzner](mailto:gregor@freenet.de) * [Morris Jobke](mailto:hey@morrisjobke.de) * [Sean Molenaar](mailto:SMillerDev@users.noreply.github.com) @@ -43,6 +43,7 @@ * [Andreas Fischer](mailto:bantu@owncloud.com) * [David Guillot](mailto:david@guillot.me) * [Gioele Falcetti](mailto:thegio.f@gmail.com) +* [Igor Bubelov](mailto:igor@bubelov.com) * [Jan C. Borchardt](mailto:hey@jancborchardt.net) * [John Kristensen](mailto:john@jerrykan.com) * [Konrad Graefe](mailto:konradgraefe@aol.com) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a09e372..3e1fb26f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## Unreleased - Added changelog enforcer action +- Unittest commands and utilities ## 15.0.6 diff --git a/composer.lock b/composer.lock index 6107be8af..78f9e22de 100644 --- a/composer.lock +++ b/composer.lock @@ -57,6 +57,10 @@ "html", "readability" ], + "support": { + "issues": "https://github.com/andreskrey/readability.php/issues", + "source": "https://github.com/andreskrey/readability.php/tree/v2.1.0" + }, "time": "2019-07-22T21:42:25+00:00" }, { @@ -110,6 +114,11 @@ "finder", "icon" ], + "support": { + "issues": "https://github.com/ArthurHoaro/favicon/issues", + "source": "https://github.com/ArthurHoaro/favicon/tree/v1.3.1", + "sources": "https://github.com/ArthurHoaro/favicon" + }, "time": "2020-10-14T09:32:44+00:00" }, { @@ -173,6 +182,10 @@ "news", "rss" ], + "support": { + "issues": "https://github.com/alexdebril/feed-io/issues", + "source": "https://github.com/alexdebril/feed-io/tree/v4.7.10" + }, "funding": [ { "url": "https://github.com/alexdebril", @@ -229,6 +242,10 @@ "keywords": [ "html" ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/master" + }, "time": "2020-06-29T00:56:53+00:00" }, { @@ -293,6 +310,10 @@ "uri", "url" ], + "support": { + "issues": "https://pear.php.net/bugs/search.php?cmd=display&package_name[]=Net_URL2", + "source": "https://github.com/pear/Net_URL2" + }, "time": "2017-08-25T06:16:11+00:00" }, { @@ -340,6 +361,9 @@ "psr", "psr-3" ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, "time": "2020-03-23T09:12:05+00:00" }, { @@ -390,20 +414,24 @@ "path", "system" ], + "support": { + "issues": "https://github.com/Riimu/Kit-PathJoin/issues", + "source": "https://github.com/Riimu/Kit-PathJoin/tree/master" + }, "time": "2017-07-09T14:41:04+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.5.6", + "version": "3.5.8", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "e97627871a7eab2f70e59166072a6b767d5834e0" + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0", - "reference": "e97627871a7eab2f70e59166072a6b767d5834e0", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", "shasum": "" }, "require": { @@ -441,7 +469,12 @@ "phpcs", "standards" ], - "time": "2020-08-10T04:50:15+00:00" + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2020-10-23T02:01:07+00:00" } ], "packages-dev": [ @@ -499,6 +532,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.3.x" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -561,6 +598,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.x" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -622,6 +663,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/master" + }, "time": "2018-07-08T19:23:20+00:00" }, { @@ -669,6 +714,10 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/master" + }, "time": "2018-07-08T19:19:57+00:00" }, { @@ -718,6 +767,10 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { @@ -770,6 +823,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, "time": "2020-09-03T19:13:55+00:00" }, { @@ -815,6 +872,10 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, "time": "2020-09-17T18:55:26+00:00" }, { @@ -878,6 +939,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.12.1" + }, "time": "2020-09-29T09:10:42+00:00" }, { @@ -920,6 +985,10 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.52" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -998,6 +1067,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/8.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1054,6 +1127,10 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1113,6 +1190,10 @@ "keywords": [ "process" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1123,16 +1204,16 @@ }, { "name": "phpunit/php-text-template", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "18c887016e60e52477e54534956d7b47bc52cd84" + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/18c887016e60e52477e54534956d7b47bc52cd84", - "reference": "18c887016e60e52477e54534956d7b47bc52cd84", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { @@ -1168,26 +1249,30 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T06:03:05+00:00" + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "c9ff14f493699e2f6adee9fd06a0245b276643b7" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/c9ff14f493699e2f6adee9fd06a0245b276643b7", - "reference": "c9ff14f493699e2f6adee9fd06a0245b276643b7", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { @@ -1223,13 +1308,17 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T06:00:25+00:00" + "time": "2020-10-26T13:16:10+00:00" }, { "name": "phpunit/php-token-stream", @@ -1278,6 +1367,10 @@ "keywords": [ "tokenizer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-token-stream/issues", + "source": "https://github.com/sebastianbergmann/php-token-stream/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1373,6 +1466,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.2.6" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -1387,16 +1484,16 @@ }, { "name": "sebastian/code-unit", - "version": "1.0.7", + "version": "1.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab" + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/59236be62b1bb9919e6d7f60b0b832dc05cef9ab", - "reference": "59236be62b1bb9919e6d7f60b0b832dc05cef9ab", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", "shasum": "" }, "require": { @@ -1429,13 +1526,17 @@ ], "description": "Collection of value objects that represent the PHP code units", "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-10-02T14:47:54+00:00" + "time": "2020-10-26T13:08:54+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1480,6 +1581,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1490,16 +1595,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.5", + "version": "4.0.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "7a8ff306445707539c1a6397372a982a1ec55120" + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/7a8ff306445707539c1a6397372a982a1ec55120", - "reference": "7a8ff306445707539c1a6397372a982a1ec55120", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", "shasum": "" }, "require": { @@ -1550,26 +1655,30 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-30T06:47:25+00:00" + "time": "2020-10-26T15:49:45+00:00" }, { "name": "sebastian/diff", - "version": "4.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "ffc949a1a2aae270ea064453d7535b82e4c32092" + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ffc949a1a2aae270ea064453d7535b82e4c32092", - "reference": "ffc949a1a2aae270ea064453d7535b82e4c32092", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", "shasum": "" }, "require": { @@ -1612,13 +1721,17 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T05:32:55+00:00" + "time": "2020-10-26T13:10:38+00:00" }, { "name": "sebastian/environment", @@ -1671,6 +1784,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1744,6 +1861,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1804,20 +1925,24 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/master" + }, "time": "2020-02-07T06:11:37+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "f6f5957013d84725427d361507e13513702888a4" + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f6f5957013d84725427d361507e13513702888a4", - "reference": "f6f5957013d84725427d361507e13513702888a4", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { @@ -1851,26 +1976,30 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T05:55:06+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5" + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5", - "reference": "d9d0ab3b12acb1768bc1e0a89b23c90d2043cbe5", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { @@ -1902,26 +2031,30 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T05:56:16+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.3", + "version": "4.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "ed8c9cd355089134bc9cba421b5cfdd58f0eaef7" + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/ed8c9cd355089134bc9cba421b5cfdd58f0eaef7", - "reference": "ed8c9cd355089134bc9cba421b5cfdd58f0eaef7", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { @@ -1961,13 +2094,17 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-09-28T05:17:32+00:00" + "time": "2020-10-26T13:17:30+00:00" }, { "name": "sebastian/resource-operations", @@ -2012,6 +2149,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2022,16 +2163,16 @@ }, { "name": "sebastian/type", - "version": "2.3.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fa592377f3923946cb90bf1f6a71ba2e5f229909" + "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fa592377f3923946cb90bf1f6a71ba2e5f229909", - "reference": "fa592377f3923946cb90bf1f6a71ba2e5f229909", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/81cd61ab7bbf2de744aba0ea61fae32f721df3d2", + "reference": "81cd61ab7bbf2de744aba0ea61fae32f721df3d2", "shasum": "" }, "require": { @@ -2064,13 +2205,17 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-10-06T08:41:03+00:00" + "time": "2020-10-26T13:18:59+00:00" }, { "name": "sebastian/version", @@ -2113,6 +2258,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -2123,20 +2272,20 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.18.1", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" + "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", - "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -2144,7 +2293,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-main": "1.20-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2181,6 +2330,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -2195,7 +2347,7 @@ "type": "tidelift" } ], - "time": "2020-07-14T12:35:20+00:00" + "time": "2020-10-23T14:02:19+00:00" }, { "name": "theseer/tokenizer", @@ -2235,6 +2387,10 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, "funding": [ { "url": "https://github.com/theseer", @@ -2290,6 +2446,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, "time": "2020-07-08T17:02:28+00:00" } ], @@ -2307,5 +2467,5 @@ "ext-curl": "*" }, "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/lib/Command/Config/FeedAdd.php b/lib/Command/Config/FeedAdd.php index 35bac6480..3c4820437 100644 --- a/lib/Command/Config/FeedAdd.php +++ b/lib/Command/Config/FeedAdd.php @@ -35,7 +35,7 @@ class FeedAdd extends Command { $this->setName('news:feed:add') ->setDescription('Add a feed') - ->addArgument('userID', InputArgument::REQUIRED, 'User to add the feed for') + ->addArgument('user-id', InputArgument::REQUIRED, 'User to add the feed for') ->addArgument('feed', InputArgument::REQUIRED, 'Feed to parse') ->addOption('folder', null, InputOption::VALUE_OPTIONAL, 'Folder ID') ->addOption('title', null, InputOption::VALUE_OPTIONAL, 'Feed title') @@ -54,13 +54,13 @@ class FeedAdd extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $url = $input->getArgument('feed'); - $user = $input->getArgument('userID'); - $folder = (int) $input->getOption('folder') ?? 0; - $title = $input->getOption('title'); - $username = $input->getOption('username'); - $full_text = $input->getOption('full-text'); - $password = $input->getOption('password'); + $user = $input->getArgument('user-id'); + $url = $input->getArgument('feed'); + $folder = (int) $input->getOption('folder') ?? 0; + $title = $input->getOption('title'); + $full_text = (bool) $input->getOption('full-text'); + $username = $input->getOption('username'); + $password = $input->getOption('password'); $feed = $this->feedService->create($user, $url, $folder, $full_text, $title, $username, $password); $this->feedService->fetch($feed); diff --git a/lib/Command/Config/FeedDelete.php b/lib/Command/Config/FeedDelete.php index c848b1fd4..fae1abdb2 100644 --- a/lib/Command/Config/FeedDelete.php +++ b/lib/Command/Config/FeedDelete.php @@ -32,8 +32,8 @@ class FeedDelete extends Command { $this->setName('news:feed:delete') ->setDescription('Remove a feed') - ->addArgument('userID', InputArgument::REQUIRED, 'User to remove the feed from') - ->addArgument('id', InputArgument::REQUIRED, 'Feed ID', null); + ->addArgument('user-id', InputArgument::REQUIRED, 'User to remove the feed from') + ->addArgument('feed-id', InputArgument::REQUIRED, 'Feed ID', null); } /** @@ -46,8 +46,8 @@ class FeedDelete extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $user = $input->getArgument('userID'); - $id = $input->getArgument('id'); + $user = $input->getArgument('user-id'); + $id = $input->getArgument('feed-id'); $this->feedService->delete($user, $id); diff --git a/lib/Command/Config/FeedList.php b/lib/Command/Config/FeedList.php index 0c547868c..3462ff5c8 100644 --- a/lib/Command/Config/FeedList.php +++ b/lib/Command/Config/FeedList.php @@ -33,7 +33,7 @@ class FeedList extends Command { $this->setName('news:feed:list') ->setDescription('List all feeds') - ->addArgument('userID', InputArgument::REQUIRED, 'User to list the feeds for') + ->addArgument('user-id', InputArgument::REQUIRED, 'User to list the feeds for') ->addOption('recursive', null, InputOption::VALUE_NONE, 'Fetch the feed recursively'); } @@ -47,7 +47,7 @@ class FeedList extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $user = $input->getArgument('userID'); + $user = $input->getArgument('user-id'); $recursive = $input->getOption('recursive'); if ($recursive !== false) { diff --git a/lib/Command/Config/FolderAdd.php b/lib/Command/Config/FolderAdd.php index 5a7155e0c..257cf2dd6 100644 --- a/lib/Command/Config/FolderAdd.php +++ b/lib/Command/Config/FolderAdd.php @@ -32,7 +32,7 @@ class FolderAdd extends Command { $this->setName('news:folder:add') ->setDescription('Add a folder') - ->addArgument('userID', InputArgument::REQUIRED, 'User to add the folder for') + ->addArgument('user-id', InputArgument::REQUIRED, 'User to add the folder for') ->addArgument('name', InputArgument::REQUIRED, 'Folder name', null) ->addOption('parent', null, InputOption::VALUE_OPTIONAL, 'Parent folder'); } @@ -47,9 +47,9 @@ class FolderAdd extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $user = $input->getArgument('userID'); + $user = $input->getArgument('user-id'); $name = $input->getArgument('name'); - $parent = $input->getOption('parent') ?? 0; + $parent = (int) $input->getOption('parent') ?? 0; $this->folderService->create($user, $name, $parent); diff --git a/lib/Command/Config/FolderDelete.php b/lib/Command/Config/FolderDelete.php index c441bd615..bf7608b02 100644 --- a/lib/Command/Config/FolderDelete.php +++ b/lib/Command/Config/FolderDelete.php @@ -33,8 +33,8 @@ class FolderDelete extends Command { $this->setName('news:folder:delete') ->setDescription('Remove a folder') - ->addArgument('userID', InputArgument::REQUIRED, 'User to remove the folder from') - ->addArgument('id', InputArgument::REQUIRED, 'Folder ID', null); + ->addArgument('user-id', InputArgument::REQUIRED, 'User to remove the folder from') + ->addArgument('folder-id', InputArgument::REQUIRED, 'Folder ID', null); } /** @@ -47,8 +47,8 @@ class FolderDelete extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $user = $input->getArgument('userID'); - $id = $input->getArgument('id'); + $user = $input->getArgument('user-id'); + $id = $input->getArgument('folder-id'); if ($id === '0') { throw new ServiceException('Can not remove root folder!'); diff --git a/lib/Command/Config/FolderList.php b/lib/Command/Config/FolderList.php index 26c61f5cf..6340f4d57 100644 --- a/lib/Command/Config/FolderList.php +++ b/lib/Command/Config/FolderList.php @@ -34,7 +34,7 @@ class FolderList extends Command { $this->setName('news:folder:list') ->setDescription('List all folders') - ->addArgument('userID', InputArgument::REQUIRED, 'User to list the folders for') + ->addArgument('user-id', InputArgument::REQUIRED, 'User to list the folders for') ->addOption('recursive', null, InputOption::VALUE_NONE, 'Fetch the folder recursively'); } @@ -48,7 +48,7 @@ class FolderList extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $user = $input->getArgument('userID'); + $user = $input->getArgument('user-id'); $recursive = $input->getOption('recursive'); if ($recursive !== false) { diff --git a/lib/Command/Config/OpmlExport.php b/lib/Command/Config/OpmlExport.php index 1642e8505..f51aed555 100644 --- a/lib/Command/Config/OpmlExport.php +++ b/lib/Command/Config/OpmlExport.php @@ -29,7 +29,7 @@ class OpmlExport extends Command { $this->setName('news:opml:export') ->setDescription('Print OPML file') - ->addArgument('userID', InputArgument::REQUIRED, 'User data to export'); + ->addArgument('user-id', InputArgument::REQUIRED, 'User data to export'); } /** @@ -42,7 +42,7 @@ class OpmlExport extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { - $user = $input->getArgument('userID'); + $user = $input->getArgument('user-id'); $output->write($this->opmlService->export($user)); return 0; diff --git a/lib/Command/ShowFeed.php b/lib/Command/ShowFeed.php index 8aace3528..0016470e6 100644 --- a/lib/Command/ShowFeed.php +++ b/lib/Command/ShowFeed.php @@ -10,18 +10,7 @@ */ namespace OCA\News\Command; -use FeedIo\FeedIo; -use Favicon\Favicon; - -use HTMLPurifier; -use OCA\News\Db\FeedMapper; -use OCA\News\Db\ItemMapper; use OCA\News\Fetcher\Fetcher; -use OCA\News\Service\FeedService; -use OCA\News\Utility\Time; -use OCP\IConfig; -use OCP\IL10N; -use OCP\ILogger; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; @@ -80,13 +69,15 @@ class ShowFeed extends Command try { list($feed, $items) = $this->feedFetcher->fetch($url, true, null, $fullTextEnabled, $user, $password); - $output->writeln("Feed: " . json_encode($feed, JSON_PRETTY_PRINT)); - $output->writeln("Items: " . json_encode($items, JSON_PRETTY_PRINT)); - return 0; - } catch (\Throwable $ex) { + } catch (\Exception $ex) { $output->writeln('Failed to fetch feed info:'); $output->writeln($ex->getMessage()); return 1; } + + $output->writeln("Feed: " . json_encode($feed, JSON_PRETTY_PRINT)); + $output->writeln("Items: " . json_encode($items, JSON_PRETTY_PRINT)); + + return 0; } } diff --git a/lib/Command/Updater/AfterUpdate.php b/lib/Command/Updater/AfterUpdate.php index 5746ff1e5..62ceb2710 100644 --- a/lib/Command/Updater/AfterUpdate.php +++ b/lib/Command/Updater/AfterUpdate.php @@ -46,7 +46,7 @@ class AfterUpdate extends Command { $count = $input->getArgument('purge_count'); - echo $this->itemService->purgeOverThreshold($count); + $output->writeln($this->itemService->purgeOverThreshold($count)); return 0; } diff --git a/lib/Command/Updater/AllFeeds.php b/lib/Command/Updater/AllFeeds.php index 6993d51ea..0dde6eac4 100644 --- a/lib/Command/Updater/AllFeeds.php +++ b/lib/Command/Updater/AllFeeds.php @@ -16,6 +16,12 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +/** + * Class AllFeeds + * + * @deprecated use news:feed:list instead + * @package OCA\News\Command\Updater + */ class AllFeeds extends Command { /** diff --git a/lib/Command/Updater/UpdateFeed.php b/lib/Command/Updater/UpdateFeed.php index 5078e92a4..71e88a15f 100644 --- a/lib/Command/Updater/UpdateFeed.php +++ b/lib/Command/Updater/UpdateFeed.php @@ -11,16 +11,12 @@ namespace OCA\News\Command\Updater; -use Exception; - use OCA\News\Service\FeedServiceV2; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use OCA\News\Service\FeedService; - class UpdateFeed extends Command { /** @@ -57,12 +53,13 @@ class UpdateFeed extends Command try { $feed = $this->feedService->findForUser($userId, $feedId); $this->feedService->fetch($feed); - } catch (Exception $e) { + } catch (\Exception $e) { $output->writeln( 'Could not update feed with id ' . $feedId . ' and user ' . $userId . ': ' . $e->getMessage() . ' ' ); + return 1; } return 0; diff --git a/lib/Service/FolderServiceV2.php b/lib/Service/FolderServiceV2.php index 5d3f149ce..cf599456b 100644 --- a/lib/Service/FolderServiceV2.php +++ b/lib/Service/FolderServiceV2.php @@ -17,6 +17,7 @@ use OCA\News\Db\Feed; use OCA\News\Db\FeedMapperV2; use OCA\News\Db\Folder; use OCA\News\Db\FolderMapperV2; +use OCP\AppFramework\Db\Entity; use Psr\Log\LoggerInterface; /** @@ -79,14 +80,14 @@ class FolderServiceV2 extends Service return $this->mapper->findAll(); } - public function create(string $userId, string $name, int $parent = 0): void + public function create(string $userId, string $name, int $parent = 0): Entity { $folder = new Folder(); $folder->setUserId($userId) ->setName($name) ->setParentId($parent); - $this->mapper->insert($folder); + return $this->mapper->insert($folder); } public function delete(string $user, int $id) diff --git a/tests/Unit/Command/AfterUpdateTest.php b/tests/Unit/Command/AfterUpdateTest.php new file mode 100644 index 000000000..fbc327ecc --- /dev/null +++ b/tests/Unit/Command/AfterUpdateTest.php @@ -0,0 +1,80 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Updater\AfterUpdate; +use OCA\News\Fetcher\Fetcher; +use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\ItemServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class AfterUpdateTest extends TestCase +{ + /** @var MockObject|ItemServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var AfterUpdate */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(ItemServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class) + ->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class) + ->getMock(); + + $this->command = new AfterUpdate($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->once()) + ->method('getArgument') + ->with('purge_count') + ->willReturn('1'); + + $this->service->expects($this->exactly(1)) + ->method('purgeOverThreshold') + ->with('1') + ->willReturn('test'); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with('test'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/BeforeUpdateTest.php b/tests/Unit/Command/BeforeUpdateTest.php new file mode 100644 index 000000000..282bdacde --- /dev/null +++ b/tests/Unit/Command/BeforeUpdateTest.php @@ -0,0 +1,67 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Updater\BeforeUpdate; +use OCA\News\Service\UpdaterService; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class BeforeUpdateTest extends TestCase +{ + /** @var MockObject|UpdaterService */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var BeforeUpdate */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(UpdaterService::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class) + ->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class) + ->getMock(); + + $this->command = new BeforeUpdate($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->service->expects($this->exactly(1)) + ->method('beforeUpdate'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/ExploreGeneratorTest.php b/tests/Unit/Command/ExploreGeneratorTest.php index 4512e206c..ec04c4241 100644 --- a/tests/Unit/Command/ExploreGeneratorTest.php +++ b/tests/Unit/Command/ExploreGeneratorTest.php @@ -30,7 +30,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; -class ExploreGeneratorTest extends TestCase { +class ExploreGeneratorTest extends TestCase +{ /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $favicon; /** @var \PHPUnit_Framework_MockObject_MockObject */ diff --git a/tests/Unit/Command/FeedAddTest.php b/tests/Unit/Command/FeedAddTest.php new file mode 100644 index 000000000..c0d4de1bd --- /dev/null +++ b/tests/Unit/Command/FeedAddTest.php @@ -0,0 +1,93 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FeedAdd; +use OCA\News\Command\Updater\UpdateFeed; +use OCA\News\Db\Feed; +use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\FeedServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FeedAddTest extends TestCase +{ + /** @var MockObject|FeedServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var UpdateFeed */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FeedServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FeedAdd($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['feed', 'http://feed'], + ['user-id', 'admin'], + ])); + + $this->consoleInput->expects($this->exactly(5)) + ->method('getOption') + ->will($this->returnValueMap([ + ['folder', '0'], + ['title', 'title'], + ['username', 'user'], + ['password', 'pass'], + ['full-text', '1'], + ])); + + $feed = $this->createMock(Feed::class); + + $this->service->expects($this->exactly(1)) + ->method('create') + ->with('admin', 'http://feed', 0, true, 'title', 'user', 'pass') + ->willReturn($feed); + + $this->service->expects($this->exactly(1)) + ->method('fetch') + ->with($feed); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/FeedDeleteTest.php b/tests/Unit/Command/FeedDeleteTest.php new file mode 100644 index 000000000..09b8fb721 --- /dev/null +++ b/tests/Unit/Command/FeedDeleteTest.php @@ -0,0 +1,77 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FeedAdd; +use OCA\News\Command\Config\FeedDelete; +use OCA\News\Command\Updater\UpdateFeed; +use OCA\News\Db\Feed; +use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\FeedServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FeedDeleteTest extends TestCase +{ + /** @var MockObject|FeedServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var UpdateFeed */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FeedServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FeedDelete($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['feed-id', '1'], + ['user-id', 'admin'], + ])); + + $this->service->expects($this->exactly(1)) + ->method('delete') + ->with('admin', '1'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/FeedListTest.php b/tests/Unit/Command/FeedListTest.php new file mode 100644 index 000000000..52b63e6ec --- /dev/null +++ b/tests/Unit/Command/FeedListTest.php @@ -0,0 +1,123 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FeedAdd; +use OCA\News\Command\Config\FeedList; +use OCA\News\Command\Updater\UpdateFeed; +use OCA\News\Db\Feed; +use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\FeedServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FeedListTest extends TestCase +{ + /** @var MockObject|FeedServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var UpdateFeed */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FeedServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FeedList($this->service); + } + + /** + * Test a valid call will work + */ + public function testValidRecurse() + { + $this->consoleInput->expects($this->exactly(1)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['user-id', 'admin'], + ])); + + $this->consoleInput->expects($this->exactly(1)) + ->method('getOption') + ->will($this->returnValueMap([ + ['recursive', true], + ])); + + $feed = $this->createMock(Feed::class); + + $this->service->expects($this->exactly(1)) + ->method('findAllForUserRecursive') + ->with('admin') + ->willReturn([$feed]); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with("[\n []\n]"); + + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->exactly(1)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['user-id', 'admin'], + ])); + + $this->consoleInput->expects($this->exactly(1)) + ->method('getOption') + ->will($this->returnValueMap([ + ['recursive', false], + ])); + + $feed = $this->createMock(Feed::class); + + $this->service->expects($this->exactly(1)) + ->method('findAllForUser') + ->with('admin') + ->willReturn([$feed]); + + $this->consoleOutput->expects($this->exactly(1)) + ->method('writeln') + ->with("[\n []\n]"); + + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/FolderAddTest.php b/tests/Unit/Command/FolderAddTest.php new file mode 100644 index 000000000..5991920bb --- /dev/null +++ b/tests/Unit/Command/FolderAddTest.php @@ -0,0 +1,83 @@ + + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation.