Use createMock

Signed-off-by: Julius Haertl <jus@bitgrid.net>
This commit is contained in:
Julius Haertl 2017-02-09 22:51:05 +01:00
parent b2cbe3530d
commit 3f0134622d
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 25 additions and 46 deletions

View 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')

View 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')