diff --git a/apps/files_trashbin/lib/Command/ExpireTrash.php b/apps/files_trashbin/lib/Command/ExpireTrash.php index 48734f6ed8f8..cde1ded9127e 100644 --- a/apps/files_trashbin/lib/Command/ExpireTrash.php +++ b/apps/files_trashbin/lib/Command/ExpireTrash.php @@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { - $output->writeln("No expiry configured."); + $output->writeln("Auto expiration is configured - expiration will be handled automatically."); return; } diff --git a/apps/files_trashbin/tests/Command/ExpireTrashTest.php b/apps/files_trashbin/tests/Command/ExpireTrashTest.php new file mode 100644 index 000000000000..52ebd657440f --- /dev/null +++ b/apps/files_trashbin/tests/Command/ExpireTrashTest.php @@ -0,0 +1,63 @@ + + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @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\Files_Trashbin\Tests\Command; + +use OCA\Files_Trashbin\Command\ExpireTrash; +use OCA\Files_Trashbin\Expiration; +use OCP\IUserManager; +use Symfony\Component\Console\Tester\CommandTester; +use Test\TestCase; + + +/** + * Class ExpireTrashTest + * + * @group DB + * + * @package OCA\Files_Trashbin\Tests\Command + */ +class ExpireTrashTest extends TestCase { + + /** @var CommandTester */ + private $commandTester; + + private $userManager; + + private $expiration; + + public function setUp() { + parent::setUp(); + + $this->userManager = $this->createMock(IUserManager::class); + $this->expiration = $this->createMock(Expiration::class); + $command = new ExpireTrash($this->userManager, $this->expiration); + $this->commandTester = new CommandTester($command); + } + + public function testExpireNoMaxRetention() { + $this->expiration->expects($this->any())->method('getMaxAgeAsTimestamp') + ->willReturn(false); + $this->commandTester->execute([]); + $output = $this->commandTester->getDisplay(); + $this->assertContains('Auto expiration is configured', $output); + } +} diff --git a/apps/files_versions/lib/Command/ExpireVersions.php b/apps/files_versions/lib/Command/ExpireVersions.php index 917267015a86..707a722d5c2d 100644 --- a/apps/files_versions/lib/Command/ExpireVersions.php +++ b/apps/files_versions/lib/Command/ExpireVersions.php @@ -71,7 +71,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $maxAge = $this->expiration->getMaxAgeAsTimestamp(); if (!$maxAge) { - $output->writeln("No expiry configured."); + $output->writeln("Auto expiration is configured - expiration will be handled automatically."); return; } diff --git a/apps/files_versions/tests/Command/ExpireVersionsTest.php b/apps/files_versions/tests/Command/ExpireVersionsTest.php new file mode 100644 index 000000000000..99edebe23d8c --- /dev/null +++ b/apps/files_versions/tests/Command/ExpireVersionsTest.php @@ -0,0 +1,63 @@ + + * + * @copyright Copyright (c) 2017, ownCloud GmbH + * @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\Files_Versions\Tests\Command; + +use OCA\Files_Versions\Command\ExpireVersions; +use OCA\Files_Versions\Expiration; +use OCP\IUserManager; +use Symfony\Component\Console\Tester\CommandTester; +use Test\TestCase; + + +/** + * Class ExpireVersionsTest + * + * @group DB + * + * @package OCA\Files_Versions\Tests\Command + */ +class ExpireVersionsTest extends TestCase { + + /** @var CommandTester */ + private $commandTester; + + private $userManager; + + private $expiration; + + public function setUp() { + parent::setUp(); + + $this->userManager = $this->createMock(IUserManager::class); + $this->expiration = $this->createMock(Expiration::class); + $command = new ExpireVersions($this->userManager, $this->expiration); + $this->commandTester = new CommandTester($command); + } + + public function testExpireNoMaxRetention() { + $this->expiration->expects($this->any())->method('getMaxAgeAsTimestamp') + ->willReturn(false); + $this->commandTester->execute([]); + $output = $this->commandTester->getDisplay(); + $this->assertContains('Auto expiration is configured', $output); + } +}