$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
$this->expectExceptionMessage('Expiration date is in the past');
-
// Expire date in the past
$past = new \DateTime();
$past->sub(new \DateInterval('P1D'));
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
}
-
public function testValidateExpirationDateEnforceButNotSet() {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Expiration date is enforced');
]);
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) {
return $data['expirationDate'] == $future;
}));
$share->setExpirationDate($date);
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
}));
public function testValidateExpirationDateNoDateNoDefault() {
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) {
return $data['expirationDate'] === null && $data['passwordSet'] === true;
}));
]);
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
return $data['expirationDate'] == $expected;
}));
$save = clone $nextWeek;
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
$data['expirationDate']->sub(new \DateInterval('P2D'));
});
$this->assertEquals($save, $share->getExpirationDate());
}
-
public function testValidateExpirationDateHookException() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid date!');
$share->setExpirationDate($nextWeek);
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
+ \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
$data['accepted'] = false;
$data['message'] = 'Invalid date!';
$this->assertEquals(null, $share->getExpirationDate());
}
-
public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Sharing is only allowed with group members');