diff options
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Command/AfterUpdateTest.php | 80 | ||||
-rw-r--r-- | tests/Unit/Command/BeforeUpdateTest.php | 67 | ||||
-rw-r--r-- | tests/Unit/Command/ExploreGeneratorTest.php | 3 | ||||
-rw-r--r-- | tests/Unit/Command/FeedAddTest.php | 93 | ||||
-rw-r--r-- | tests/Unit/Command/FeedDeleteTest.php | 77 | ||||
-rw-r--r-- | tests/Unit/Command/FeedListTest.php | 123 | ||||
-rw-r--r-- | tests/Unit/Command/FolderAddTest.php | 83 | ||||
-rw-r--r-- | tests/Unit/Command/FolderDeleteTest.php | 101 | ||||
-rw-r--r-- | tests/Unit/Command/FolderListTest.php | 120 | ||||
-rw-r--r-- | tests/Unit/Command/OpmlExportTest.php | 78 | ||||
-rw-r--r-- | tests/Unit/Command/ShowFeedTest.php | 122 | ||||
-rw-r--r-- | tests/Unit/Command/UpdateFeedTest.php | 110 | ||||
-rw-r--r-- | tests/Unit/Utility/TimeTest.php | 50 |
13 files changed, 1106 insertions, 1 deletions
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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +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 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FolderAdd; +use OCA\News\Db\Folder; +use OCA\News\Service\FolderServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FolderAddTest extends TestCase +{ + /** @var MockObject|FolderServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var FolderAdd */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FolderServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FolderAdd($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['name', 'folder'], + ['user-id', 'admin'], + ])); + + $this->consoleInput->expects($this->exactly(1)) + ->method('getOption') + ->will($this->returnValueMap([ + ['parent', '0'], + ])); + + $feed = $this->createMock(Folder::class); + + $this->service->expects($this->exactly(1)) + ->method('create') + ->with('admin', 'folder', 0) + ->willReturn($feed); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/FolderDeleteTest.php b/tests/Unit/Command/FolderDeleteTest.php new file mode 100644 index 000000000..9db078b33 --- /dev/null +++ b/tests/Unit/Command/FolderDeleteTest.php @@ -0,0 +1,101 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FeedAdd; +use OCA\News\Command\Config\FeedDelete; +use OCA\News\Command\Config\FolderDelete; +use OCA\News\Command\Updater\UpdateFeed; +use OCA\News\Db\Feed; +use OCA\News\Service\Exceptions\ServiceNotFoundException; +use OCA\News\Service\FeedServiceV2; +use OCA\News\Service\FolderServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FolderDeleteTest extends TestCase +{ + /** @var MockObject|FolderServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var UpdateFeed */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FolderServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FolderDelete($this->service); + } + + /** + * Test a valid call will work + */ + public function testValid() + { + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['folder-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); + } + + /** + * Test a valid call will work + */ + public function testInValid() + { + $this->expectException('OCA\News\Service\Exceptions\ServiceException'); + $this->expectExceptionMessage('Can not remove root folder!'); + + $this->consoleInput->expects($this->exactly(2)) + ->method('getArgument') + ->will($this->returnValueMap([ + ['folder-id', '0'], + ['user-id', 'admin'], + ])); + + $this->service->expects($this->never()) + ->method('delete'); + + $result = $this->command->run($this->consoleInput, $this->consoleOutput); + $this->assertSame(0, $result); + } +} diff --git a/tests/Unit/Command/FolderListTest.php b/tests/Unit/Command/FolderListTest.php new file mode 100644 index 000000000..04f20dce6 --- /dev/null +++ b/tests/Unit/Command/FolderListTest.php @@ -0,0 +1,120 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @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 <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\News\Tests\Unit\Command; + +use OCA\News\Command\Config\FolderList; +use OCA\News\Db\Folder; +use OCA\News\Service\FolderServiceV2; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class FolderListTest extends TestCase +{ + /** @var MockObject|FolderServiceV2 */ + protected $service; + /** @var MockObject|InputInterface */ + protected $consoleInput; + /** @var MockObject|OutputInterface */ + protected $consoleOutput; + + /** @var FolderList */ + protected $command; + + protected function setUp(): void + { + $this->service = $this->getMockBuilder(FolderServiceV2::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); + $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); + + $this->command = new FolderList($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(Folder::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(Folder::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/OpmlExportTest.php b/tests/Unit/Command/OpmlExportTest.php new file mode 100644 index 000000000..a7828279e --- /dev/null +++ b/tests/Unit/Command/OpmlExportTest.php @@ -0,0 +1,78 @@ +<?php +/** + * @author Sean Molenaar <sean@seanmolenaar.eu> + * + * @license AGPL-3.0 |