Skip to content

Commit 9a26169

Browse files
committed
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>
1 parent e56e42e commit 9a26169

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

tests/lib/Files/Cache/WatcherTest.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212
use OC\Files\Cache\Watcher;
1313
use OC\Files\Storage\Storage;
1414
use OC\Files\Storage\Temporary;
15+
use OCP\Files\Cache\ICache;
16+
use OCP\Files\Cache\IScanner;
1517
use OCP\Files\Cache\IWatcher;
1618
use OCP\Files\Storage\IStorage;
1719
use PHPUnit\Framework\Attributes\DataProvider;
20+
use PHPUnit\Framework\Attributes\Group;
21+
use PHPUnit\Framework\Attributes\Medium;
22+
use Test\TestCase;
1823

19-
/**
20-
* Class WatcherTest
21-
*
22-
*
23-
* @package Test\Files\Cache
24-
*/
25-
#[\PHPUnit\Framework\Attributes\Medium]
26-
#[\PHPUnit\Framework\Attributes\Group('DB')]
27-
class WatcherTest extends \Test\TestCase {
24+
#[Medium]
25+
#[Group(name: 'DB')]
26+
class WatcherTest extends TestCase {
2827
/**
2928
* @var Storage[] $storages
3029
*/
31-
private $storages = [];
30+
private array $storages = [];
3231

3332
protected function setUp(): void {
3433
parent::setUp();
@@ -175,11 +174,7 @@ public function testPolicyAlways(): void {
175174
$this->assertTrue($updater->checkUpdate('foo.txt'));
176175
}
177176

178-
/**
179-
* @param bool $scan
180-
* @return Storage
181-
*/
182-
private function getTestStorage($scan = true) {
177+
private function getTestStorage(bool $scan = true): IStorage {
183178
$storage = new Temporary([]);
184179
$textData = "dummy file data\n";
185180
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png');
@@ -217,11 +212,15 @@ public static function checkFilterProvider(): array {
217212
];
218213
}
219214

220-
#[DataProvider('checkFilterProvider')]
221-
public function testCheckFilter($filter, $paths) {
215+
#[DataProvider(methodName: 'checkFilterProvider')]
216+
public function testCheckFilter(?string $filter, array $paths): void {
222217
$storage = $this->createMock(IStorage::class);
223218
$storage->method('hasUpdated')
224219
->willReturn(true);
220+
$storage->method('getCache')
221+
->willReturn($this->createMock(ICache::class));
222+
$storage->method('getScanner')
223+
->willReturn($this->createMock(IScanner::class));
225224
$watcher = new Watcher($storage);
226225
$watcher->setPolicy(IWatcher::CHECK_ALWAYS);
227226

0 commit comments

Comments
 (0)