]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use createMock
authorJulius Haertl <jus@bitgrid.net>
Thu, 9 Feb 2017 21:51:05 +0000 (22:51 +0100)
committerJulius Haertl <jus@bitgrid.net>
Thu, 16 Feb 2017 14:13:39 +0000 (15:13 +0100)
Signed-off-by: Julius Haertl <jus@bitgrid.net>
apps/theming/tests/Controller/ThemingControllerTest.php
apps/theming/tests/Migration/ThemingImages.php

index 0c47ac972b7812eb6c959efb4c8b0d4a485d2a58..38cd8c96202761d3a1403abe8e84d9e720ef9e6a 100644 (file)
@@ -68,22 +68,19 @@ class ThemingControllerTest extends TestCase {
        private $appData;
 
        public function setUp() {
-               $this->request = $this->getMockBuilder(IRequest::class)->getMock();
-               $this->config = $this->getMockBuilder(IConfig::class)->getMock();
-               $this->template = $this->getMockBuilder(ThemingDefaults::class)
-                       ->disableOriginalConstructor()->getMock();
-               $this->timeFactory = $this->getMockBuilder(ITimeFactory::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $this->l10n = $this->getMockBuilder(L10N::class)->getMock();
-               $this->rootFolder = $this->getMockBuilder(IRootFolder::class)->getMock();
-               $this->appManager = $this->getMockBuilder(IAppManager::class)->getMock();
+               $this->request = $this->createMock(IRequest::class);
+               $this->config = $this->createMock(IConfig::class);
+               $this->template = $this->createMock(ThemingDefaults::class);
+               $this->timeFactory = $this->createMock(ITimeFactory::class);
+               $this->l10n = $this->createMock(L10N::class);
+               $this->rootFolder = $this->createMock(IRootFolder::class);
+               $this->appManager = $this->createMock(IAppManager::class);
                $this->util = new Util($this->config, $this->rootFolder, $this->appManager);
                $this->timeFactory->expects($this->any())
                        ->method('getTime')
                        ->willReturn(123);
                $this->tempManager = \OC::$server->getTempManager();
-               $this->appData = $this->getMockBuilder(IAppData::class)->getMock();
+               $this->appData = $this->createMock(IAppData::class);
 
                $this->themingController = new ThemingController(
                        'theming',
@@ -200,12 +197,8 @@ class ThemingControllerTest extends TestCase {
                        ->willReturn('Saved');
 
 
-               $file = $this->getMockBuilder(ISimpleFile::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $folder = $this->getMockBuilder(ISimpleFolder::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
+               $file = $this->createMock(ISimpleFile::class);
+               $folder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
@@ -255,12 +248,8 @@ class ThemingControllerTest extends TestCase {
                        ->with('Saved')
                        ->willReturn('Saved');
 
-               $file = $this->getMockBuilder(ISimpleFile::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $folder = $this->getMockBuilder(ISimpleFolder::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
+               $file = $this->createMock(ISimpleFile::class);
+               $folder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
@@ -309,9 +298,7 @@ class ThemingControllerTest extends TestCase {
                        ->with('Unsupported image type')
                        ->willReturn('Unsupported image type');
 
-               $folder = $this->getMockBuilder(ISimpleFolder::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
+               $folder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
@@ -366,12 +353,8 @@ class ThemingControllerTest extends TestCase {
        }
 
        public function testGetLogo() {
-               $file = $this->getMockBuilder(ISimpleFile::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $folder = $this->getMockBuilder(ISimpleFolder::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
+               $file = $this->createMock(ISimpleFile::class);
+               $folder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
@@ -409,12 +392,8 @@ class ThemingControllerTest extends TestCase {
        }
 
        public function testGetLoginBackground() {
-               $file = $this->getMockBuilder(ISimpleFile::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
-               $folder = $this->getMockBuilder(ISimpleFolder::class)
-                       ->disableOriginalConstructor()
-                       ->getMock();
+               $file = $this->createMock(ISimpleFile::class);
+               $folder = $this->createMock(ISimpleFolder::class);
                $this->appData
                        ->expects($this->once())
                        ->method('getFolder')
index e5e3b1df5d3e83f9e2449ab781ad6d788baa4dd7..e15d0fd1bbc38dcd73a316dc1c492f3e65d02ac6 100644 (file)
@@ -47,11 +47,11 @@ class ThemingImagesTest extends TestCase {
 
        public function setUp() {
                parent::setUp();
-               $this->appData = $this->getMockBuilder(IAppData::class)->getMock();
-               $this->rootFolder = $this->getMockBuilder(IRootFolder::class)->getMock();
+               $this->appData = $this->createMock(IAppData::class);
+               $this->rootFolder = $this->createMock(IRootFolder::class);
                $this->repairStep = new ThemingImages($this->appData, $this->rootFolder);
-               $this->imageFolder = $this->getMockBuilder(ISimpleFolder::class)->getMock();
-               $this->output = $this->getMockBuilder(IOutput::class)->getMock();
+               $this->imageFolder = $this->createMock(ISimpleFolder::class);
+               $this->output = $this->createMock(IOutput::class);
        }
 
        public function testGetName() {
@@ -76,8 +76,8 @@ class ThemingImagesTest extends TestCase {
        }
 
        public function testRunLogo() {
-               $oldFile = $this->getMockBuilder(File::class)->getMock();
-               $newFile = $this->getMockBuilder(ISimpleFile::class)->getMock();
+               $oldFile = $this->createMock(File::class);
+               $newFile = $this->createMock(ISimpleFile::class);
 
                $this->appData->expects($this->once())
                        ->method('newFolder')
@@ -107,8 +107,8 @@ class ThemingImagesTest extends TestCase {
        }
 
        public function testRunBackground() {
-               $oldFile = $this->getMockBuilder(File::class)->getMock();
-               $newFile = $this->getMockBuilder(ISimpleFile::class)->getMock();
+               $oldFile = $this->createMock(File::class);
+               $newFile = $this->createMock(ISimpleFile::class);
                
                $this->appData->expects($this->once())
                        ->method('newFolder')