Wrote unit tests for checkFirstRun method in the default board service
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
@@ -73,6 +73,46 @@ class DefaultBoardServiceTest extends TestCase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCheckFirstRunCaseTrue() {
|
||||||
|
$appName = "Deck";
|
||||||
|
$userBoards = [];
|
||||||
|
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getUserValue')
|
||||||
|
->willReturn('yes');
|
||||||
|
|
||||||
|
$this->boardMapper->expects($this->once())
|
||||||
|
->method('findAllByUser')
|
||||||
|
->willReturn($userBoards);
|
||||||
|
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('setUserValue');
|
||||||
|
|
||||||
|
$result = $this->service->checkFirstRun($this->userId, $appName);
|
||||||
|
$this->assertEquals($result, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCheckFirstRunCaseFalse() {
|
||||||
|
$appName = "deck";
|
||||||
|
$board = new Board();
|
||||||
|
$board->setTitle('Personal');
|
||||||
|
$board->setOwner($this->userId);
|
||||||
|
$board->setColor('000000');
|
||||||
|
|
||||||
|
$userBoards = [$board];
|
||||||
|
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('getUserValue')
|
||||||
|
->willReturn('no');
|
||||||
|
|
||||||
|
$this->boardMapper->expects($this->once())
|
||||||
|
->method('findAllByUser')
|
||||||
|
->willReturn($userBoards);
|
||||||
|
|
||||||
|
$result = $this->service->checkFirstRun($this->userId, $appName);
|
||||||
|
$this->assertEquals($result, false);
|
||||||
|
}
|
||||||
|
|
||||||
public function testCreateDefaultBoard() {
|
public function testCreateDefaultBoard() {
|
||||||
$title = 'Personal';
|
$title = 'Personal';
|
||||||
$color = '000000';
|
$color = '000000';
|
||||||
@@ -84,8 +124,8 @@ class DefaultBoardServiceTest extends TestCase {
|
|||||||
$board->setOwner($this->userId);
|
$board->setOwner($this->userId);
|
||||||
$board->setColor($color);
|
$board->setColor($color);
|
||||||
$this->boardService->expects($this->once())
|
$this->boardService->expects($this->once())
|
||||||
->method('create')
|
->method('create')
|
||||||
->willReturn($board);
|
->willReturn($board);
|
||||||
|
|
||||||
$stackToDoId = '123';
|
$stackToDoId = '123';
|
||||||
$stackToDo = $this->assembleTestStack('To do', $stackToDoId, $boardId);
|
$stackToDo = $this->assembleTestStack('To do', $stackToDoId, $boardId);
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ class PageControllerTest extends \Test\TestCase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO-ryan: update this test to ensure that checkFirstRun is bieng called, if it is then
|
||||||
|
// test that the createDefaultBoard is also being called.
|
||||||
public function testIndex() {
|
public function testIndex() {
|
||||||
$response = $this->controller->index();
|
$response = $this->controller->index();
|
||||||
$this->assertEquals('main', $response->getTemplateName());
|
$this->assertEquals('main', $response->getTemplateName());
|
||||||
|
|||||||
Reference in New Issue
Block a user