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() {
|
||||
$title = 'Personal';
|
||||
$color = '000000';
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user