diff --git a/apps/encryption/appinfo/application.php b/apps/encryption/lib/AppInfo/Application.php similarity index 100% rename from apps/encryption/appinfo/application.php rename to apps/encryption/lib/AppInfo/Application.php diff --git a/apps/encryption/command/enablemasterkey.php b/apps/encryption/lib/Command/EnableMasterKey.php similarity index 100% rename from apps/encryption/command/enablemasterkey.php rename to apps/encryption/lib/Command/EnableMasterKey.php diff --git a/apps/encryption/command/migratekeys.php b/apps/encryption/lib/Command/MigrateKeys.php similarity index 100% rename from apps/encryption/command/migratekeys.php rename to apps/encryption/lib/Command/MigrateKeys.php diff --git a/apps/encryption/controller/recoverycontroller.php b/apps/encryption/lib/Controller/RecoveryController.php similarity index 100% rename from apps/encryption/controller/recoverycontroller.php rename to apps/encryption/lib/Controller/RecoveryController.php diff --git a/apps/encryption/controller/settingscontroller.php b/apps/encryption/lib/Controller/SettingsController.php similarity index 100% rename from apps/encryption/controller/settingscontroller.php rename to apps/encryption/lib/Controller/SettingsController.php diff --git a/apps/encryption/controller/statuscontroller.php b/apps/encryption/lib/Controller/StatusController.php similarity index 100% rename from apps/encryption/controller/statuscontroller.php rename to apps/encryption/lib/Controller/StatusController.php diff --git a/apps/encryption/lib/crypto/crypt.php b/apps/encryption/lib/Crypto/Crypt.php similarity index 100% rename from apps/encryption/lib/crypto/crypt.php rename to apps/encryption/lib/Crypto/Crypt.php diff --git a/apps/encryption/lib/crypto/decryptall.php b/apps/encryption/lib/Crypto/DecryptAll.php similarity index 100% rename from apps/encryption/lib/crypto/decryptall.php rename to apps/encryption/lib/Crypto/DecryptAll.php diff --git a/apps/encryption/lib/crypto/encryptall.php b/apps/encryption/lib/Crypto/EncryptAll.php similarity index 100% rename from apps/encryption/lib/crypto/encryptall.php rename to apps/encryption/lib/Crypto/EncryptAll.php diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/Crypto/Encryption.php similarity index 100% rename from apps/encryption/lib/crypto/encryption.php rename to apps/encryption/lib/Crypto/Encryption.php diff --git a/apps/encryption/lib/exceptions/multikeydecryptexception.php b/apps/encryption/lib/Exceptions/MultiKeyDecryptException.php similarity index 100% rename from apps/encryption/lib/exceptions/multikeydecryptexception.php rename to apps/encryption/lib/Exceptions/MultiKeyDecryptException.php diff --git a/apps/encryption/lib/exceptions/multikeyencryptexception.php b/apps/encryption/lib/Exceptions/MultiKeyEncryptException.php similarity index 100% rename from apps/encryption/lib/exceptions/multikeyencryptexception.php rename to apps/encryption/lib/Exceptions/MultiKeyEncryptException.php diff --git a/apps/encryption/lib/exceptions/privatekeymissingexception.php b/apps/encryption/lib/Exceptions/PrivateKeyMissingException.php similarity index 100% rename from apps/encryption/lib/exceptions/privatekeymissingexception.php rename to apps/encryption/lib/Exceptions/PrivateKeyMissingException.php diff --git a/apps/encryption/lib/exceptions/publickeymissingexception.php b/apps/encryption/lib/Exceptions/PublicKeyMissingException.php similarity index 100% rename from apps/encryption/lib/exceptions/publickeymissingexception.php rename to apps/encryption/lib/Exceptions/PublicKeyMissingException.php diff --git a/apps/encryption/lib/hookmanager.php b/apps/encryption/lib/HookManager.php similarity index 100% rename from apps/encryption/lib/hookmanager.php rename to apps/encryption/lib/HookManager.php diff --git a/apps/encryption/hooks/contracts/ihook.php b/apps/encryption/lib/Hooks/Contracts/IHook.php similarity index 100% rename from apps/encryption/hooks/contracts/ihook.php rename to apps/encryption/lib/Hooks/Contracts/IHook.php diff --git a/apps/encryption/hooks/userhooks.php b/apps/encryption/lib/Hooks/UserHooks.php similarity index 100% rename from apps/encryption/hooks/userhooks.php rename to apps/encryption/lib/Hooks/UserHooks.php diff --git a/apps/encryption/lib/keymanager.php b/apps/encryption/lib/KeyManager.php similarity index 100% rename from apps/encryption/lib/keymanager.php rename to apps/encryption/lib/KeyManager.php diff --git a/apps/encryption/lib/migration.php b/apps/encryption/lib/Migration.php similarity index 100% rename from apps/encryption/lib/migration.php rename to apps/encryption/lib/Migration.php diff --git a/apps/encryption/lib/recovery.php b/apps/encryption/lib/Recovery.php similarity index 100% rename from apps/encryption/lib/recovery.php rename to apps/encryption/lib/Recovery.php diff --git a/apps/encryption/lib/session.php b/apps/encryption/lib/Session.php similarity index 100% rename from apps/encryption/lib/session.php rename to apps/encryption/lib/Session.php diff --git a/apps/encryption/lib/users/setup.php b/apps/encryption/lib/Users/Setup.php similarity index 100% rename from apps/encryption/lib/users/setup.php rename to apps/encryption/lib/Users/Setup.php diff --git a/apps/encryption/lib/util.php b/apps/encryption/lib/Util.php similarity index 100% rename from apps/encryption/lib/util.php rename to apps/encryption/lib/Util.php diff --git a/apps/encryption/tests/command/testenablemasterkey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php similarity index 99% rename from apps/encryption/tests/command/testenablemasterkey.php rename to apps/encryption/tests/Command/TestEnableMasterKey.php index e408a7c2b1..da04e017a1 100644 --- a/apps/encryption/tests/command/testenablemasterkey.php +++ b/apps/encryption/tests/Command/TestEnableMasterKey.php @@ -24,6 +24,7 @@ namespace OCA\Encryption\Tests\Command; use OCA\Encryption\Command\EnableMasterKey; +use OCA\Encryption\Util; use Test\TestCase; class TestEnableMasterKey extends TestCase { diff --git a/apps/encryption/tests/controller/RecoveryControllerTest.php b/apps/encryption/tests/Controller/RecoveryControllerTest.php similarity index 82% rename from apps/encryption/tests/controller/RecoveryControllerTest.php rename to apps/encryption/tests/Controller/RecoveryControllerTest.php index a434913989..63c99e1277 100644 --- a/apps/encryption/tests/controller/RecoveryControllerTest.php +++ b/apps/encryption/tests/Controller/RecoveryControllerTest.php @@ -28,47 +28,36 @@ use OCP\AppFramework\Http; use Test\TestCase; class RecoveryControllerTest extends TestCase { - /** - * @var RecoveryController - */ + /** @var RecoveryController */ private $controller; - private $appName; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ + /** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $requestMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ + /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $configMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ + /** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l10nMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ + /** @var \OCA\Encryption\Recovery|\PHPUnit_Framework_MockObject_MockObject */ private $recoveryMock; public function adminRecoveryProvider() { return [ - ['test', 'test', '1', 'Recovery key successfully enabled', HTTP::STATUS_OK], - ['', 'test', '1', 'Missing recovery key password', HTTP::STATUS_BAD_REQUEST], - ['test', '', '1', 'Please repeat the recovery key password', HTTP::STATUS_BAD_REQUEST], - ['test', 'soimething that doesn\'t match', '1', 'Repeated recovery key password does not match the provided recovery key password', HTTP::STATUS_BAD_REQUEST], - ['test', 'test', '0', 'Recovery key successfully disabled', HTTP::STATUS_OK], + ['test', 'test', '1', 'Recovery key successfully enabled', Http::STATUS_OK], + ['', 'test', '1', 'Missing recovery key password', Http::STATUS_BAD_REQUEST], + ['test', '', '1', 'Please repeat the recovery key password', Http::STATUS_BAD_REQUEST], + ['test', 'soimething that doesn\'t match', '1', 'Repeated recovery key password does not match the provided recovery key password', Http::STATUS_BAD_REQUEST], + ['test', 'test', '0', 'Recovery key successfully disabled', Http::STATUS_OK], ]; } /** * @dataProvider adminRecoveryProvider * @param $recoveryPassword - * @param $passconfirm + * @param $passConfirm * @param $enableRecovery * @param $expectedMessage * @param $expectedStatus */ - public function testAdminRecovery($recoveryPassword, $passconfirm, $enableRecovery, $expectedMessage, $expectedStatus) { + public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus) { $this->recoveryMock->expects($this->any()) @@ -80,7 +69,7 @@ class RecoveryControllerTest extends TestCase { ->willReturn(true); $response = $this->controller->adminRecovery($recoveryPassword, - $passconfirm, + $passConfirm, $enableRecovery); @@ -92,11 +81,11 @@ class RecoveryControllerTest extends TestCase { public function changeRecoveryPasswordProvider() { return [ - ['test', 'test', 'oldtestFail', 'Could not change the password. Maybe the old password was not correct.', HTTP::STATUS_BAD_REQUEST], - ['test', 'test', 'oldtest', 'Password successfully changed.', HTTP::STATUS_OK], - ['test', 'notmatch', 'oldtest', 'Repeated recovery key password does not match the provided recovery key password', HTTP::STATUS_BAD_REQUEST], - ['', 'test', 'oldtest', 'Please provide a new recovery password', HTTP::STATUS_BAD_REQUEST], - ['test', 'test', '', 'Please provide the old recovery password', HTTP::STATUS_BAD_REQUEST] + ['test', 'test', 'oldtestFail', 'Could not change the password. Maybe the old password was not correct.', Http::STATUS_BAD_REQUEST], + ['test', 'test', 'oldtest', 'Password successfully changed.', Http::STATUS_OK], + ['test', 'notmatch', 'oldtest', 'Repeated recovery key password does not match the provided recovery key password', Http::STATUS_BAD_REQUEST], + ['', 'test', 'oldtest', 'Please provide a new recovery password', Http::STATUS_BAD_REQUEST], + ['test', 'test', '', 'Please provide the old recovery password', Http::STATUS_BAD_REQUEST] ]; } @@ -160,8 +149,7 @@ class RecoveryControllerTest extends TestCase { protected function setUp() { parent::setUp(); - $this->appName = 'encryption'; - $this->requestMock = $this->getMockBuilder('\OCP\IRequest') + $this->requestMock = $this->getMockBuilder('OCP\IRequest') ->disableOriginalConstructor() ->getMock(); @@ -182,7 +170,7 @@ class RecoveryControllerTest extends TestCase { ->disableOriginalConstructor() ->getMock(); - $this->controller = new RecoveryController($this->appName, + $this->controller = new RecoveryController('encryption', $this->requestMock, $this->configMock, $this->l10nMock, diff --git a/apps/encryption/tests/controller/SettingsControllerTest.php b/apps/encryption/tests/Controller/SettingsControllerTest.php similarity index 89% rename from apps/encryption/tests/controller/SettingsControllerTest.php rename to apps/encryption/tests/Controller/SettingsControllerTest.php index 61391a3300..8180cae113 100644 --- a/apps/encryption/tests/controller/SettingsControllerTest.php +++ b/apps/encryption/tests/Controller/SettingsControllerTest.php @@ -32,31 +32,31 @@ class SettingsControllerTest extends TestCase { /** @var SettingsController */ private $controller; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $requestMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l10nMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManagerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ private $userSessionMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */ private $keyManagerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */ private $sessionMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */ private $ocSessionMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */ private $utilMock; protected function setUp() { @@ -96,7 +96,7 @@ class SettingsControllerTest extends TestCase { ]) ->getMock(); - $this->ocSessionMock = $this->getMockBuilder('\OCP\ISession')->disableOriginalConstructor()->getMock(); + $this->ocSessionMock = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock(); $this->userSessionMock->expects($this->any()) ->method('getUID') diff --git a/apps/encryption/tests/controller/StatusControllerTest.php b/apps/encryption/tests/Controller/StatusControllerTest.php similarity index 93% rename from apps/encryption/tests/controller/StatusControllerTest.php rename to apps/encryption/tests/Controller/StatusControllerTest.php index 3c937623b7..0410b36cd2 100644 --- a/apps/encryption/tests/controller/StatusControllerTest.php +++ b/apps/encryption/tests/Controller/StatusControllerTest.php @@ -29,11 +29,11 @@ use Test\TestCase; class StatusControllerTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $requestMock; + /** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */ + private $requestMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $l10nMock; + /** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ + private $l10nMock; /** @var \OCA\Encryption\Session | \PHPUnit_Framework_MockObject_MockObject */ protected $sessionMock; diff --git a/apps/encryption/tests/lib/crypto/cryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php similarity index 97% rename from apps/encryption/tests/lib/crypto/cryptTest.php rename to apps/encryption/tests/Crypto/CryptTest.php index 2f290db21a..4b8147ab21 100644 --- a/apps/encryption/tests/lib/crypto/cryptTest.php +++ b/apps/encryption/tests/Crypto/CryptTest.php @@ -22,29 +22,28 @@ */ -namespace OCA\Encryption\Tests\lib\Crypto; +namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Crypto\Crypt; use Test\TestCase; -class cryptTest extends TestCase { +class CryptTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */ private $logger; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ private $userSession; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $config; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l; - /** @var Crypt */ + /** @var Crypt */ private $crypt; public function setUp() { diff --git a/apps/encryption/tests/lib/crypto/decryptalltest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php similarity index 99% rename from apps/encryption/tests/lib/crypto/decryptalltest.php rename to apps/encryption/tests/Crypto/DecryptAllTest.php index 0945692e42..a094f3b3a2 100644 --- a/apps/encryption/tests/lib/crypto/decryptalltest.php +++ b/apps/encryption/tests/Crypto/DecryptAllTest.php @@ -20,7 +20,7 @@ */ -namespace OCA\Encryption\Tests\lib\Crypto; +namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Crypto\Crypt; diff --git a/apps/encryption/tests/lib/crypto/encryptalltest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php similarity index 99% rename from apps/encryption/tests/lib/crypto/encryptalltest.php rename to apps/encryption/tests/Crypto/EncryptAllTest.php index d31f58377c..baa80eaaf8 100644 --- a/apps/encryption/tests/lib/crypto/encryptalltest.php +++ b/apps/encryption/tests/Crypto/EncryptAllTest.php @@ -20,7 +20,7 @@ */ -namespace OCA\Encryption\Tests\lib\Crypto; +namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Crypto\EncryptAll; diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php similarity index 93% rename from apps/encryption/tests/lib/crypto/encryptionTest.php rename to apps/encryption/tests/Crypto/EncryptionTest.php index ad20efb445..723c6e31b9 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/Crypto/EncryptionTest.php @@ -20,7 +20,7 @@ * */ -namespace OCA\Encryption\Tests\lib\Crypto; +namespace OCA\Encryption\Tests\Crypto; use OCA\Encryption\Exceptions\PublicKeyMissingException; use Test\TestCase; @@ -31,31 +31,31 @@ class EncryptionTest extends TestCase { /** @var Encryption */ private $instance; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */ private $keyManagerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Crypto\EncryptAll|\PHPUnit_Framework_MockObject_MockObject */ private $encryptAllMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Crypto\DecryptAll|\PHPUnit_Framework_MockObject_MockObject */ private $decryptAllMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */ private $sessionMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */ private $utilMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */ private $loggerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */ private $l10nMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\Files\Storage|\PHPUnit_Framework_MockObject_MockObject */ private $storageMock; public function setUp() { @@ -410,7 +410,9 @@ class EncryptionTest extends TestCase { } public function testPrepareDecryptAll() { + /** @var \Symfony\Component\Console\Input\InputInterface $input */ $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + /** @var \Symfony\Component\Console\Output\OutputInterface $output */ $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $this->decryptAllMock->expects($this->once())->method('prepare') diff --git a/apps/encryption/tests/lib/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php similarity index 97% rename from apps/encryption/tests/lib/HookManagerTest.php rename to apps/encryption/tests/HookManagerTest.php index d69674faec..4228db318a 100644 --- a/apps/encryption/tests/lib/HookManagerTest.php +++ b/apps/encryption/tests/HookManagerTest.php @@ -65,6 +65,7 @@ class HookManagerTest extends TestCase { */ public function testRegisterHooksWithInstance() { $mock = $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock(); + /** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */ self::$instance->registerHook($mock); $hookInstances = self::invokePrivate(self::$instance, 'hookInstances'); diff --git a/apps/encryption/tests/hooks/UserHooksTest.php b/apps/encryption/tests/Hooks/UserHooksTest.php similarity index 95% rename from apps/encryption/tests/hooks/UserHooksTest.php rename to apps/encryption/tests/Hooks/UserHooksTest.php index df3d12b340..a4767bfb74 100644 --- a/apps/encryption/tests/hooks/UserHooksTest.php +++ b/apps/encryption/tests/Hooks/UserHooksTest.php @@ -69,6 +69,10 @@ class UserHooksTest extends TestCase { * @var \PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $loggerMock; /** * @var UserHooks */ @@ -91,15 +95,16 @@ class UserHooksTest extends TestCase { public function testLogout() { $this->sessionMock->expects($this->once()) ->method('clear'); - - $this->assertNull($this->instance->logout()); + $this->instance->logout(); + $this->assertTrue(true); } public function testPostCreateUser() { $this->userSetupMock->expects($this->once()) ->method('setupUser'); - $this->assertNull($this->instance->postCreateUser($this->params)); + $this->instance->postCreateUser($this->params); + $this->assertTrue(true); } public function testPostDeleteUser() { @@ -107,7 +112,8 @@ class UserHooksTest extends TestCase { ->method('deletePublicKey') ->with('testUser'); - $this->assertNull($this->instance->postDeleteUser($this->params)); + $this->instance->postDeleteUser($this->params); + $this->assertTrue(true); } /** @@ -273,6 +279,7 @@ class UserHooksTest extends TestCase { ] )->setMethods(['initMountPoints'])->getMock(); + /** @var \OCA\Encryption\Hooks\UserHooks $userHooks */ $this->assertNull($userHooks->setPassphrase($this->params)); } @@ -285,7 +292,8 @@ class UserHooksTest extends TestCase { ->method('setupUser') ->with('testUser', 'password'); - $this->assertNull($this->instance->postPasswordReset($this->params)); + $this->instance->postPasswordReset($this->params); + $this->assertTrue(true); } protected function setUp() { diff --git a/apps/encryption/tests/lib/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php similarity index 96% rename from apps/encryption/tests/lib/KeyManagerTest.php rename to apps/encryption/tests/KeyManagerTest.php index 7ede6177de..6f6fb3a02d 100644 --- a/apps/encryption/tests/lib/KeyManagerTest.php +++ b/apps/encryption/tests/KeyManagerTest.php @@ -43,25 +43,25 @@ class KeyManagerTest extends TestCase { /** @var string */ private $systemKeyId; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\Encryption\Keys\IStorage|\PHPUnit_Framework_MockObject_MockObject */ private $keyStorageMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ private $userMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */ private $sessionMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */ private $logMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */ private $utilMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $configMock; public function setUp() { @@ -245,6 +245,7 @@ class KeyManagerTest extends TestCase { */ public function testInit($useMasterKey) { + /** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */ $instance = $this->getMockBuilder('OCA\Encryption\KeyManager') ->setConstructorArgs( [ @@ -588,6 +589,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn(false); + /** @var \OC\Files\View $view */ $this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view)); } @@ -604,6 +606,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn($fileInfo); + /** @var \OC\Files\View $view */ $this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view)); } @@ -633,6 +636,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn($fileInfo); + /** @var \OC\Files\View $view */ $this->instance->setVersion('/admin/files/myfile.txt', 5, $view); } @@ -644,6 +648,7 @@ class KeyManagerTest extends TestCase { ->with('/admin/files/myfile.txt') ->willReturn(false); + /** @var \OC\Files\View $view */ $this->instance->setVersion('/admin/files/myfile.txt', 5, $view); } diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/MigrationTest.php similarity index 99% rename from apps/encryption/tests/lib/MigrationTest.php rename to apps/encryption/tests/MigrationTest.php index 18f7c8b35d..c77693d24a 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/MigrationTest.php @@ -39,7 +39,7 @@ class MigrationTest extends \Test\TestCase { private $recovery_key_id = 'recovery_key_id'; private $moduleId; - /** @var PHPUnit_Framework_MockObject_MockObject | ILogger */ + /** @var \PHPUnit_Framework_MockObject_MockObject | ILogger */ private $logger; public static function setUpBeforeClass() { diff --git a/apps/encryption/tests/lib/RecoveryTest.php b/apps/encryption/tests/RecoveryTest.php similarity index 93% rename from apps/encryption/tests/lib/RecoveryTest.php rename to apps/encryption/tests/RecoveryTest.php index 68c21c80b3..c8bd838242 100644 --- a/apps/encryption/tests/lib/RecoveryTest.php +++ b/apps/encryption/tests/RecoveryTest.php @@ -32,27 +32,27 @@ use Test\TestCase; class RecoveryTest extends TestCase { private static $tempStorage = []; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCP\Encryption\IFile|\PHPUnit_Framework_MockObject_MockObject */ private $fileMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OC\Files\View|\PHPUnit_Framework_MockObject_MockObject */ private $viewMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ private $userSessionMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */ private $keyManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $configMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; /** @@ -201,7 +201,8 @@ class RecoveryTest extends TestCase { $this->cryptMock->expects($this->once()) ->method('decryptPrivateKey'); - $this->assertNull($this->instance->recoverUsersFiles('password', 'admin')); + $this->instance->recoverUsersFiles('password', 'admin'); + $this->assertTrue(true); } public function testRecoverFile() { @@ -265,9 +266,11 @@ class RecoveryTest extends TestCase { ->will($this->returnSelf()); $this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock(); + /** @var \OCP\Security\ISecureRandom $randomMock */ $randomMock = $this->getMock('OCP\Security\ISecureRandom'); $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock(); $this->configMock = $this->getMock('OCP\IConfig'); + /** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */ $keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage'); $this->fileMock = $this->getMock('OCP\Encryption\IFile'); $this->viewMock = $this->getMock('OC\Files\View'); diff --git a/apps/encryption/tests/lib/SessionTest.php b/apps/encryption/tests/SessionTest.php similarity index 98% rename from apps/encryption/tests/lib/SessionTest.php rename to apps/encryption/tests/SessionTest.php index f7a8a0369b..b2944d450a 100644 --- a/apps/encryption/tests/lib/SessionTest.php +++ b/apps/encryption/tests/SessionTest.php @@ -34,6 +34,7 @@ class SessionTest extends TestCase { * @var Session */ private $instance; + /** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */ private $sessionMock; /** diff --git a/apps/encryption/tests/lib/users/SetupTest.php b/apps/encryption/tests/Users/SetupTest.php similarity index 91% rename from apps/encryption/tests/lib/users/SetupTest.php rename to apps/encryption/tests/Users/SetupTest.php index e7d8afbb10..9e7cbde0c1 100644 --- a/apps/encryption/tests/lib/users/SetupTest.php +++ b/apps/encryption/tests/Users/SetupTest.php @@ -29,11 +29,11 @@ use Test\TestCase; class SetupTest extends TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */ private $keyManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */ private $cryptMock; /** @@ -55,6 +55,8 @@ class SetupTest extends TestCase { ->disableOriginalConstructor() ->getMock(); + /** @var \OCP\ILogger $logMock */ + /** @var \OCP\IUserSession $userSessionMock */ $this->instance = new Setup($logMock, $userSessionMock, $this->cryptMock, diff --git a/apps/encryption/tests/lib/UtilTest.php b/apps/encryption/tests/UtilTest.php similarity index 85% rename from apps/encryption/tests/lib/UtilTest.php rename to apps/encryption/tests/UtilTest.php index fa90125d6e..e052bff863 100644 --- a/apps/encryption/tests/lib/UtilTest.php +++ b/apps/encryption/tests/UtilTest.php @@ -30,16 +30,16 @@ use Test\TestCase; class UtilTest extends TestCase { private static $tempStorage = []; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */ private $configMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OC\Files\View|\PHPUnit_Framework_MockObject_MockObject */ private $filesMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManagerMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ + /** @var \OCP\Files\Mount\IMountPoint|\PHPUnit_Framework_MockObject_MockObject */ private $mountMock; /** @var Util */ @@ -72,10 +72,13 @@ class UtilTest extends TestCase { $this->filesMock = $this->getMock('OC\Files\View'); $this->userManagerMock = $this->getMock('\OCP\IUserManager'); + /** @var \OCA\Encryption\Crypto\Crypt $cryptMock */ $cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt') ->disableOriginalConstructor() ->getMock(); + /** @var \OCP\ILogger $loggerMock */ $loggerMock = $this->getMock('OCP\ILogger'); + /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */ $userSessionMock = $this->getMockBuilder('OCP\IUserSession') ->disableOriginalConstructor() ->setMethods([ @@ -97,7 +100,7 @@ class UtilTest extends TestCase { ->will($this->returnSelf()); - $this->configMock = $configMock = $this->getMock('OCP\IConfig'); + $this->configMock = $this->getMock('OCP\IConfig'); $this->configMock->expects($this->any()) ->method('getUserValue') @@ -107,7 +110,7 @@ class UtilTest extends TestCase { ->method('setUserValue') ->will($this->returnCallback([$this, 'setValueTester'])); - $this->instance = new Util($this->filesMock, $cryptMock, $loggerMock, $userSessionMock, $configMock, $this->userManagerMock); + $this->instance = new Util($this->filesMock, $cryptMock, $loggerMock, $userSessionMock, $this->configMock, $this->userManagerMock); } /** @@ -157,8 +160,8 @@ class UtilTest extends TestCase { /** * @dataProvider dataTestShouldEncryptHomeStorage - * @param $returnValue return value from getAppValue() - * @param $expected + * @param string $returnValue return value from getAppValue() + * @param bool $expected */ public function testShouldEncryptHomeStorage($returnValue, $expected) { $this->configMock->expects($this->once())->method('getAppValue') @@ -195,12 +198,16 @@ class UtilTest extends TestCase { } public function testGetStorage() { + $return = $this->getMockBuilder('OC\Files\Storage\Storage') + ->disableOriginalConstructor() + ->getMock(); + $path = '/foo/bar.txt'; $this->filesMock->expects($this->once())->method('getMount')->with($path) ->willReturn($this->mountMock); - $this->mountMock->expects($this->once())->method('getStorage')->willReturn(true); + $this->mountMock->expects($this->once())->method('getStorage')->willReturn($return); - $this->assertTrue($this->instance->getStorage($path)); + $this->assertEquals($return, $this->instance->getStorage($path)); } }