summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/GroupsControllerTest.php5
-rw-r--r--tests/acceptance/features/app-files.feature16
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php48
-rwxr-xr-xtests/acceptance/run.sh2
-rw-r--r--tests/lib/Collaboration/Collaborators/SearchResultTest.php105
-rw-r--r--tests/lib/DB/MigratorTest.php39
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php16
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php3
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php3
-rw-r--r--tests/lib/Encryption/UpdateTest.php3
-rw-r--r--tests/lib/Encryption/UtilTest.php3
-rw-r--r--tests/lib/FileChunkingTest.php2
-rw-r--r--tests/lib/Files/Node/FolderTest.php6
-rw-r--r--tests/lib/Files/Node/NodeTest.php3
-rw-r--r--tests/lib/Files/Node/RootTest.php2
-rw-r--r--tests/lib/Files/Storage/Wrapper/EncryptionTest.php8
-rw-r--r--tests/lib/Files/Type/DetectionTest.php2
-rw-r--r--tests/lib/Files/ViewTest.php4
-rw-r--r--tests/lib/LoggerTest.php26
-rw-r--r--tests/lib/Security/CertificateManagerTest.php3
-rw-r--r--tests/lib/Session/CryptoWrappingTest.php3
21 files changed, 266 insertions, 36 deletions
diff --git a/tests/Settings/Controller/GroupsControllerTest.php b/tests/Settings/Controller/GroupsControllerTest.php
index 78df5f3a3cb..ecbfa9ea05e 100644
--- a/tests/Settings/Controller/GroupsControllerTest.php
+++ b/tests/Settings/Controller/GroupsControllerTest.php
@@ -13,6 +13,7 @@ namespace Tests\Settings\Controller;
use OC\Group\Group;
use OC\Group\MetaData;
use OC\Settings\Controller\GroupsController;
+use OC\User\User;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\IGroupManager;
@@ -99,7 +100,7 @@ class GroupsControllerTest extends \Test\TestCase {
$groups[] = $thirdGroup;
$groups[] = $fourthGroup;
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -191,7 +192,7 @@ class GroupsControllerTest extends \Test\TestCase {
$groups[] = $thirdGroup;
$groups[] = $fourthGroup;
- $user = $this->getMockBuilder('\OC\User\User')
+ $user = $this->getMockBuilder(User::class)
->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature
index 37e01bcada2..ac2d05fac2c 100644
--- a/tests/acceptance/features/app-files.feature
+++ b/tests/acceptance/features/app-files.feature
@@ -145,6 +145,14 @@ Feature: app-files
Given I am logged in
And I create a new folder named "A name alphabetically lower than welcome.txt"
And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list
+ # To mark the file as favorite the file actions menu has to be shown but, as
+ # the details view is opened automatically when the folder is created,
+ # clicking on the menu trigger could fail if it is covered by the details
+ # view due to its opening animation. Instead of ensuring that the animations
+ # of the contents and the details view have both finished it is easier to
+ # close the details view and wait until it is closed before continuing.
+ And I close the details view
+ And I see that the details view is closed
When I mark "welcome.txt" as favorite
Then I see that "welcome.txt" is marked as favorite
And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list
@@ -153,6 +161,14 @@ Feature: app-files
Given I am logged in
And I create a new folder named "A name alphabetically lower than welcome.txt"
And I see that "A name alphabetically lower than welcome.txt" precedes "welcome.txt" in the file list
+ # To mark the file as favorite the file actions menu has to be shown but, as
+ # the details view is opened automatically when the folder is created,
+ # clicking on the menu trigger could fail if it is covered by the details
+ # view due to its opening animation. Instead of ensuring that the animations
+ # of the contents and the details view have both finished it is easier to
+ # close the details view and wait until it is closed before continuing.
+ And I close the details view
+ And I see that the details view is closed
And I mark "welcome.txt" as favorite
And I see that "welcome.txt" is marked as favorite
And I see that "welcome.txt" precedes "A name alphabetically lower than welcome.txt" in the file list
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index bb088c0a2c3..338823a9478 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -80,6 +80,15 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function closeDetailsViewButton() {
+ return Locator::forThe()->css(".icon-close")->
+ descendantOf(self::currentSectionDetailsView())->
+ describedAs("Close current section details view in Files app");
+ }
+
+ /**
+ * @return Locator
+ */
public static function fileDetailsInCurrentSectionDetailsViewWithText($fileDetailsText) {
return Locator::forThe()->xpath("//span[normalize-space() = '$fileDetailsText']")->
descendantOf(self::fileDetailsInCurrentSectionDetailsView())->
@@ -278,16 +287,16 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
- public static function favoriteActionForFile($fileName) {
- return Locator::forThe()->css(".action-favorite")->descendantOf(self::rowForFile($fileName))->
- describedAs("Favorite action for file $fileName in Files app");
+ public static function favoriteMarkForFile($fileName) {
+ return Locator::forThe()->css(".favorite-mark")->descendantOf(self::rowForFile($fileName))->
+ describedAs("Favorite mark for file $fileName in Files app");
}
/**
* @return Locator
*/
public static function notFavoritedStateIconForFile($fileName) {
- return Locator::forThe()->css(".icon-star")->descendantOf(self::favoriteActionForFile($fileName))->
+ return Locator::forThe()->css(".icon-star")->descendantOf(self::favoriteMarkForFile($fileName))->
describedAs("Not favorited state icon for file $fileName in Files app");
}
@@ -295,7 +304,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function favoritedStateIconForFile($fileName) {
- return Locator::forThe()->css(".icon-starred")->descendantOf(self::favoriteActionForFile($fileName))->
+ return Locator::forThe()->css(".icon-starred")->descendantOf(self::favoriteMarkForFile($fileName))->
describedAs("Favorited state icon for file $fileName in Files app");
}
@@ -341,6 +350,20 @@ class FilesAppContext implements Context, ActorAwareInterface {
/**
* @return Locator
*/
+ public static function addToFavoritesMenuItem() {
+ return self::fileActionsMenuItemFor("Add to favorites");
+ }
+
+ /**
+ * @return Locator
+ */
+ public static function removeFromFavoritesMenuItem() {
+ return self::fileActionsMenuItemFor("Remove from favorites");
+ }
+
+ /**
+ * @return Locator
+ */
public static function viewFileInFolderMenuItem() {
return self::fileActionsMenuItemFor("View in folder");
}
@@ -374,6 +397,13 @@ class FilesAppContext implements Context, ActorAwareInterface {
}
/**
+ * @Given I close the details view
+ */
+ public function iCloseTheDetailsView() {
+ $this->actor->find(self::closeDetailsViewButton(), 10)->click();
+ }
+
+ /**
* @Given I open the input field for tags in the details view
*/
public function iOpenTheInputFieldForTagsInTheDetailsView() {
@@ -393,7 +423,9 @@ class FilesAppContext implements Context, ActorAwareInterface {
public function iMarkAsFavorite($fileName) {
$this->iSeeThatIsNotMarkedAsFavorite($fileName);
- $this->actor->find(self::favoriteActionForFile($fileName), 10)->click();
+ $this->actor->find(self::fileActionsMenuButtonForFile($fileName), 10)->click();
+
+ $this->actor->find(self::addToFavoritesMenuItem(), 2)->click();
}
/**
@@ -402,7 +434,9 @@ class FilesAppContext implements Context, ActorAwareInterface {
public function iUnmarkAsFavorite($fileName) {
$this->iSeeThatIsMarkedAsFavorite($fileName);
- $this->actor->find(self::favoriteActionForFile($fileName), 10)->click();
+ $this->actor->find(self::fileActionsMenuButtonForFile($fileName), 10)->click();
+
+ $this->actor->find(self::removeFromFavoritesMenuItem(), 2)->click();
}
/**
diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh
index 1b68f8655ae..89fdda02630 100755
--- a/tests/acceptance/run.sh
+++ b/tests/acceptance/run.sh
@@ -138,7 +138,7 @@ function prepareDocker() {
# Selenium server.
# The container exits immediately if no command is given, so a Bash session
# is created to prevent that.
- docker run --detach --name=$NEXTCLOUD_LOCAL_CONTAINER --network=container:$SELENIUM_CONTAINER --interactive --tty nextcloudci/php7.0:php7.0-7 bash
+ docker run --detach --name=$NEXTCLOUD_LOCAL_CONTAINER --network=container:$SELENIUM_CONTAINER --interactive --tty nextcloudci/php7.1:php7.1-15 bash
# Use the $TMPDIR or, if not set, fall back to /tmp.
NEXTCLOUD_LOCAL_TAR="$($MKTEMP --tmpdir="${TMPDIR:-/tmp}" --suffix=.tar nextcloud-local-XXXXXXXXXX)"
diff --git a/tests/lib/Collaboration/Collaborators/SearchResultTest.php b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
new file mode 100644
index 00000000000..90ea90237a1
--- /dev/null
+++ b/tests/lib/Collaboration/Collaborators/SearchResultTest.php
@@ -0,0 +1,105 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Joas Schilling
+ *
+ * @author Joas Schilling <coding@schilljs.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Test\Collaboration\Collaborators;
+
+
+use OC\Collaboration\Collaborators\Search;
+use OC\Collaboration\Collaborators\SearchResult;
+use OCP\Collaboration\Collaborators\ISearch;
+use OCP\Collaboration\Collaborators\ISearchPlugin;
+use OCP\Collaboration\Collaborators\SearchResultType;
+use OCP\IContainer;
+use OCP\Share;
+use Test\TestCase;
+
+class SearchResultTest extends TestCase {
+ /** @var IContainer|\PHPUnit_Framework_MockObject_MockObject */
+ protected $container;
+ /** @var ISearch */
+ protected $search;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->container = $this->createMock(IContainer::class);
+
+ $this->search = new Search($this->container);
+ }
+
+ public function dataAddResultSet() {
+ return [
+ [[], ['exact' => []]],
+ [['users' => ['exact' => null, 'loose' => []]], ['exact' => ['users' => []], 'users' => []]],
+ [['groups' => ['exact' => null, 'loose' => ['l1']]], ['exact' => ['groups' => []], 'groups' => ['l1']]],
+ [['users' => ['exact' => ['e1'], 'loose' => []]], ['exact' => ['users' => ['e1']], 'users' => []]],
+ ];
+ }
+
+ /**
+ * @dataProvider dataAddResultSet
+ * @param array $toAdd
+ * @param array $expected
+ */
+ public function testAddResultSet(array $toAdd, array $expected) {
+ $result = new SearchResult();
+
+ foreach ($toAdd as $type => $results) {
+ $result->addResultSet(new SearchResultType($type), $results['loose'], $results['exact']);
+ }
+
+ $this->assertEquals($expected, $result->asArray());
+ }
+
+ public function dataHasResult() {
+ $result = ['value' => ['shareWith' => 'l1']];
+ return [
+ [[],'users', 'n1', false],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l1', true],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'users', 'l2', false],
+ [['users' => ['exact' => null, 'loose' => [$result]]], 'groups', 'l1', false],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l1', true],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'users', 'l2', false],
+ [['users' => ['exact' => [$result], 'loose' => []]], 'groups', 'l1', false],
+
+ ];
+ }
+
+ /**
+ * @dataProvider dataHasResult
+ * @param array $toAdd
+ * @param string $type
+ * @param string $id
+ * @param bool $expected
+ */
+ public function testHasResult(array $toAdd, $type, $id, $expected) {
+ $result = new SearchResult();
+
+ foreach ($toAdd as $addType => $results) {
+ $result->addResultSet(new SearchResultType($addType), $results['loose'], $results['exact']);
+ }
+
+ $this->assertSame($expected, $result->hasResult(new SearchResultType($type), $id));
+ }
+
+}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index e4f45c4bb86..ea718240c5e 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -41,6 +41,9 @@ class MigratorTest extends \Test\TestCase {
/** @var string */
private $tableName;
+ /** @var string */
+ private $tableNameTmp;
+
protected function setUp() {
parent::setUp();
@@ -50,11 +53,23 @@ class MigratorTest extends \Test\TestCase {
$this->markTestSkipped('DB migration tests are not supported on OCI');
}
$this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
- $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
+ $this->tableName = $this->getUniqueTableName();
+ $this->tableNameTmp = $this->getUniqueTableName();
+ }
+
+ private function getUniqueTableName() {
+ return strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
}
protected function tearDown() {
- $this->connection->exec('DROP TABLE ' . $this->tableName);
+ // Try to delete if exists (IF EXISTS NOT SUPPORTED IN ORACLE)
+ try {
+ $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableNameTmp));
+ } catch (\Doctrine\DBAL\DBALException $e) {}
+
+ try {
+ $this->connection->exec('DROP TABLE ' . $this->connection->quoteIdentifier($this->tableName));
+ } catch (\Doctrine\DBAL\DBALException $e) {}
parent::tearDown();
}
@@ -200,4 +215,24 @@ class MigratorTest extends \Test\TestCase {
$this->assertTrue(true);
}
+
+ public function testAddingForeignKey() {
+ $startSchema = new Schema([], [], $this->getSchemaConfig());
+ $table = $startSchema->createTable($this->tableName);
+ $table->addColumn('id', 'integer', ['autoincrement' => true]);
+ $table->addColumn('name', 'string');
+ $table->setPrimaryKey(['id']);
+
+ $fkName = "fkc";
+ $tableFk = $startSchema->createTable($this->tableNameTmp);
+ $tableFk->addColumn('fk_id', 'integer');
+ $tableFk->addColumn('name', 'string');
+ $tableFk->addForeignKeyConstraint($this->tableName, array('fk_id'), array('id'), array(), $fkName);
+
+ $migrator = $this->manager->getMigrator();
+ $migrator->migrate($startSchema);
+
+
+ $this->assertTrue($startSchema->getTable($this->tableNameTmp)->hasForeignKey($fkName));
+ }
}
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index c52619c3b12..06c5e0e2df8 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -28,9 +28,13 @@ use OC\Encryption\Exceptions\DecryptionFailedException;
use OC\Encryption\Manager;
use OC\Files\FileInfo;
use OC\Files\View;
+use OCP\Files\Storage;
use OCP\IUserManager;
use OCP\UserInterface;
use Symfony\Component\Console\Formatter\OutputFormatterInterface;
+use Symfony\Component\Console\Helper\ProgressBar;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
/**
@@ -70,11 +74,11 @@ class DecryptAllTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder('OC\Encryption\Manager')
->disableOriginalConstructor()->getMock();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
- $this->inputInterface = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')
+ $this->inputInterface = $this->getMockBuilder(InputInterface::class)
->disableOriginalConstructor()->getMock();
- $this->outputInterface = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')
+ $this->outputInterface = $this->getMockBuilder(OutputInterface::class)
->disableOriginalConstructor()->getMock();
$this->userInterface = $this->getMockBuilder(UserInterface::class)
->disableOriginalConstructor()->getMock();
@@ -253,11 +257,11 @@ class DecryptAllTest extends TestCase {
->setMethods(['decryptFile'])
->getMock();
- $storage = $this->getMockBuilder('OCP\Files\Storage')
+ $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock();
- $sharedStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $sharedStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()->getMock();
$sharedStorage->expects($this->once())->method('instanceOfStorage')
@@ -296,7 +300,7 @@ class DecryptAllTest extends TestCase {
->method('decryptFile')
->with('/user1/files/foo/subfile');
- $progressBar = $this->getMockBuilder('Symfony\Component\Console\Helper\ProgressBar')
+ $progressBar = $this->getMockBuilder(ProgressBar::class)
->disableOriginalConstructor()->getMock();
$this->invokePrivate($instance, 'decryptUsersFiles', ['user1', $progressBar, '']);
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 6a6a3db2f68..d20efa8821f 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -26,6 +26,7 @@ namespace Test\Encryption;
use OC\Encryption\EncryptionWrapper;
use OC\Encryption\Manager;
use OC\Memcache\ArrayCache;
+use OCP\Files\Storage;
use OCP\ILogger;
use Test\TestCase;
@@ -59,7 +60,7 @@ class EncryptionWrapperTest extends TestCase {
* @dataProvider provideWrapStorage
*/
public function testWrapStorage($expectedWrapped, $wrappedStorages) {
- $storage = $this->getMockBuilder('OC\Files\Storage\Storage')
+ $storage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index a5924d1dc88..cd8f1e9b953 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -24,6 +24,7 @@
namespace Test\Encryption\Keys;
use OC\Encryption\Keys\Storage;
+use OC\Files\View;
use OCP\IConfig;
use Test\TestCase;
@@ -48,7 +49,7 @@ class StorageTest extends TestCase {
->disableOriginalConstructor()
->getMock();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Encryption/UpdateTest.php b/tests/lib/Encryption/UpdateTest.php
index ccd2bb796fc..a8cbef70d75 100644
--- a/tests/lib/Encryption/UpdateTest.php
+++ b/tests/lib/Encryption/UpdateTest.php
@@ -24,6 +24,7 @@ namespace Test\Encryption;
use OC\Encryption\Update;
+use OC\Files\Mount\Manager;
use OC\Files\View;
use Test\TestCase;
@@ -60,7 +61,7 @@ class UpdateTest extends TestCase {
->disableOriginalConstructor()->getMock();
$this->util = $this->getMockBuilder('\OC\Encryption\Util')
->disableOriginalConstructor()->getMock();
- $this->mountManager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->mountManager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()->getMock();
$this->encryptionManager = $this->getMockBuilder('\OC\Encryption\Manager')
->disableOriginalConstructor()->getMock();
diff --git a/tests/lib/Encryption/UtilTest.php b/tests/lib/Encryption/UtilTest.php
index e313274516e..1e1b21d3671 100644
--- a/tests/lib/Encryption/UtilTest.php
+++ b/tests/lib/Encryption/UtilTest.php
@@ -3,6 +3,7 @@
namespace Test\Encryption;
use OC\Encryption\Util;
+use OC\Files\View;
use OCP\Encryption\IEncryptionModule;
use OCP\IConfig;
use Test\TestCase;
@@ -33,7 +34,7 @@ class UtilTest extends TestCase {
public function setUp() {
parent::setUp();
- $this->view = $this->getMockBuilder('OC\Files\View')
+ $this->view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/FileChunkingTest.php b/tests/lib/FileChunkingTest.php
index cf0fed251a4..42fc820c5d0 100644
--- a/tests/lib/FileChunkingTest.php
+++ b/tests/lib/FileChunkingTest.php
@@ -47,7 +47,7 @@ class FileChunkingTest extends \Test\TestCase {
* @param $expected
*/
public function testIsComplete($total, array $present, $expected) {
- $fileChunking = $this->getMockBuilder('\OC_FileChunking')
+ $fileChunking = $this->getMockBuilder(\OC_FileChunking::class)
->setMethods(['getCache'])
->setConstructorArgs([[
'name' => 'file',
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index ec043c7b81e..6479dad58d3 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -786,7 +786,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
@@ -847,7 +847,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
@@ -906,7 +906,7 @@ class FolderTest extends NodeTest {
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
->getMock();
/** @var \PHPUnit_Framework_MockObject_MockObject|\OC\Files\FileInfo $folderInfo */
- $folderInfo = $this->getMockBuilder('\OC\Files\FileInfo')
+ $folderInfo = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()->getMock();
$baseTime = 1000;
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index 160787411f1..9200ae69f75 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -9,6 +9,7 @@
namespace Test\Files\Node;
use OC\Files\FileInfo;
+use OC\Files\Mount\Manager;
use OC\Files\View;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\IRootFolder;
@@ -52,7 +53,7 @@ abstract class NodeTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlGenerator);
- $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->manager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
$this->view = $this->getMockBuilder(View::class)
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 2f81a96d486..fd050c8d90c 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -47,7 +47,7 @@ class RootTest extends \Test\TestCase {
->getMock();
$this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlgenerator);
- $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager')
+ $this->manager = $this->getMockBuilder(Manager::class)
->disableOriginalConstructor()
->getMock();
$this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache')
diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
index 459abf3b64c..c184752ff7e 100644
--- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
+++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php
@@ -719,7 +719,7 @@ class EncryptionTest extends Storage {
}
public function testCopyBetweenStorageMinimumEncryptedVersion() {
- $storage2 = $this->getMockBuilder('OCP\Files\Storage')
+ $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
@@ -768,7 +768,7 @@ class EncryptionTest extends Storage {
* @param bool $expectedEncrypted
*/
public function testCopyBetweenStorage($encryptionEnabled, $mountPointEncryptionEnabled, $expectedEncrypted) {
- $storage2 = $this->getMockBuilder('OCP\Files\Storage')
+ $storage2 = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
@@ -830,11 +830,11 @@ class EncryptionTest extends Storage {
*/
public function testCopyBetweenStorageVersions($sourceInternalPath, $targetInternalPath, $copyResult, $encrypted) {
- $sourceStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $sourceStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
- $targetStorage = $this->getMockBuilder('OCP\Files\Storage')
+ $targetStorage = $this->getMockBuilder(Storage::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php
index 295b9bf9fac..1d01a96fcc0 100644
--- a/tests/lib/Files/Type/DetectionTest.php
+++ b/tests/lib/Files/Type/DetectionTest.php
@@ -84,6 +84,8 @@ class DetectionTest extends \Test\TestCase {
$this->assertEquals('application/octet-stream', $this->detection->detectPath('..hidden'));
$this->assertEquals('application/octet-stream', $this->detection->detectPath('foo'));
$this->assertEquals('application/octet-stream', $this->detection->detectPath(''));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.png.ocTransferId123456789.part'));
+ $this->assertEquals('image/png', $this->detection->detectPath('foo.png.v1234567890'));
}
public function testDetectString() {
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index cab8bd62739..33d5cc0a8a6 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -2350,7 +2350,7 @@ class ViewTest extends \Test\TestCase {
return;
}
- $eventHandler = $this->getMockBuilder('\stdclass')
+ $eventHandler = $this->getMockBuilder(\stdclass::class)
->setMethods(['preCallback', 'postCallback'])
->getMock();
@@ -2425,7 +2425,7 @@ class ViewTest extends \Test\TestCase {
Filesystem::getMountManager()->addMount($mount);
// Listen for events
- $eventHandler = $this->getMockBuilder('\stdclass')
+ $eventHandler = $this->getMockBuilder(\stdclass::class)
->setMethods(['umount', 'post_umount'])
->getMock();
$eventHandler->expects($this->once())
diff --git a/tests/lib/LoggerTest.php b/tests/lib/LoggerTest.php
index da9cedc9f56..3a30bbd1d3b 100644
--- a/tests/lib/LoggerTest.php
+++ b/tests/lib/LoggerTest.php
@@ -138,6 +138,32 @@ class LoggerTest extends TestCase {
}
}
+ /**
+ * @dataProvider userAndPasswordData
+ */
+ public function testDetectclosure($user, $password) {
+ $a = function($user, $password) {
+ throw new \Exception('test');
+ };
+
+ try {
+ $a($user, $password);
+ } catch (\Exception $e) {
+ $this->logger->logException($e);
+ }
+ $logLines = $this->getLogs();
+
+ foreach($logLines as $logLine) {
+ $log = explode('\n', $logLine);
+ unset($log[1]); // Remove `testDetectclosure(` because we are not testing this here, but the closure on stack trace 0
+ $logLine = implode('\n', $log);
+
+ $this->assertNotContains($user, $logLine);
+ $this->assertNotContains($password, $logLine);
+ $this->assertContains('{closure}(*** sensitive parameters replaced ***)', $logLine);
+ }
+ }
+
public function dataGetLogClass() {
return [
['file', \OC\Log\File::class],
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index 6bdb647abc5..2804ad99c0f 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -9,6 +9,7 @@
namespace Test\Security;
use OC\Files\Storage\Temporary;
+use OC\Files\View;
use \OC\Security\CertificateManager;
use OCP\IConfig;
use OCP\ILogger;
@@ -152,7 +153,7 @@ class CertificateManagerTest extends \Test\TestCase {
$expected
) {
- $view = $this->getMockBuilder('OC\Files\View')
+ $view = $this->getMockBuilder(View::class)
->disableOriginalConstructor()->getMock();
$config = $this->createMock(IConfig::class);
diff --git a/tests/lib/Session/CryptoWrappingTest.php b/tests/lib/Session/CryptoWrappingTest.php
index e1fadbf933f..f34148fb50e 100644
--- a/tests/lib/Session/CryptoWrappingTest.php
+++ b/tests/lib/Session/CryptoWrappingTest.php
@@ -22,6 +22,7 @@
namespace Test\Session;
use OC\Session\CryptoSessionData;
+use OCP\ISession;
use Test\TestCase;
class CryptoWrappingTest extends TestCase {
@@ -37,7 +38,7 @@ class CryptoWrappingTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->wrappedSession = $this->getMockBuilder('OCP\ISession')
+ $this->wrappedSession = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor()
->getMock();
$this->crypto = $this->getMockBuilder('OCP\Security\ICrypto')