1
0

ScannerTest.php 1.8 KB

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