private $logger;
/** @var ITempManager|MockObject */
private $tempManager;
+ /** @var ISimpleFolder|MockObject */
+ private $rootFolder;
protected function setUp(): void {
parent::setUp();
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->logger = $this->createMock(ILogger::class);
$this->tempManager = $this->createMock(ITempManager::class);
+ $this->rootFolder = $this->createMock(ISimpleFolder::class);
$this->imageManager = new ImageManager(
$this->config,
$this->appData,
$this->logger,
$this->tempManager
);
+ $this->appData
+ ->expects($this->any())
+ ->method('getFolder')
+ ->with('global')
+ ->willReturn($this->rootFolder);
}
private function checkImagick() {
->willReturn($newFile);
$newFile->expects($this->once())
->method('putContent');
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getFolder')
->with('images')
->willReturn($folder);
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getFolder')
->with('0')
->willReturn($folder);
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
- $this->appData->expects($this->exactly(2))
+ $this->rootFolder->expects($this->exactly(2))
->method('getFolder')
->with('0')
->willReturnOnConsecutiveCalls(
$this->throwException(new NotFoundException()),
$folder,
);
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('newFolder')
->with('0')
->willReturn($folder);
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getDirectoryListing')
->willReturn([]);
$this->assertEquals($folder, $this->imageManager->getCacheFolder());
->method('getAppValue')
->with('theming', 'cachebuster', '0')
->willReturn('0');
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getFolder')
->with('0')
->willReturn($folder);
->method('getAppValue')
->with('theming','cachebuster','0')
->willReturn('2');
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getDirectoryListing')
->willReturn($folders);
- $this->appData->expects($this->once())
+ $this->rootFolder->expects($this->once())
->method('getFolder')
->with('2')
->willReturn($folders[2]);
$folder->expects($this->any())
->method('getFile')
->willReturn($oldFile);
+
if ($folderExists) {
- $this->appData
+ $this->rootFolder
->expects($this->any())
->method('getFolder')
->with('images')
->willReturn($folder);
} else {
- $this->appData
+ $this->rootFolder
->expects($this->any())
->method('getFolder')
->with('images')
->willThrowException(new NotFoundException());
- $this->appData
+ $this->rootFolder
->expects($this->any())
->method('newFolder')
->with('images')
->willReturn($folder);
}
+
$folder->expects($this->once())
->method('newFile')
->with($key)
use OCP\Files\Folder;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
+use OCP\Files\SimpleFS\ISimpleFolder;
use Test\Traits\MountProviderTrait;
use Test\Traits\UserTrait;
$this->assertInstanceOf(ISimpleFile::class, $result[0]);
$this->assertInstanceOf(ISimpleFile::class, $result[1]);
}
+
+ public function testGetFolder() {
+ $this->folder->newFolder('exists');
+
+ $result = $this->simpleFolder->getFolder('exists');
+ $this->assertInstanceOf(ISimpleFolder::class, $result);
+
+ $this->expectException(NotFoundException::class);
+ $this->simpleFolder->getFolder('not-exists');
+ }
+
+ public function testNewFolder() {
+ $result = $this->simpleFolder->newFolder('folder');
+ $this->assertInstanceOf(ISimpleFolder::class, $result);
+ $result->newFile('file');
+
+ $this->assertTrue($this->folder->nodeExists('folder'));
+ }
}