Skip to content

Commit

Permalink
Convert empty accountId to null
Browse files Browse the repository at this point in the history
  • Loading branch information
amacneil committed May 12, 2014
1 parent d7cead7 commit 2a67235
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getData()
$this->validate('amount', 'currency', 'description');

$data = array();
$data['account_id'] = $this->getAccountId();
$data['account_id'] = $this->getAccountId() ?: null;
$data['button'] = array();
$data['button']['name'] = $this->getDescription();
$data['button']['price_string'] = $this->getAmount();
Expand Down
10 changes: 10 additions & 0 deletions tests/Message/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public function testGetData()
$this->assertSame('https://example.com/notify', $data['button']['callback_url']);
}

public function testGetDataAccountIdNull()
{
// empty string must be converted to null
$this->request->setAccountId('');

$data = $this->request->getData();
$this->assertNull($data['account_id']);

}

public function testSendSuccess()
{
$this->setMockHttpResponse('PurchaseSuccess.txt');
Expand Down

0 comments on commit 2a67235

Please sign in to comment.