diff options
Diffstat (limited to 'apps/files_sharing/tests/Migration/SetPasswordColumnTest.php')
-rw-r--r-- | apps/files_sharing/tests/Migration/SetPasswordColumnTest.php | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index c4c78b04a23..3cbbad0f8bc 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -1,33 +1,19 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2017 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ - namespace OCA\Files_Sharing\Tests\Migration; - use OCA\Files_Sharing\Migration\SetPasswordColumn; use OCA\Files_Sharing\Tests\TestCase; use OCP\IConfig; +use OCP\IDBConnection; use OCP\Migration\IOutput; -use OCP\Share; +use OCP\Server; +use OCP\Share\IShare; /** * Class SetPasswordColumnTest @@ -36,10 +22,10 @@ use OCP\Share; */ class SetPasswordColumnTest extends TestCase { - /** @var \OCP\IDBConnection */ + /** @var IDBConnection */ private $connection; - /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ + /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */ private $config; /** @var SetPasswordColumn */ @@ -47,17 +33,17 @@ class SetPasswordColumnTest extends TestCase { private $table = 'share'; - public function setUp() { + protected function setUp(): void { parent::setUp(); - $this->connection = \OC::$server->getDatabaseConnection(); + $this->connection = Server::get(IDBConnection::class); $this->config = $this->createMock(IConfig::class); $this->migration = new SetPasswordColumn($this->connection, $this->config); $this->cleanDB(); } - public function tearDown() { + protected function tearDown(): void { parent::tearDown(); $this->cleanDB(); } @@ -67,13 +53,13 @@ class SetPasswordColumnTest extends TestCase { $query->delete($this->table)->execute(); } - public function testAddPasswordColumn() { + public function testAddPasswordColumn(): void { $this->config->expects($this->once()) ->method('getAppValue') ->with('files_sharing', 'installed_version', '0.0.0') ->willReturn('1.3.0'); - $shareTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_LINK]; + $shareTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL, IShare::TYPE_LINK]; foreach ($shareTypes as $shareType) { for ($i = 0; $i < 5; $i++) { @@ -105,11 +91,13 @@ class SetPasswordColumnTest extends TestCase { $query = $this->connection->getQueryBuilder(); $query->select('*') ->from('share'); - $allShares = $query->execute()->fetchAll(); + $result = $query->execute(); + $allShares = $result->fetchAll(); + $result->closeCursor(); foreach ($allShares as $share) { - if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) { - $this->assertNull( $share['share_with']); + if ((int)$share['share_type'] === IShare::TYPE_LINK) { + $this->assertNull($share['share_with']); $this->assertSame('shareWith', $share['password']); } else { $this->assertSame('shareWith', $share['share_with']); |