Fix NotifierTest to mock the new StackMapper::findStackFromCardId() method correctly.
Signed-off-by: Raul Ferreira Fuentes <raul@nextcloud.com>
This commit is contained in:
@@ -25,6 +25,7 @@ namespace OCA\Deck\Notification;
|
|||||||
|
|
||||||
use OCA\Deck\Db\BoardMapper;
|
use OCA\Deck\Db\BoardMapper;
|
||||||
use OCA\Deck\Db\CardMapper;
|
use OCA\Deck\Db\CardMapper;
|
||||||
|
use OCA\Deck\Db\Stack;
|
||||||
use OCA\Deck\Db\StackMapper;
|
use OCA\Deck\Db\StackMapper;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
@@ -103,9 +104,9 @@ class NotifierTest extends \Test\TestCase {
|
|||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('getObjectId')
|
->method('getObjectId')
|
||||||
->willReturn('123');
|
->willReturn('123');
|
||||||
$this->cardMapper->expects($this->once())
|
$this->stackMapper->expects($this->once())
|
||||||
->method('findBoardId')
|
->method('findStackFromCardId')
|
||||||
->willReturn(999);
|
->willReturn($this->buildMockStack());
|
||||||
$expectedMessage = 'The card "Card title" on "Board title" has reached its due date.';
|
$expectedMessage = 'The card "Card title" on "Board title" has reached its due date.';
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('setParsedSubject')
|
->method('setParsedSubject')
|
||||||
@@ -146,9 +147,9 @@ class NotifierTest extends \Test\TestCase {
|
|||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('getObjectId')
|
->method('getObjectId')
|
||||||
->willReturn('123');
|
->willReturn('123');
|
||||||
$this->cardMapper->expects($this->once())
|
$this->stackMapper->expects($this->once())
|
||||||
->method('findBoardId')
|
->method('findStackFromCardId')
|
||||||
->willReturn(999);
|
->willReturn($this->buildMockStack());
|
||||||
$expectedMessage = 'admin has mentioned you in a comment on "Card title".';
|
$expectedMessage = 'admin has mentioned you in a comment on "Card title".';
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
->method('setParsedSubject')
|
->method('setParsedSubject')
|
||||||
@@ -183,9 +184,9 @@ class NotifierTest extends \Test\TestCase {
|
|||||||
|
|
||||||
/** @dataProvider dataPrepareCardAssigned */
|
/** @dataProvider dataPrepareCardAssigned */
|
||||||
public function testPrepareCardAssigned($withUserFound = true) {
|
public function testPrepareCardAssigned($withUserFound = true) {
|
||||||
$this->cardMapper->expects($this->once())
|
$this->stackMapper->expects($this->once())
|
||||||
->method('findBoardId')
|
->method('findStackFromCardId')
|
||||||
->willReturn(123);
|
->willReturn($this->buildMockStack(123));
|
||||||
|
|
||||||
/** @var INotification $notification */
|
/** @var INotification $notification */
|
||||||
$notification = $this->createMock(INotification::class);
|
$notification = $this->createMock(INotification::class);
|
||||||
@@ -338,4 +339,17 @@ class NotifierTest extends \Test\TestCase {
|
|||||||
|
|
||||||
$this->assertEquals($notification, $actualNotification);
|
$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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user