Update API tests

This commit is contained in:
kiswa 2016-08-25 23:00:25 +00:00
parent 17632b06c8
commit 80798ab0a4
8 changed files with 38 additions and 22 deletions

View File

@ -96,6 +96,25 @@ class DataMock {
return $board; return $board;
} }
public static function getBoardForDb() {
$board = new stdClass();
$board->id = 0;
$board->name = 'test';
$board->is_active = true;
$board->columns = [];
$board->categories = [];
$board->auto_actions = [];
$board->issue_trackers = [];
$board->users = [];
$column = self::getColumn();
$column->id = 0;
$column->tasks = [];
$board->columns[] = $column;
return $board;
}
public static function getColumn() { public static function getColumn() {
$column = new stdClass(); $column = new stdClass();
$column->id = 1; $column->id = 1;

View File

@ -221,10 +221,7 @@ class AttachmentsTest extends PHPUnit_Framework_TestCase {
} }
private function createBoard() { private function createBoard() {
$board = DataMock::getBoard(); $board = DataMock::getBoardForDb();
$board->users = [];
$board->users[] = new User(new ContainerMock(), 1);
$board->auto_actions = [];
$request = new RequestMock(); $request = new RequestMock();
$request->payload = $board; $request->payload = $board;

View File

@ -232,9 +232,7 @@ class BoardsTest extends PHPUnit_Framework_TestCase {
$request = new RequestMock(); $request = new RequestMock();
$request->header = [DataMock::getJwt()]; $request->header = [DataMock::getJwt()];
$board = DataMock::getBoard(); $board = DataMock::getBoardForDb();
$board->id = 0;
$request->payload = $board; $request->payload = $board;
$response = $this->boards->addBoard($request, $response = $this->boards->addBoard($request,

View File

@ -257,10 +257,9 @@ class ColumnsTest extends PHPUnit_Framework_TestCase {
$request = new RequestMock(); $request = new RequestMock();
$request->header = [DataMock::getJwt()]; $request->header = [DataMock::getJwt()];
$board = DataMock::getBoard(); $board = DataMock::getBoardForDb();
$board->id = 0;
$request->payload = $board; $request->payload = $board;
$boards = new Boards(new ContainerMock()); $boards = new Boards(new ContainerMock());
$response = $boards->addBoard($request, $response = $boards->addBoard($request,

View File

@ -7,7 +7,6 @@ class CommentsTest extends PHPUnit_Framework_TestCase {
public static function setupBeforeClass() { public static function setupBeforeClass() {
try { try {
RedBeanPHP\R::setup('sqlite:tests.db'); RedBeanPHP\R::setup('sqlite:tests.db');
// RedBeanPHP\R::fancyDebug(true);
} catch (Exception $ex) { } } catch (Exception $ex) { }
} }
@ -299,10 +298,7 @@ class CommentsTest extends PHPUnit_Framework_TestCase {
} }
private function createBoard() { private function createBoard() {
$board = DataMock::getBoard(); $board = DataMock::getBoardForDb();
$board->users = [];
$board->users[] = new User(new ContainerMock(), 1);
$board->auto_actions = [];
$request = new RequestMock(); $request = new RequestMock();
$request->payload = $board; $request->payload = $board;

View File

@ -236,10 +236,7 @@ class TasksTest extends PHPUnit_Framework_TestCase {
} }
private function createBoard() { private function createBoard() {
$board = DataMock::getBoard(); $board = DataMock::getBoardForDb();
$board->users = [];
$board->users[] = new User(new ContainerMock(), 1);
$board->auto_actions = [];
$request = new RequestMock(); $request = new RequestMock();
$request->payload = $board; $request->payload = $board;

View File

@ -1,9 +1,6 @@
<?php <?php
require_once __DIR__ . '/../Mocks.php'; require_once __DIR__ . '/../Mocks.php';
/**
* @group single
*/
class IssueTrackerTest extends PHPUnit_Framework_TestCase { class IssueTrackerTest extends PHPUnit_Framework_TestCase {
private $json = ''; private $json = '';
private $bean; private $bean;

View File

@ -23,6 +23,19 @@ global.ConstantsMock = {
VERSION: 'TEST' VERSION: 'TEST'
}; };
global.TitleMock = function() {
var title = '';
return {
getTitle: () => {
return title;
},
setTitle: (text) => {
title = text;
}
};
};
global.RouterMock = function() { global.RouterMock = function() {
return { return {
path: 'test', path: 'test',