mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(WatcherTest): Properly mock getCache and getScanner in IStorage
Otherwise we end up with trying to assign null to a property which has strict types. Signed-off-by: Carl Schwan <carlschwan@kde.org>
This commit is contained in:
parent
e56e42e7e7
commit
9a26169323
1 changed files with 16 additions and 17 deletions
|
|
@ -12,23 +12,22 @@ use OC\Files\Cache\CacheEntry;
|
|||
use OC\Files\Cache\Watcher;
|
||||
use OC\Files\Storage\Storage;
|
||||
use OC\Files\Storage\Temporary;
|
||||
use OCP\Files\Cache\ICache;
|
||||
use OCP\Files\Cache\IScanner;
|
||||
use OCP\Files\Cache\IWatcher;
|
||||
use OCP\Files\Storage\IStorage;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\Group;
|
||||
use PHPUnit\Framework\Attributes\Medium;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
* Class WatcherTest
|
||||
*
|
||||
*
|
||||
* @package Test\Files\Cache
|
||||
*/
|
||||
#[\PHPUnit\Framework\Attributes\Medium]
|
||||
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
||||
class WatcherTest extends \Test\TestCase {
|
||||
#[Medium]
|
||||
#[Group(name: 'DB')]
|
||||
class WatcherTest extends TestCase {
|
||||
/**
|
||||
* @var Storage[] $storages
|
||||
*/
|
||||
private $storages = [];
|
||||
private array $storages = [];
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -175,11 +174,7 @@ class WatcherTest extends \Test\TestCase {
|
|||
$this->assertTrue($updater->checkUpdate('foo.txt'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $scan
|
||||
* @return Storage
|
||||
*/
|
||||
private function getTestStorage($scan = true) {
|
||||
private function getTestStorage(bool $scan = true): IStorage {
|
||||
$storage = new Temporary([]);
|
||||
$textData = "dummy file data\n";
|
||||
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png');
|
||||
|
|
@ -217,11 +212,15 @@ class WatcherTest extends \Test\TestCase {
|
|||
];
|
||||
}
|
||||
|
||||
#[DataProvider('checkFilterProvider')]
|
||||
public function testCheckFilter($filter, $paths) {
|
||||
#[DataProvider(methodName: 'checkFilterProvider')]
|
||||
public function testCheckFilter(?string $filter, array $paths): void {
|
||||
$storage = $this->createMock(IStorage::class);
|
||||
$storage->method('hasUpdated')
|
||||
->willReturn(true);
|
||||
$storage->method('getCache')
|
||||
->willReturn($this->createMock(ICache::class));
|
||||
$storage->method('getScanner')
|
||||
->willReturn($this->createMock(IScanner::class));
|
||||
$watcher = new Watcher($storage);
|
||||
$watcher->setPolicy(IWatcher::CHECK_ALWAYS);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue