WIP - build will fail

This commit is contained in:
Matthew Ross 2016-05-09 06:33:48 -04:00
parent eaf88269d7
commit d4a1eed8ae
5 changed files with 16 additions and 17 deletions

View File

@ -27,7 +27,6 @@ abstract class BaseModel {
try {
$id = R::store($this->bean);
assert($id === $this->id);
$this->loadFromBean($this->bean);
} catch (Exception $ex) {
$this->logger->addError('Save Error: ', [

View File

@ -33,6 +33,10 @@ class Board extends BaseModel {
}
public function updateBean() {
if ($this->bean === null) {
return;
}
$bean = $this->bean;
$bean->name = $this->name;
@ -66,6 +70,7 @@ class Board extends BaseModel {
public function loadFromBean($bean) {
if (!isset($bean->id) || $bean->id === 0) {
$this->bean = null;
return;
}
@ -103,6 +108,7 @@ class Board extends BaseModel {
$obj = json_decode($json);
if (!isset($obj->id) || $obj->id === 0) {
$this->bean = null;
return;
}

View File

@ -159,24 +159,15 @@ class ContainerMock {
}
class RequestMock {
public $board;
public $invalidPayload = false;
public function getBody() {
if ($this->board) {
return json_encode($this->board);
if ($this->invalidPayload) {
return '{}';
}
return json_encode(DataMock::getBoard());
}
}
class BadRequestMock {
public function getBody() {
return '{}';
}
}
class ResponseMock {

View File

@ -67,7 +67,10 @@ class BoardsTest extends PHPUnit_Framework_TestCase {
}
public function testAddBadBoard() {
$response = $this->boards->addBoard(new BadRequestMock(),
$request = new RequestMock();
$request->invalidPayload = true;
$response = $this->boards->addBoard($request,
new ResponseMock(), null);
$this->assertTrue($response->status === 'failure');
@ -93,13 +96,13 @@ class BoardsTest extends PHPUnit_Framework_TestCase {
$args['id'] = $board->id;
$request = new RequestMock();
$request->board = $board;
$request->payload = $board;
$response = $this->boards->updateBoard($request,
new ResponseMock(), $args);
$this->assertTrue($response->status === 'success');
$request->board = new stdClass();
$request->payload = new stdClass();
$response = $this->boards->updateBoard($request,
new ResponseMock(), $args);
$this->assertTrue($response->alerts[2]['type'] === 'error');

View File

@ -99,7 +99,7 @@ class BoardTest extends PHPUnit_Framework_TestCase {
$this->assertTrue($bean->id === 0);
$this->assertArraySubset($bean->xownColumnList, []);
$board->save();
$this->assertTrue($board->save());
$bean = $board->getBean();
$this->assertTrue((int)$bean->id === 1);