-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,13 @@ class BunqSdkTestBase extends TestCase | |
*/ | ||
const INDEX_FIRST = 0; | ||
|
||
/** | ||
* Spending money constants. | ||
*/ | ||
const SPENDING_MONEY_AMOUNT = '500'; | ||
const SPENDING_MONEY_RECIPIENT = '[email protected]'; | ||
const SPENDING_MONEY_DESCRIPTION = 'sdk php test, thanks daddy <3'; | ||
|
||
/** | ||
* @var MonetaryAccountBank | ||
*/ | ||
|
@@ -77,13 +84,6 @@ class BunqSdkTestBase extends TestCase | |
*/ | ||
protected $cashRegister; | ||
|
||
/** | ||
* Spending money constants. | ||
*/ | ||
const SPENDING_MONEY_AMOUNT = '500'; | ||
const SPENDING_MONEY_RECIPIENT = '[email protected]'; | ||
const SPENDING_MONEY_DESCRIPTION = 'sdk php test, thanks daddy <3'; | ||
|
||
/** | ||
*/ | ||
public static function setUpBeforeClass() | ||
|
@@ -112,43 +112,6 @@ protected function setUp() | |
BunqContext::getUserContext()->refreshUserContext(); | ||
} | ||
|
||
/** | ||
*/ | ||
private function setCashRegister() | ||
{ | ||
$attachmentUuid = AttachmentPublic::create( | ||
FileUtil::getFileContents(__DIR__ . self::FILE_PATH_AVATAR), | ||
[ | ||
ApiClient::HEADER_CONTENT_TYPE => $this->getAttachmentContentType(), | ||
ApiClient::HEADER_ATTACHMENT_DESCRIPTION => $this->getAttachmentDescription(), | ||
] | ||
); | ||
$avatarUuid = Avatar::create($attachmentUuid->getValue()); | ||
$cashRegisterId = CashRegister::create( | ||
self::CASH_REGISTER_NAME, | ||
self::CASH_REGISTER_STATUS, | ||
$avatarUuid->getValue() | ||
); | ||
|
||
$this->cashRegister = CashRegister::get($cashRegisterId->getValue()); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getAttachmentContentType(): string | ||
{ | ||
return self::ATTACHMENT_CONTENT_TYPE; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getAttachmentDescription(): string | ||
{ | ||
return self::ATTACHMENT_DESCRIPTION; | ||
} | ||
|
||
/** | ||
*/ | ||
private function setSecondMonetaryAccountBank() | ||
|
@@ -181,6 +144,14 @@ private function requestSpendingMoney() | |
); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
protected function getSecondMonetaryAccountId(): int | ||
{ | ||
return $this->secondMonetaryAccountBank->getId(); | ||
} | ||
|
||
/** | ||
* @return Pointer | ||
* | ||
|
@@ -234,14 +205,6 @@ protected function getPointerUserBravo(): Pointer | |
); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
protected function getSecondMonetaryAccountId(): int | ||
{ | ||
return $this->secondMonetaryAccountBank->getId(); | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
|
@@ -255,13 +218,40 @@ protected function getCashRegisterId(): int | |
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
protected function isMonetaryAccountBalanceSufficient(): bool | ||
private function setCashRegister() | ||
{ | ||
$balance = floatval(BunqContext::getUserContext()->getPrimaryMonetaryAccount()->getBalance()->getValue()); | ||
$attachmentUuid = AttachmentPublic::create( | ||
FileUtil::getFileContents(__DIR__ . self::FILE_PATH_AVATAR), | ||
[ | ||
ApiClient::HEADER_CONTENT_TYPE => $this->getAttachmentContentType(), | ||
ApiClient::HEADER_ATTACHMENT_DESCRIPTION => $this->getAttachmentDescription(), | ||
] | ||
); | ||
$avatarUuid = Avatar::create($attachmentUuid->getValue()); | ||
$cashRegisterId = CashRegister::create( | ||
self::CASH_REGISTER_NAME, | ||
self::CASH_REGISTER_STATUS, | ||
$avatarUuid->getValue() | ||
); | ||
|
||
return $balance > self::MONETARY_ACCOUNT_BALANCE_THRESHOLD; | ||
$this->cashRegister = CashRegister::get($cashRegisterId->getValue()); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getAttachmentContentType(): string | ||
{ | ||
return self::ATTACHMENT_CONTENT_TYPE; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getAttachmentDescription(): string | ||
{ | ||
return self::ATTACHMENT_DESCRIPTION; | ||
} | ||
|
||
/** | ||
|
@@ -275,4 +265,14 @@ protected function skipTestIfNeededDueToInsufficientBalance(): bool | |
|
||
return true; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
protected function isMonetaryAccountBalanceSufficient(): bool | ||
{ | ||
$balance = floatval(BunqContext::getUserContext()->getPrimaryMonetaryAccount()->getBalance()->getValue()); | ||
|
||
return $balance > self::MONETARY_ACCOUNT_BALANCE_THRESHOLD; | ||
} | ||
} |