- Add typing for most of the services, controllers and mappers - Add api doc for mappers - Use vendor-bin for psalm - Use attributes for controllers - Fix upload of attachments Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
87 lines
2.5 KiB
PHP
87 lines
2.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
|
|
*
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
|
*
|
|
* @license GNU AGPL version 3 or any later version
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
namespace OCA\Deck\Controller;
|
|
|
|
use OCA\Deck\Db\Label;
|
|
use OCA\Deck\Service\LabelService;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\IRequest;
|
|
|
|
class LabelControllerTest extends \Test\TestCase {
|
|
|
|
/** @var Controller|\PHPUnit\Framework\MockObject\MockObject */
|
|
private $controller;
|
|
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
|
private $request;
|
|
/** @var LabelService|\PHPUnit\Framework\MockObject\MockObject */
|
|
private $labelService;
|
|
/** @var string */
|
|
private $userId = 'user';
|
|
|
|
public function setUp(): void {
|
|
$this->request = $this->getMockBuilder(
|
|
'\OCP\IRequest')
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$this->labelService = $this->getMockBuilder(
|
|
'\OCA\Deck\Service\LabelService')
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$this->controller = new LabelController(
|
|
'deck',
|
|
$this->request,
|
|
$this->labelService
|
|
);
|
|
}
|
|
|
|
|
|
public function testCreate(): void {
|
|
$label = $this->createMock(Label::class);
|
|
$this->labelService->expects($this->once())
|
|
->method('create')
|
|
->with(1, 2, 3)
|
|
->willReturn($label);
|
|
$this->assertEquals($label, $this->controller->create(1, 2, 3));
|
|
}
|
|
|
|
public function testUpdate(): void {
|
|
$label = $this->createMock(Label::class);
|
|
$this->labelService->expects($this->once())
|
|
->method('update')
|
|
->with(1, 2, 3)
|
|
->willReturn($label);
|
|
$this->assertEquals($label, $this->controller->update(1, 2, 3));
|
|
}
|
|
|
|
public function testDelete(): void {
|
|
$label = $this->createMock(Label::class);
|
|
$this->labelService->expects($this->once())
|
|
->method('delete')
|
|
->with(123)
|
|
->willReturn($label);
|
|
$this->assertEquals($label, $this->controller->delete(123));
|
|
}
|
|
}
|