summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-06-27 10:46:39 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2016-06-27 14:05:27 +0200
commitd4989c80379d4cac71ae76ec8df79090f2e4c25f (patch)
tree9b08815b7829691764427846596737eb5f5af708 /tests
parent630e4b1b463c773e4a23556672fbd90af6176cab (diff)
downloadnextcloud-server-d4989c80379d4cac71ae76ec8df79090f2e4c25f.tar.gz
nextcloud-server-d4989c80379d4cac71ae76ec8df79090f2e4c25f.zip
remove old hook, no longer needed
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Share20/ManagerTest.php35
1 files changed, 16 insertions, 19 deletions
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 9f543e51592..5f7579474aa 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -20,6 +20,7 @@
*/
namespace Test\Share20;
+use OC\HintException;
use OCP\Files\IRootFolder;
use OCP\IUserManager;
use OCP\Share\Exceptions\ShareNotFound;
@@ -38,6 +39,7 @@ use OCP\Security\IHasher;
use OCP\Files\Mount\IMountManager;
use OCP\IGroupManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class ManagerTest
@@ -549,16 +551,12 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]));
- $hookListner = $this->getMockBuilder('Dummy')->setMethods(['listner'])->getMock();
- \OCP\Util::connectHook('\OC\Share', 'verifyPassword', $hookListner, 'listner');
-
- $hookListner->expects($this->once())
- ->method('listner')
- ->with([
- 'password' => 'password',
- 'accepted' => true,
- 'message' => ''
- ]);
+ $this->eventDispatcher->expects($this->once())->method('dispatch')
+ ->willReturnCallback(function($eventName, GenericEvent $event) {
+ $this->assertSame('OCP\PasswordPolicy::validate', $eventName);
+ $this->assertSame('password', $event->getSubject());
+ }
+ );
$result = $this->invokePrivate($this->manager, 'verifyPassword', ['password']);
$this->assertNull($result);
@@ -573,8 +571,14 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]));
- $dummy = new DummyPassword();
- \OCP\Util::connectHook('\OC\Share', 'verifyPassword', $dummy, 'listner');
+ $this->eventDispatcher->expects($this->once())->method('dispatch')
+ ->willReturnCallback(function($eventName, GenericEvent $event) {
+ $this->assertSame('OCP\PasswordPolicy::validate', $eventName);
+ $this->assertSame('password', $event->getSubject());
+ throw new HintException('message', 'password not accepted');
+ }
+ );
+
$this->invokePrivate($this->manager, 'verifyPassword', ['password']);
}
@@ -2539,13 +2543,6 @@ class ManagerTest extends \Test\TestCase {
}
}
-class DummyPassword {
- public function listner($array) {
- $array['accepted'] = false;
- $array['message'] = 'password not accepted';
- }
-}
-
class DummyFactory implements IProviderFactory {
/** @var IShareProvider */