Skip to content

Commit

Permalink
some test mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Maguire committed Feb 4, 2015
1 parent 6d96f06 commit 5b588ec
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 20 deletions.
34 changes: 17 additions & 17 deletions src/Trello/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Board extends Model
* @param string $name Name of checklist
*
* @return Checklist|Collection Newly minted checklist
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
* @throws Exception_NotFound
*/
public function addChecklist($name = null)
Expand All @@ -121,7 +121,7 @@ public function addChecklist($name = null)
* @param array $attributes List attributes
*
* @return List|Collection Newly minted List object
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
* @throws Exception_NotFound
*/
public function addList($attributes = [])
Expand All @@ -138,7 +138,7 @@ public function addList($attributes = [])
* @param string $powerup Powerup name
*
* @return stdClass|null List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function addPowerUp($powerup = null)
{
Expand All @@ -154,7 +154,7 @@ public function addPowerUp($powerup = null)
* add card aging powerup to current board
*
* @return stdClass|null List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function addPowerUpCardAging()
{
Expand All @@ -165,7 +165,7 @@ public function addPowerUpCardAging()
* add calendar powerup to current board
*
* @return stdClass|null List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function addPowerUpCalendar()
{
Expand All @@ -176,7 +176,7 @@ public function addPowerUpCalendar()
* add recap powerup to current board
*
* @return stdClass|null List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function addPowerUpRecap()
{
Expand All @@ -187,7 +187,7 @@ public function addPowerUpRecap()
* add voting powerup to current board
*
* @return stdClass|null List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function addPowerUpVoting()
{
Expand All @@ -198,7 +198,7 @@ public function addPowerUpVoting()
* close current board
*
* @return bool Did the board close?
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function close()
{
Expand All @@ -211,7 +211,7 @@ public function close()
* @param string $board_id Board id to close
*
* @return bool Did the board close?
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public static function closeBoard($board_id = null)
{
Expand All @@ -230,7 +230,7 @@ public static function closeBoard($board_id = null)
* @param array $attributes Board attributes to set
*
* @return Board Newly minted trello board
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public static function create($attributes = [])
{
Expand All @@ -251,7 +251,7 @@ public static function create($attributes = [])
* @param string|array $board_id Board id(s) to fetch
*
* @return Collection|Board Trello board matching id
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public static function fetch($board_id = null)
{
Expand Down Expand Up @@ -347,7 +347,7 @@ public function markAsViewed()
* @param string $powerup Powerup name
*
* @return boolean List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function removePowerUp($powerup = null)
{
Expand All @@ -363,7 +363,7 @@ public function removePowerUp($powerup = null)
* remove card aging powerup from current board
*
* @return boolean List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function removePowerUpCardAging()
{
Expand All @@ -374,7 +374,7 @@ public function removePowerUpCardAging()
* remove calendar powerup from current board
*
* @return boolean List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function removePowerUpCalendar()
{
Expand All @@ -385,7 +385,7 @@ public function removePowerUpCalendar()
* remove recap powerup from current board
*
* @return boolean List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function removePowerUpRecap()
{
Expand All @@ -396,7 +396,7 @@ public function removePowerUpRecap()
* remove voting powerup from current board
*
* @return boolean List of existing powerups
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function removePowerUpVoting()
{
Expand Down Expand Up @@ -437,7 +437,7 @@ public function updateDescription($description = null)
* @param string $name
*
* @return Board Updated board object
* @throws Exception_ValidationsFailed
* @throws Exception\ValidationsFailed
*/
public function updateName($name = null)
{
Expand Down
8 changes: 8 additions & 0 deletions tests/helpers/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ public static function make($class = null)
return $response;
}

public function setAttributes($attributes = [])
{
foreach ($attributes as $key => $value) {
$this->set($key, $value);
}
return $this;
}

public function set($attribute, $value = null)
{
$this->setPayloadAttribute($attribute, $value);
Expand Down
86 changes: 83 additions & 3 deletions tests/unit/Board_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,96 @@ class Board_Test extends UnitTestCase
{
public function test_It_Can_Create_A_New_Board_With_Only_A_Name_Provided()
{
$attributes = ['name' => $this->board_name];
$board = Response::make(Board::class)
->set('name', $this->board_name)
->setAttributes($attributes)
->get();
$this->successWith($board);
$attributes = ['name' => $this->board_name];

$result = Board::create($attributes);

$this->assertInstanceOf('Trello\Board', $result);
$this->assertEquals($this->board_name, $result->name);
$this->assertEquals($attributes['name'], $result->name);
$this->assertNull($result->cash_money);
}

public function test_It_Can_Update_Board_Name_When_Name_Provided()
{
$attributes = ['name' => $this->board_name];
$board_data = Response::make(Board::class)
->setAttributes($attributes)
->get();
$this->successWith($board_data);

$board = new Board;

$result = $board->updateName($attributes['name']);

$this->assertInstanceOf('Trello\Board', $result);
$this->assertEquals($attributes['name'], $result->name);
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Create_A_New_Board_When_Name_Not_Provided()
{
$result = Board::create();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Add_Checklist_To_Board_When_Name_Not_Provided()
{
$board = new Board;

$board->addChecklist();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Add_Powerup_To_Board_When_Powerup_Not_Provided()
{
$board = new Board;

$board->addPowerUp();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Close_Board_When_No_Board_Id_Provided()
{
Board::closeBoard();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Fetch_Board_When_No_Board_Id_Provided()
{
Board::fetch();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Remove_Powerup_To_Board_When_Powerup_Not_Provided()
{
$board = new Board;

$board->removePowerUp();
}

/**
* @expectedException Trello\Exception\ValidationsFailed
*/
public function test_It_Can_Not_Update_Board_Name_When_Powerup_Not_Provided()
{
$board = new Board;

$board->updateName();
}
}

0 comments on commit 5b588ec

Please sign in to comment.