Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jun 25, 2018
1 parent 014f76b commit b0f7bef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions tests/unit/Service/AttachmentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use OCP\AppFramework\IAppContainer;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IL10N;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;

Expand Down Expand Up @@ -67,6 +68,8 @@ class AttachmentServiceTest extends TestCase {
private $appContainer;
/** ICache */
private $cache;
/** @var IL10N */
private $l10n;

/**
* @throws \OCP\AppFramework\QueryException
Expand All @@ -91,7 +94,9 @@ public function setUp() {
->method('getContainer')
->willReturn($this->appContainer);

$this->attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $this->application, $this->cacheFactory, $this->userId);
$this->l10n = $this->createMock(IL10N::class);

$this->attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $this->application, $this->cacheFactory, $this->userId, $this->l10n);
}

public function testRegisterAttachmentService() {
Expand All @@ -103,7 +108,7 @@ public function testRegisterAttachmentService() {
$application->expects($this->any())
->method('getContainer')
->willReturn($appContainer);
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId);
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n);
$attachmentService->registerAttachmentService('custom', MyAttachmentService::class);
$this->assertEquals($fileServiceMock, $attachmentService->getService('deck_file'));
$this->assertEquals(MyAttachmentService::class, get_class($attachmentService->getService('custom')));
Expand All @@ -121,7 +126,7 @@ public function testRegisterAttachmentServiceNotExisting() {
$application->expects($this->any())
->method('getContainer')
->willReturn($appContainer);
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId);
$attachmentService = new AttachmentService($this->attachmentMapper, $this->cardMapper, $this->permissionService, $application, $this->cacheFactory, $this->userId, $this->l10n);
$attachmentService->registerAttachmentService('custom', MyAttachmentService::class);
$attachmentService->getService('deck_file_invalid');
}
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/Service/FileServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public function testCreate() {
->willReturn(false);
$file = $this->createMock(ISimpleFile::class);
$file->expects($this->once())
->method('putContent')
->with(file_get_contents(__FILE__, 'r'));
->method('putContent');
// FIXME: test fopen call properly
$folder->expects($this->once())
->method('newFile')
->willReturn($file);
Expand All @@ -202,8 +202,8 @@ public function testCreateNoFolder() {
->willReturn(false);
$file = $this->createMock(ISimpleFile::class);
$file->expects($this->once())
->method('putContent')
->with(file_get_contents(__FILE__, 'r'));
->method('putContent');
// FIXME: test fopen call properly
$folder->expects($this->once())
->method('newFile')
->willReturn($file);
Expand Down Expand Up @@ -231,8 +231,8 @@ public function testUpdate() {
$folder = $this->mockGetFolder(123);
$file = $this->createMock(ISimpleFile::class);
$file->expects($this->once())
->method('putContent')
->with(file_get_contents(__FILE__, 'r'));
->method('putContent');
// FIXME: test fopen call properly
$folder->expects($this->once())
->method('getFile')
->willReturn($file);
Expand Down

0 comments on commit b0f7bef

Please sign in to comment.