Skip to content

Commit

Permalink
Improve transaction model
Browse files Browse the repository at this point in the history
* Add missing `type` variable.
* Update docblocks.
* Update transaction tests.
  • Loading branch information
Nuno Rafael Rocha committed Feb 26, 2015
1 parent 8352bdc commit b9c8865
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 18 deletions.
51 changes: 42 additions & 9 deletions lib/Bitreserve/Model/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,75 @@
class Transaction extends BaseModel implements TransactionInterface
{
/**
* @var id
* Id.
*
* @var string
*/
protected $id;

/**
* @var createdAt
* Created at.
*
* @var string
*/
protected $createdAt;

/**
* @var denomination
* Denomination.
*
* @var array
*/
protected $denomination;

/**
* @var destination
* Destinantion information.
*
* @var array
*/
protected $destination;

/**
* @var message
* Message.
*
* @var string
*/
protected $message;

/**
* @var origin
* Origin information.
*
* @var array
*/
protected $origin;

/**
* @var params
* Params.
*
* @var array
*/
protected $params;

/**
* @var refundedById
* Refunded Id.
*
* @var string.
*/
protected $refundedById;

/**
* @var status
* Status.
*
* @var string
*/
protected $status;

/**
* Type
*
* @var string
*/
protected $type;

/**
* Constructor.
*
Expand Down Expand Up @@ -140,6 +165,14 @@ public function getStatus()
return $this->status;
}

/**
* {@inheritdoc}
*/
public function getType()
{
return $this->type;
}

/**
* {@inheritdoc}
*/
Expand Down
25 changes: 16 additions & 9 deletions lib/Bitreserve/Model/TransactionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,75 @@
interface TransactionInterface
{
/**
* Gets transaction creation date.
* Get transaction creation date.
*
* @return $createdAt
*/
public function getCreatedAt();

/**
* Gets transaction denomination.
* Get transaction denomination.
*
* @return $denomination
*/
public function getDenomination();

/**
* Gets transaction destinantion.
* Get transaction destinantion.
*
* @return $destination
*/
public function getDestination();

/**
* Gets transaction id.
* Get transaction id.
*
* @return $id
*/
public function getId();

/**
* Gets transaction message.
* Get transaction message.
*
* @return $message
*/
public function getMessage();

/**
* Gets transaction origin.
* Get transaction origin.
*
* @return $origin
*/
public function getOrigin();

/**
* Gets transaction params.
* Get transaction params.
*
* @return $params
*/
public function getParams();

/**
* Gets transaction refunded by id.
* Get transaction refunded by id.
*
* @return $refundedById
*/
public function getRefundedById();

/**
* Gets transaction current status.
* Get transaction current status.
*
* @return $status
*/
public function getStatus();

/**
* Get transaction type.
*
* @return $status
*/
public function getType();

/**
* Cancel current transaction.
*
Expand Down
14 changes: 14 additions & 0 deletions test/Bitreserve/Tests/Model/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,20 @@ public function shouldReturnParams()
$this->assertEquals($data['params'], $transaction->getParams());
}

/**
* @test
*/
public function shouldReturnType()
{
$data = array('type' => 'foobar');

$client = $this->getBitreserveClientMock();

$transaction = new Transaction($client, $data);

$this->assertEquals($data['type'], $transaction->getType());
}

/**
* @test
*/
Expand Down

0 comments on commit b9c8865

Please sign in to comment.