@@ -42,7 +42,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
/** @internal Just for testing the service registration */
|
||||
class MyAttachmentService {
|
||||
class MyAttachmentService implements IAttachmentService {
|
||||
public function extendData(Attachment $attachment) {
|
||||
}
|
||||
public function display(Attachment $attachment) {
|
||||
@@ -84,6 +84,10 @@ class AttachmentServiceTest extends TestCase {
|
||||
private $l10n;
|
||||
/** @var ChangeHelper */
|
||||
private $changeHelper;
|
||||
/**
|
||||
* @var IAttachmentService|MockObject
|
||||
*/
|
||||
private $filesAppServiceImpl;
|
||||
|
||||
/**
|
||||
* @throws \OCP\AppFramework\QueryException
|
||||
@@ -92,6 +96,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
parent::setUp();
|
||||
|
||||
$this->attachmentServiceImpl = $this->createMock(IAttachmentService::class);
|
||||
$this->filesAppServiceImpl = $this->createMock(IAttachmentService::class);
|
||||
|
||||
$this->appContainer = $this->createMock(IAppContainer::class);
|
||||
|
||||
$this->attachmentMapper = $this->createMock(AttachmentMapper::class);
|
||||
@@ -105,6 +111,8 @@ class AttachmentServiceTest extends TestCase {
|
||||
$this->cacheFactory->expects($this->any())->method('createDistributed')->willReturn($this->cache);
|
||||
|
||||
$this->appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($this->attachmentServiceImpl);
|
||||
$this->appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($this->filesAppServiceImpl);
|
||||
|
||||
$this->application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($this->appContainer);
|
||||
@@ -119,8 +127,12 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$fileAppServiceMock = $this->createMock(FilesAppService::class);
|
||||
|
||||
$appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($fileServiceMock);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($fileAppServiceMock);
|
||||
$appContainer->expects($this->at(2))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
@@ -135,8 +147,10 @@ class AttachmentServiceTest extends TestCase {
|
||||
$application = $this->createMock(Application::class);
|
||||
$appContainer = $this->createMock(IAppContainer::class);
|
||||
$fileServiceMock = $this->createMock(FileService::class);
|
||||
$fileAppServiceMock = $this->createMock(FilesAppService::class);
|
||||
$appContainer->expects($this->at(0))->method('query')->with(FileService::class)->willReturn($fileServiceMock);
|
||||
$appContainer->expects($this->at(1))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$appContainer->expects($this->at(1))->method('query')->with(FilesAppService::class)->willReturn($fileAppServiceMock);
|
||||
$appContainer->expects($this->at(2))->method('query')->with(MyAttachmentService::class)->willReturn(new MyAttachmentService());
|
||||
$application->expects($this->any())
|
||||
->method('getContainer')
|
||||
->willReturn($appContainer);
|
||||
|
||||
@@ -123,20 +123,9 @@ class BoardServiceTest extends TestCase {
|
||||
$b3 = new Board();
|
||||
$b3->setId(3);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByUser')
|
||||
->method('findAllForUser')
|
||||
->with('admin')
|
||||
->willReturn([$b1, $b2]);
|
||||
$this->stackMapper->expects($this->any())
|
||||
->method('findAll')
|
||||
->willReturn([]);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByGroups')
|
||||
->with('admin', ['a', 'b', 'c'])
|
||||
->willReturn([$b2, $b3]);
|
||||
$this->boardMapper->expects($this->once())
|
||||
->method('findAllByCircles')
|
||||
->with('admin')
|
||||
->willReturn([]);
|
||||
->willReturn([$b1, $b2, $b3]);
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->groupManager->method('getUserGroupIds')
|
||||
->willReturn(['a', 'b', 'c']);
|
||||
|
||||
Reference in New Issue
Block a user