Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more precise when refuse to expire #29646

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/Command/ExpireTrash.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
63 changes: 63 additions & 0 deletions apps/files_trashbin/tests/Command/ExpireTrashTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @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 <http://www.gnu.org/licenses/>
*
*/

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uh oh, class name mismatch

*
* @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);
}
}
2 changes: 1 addition & 1 deletion apps/files_versions/lib/Command/ExpireVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
63 changes: 63 additions & 0 deletions apps/files_versions/tests/Command/ExpireVersionsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php
/**
* @author Viktar Dubiniuk <dubiniuk@owncloud.com>
*
* @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 <http://www.gnu.org/licenses/>
*
*/

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);
}
}