Fix unit test for expiration date without date but with default

The expiration date was explicitly given, so it was not testing what it
should. Moreover, "link_defaultExpDays" needs to be mapped when testing
the default value (even if it will just fallback to the value of
"shareapi_expire_after_n_days").

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2020-11-12 09:34:58 +01:00
parent 3a53c2b6e5
commit 70018ddabf
1 changed files with 5 additions and 7 deletions

View File

@ -940,19 +940,17 @@ class ManagerTest extends \Test\TestCase {
} }
public function testValidateExpirationDateNoDateDefault() { public function testValidateExpirationDateNoDateDefault() {
$future = new \DateTime();
$future->add(new \DateInterval('P3D'));
$future->setTime(0,0,0);
$expected = clone $future;
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($future);
$expected = new \DateTime();
$expected->add(new \DateInterval('P3D'));
$expected->setTime(0,0,0);
$this->config->method('getAppValue') $this->config->method('getAppValue')
->willReturnMap([ ->willReturnMap([
['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'link_defaultExpDays', 3, '3'],
]); ]);
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();