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:
Ryan Fletcher
2018-07-11 12:59:40 -04:00
parent 08f9874745
commit 2002841c61
2 changed files with 44 additions and 3 deletions

View File

@@ -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() {
$title = 'Personal';
$color = '000000';
@@ -84,8 +124,8 @@ class DefaultBoardServiceTest extends TestCase {
$board->setOwner($this->userId);
$board->setColor($color);
$this->boardService->expects($this->once())
->method('create')
->willReturn($board);
->method('create')
->willReturn($board);
$stackToDoId = '123';
$stackToDo = $this->assembleTestStack('To do', $stackToDoId, $boardId);

View File

@@ -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() {
$response = $this->controller->index();
$this->assertEquals('main', $response->getTemplateName());