Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaul Ferreira Fuentes <raul@nextcloud.com>2022-04-05 19:07:06 +0300
committerRaul Ferreira Fuentes <raul@nextcloud.com>2022-04-05 19:07:06 +0300
commit6181d9edf73c05ebf03ae27a1561bc94d98d7704 (patch)
tree4648e5fa739cfcca73bd5183c3538b4bdf9c5402 /tests
parent575b885a3a9690638393d96ab954078c21f982cf (diff)
Fix NotifierTest to mock the new `StackMapper::findStackFromCardId()` method correctly.
Signed-off-by: Raul Ferreira Fuentes <raul@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/Notification/NotifierTest.php32
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/unit/Notification/NotifierTest.php b/tests/unit/Notification/NotifierTest.php
index a26d8db9..da6e3348 100644
--- a/tests/unit/Notification/NotifierTest.php
+++ b/tests/unit/Notification/NotifierTest.php
@@ -25,6 +25,7 @@ namespace OCA\Deck\Notification;
use OCA\Deck\Db\BoardMapper;
use OCA\Deck\Db\CardMapper;
+use OCA\Deck\Db\Stack;
use OCA\Deck\Db\StackMapper;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -103,9 +104,9 @@ class NotifierTest extends \Test\TestCase {
$notification->expects($this->once())
->method('getObjectId')
->willReturn('123');
- $this->cardMapper->expects($this->once())
- ->method('findBoardId')
- ->willReturn(999);
+ $this->stackMapper->expects($this->once())
+ ->method('findStackFromCardId')
+ ->willReturn($this->buildMockStack());
$expectedMessage = 'The card "Card title" on "Board title" has reached its due date.';
$notification->expects($this->once())
->method('setParsedSubject')
@@ -146,9 +147,9 @@ class NotifierTest extends \Test\TestCase {
$notification->expects($this->once())
->method('getObjectId')
->willReturn('123');
- $this->cardMapper->expects($this->once())
- ->method('findBoardId')
- ->willReturn(999);
+ $this->stackMapper->expects($this->once())
+ ->method('findStackFromCardId')
+ ->willReturn($this->buildMockStack());
$expectedMessage = 'admin has mentioned you in a comment on "Card title".';
$notification->expects($this->once())
->method('setParsedSubject')
@@ -183,9 +184,9 @@ class NotifierTest extends \Test\TestCase {
/** @dataProvider dataPrepareCardAssigned */
public function testPrepareCardAssigned($withUserFound = true) {
- $this->cardMapper->expects($this->once())
- ->method('findBoardId')
- ->willReturn(123);
+ $this->stackMapper->expects($this->once())
+ ->method('findStackFromCardId')
+ ->willReturn($this->buildMockStack(123));
/** @var INotification $notification */
$notification = $this->createMock(INotification::class);
@@ -338,4 +339,17 @@ class NotifierTest extends \Test\TestCase {
$this->assertEquals($notification, $actualNotification);
}
+
+ /**
+ * @param int $boardId
+ * @return Stack|MockObject
+ */
+ private function buildMockStack(int $boardId = 999) {
+ $mock_stack = $this->getMockBuilder(Stack::class)
+ ->addMethods(['getBoardId'])
+ ->getMock();
+
+ $mock_stack->method('getBoardId')->willReturn($boardId);
+ return $mock_stack;
+ }
}