diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/contacts/localadressbook.php | 114 | ||||
-rw-r--r-- | tests/lib/share20/managertest.php | 21 | ||||
-rw-r--r-- | tests/lib/systemtag/systemtagmanagertest.php | 17 | ||||
-rw-r--r-- | tests/lib/systemtag/systemtagobjectmappertest.php | 27 |
4 files changed, 56 insertions, 123 deletions
diff --git a/tests/lib/contacts/localadressbook.php b/tests/lib/contacts/localadressbook.php deleted file mode 100644 index ad3c088e3cd..00000000000 --- a/tests/lib/contacts/localadressbook.php +++ /dev/null @@ -1,114 +0,0 @@ -<?php -use OC\Contacts\LocalAddressBook; -use OCP\IUser; - -/** - * ownCloud - * - * @author Thomas Müller - * @copyright 2014 Thomas Müller thomas.mueller@tmit.eu - * - * You should have received a copy of the GNU Affero General Public - * License along with this library. If not, see <http://www.gnu.org/licenses/>. - */ - -class Test_LocalAddressBook extends \Test\TestCase -{ - - public function testSearchFN() { - $stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName')); - - $stub->expects($this->any())->method('searchDisplayName')->will($this->returnValue(array( - new SimpleUserForTesting('tom', 'Thomas'), - new SimpleUserForTesting('tomtom', 'Thomas T.'), - ))); - - $localAddressBook = new LocalAddressBook($stub); - - $result = $localAddressBook->search('tom', array('FN'), array()); - $this->assertEquals(2, count($result)); - } - - public function testSearchId() { - $stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName')); - - $stub->expects($this->any())->method('search')->will($this->returnValue(array( - new SimpleUserForTesting('tom', 'Thomas'), - new SimpleUserForTesting('tomtom', 'Thomas T.'), - ))); - - $localAddressBook = new LocalAddressBook($stub); - - $result = $localAddressBook->search('tom', array('id'), array()); - $this->assertEquals(2, count($result)); - } -} - - -class SimpleUserForTesting implements IUser { - - private $uid; - private $displayName; - - public function __construct($uid, $displayName) { - - $this->uid = $uid; - $this->displayName = $displayName; - } - - public function getUID() { - return $this->uid; - } - - public function getDisplayName() { - return $this->displayName; - } - - public function setDisplayName($displayName) { - } - - public function getLastLogin() { - } - - public function updateLastLoginTimestamp() { - } - - public function delete() { - } - - public function setPassword($password, $recoveryPassword = null) { - } - - public function getHome() { - } - - public function getBackendClassName() { - } - - public function canChangeAvatar() { - } - - public function canChangePassword() { - } - - public function canChangeDisplayName() { - } - - public function isEnabled() { - } - - public function setEnabled($enabled) { - } - - public function getEMailAddress() { - } - - public function getAvatarImage($size) { - } - - public function getCloudId() { - } - - public function setEMailAddress($mailAddress) { - } -} diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index 1a6e8200ade..6043d30a0bb 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -1645,6 +1645,27 @@ class ManagerTest extends \Test\TestCase { $this->assertTrue($this->manager->checkPassword($share, 'password')); } + public function testCheckPasswordUpdateShare() { + $share = $this->manager->newShare(); + $share->setShareType(\OCP\Share::SHARE_TYPE_LINK) + ->setPassword('passwordHash'); + + $this->hasher->method('verify')->with('password', 'passwordHash', '') + ->will($this->returnCallback(function($pass, $hash, &$newHash) { + $newHash = 'newHash'; + + return true; + })); + + $this->defaultProvider->expects($this->once()) + ->method('update') + ->with($this->callback(function (\OCP\Share\IShare $share) { + return $share->getPassword() === 'newHash'; + })); + + $this->assertTrue($this->manager->checkPassword($share, 'password')); + } + /** * @expectedException Exception * @expectedExceptionMessage The Share API is disabled diff --git a/tests/lib/systemtag/systemtagmanagertest.php b/tests/lib/systemtag/systemtagmanagertest.php index 97c072f33f6..64220205ade 100644 --- a/tests/lib/systemtag/systemtagmanagertest.php +++ b/tests/lib/systemtag/systemtagmanagertest.php @@ -15,6 +15,7 @@ use OC\SystemTag\SystemTagObjectMapper; use OCP\IDBConnection; use OCP\SystemTag\ISystemTag; use OCP\SystemTag\ISystemTagManager; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -35,11 +36,23 @@ class SystemTagManagerTest extends TestCase { */ private $connection; + /** + * @var EventDispatcherInterface + */ + private $dispatcher; + public function setUp() { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); - $this->tagManager = new SystemTagManager($this->connection); + + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') + ->getMock(); + + $this->tagManager = new SystemTagManager( + $this->connection, + $this->dispatcher + ); $this->pruneTagsTables(); } @@ -378,7 +391,7 @@ class SystemTagManagerTest extends TestCase { $tag1 = $this->tagManager->createTag('one', true, false); $tag2 = $this->tagManager->createTag('two', true, true); - $tagMapper = new SystemTagObjectMapper($this->connection, $this->tagManager); + $tagMapper = new SystemTagObjectMapper($this->connection, $this->tagManager, $this->dispatcher); $tagMapper->assignTags(1, 'testtype', $tag1->getId()); $tagMapper->assignTags(1, 'testtype', $tag2->getId()); diff --git a/tests/lib/systemtag/systemtagobjectmappertest.php b/tests/lib/systemtag/systemtagobjectmappertest.php index 4ea80c216ed..5c8204f6a87 100644 --- a/tests/lib/systemtag/systemtagobjectmappertest.php +++ b/tests/lib/systemtag/systemtagobjectmappertest.php @@ -10,14 +10,15 @@ namespace Test\SystemTag; +use OC\SystemTag\SystemTag; use OC\SystemTag\SystemTagManager; use OC\SystemTag\SystemTagObjectMapper; -use \OCP\SystemTag\ISystemTag; -use \OCP\SystemTag\ISystemTagManager; -use \OCP\SystemTag\ISystemTagObjectMapper; -use \OCP\SystemTag\TagNotFoundException; -use \OCP\IDBConnection; -use \OC\SystemTag\SystemTag; +use OCP\IDBConnection; +use OCP\SystemTag\ISystemTag; +use OCP\SystemTag\ISystemTagManager; +use OCP\SystemTag\ISystemTagObjectMapper; +use OCP\SystemTag\TagNotFoundException; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -44,6 +45,11 @@ class SystemTagObjectMapperTest extends TestCase { private $connection; /** + * @var EventDispatcherInterface + */ + private $dispatcher; + + /** * @var ISystemTag */ private $tag1; @@ -67,7 +73,14 @@ class SystemTagObjectMapperTest extends TestCase { $this->tagManager = $this->getMockBuilder('OCP\SystemTag\ISystemTagManager') ->getMock(); - $this->tagMapper = new SystemTagObjectMapper($this->connection, $this->tagManager); + $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') + ->getMock(); + + $this->tagMapper = new SystemTagObjectMapper( + $this->connection, + $this->tagManager, + $this->dispatcher + ); $this->tag1 = new SystemTag(1, 'testtag1', false, false); $this->tag2 = new SystemTag(2, 'testtag2', true, false); |