ScannerTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_Sharing\Tests\External;
  8. use OCA\Files_Sharing\External\Scanner;
  9. use Test\TestCase;
  10. /**
  11. * @group DB
  12. */
  13. class ScannerTest extends TestCase {
  14. protected Scanner $scanner;
  15. /** @var \OCA\Files_Sharing\External\Storage|\PHPUnit\Framework\MockObject\MockObject */
  16. protected $storage;
  17. /** @var \OC\Files\Cache\Cache|\PHPUnit\Framework\MockObject\MockObject */
  18. protected $cache;
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->storage = $this->getMockBuilder('\OCA\Files_Sharing\External\Storage')
  22. ->disableOriginalConstructor()
  23. ->getMock();
  24. $this->cache = $this->getMockBuilder('\OC\Files\Cache\Cache')
  25. ->disableOriginalConstructor()
  26. ->getMock();
  27. $this->storage->expects($this->any())
  28. ->method('getCache')
  29. ->willReturn($this->cache);
  30. $this->scanner = new Scanner($this->storage);
  31. }
  32. public function testScan() {
  33. $this->storage->expects($this->any())
  34. ->method('getShareInfo')
  35. ->willReturn(['status' => 'success', 'data' => []]);
  36. // FIXME add real tests, we are currently only checking for
  37. // Declaration of OCA\Files_Sharing\External\Scanner::*() should be
  38. // compatible with OC\Files\Cache\Scanner::*()
  39. $this->scanner->scan('test', Scanner::SCAN_RECURSIVE);
  40. $this->addToAssertionCount(1);
  41. }
  42. public function testScanFile() {
  43. // FIXME add real tests, we are currently only checking for
  44. // Declaration of OCA\Files_Sharing\External\Scanner::*() should be
  45. // compatible with OC\Files\Cache\Scanner::*()
  46. $this->scanner->scanFile('test', Scanner::SCAN_RECURSIVE);
  47. $this->addToAssertionCount(1);
  48. }
  49. }