Fix tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-05 10:49:44 +02:00
parent 63a34e7018
commit e29efe8935
4 changed files with 20 additions and 7 deletions

View File

@@ -245,8 +245,8 @@ class DeckProvider implements IProvider {
$event->setParsedMessage($comment->getMessage()); $event->setParsedMessage($comment->getMessage());
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
} }
$params['comment'] = $subjectParams['comment'];
} }
$params['comment'] = $subjectParams['comment'];
return $params; return $params;
} }

View File

@@ -26,6 +26,7 @@ namespace OCA\Deck\Activity;
use OC\Activity\Event; use OC\Activity\Event;
use OCA\Deck\Db\Acl; use OCA\Deck\Db\Acl;
use OCP\Activity\IEvent; use OCP\Activity\IEvent;
use OCP\Comments\ICommentsManager;
use OCP\IL10N; use OCP\IL10N;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUser; use OCP\IUser;
@@ -48,6 +49,9 @@ class DeckProviderTest extends TestCase {
/** @var IUserManager|MockObject */ /** @var IUserManager|MockObject */
private $userManager; private $userManager;
/** @var ICommentsManager|MockObject */
private $commentsManager;
/** @var string */ /** @var string */
private $userId = 'admin'; private $userId = 'admin';
@@ -56,7 +60,8 @@ class DeckProviderTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class); $this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->activityManager = $this->createMock(ActivityManager::class); $this->activityManager = $this->createMock(ActivityManager::class);
$this->userManager = $this->createMock(IUserManager::class); $this->userManager = $this->createMock(IUserManager::class);
$this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->userId); $this->commentsManager = $this->createMock(ICommentsManager::class);
$this->provider = new DeckProvider($this->urlGenerator, $this->activityManager, $this->userManager, $this->commentsManager, $this->userId);
} }
private function mockEvent($objectType, $objectId, $objectName, $subject, $subjectParameters = []) { private function mockEvent($objectType, $objectId, $objectName, $subject, $subjectParameters = []) {

View File

@@ -81,7 +81,8 @@ class CardTest extends TestCase {
'attachments' => null, 'attachments' => null,
'attachmentCount' => null, 'attachmentCount' => null,
'assignedUsers' => null, 'assignedUsers' => null,
'deletedAt' => 0 'deletedAt' => 0,
'commentsUnread' => 0,
], $card->jsonSerialize()); ], $card->jsonSerialize());
} }
public function testJsonSerializeLabels() { public function testJsonSerializeLabels() {
@@ -104,7 +105,8 @@ class CardTest extends TestCase {
'attachments' => null, 'attachments' => null,
'attachmentCount' => null, 'attachmentCount' => null,
'assignedUsers' => null, 'assignedUsers' => null,
'deletedAt' => 0 'deletedAt' => 0,
'commentsUnread' => 0,
], $card->jsonSerialize()); ], $card->jsonSerialize());
} }
@@ -137,7 +139,8 @@ class CardTest extends TestCase {
'attachments' => null, 'attachments' => null,
'attachmentCount' => null, 'attachmentCount' => null,
'assignedUsers' => ['user1'], 'assignedUsers' => ['user1'],
'deletedAt' => 0 'deletedAt' => 0,
'commentsUnread' => 0,
], $card->jsonSerialize()); ], $card->jsonSerialize());
} }

View File

@@ -36,6 +36,7 @@ use OCA\Deck\NotFoundException;
use OCA\Deck\Notification\NotificationHelper; use OCA\Deck\Notification\NotificationHelper;
use OCA\Deck\StatusException; use OCA\Deck\StatusException;
use OCP\Activity\IEvent; use OCP\Activity\IEvent;
use OCP\Comments\ICommentsManager;
use Test\TestCase; use Test\TestCase;
class CardServiceTest extends TestCase { class CardServiceTest extends TestCase {
@@ -61,6 +62,8 @@ class CardServiceTest extends TestCase {
private $attachmentService; private $attachmentService;
/** @var ActivityManager|\PHPUnit\Framework\MockObject\MockObject */ /** @var ActivityManager|\PHPUnit\Framework\MockObject\MockObject */
private $activityManager; private $activityManager;
/** @var ICommentsManager|\PHPUnit\Framework\MockObject\MockObject */
private $commentsManager;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
@@ -74,6 +77,7 @@ class CardServiceTest extends TestCase {
$this->assignedUsersMapper = $this->createMock(AssignedUsersMapper::class); $this->assignedUsersMapper = $this->createMock(AssignedUsersMapper::class);
$this->attachmentService = $this->createMock(AttachmentService::class); $this->attachmentService = $this->createMock(AttachmentService::class);
$this->activityManager = $this->createMock(ActivityManager::class); $this->activityManager = $this->createMock(ActivityManager::class);
$this->commentsManager = $this->createMock(ICommentsManager::class);
$this->cardService = new CardService( $this->cardService = new CardService(
$this->cardMapper, $this->cardMapper,
$this->stackMapper, $this->stackMapper,
@@ -85,6 +89,7 @@ class CardServiceTest extends TestCase {
$this->assignedUsersMapper, $this->assignedUsersMapper,
$this->attachmentService, $this->attachmentService,
$this->activityManager, $this->activityManager,
$this->commentsManager,
'user1' 'user1'
); );
} }
@@ -104,11 +109,11 @@ class CardServiceTest extends TestCase {
public function testFind() { public function testFind() {
$card = new Card(); $card = new Card();
$card->setId(1337); $card->setId(1337);
$this->cardMapper->expects($this->once()) $this->cardMapper->expects($this->any())
->method('find') ->method('find')
->with(123) ->with(123)
->willReturn($card); ->willReturn($card);
$this->assignedUsersMapper->expects($this->once()) $this->assignedUsersMapper->expects($this->any())
->method('find') ->method('find')
->with(1337) ->with(1337)
->willReturn(['user1', 'user2']); ->willReturn(['user1', 'user2']);