ManagerTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\Collaboration\Resources;
  8. use OC\Collaboration\Resources\Manager;
  9. use OCP\Collaboration\Resources\IManager;
  10. use OCP\Collaboration\Resources\IProviderManager;
  11. use OCP\IDBConnection;
  12. use PHPUnit\Framework\MockObject\MockObject;
  13. use Psr\Log\LoggerInterface;
  14. use Test\TestCase;
  15. class ManagerTest extends TestCase {
  16. protected LoggerInterface&MockObject $logger;
  17. protected IProviderManager&MockObject $providerManager;
  18. protected IManager $manager;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->logger = $this->createMock(LoggerInterface::class);
  22. $this->providerManager = $this->createMock(IProviderManager::class);
  23. /** @var IDBConnection $connection */
  24. $connection = $this->createMock(IDBConnection::class);
  25. $this->manager = new Manager($connection, $this->providerManager, $this->logger);
  26. }
  27. public function testRegisterResourceProvider(): void {
  28. $this->logger->expects($this->once())
  29. ->method('debug')
  30. ->with($this->equalTo('\OC\Collaboration\Resources\Manager::registerResourceProvider is deprecated'), $this->equalTo(['provider' => 'AwesomeResourceProvider']));
  31. $this->providerManager->expects($this->once())
  32. ->method('registerResourceProvider')
  33. ->with($this->equalTo('AwesomeResourceProvider'));
  34. $this->manager->registerResourceProvider('AwesomeResourceProvider');
  35. }
  36. }