diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-03-21 11:17:14 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-03-24 16:21:26 +0100 |
commit | 61f7f13bd81948f6179bb8f70b6711c002ddd70e (patch) | |
tree | f1238dd97d93203637bb203d4cf649b65c8fbc4a /tests/lib/Files | |
parent | e8c1f75064ae008e50daa087924de5d29368747e (diff) | |
download | nextcloud-server-61f7f13bd81948f6179bb8f70b6711c002ddd70e.tar.gz nextcloud-server-61f7f13bd81948f6179bb8f70b6711c002ddd70e.zip |
Migrate from ILogger to LoggerInterface where needed in the tests
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r-- | tests/lib/Files/Config/UserMountCacheTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/EtagTest.php | 3 | ||||
-rw-r--r-- | tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Files/Node/HookConnectorTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/Node/IntegrationTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Files/Node/NodeTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Files/Node/RootTest.php | 6 | ||||
-rw-r--r-- | tests/lib/Files/Storage/Wrapper/EncryptionTest.php | 13 | ||||
-rw-r--r-- | tests/lib/Files/Type/DetectionTest.php | 8 | ||||
-rw-r--r-- | tests/lib/Files/Utils/ScannerTest.php | 13 |
10 files changed, 34 insertions, 33 deletions
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php index 0922dab3672..f4c6a427abd 100644 --- a/tests/lib/Files/Config/UserMountCacheTest.php +++ b/tests/lib/Files/Config/UserMountCacheTest.php @@ -11,7 +11,6 @@ namespace Test\Files\Config; use OC\DB\QueryBuilder\Literal; use OC\Files\Mount\MountPoint; use OC\Files\Storage\Storage; -use OC\Log; use OC\User\Manager; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\ICachedMountInfo; @@ -19,6 +18,7 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; use Test\Util\User\Dummy; @@ -66,7 +66,7 @@ class UserMountCacheTest extends TestCase { $userBackend->createUser('u2', ''); $userBackend->createUser('u3', ''); $this->userManager->registerBackend($userBackend); - $this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(Log::class)); + $this->cache = new \OC\Files\Config\UserMountCache($this->connection, $this->userManager, $this->createMock(LoggerInterface::class)); } protected function tearDown(): void { diff --git a/tests/lib/Files/EtagTest.php b/tests/lib/Files/EtagTest.php index 39069ce4dfe..43b92c12391 100644 --- a/tests/lib/Files/EtagTest.php +++ b/tests/lib/Files/EtagTest.php @@ -11,6 +11,7 @@ namespace Test\Files; use OC\Files\Filesystem; use OCP\EventDispatcher\IEventDispatcher; use OCA\Files_Sharing\AppInfo\Application; +use Psr\Log\LoggerInterface; /** * Class EtagTest @@ -69,7 +70,7 @@ class EtagTest extends \Test\TestCase { $files = ['/foo.txt', '/folder/bar.txt', '/folder/subfolder', '/folder/subfolder/qwerty.txt']; $originalEtags = $this->getEtags($files); - $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new \OC\Files\Utils\Scanner($user1, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->backgroundScan('/'); $newEtags = $this->getEtags($files); diff --git a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php index 400808d7cd5..ef2ede729ce 100644 --- a/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php +++ b/tests/lib/Files/Mount/ObjectStorePreviewCacheMountProviderTest.php @@ -30,8 +30,8 @@ use OC\Files\ObjectStore\S3; use OC\Files\Storage\StorageFactory; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; -use OCP\ILogger; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; /** * @group DB @@ -43,7 +43,7 @@ class ObjectStorePreviewCacheMountProviderTest extends \Test\TestCase { /** @var ObjectStorePreviewCacheMountProvider */ protected $provider; - /** @var ILogger|MockObject */ + /** @var LoggerInterface|MockObject */ protected $logger; /** @var IConfig|MockObject */ protected $config; @@ -54,7 +54,7 @@ class ObjectStorePreviewCacheMountProviderTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->config = $this->createMock(IConfig::class); $this->loader = $this->createMock(StorageFactory::class); diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php index 5e0b4017243..f99db6599fd 100644 --- a/tests/lib/Files/Node/HookConnectorTest.php +++ b/tests/lib/Files/Node/HookConnectorTest.php @@ -30,9 +30,9 @@ use OCP\Files\Events\Node\NodeRenamedEvent; use OCP\Files\Events\Node\NodeTouchedEvent; use OCP\Files\Events\Node\NodeWrittenEvent; use OCP\Files\Node; -use OCP\ILogger; use OCP\IUserManager; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; @@ -77,7 +77,7 @@ class HookConnectorTest extends TestCase { $this->view, \OC::$server->getUserManager()->get($this->userId), \OC::$server->getUserMountCache(), - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->createMock(IUserManager::class), $this->createMock(IEventDispatcher::class) ); diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index 71e8793ad6f..5ef5a134e1b 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -13,8 +13,8 @@ use OC\Files\Storage\Temporary; use OC\Files\View; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Mount\IMountManager; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Test\Traits\UserTrait; /** @@ -59,7 +59,7 @@ class IntegrationTest extends \Test\TestCase { $this->view, $user, \OC::$server->getUserMountCache(), - $this->createMock(ILogger::class), + $this->createMock(LoggerInterface::class), $this->createMock(IUserManager::class), $this->createMock(IEventDispatcher::class) ); diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php index a60a20b99f3..cc936baacb0 100644 --- a/tests/lib/Files/Node/NodeTest.php +++ b/tests/lib/Files/Node/NodeTest.php @@ -16,9 +16,9 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\Files\Storage; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class NodeTest @@ -36,7 +36,7 @@ abstract class NodeTest extends \Test\TestCase { protected $root; /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit\Framework\MockObject\MockObject */ protected $userMountCache; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $logger; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ protected $userManager; @@ -56,7 +56,7 @@ abstract class NodeTest extends \Test\TestCase { $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->userManager = $this->createMock(IUserManager::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); $this->root = $this->getMockBuilder('\OC\Files\Node\Root') diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index a7f7dc02e01..fe151d70dc3 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -14,9 +14,9 @@ use OC\Files\Mount\Manager; use OC\Files\Node\Folder; use OC\Files\View; use OCP\EventDispatcher\IEventDispatcher; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class RootTest @@ -30,7 +30,7 @@ class RootTest extends \Test\TestCase { private $manager; /** @var \OCP\Files\Config\IUserMountCache|\PHPUnit\Framework\MockObject\MockObject */ private $userMountCache; - /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */ + /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $logger; /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */ private $userManager; @@ -47,7 +47,7 @@ class RootTest extends \Test\TestCase { $this->userMountCache = $this->getMockBuilder('\OCP\Files\Config\IUserMountCache') ->disableOriginalConstructor() ->getMock(); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->userManager = $this->createMock(IUserManager::class); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); } diff --git a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php index 71af8fb7ece..9f63f173129 100644 --- a/tests/lib/Files/Storage/Wrapper/EncryptionTest.php +++ b/tests/lib/Files/Storage/Wrapper/EncryptionTest.php @@ -19,7 +19,7 @@ use OCP\Files\Cache\ICache; use OCP\Files\Mount\IMountPoint; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\Files\Storage\Storage; @@ -151,7 +151,7 @@ class EncryptionTest extends Storage { ->getMock(); $this->file->expects($this->any())->method('getAccessList')->willReturn([]); - $this->logger = $this->createMock(Log::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->sourceStorage = new Temporary([]); @@ -584,7 +584,7 @@ class EncryptionTest extends Storage { $this->arrayCache ] )->getMock(); - + $cache = $this->getMockBuilder('\OC\Files\Cache\Cache') ->disableOriginalConstructor()->getMock(); $cache->expects($this->any()) @@ -607,9 +607,9 @@ class EncryptionTest extends Storage { ) ->setMethods(['getCache','readFirstBlock', 'parseRawHeader']) ->getMock(); - + $instance->expects($this->once())->method('getCache')->willReturn($cache); - + $instance->expects($this->once())->method(('parseRawHeader')) ->willReturn([Util::HEADER_ENCRYPTION_MODULE_KEY => 'OC_DEFAULT_MODULE']); @@ -989,7 +989,6 @@ class EncryptionTest extends Storage { ) { $encryptionManager = $this->createMock(\OC\Encryption\Manager::class); $util = $this->createMock(Util::class); - $logger = $this->createMock(ILogger::class); $fileHelper = $this->createMock(IFile::class); $uid = null; $keyStorage = $this->createMock(IStorage::class); @@ -1007,7 +1006,7 @@ class EncryptionTest extends Storage { ['mountPoint' => '', 'mount' => $mount, 'storage' => ''], $encryptionManager, $util, - $logger, + $this->logger, $fileHelper, $uid, $keyStorage, diff --git a/tests/lib/Files/Type/DetectionTest.php b/tests/lib/Files/Type/DetectionTest.php index a7ac6c8057d..568dbb0cf56 100644 --- a/tests/lib/Files/Type/DetectionTest.php +++ b/tests/lib/Files/Type/DetectionTest.php @@ -22,8 +22,8 @@ namespace Test\Files\Type; use OC\Files\Type\Detection; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class DetectionTest extends \Test\TestCase { /** @var Detection */ @@ -33,7 +33,7 @@ class DetectionTest extends \Test\TestCase { parent::setUp(); $this->detection = new Detection( \OC::$server->getURLGenerator(), - \OC::$server->getLogger(), + \OC::$server->get(LoggerInterface::class), \OC::$SERVERROOT . '/config/', \OC::$SERVERROOT . '/resources/config/' ); @@ -151,8 +151,8 @@ class DetectionTest extends \Test\TestCase { ->disableOriginalConstructor() ->getMock(); - /** @var ILogger $logger */ - $logger = $this->createMock(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $this->createMock(LoggerInterface::class); //Only call the url generator once $urlGenerator->expects($this->once()) diff --git a/tests/lib/Files/Utils/ScannerTest.php b/tests/lib/Files/Utils/ScannerTest.php index 414d38bae06..eb0b9938886 100644 --- a/tests/lib/Files/Utils/ScannerTest.php +++ b/tests/lib/Files/Utils/ScannerTest.php @@ -15,6 +15,7 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\Config\IMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IUser; +use Psr\Log\LoggerInterface; class TestScanner extends \OC\Files\Utils\Scanner { /** @@ -71,7 +72,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -93,7 +94,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -131,7 +132,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('foo.txt', 'qwerty'); $storage->file_put_contents('folder/bar.txt', 'qwerty'); - $scanner = new \OC\Files\Utils\Scanner($uid, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new \OC\Files\Utils\Scanner($uid, \OC::$server->getDatabaseConnection(), \OC::$server->query(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $this->assertFalse($cache->inCache('folder/bar.txt')); $scanner->scan('/' . $uid . '/files/foo'); @@ -163,7 +164,7 @@ class ScannerTest extends \Test\TestCase { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid path to scan'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->scan($invalidPath); } @@ -177,7 +178,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('folder/bar.txt', 'qwerty'); $storage->touch('folder/bar.txt', time() - 200); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan(''); @@ -203,7 +204,7 @@ class ScannerTest extends \Test\TestCase { $storage->file_put_contents('folder/bar.txt', 'qwerty'); $storage->file_put_contents('folder/subfolder/foobar.txt', 'qwerty'); - $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->getLogger()); + $scanner = new TestScanner('', \OC::$server->getDatabaseConnection(), $this->createMock(IEventDispatcher::class), \OC::$server->get(LoggerInterface::class)); $scanner->addMount($mount); $scanner->scan('', $recusive = false); |