committed by
Raul Ferreira Fuentes
parent
af8e61ece6
commit
24a4260e55
@@ -42,6 +42,7 @@ use OCA\Deck\Event\AclUpdatedEvent;
|
||||
use OCA\Deck\NoPermissionException;
|
||||
use OCA\Deck\Notification\NotificationHelper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
@@ -55,6 +56,8 @@ use OCP\IUserManager;
|
||||
use OCA\Deck\BadRequestException;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\Server;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class BoardService {
|
||||
private BoardMapper $boardMapper;
|
||||
@@ -592,12 +595,14 @@ class BoardService {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws DbException
|
||||
* @throws DoesNotExistException
|
||||
* @throws \OCA\Deck\NoPermissionException
|
||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
|
||||
* @throws BadRequestException
|
||||
* @throws NoPermissionException
|
||||
* @throws MultipleObjectsReturnedException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function deleteAcl(int $id): bool {
|
||||
public function deleteAcl(int $id): ?Acl {
|
||||
$this->permissionService->checkPermission($this->aclMapper, $id, Acl::PERMISSION_SHARE);
|
||||
/** @var Acl $acl */
|
||||
$acl = $this->aclMapper->find($id);
|
||||
@@ -622,8 +627,10 @@ class BoardService {
|
||||
}
|
||||
}
|
||||
|
||||
$deletedAcl = $this->aclMapper->delete($acl);
|
||||
$this->eventDispatcher->dispatchTyped(new AclDeletedEvent($acl));
|
||||
return (bool) $this->aclMapper->delete($acl);
|
||||
|
||||
return $deletedAcl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -427,6 +427,6 @@ class BoardServiceTest extends TestCase {
|
||||
->method('delete')
|
||||
->with($acl)
|
||||
->willReturn($acl);
|
||||
$this->assertTrue($this->service->deleteAcl(123));
|
||||
$this->assertEquals($acl, $this->service->deleteAcl(123));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,10 +164,14 @@ class BoardControllerTest extends \Test\TestCase {
|
||||
}
|
||||
|
||||
public function testDeleteAcl() {
|
||||
$acl = $this->getMockBuilder(Acl::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->boardService->expects($this->once())
|
||||
->method('deleteAcl')
|
||||
->with(1)
|
||||
->willReturn(true);
|
||||
$this->assertEquals(true, $this->controller->deleteAcl(1));
|
||||
->willReturn($acl);
|
||||
$this->assertEquals($acl, $this->controller->deleteAcl(1));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user