Skip to content
Snippets Groups Projects
Unverified Commit e5ddb40a authored by Julius Haertl's avatar Julius Haertl
Browse files

Add test for creating AppData folder


Signed-off-by: default avatarJulius Haertl <jus@bitgrid.net>
parent 3f013462
No related branches found
No related tags found
No related merge requests found
...@@ -171,7 +171,15 @@ class ThemingControllerTest extends TestCase { ...@@ -171,7 +171,15 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->updateLogo()); $this->assertEquals($expected, $this->themingController->updateLogo());
} }
public function testUpdateLogoNormalLogoUpload() { public function dataUpdateImages() {
return [
[false],
[true]
];
}
/** @dataProvider dataUpdateImages */
public function testUpdateLogoNormalLogoUpload($folderExists) {
$tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg'; $tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg';
$destination = \OC::$server->getTempManager()->getTemporaryFolder(); $destination = \OC::$server->getTempManager()->getTemporaryFolder();
...@@ -199,16 +207,28 @@ class ThemingControllerTest extends TestCase { ...@@ -199,16 +207,28 @@ class ThemingControllerTest extends TestCase {
$file = $this->createMock(ISimpleFile::class); $file = $this->createMock(ISimpleFile::class);
$folder = $this->createMock(ISimpleFolder::class); $folder = $this->createMock(ISimpleFolder::class);
$this->appData if($folderExists) {
->expects($this->once()) $this->appData
->method('getFolder') ->expects($this->once())
->with('images') ->method('getFolder')
->willReturn($folder); ->with('images')
->willReturn($folder);
} else {
$this->appData
->expects($this->at(0))
->method('getFolder')
->with('images')
->willThrowException(new NotFoundException());
$this->appData
->expects($this->at(1))
->method('newFolder')
->with('images')
->willReturn($folder);
}
$folder->expects($this->once()) $folder->expects($this->once())
->method('newFile') ->method('newFile')
->with('logo') ->with('logo')
->willReturn($file); ->willReturn($file);
$expected = new DataResponse( $expected = new DataResponse(
[ [
'data' => 'data' =>
...@@ -223,7 +243,8 @@ class ThemingControllerTest extends TestCase { ...@@ -223,7 +243,8 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->updateLogo()); $this->assertEquals($expected, $this->themingController->updateLogo());
} }
public function testUpdateLogoLoginScreenUpload() { /** @dataProvider dataUpdateImages */
public function testUpdateLogoLoginScreenUpload($folderExists) {
$tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg'; $tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg';
touch($tmpLogo); touch($tmpLogo);
...@@ -250,11 +271,24 @@ class ThemingControllerTest extends TestCase { ...@@ -250,11 +271,24 @@ class ThemingControllerTest extends TestCase {
$file = $this->createMock(ISimpleFile::class); $file = $this->createMock(ISimpleFile::class);
$folder = $this->createMock(ISimpleFolder::class); $folder = $this->createMock(ISimpleFolder::class);
$this->appData if($folderExists) {
->expects($this->once()) $this->appData
->method('getFolder') ->expects($this->once())
->with('images') ->method('getFolder')
->willReturn($folder); ->with('images')
->willReturn($folder);
} else {
$this->appData
->expects($this->at(0))
->method('getFolder')
->with('images')
->willThrowException(new NotFoundException());
$this->appData
->expects($this->at(1))
->method('newFolder')
->with('images')
->willReturn($folder);
}
$folder->expects($this->once()) $folder->expects($this->once())
->method('newFile') ->method('newFile')
->with('background') ->with('background')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment