Skip to content

Commit

Permalink
updated tests and models
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Oct 30, 2024
1 parent 374664f commit a4a3d22
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 70 deletions.
9 changes: 5 additions & 4 deletions MangoPay/ApiVirtualAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ public function GetAll($walletId, $pagination = null, $sorting = null)
* @param string $virtualAccountId
* @return \MangoPay\VirtualAccount
*/
public function Deactivate($virtualAccount, $walletId, $virtualAccountId)
public function Deactivate($walletId, $virtualAccountId)
{
return $this->SaveObject('virtual_account_deactivate', $virtualAccount, '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
$empty_object = "";
return $this->SaveObject('virtual_account_deactivate', $empty_object, '\MangoPay\VirtualAccount', $walletId, $virtualAccountId);
}

/**
* @return \MangoPay\VirtualAccountAvailabilities
*/
public function GetAvailabilities()
{
return $this->GetObject('virtual_account_get_availabilities','\MangoPay\VirtualAccountAvailabilities');
return $this->GetObject('virtual_account_get_availabilities', '\MangoPay\VirtualAccountAvailabilities');
}
}
}
4 changes: 2 additions & 2 deletions MangoPay/InternationalAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MangoPay;

class InternationalAccount
class InternationalAccount extends Libraries\Dto
{
/**
* @var string
Expand All @@ -13,4 +13,4 @@ class InternationalAccount
* @var string
*/
public $Bic;
}
}
4 changes: 2 additions & 2 deletions MangoPay/InternationalAccountDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MangoPay;

class InternationalAccountDetails
class InternationalAccountDetails extends Libraries\Dto
{
/**
* Information about the address associated with the international IBAN account.
Expand All @@ -15,4 +15,4 @@ class InternationalAccountDetails
* @var InternationalAccount
*/
public $Account;
}
}
6 changes: 4 additions & 2 deletions MangoPay/LocalAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

namespace MangoPay;

class LocalAccount
class LocalAccount extends Libraries\Dto
{
/**
* The account number of the account
* @var string
*/
public $AccountNumber;

/**
* The sort code of the account.
* @var string
*/
public $SortCode;
}
}
4 changes: 2 additions & 2 deletions MangoPay/LocalAccountDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MangoPay;

class LocalAccountDetails
class LocalAccountDetails extends Libraries\Dto
{
/**
* Information about the address associated with the local IBAN account.
Expand All @@ -15,4 +15,4 @@ class LocalAccountDetails
* @var LocalAccount
*/
public $Account;
}
}
4 changes: 1 addition & 3 deletions MangoPay/VirtualAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,4 @@ class VirtualAccount extends Libraries\EntityBase
* @var \MangoPay\VirtualAccountCapabilities
*/
public $Capabilities;


}
}
3 changes: 1 addition & 2 deletions MangoPay/VirtualAccountAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ class VirtualAccountAddress extends Libraries\Dto
* @var string
*/
public $Country;

}
}
18 changes: 2 additions & 16 deletions MangoPay/VirtualAccountAvailabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MangoPay;

class VirtualAccountAvailabilities extends Libraries\EntityBase
class VirtualAccountAvailabilities extends Libraries\Dto
{
/**
* * @var VirtualAccountAvailability[]
Expand All @@ -13,18 +13,4 @@ class VirtualAccountAvailabilities extends Libraries\EntityBase
* * @var VirtualAccountAvailability[]
*/
public $UserOwned;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();

$subObjects['Collection'] = '\MangoPay\VirtualAccountAvailability';
$subObjects['UserOwned'] = '\MangoPay\VirtualAccountAvailability';

return $subObjects;
}
}
}
15 changes: 1 addition & 14 deletions MangoPay/VirtualAccountAvailability.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,4 @@ class VirtualAccountAvailability extends Libraries\EntityBase
* @var CurrencyIso[]
* */
public $Currencies;

/**
* Get array with mapping which property is object and what type of object
* @return array
*/
public function GetSubObjects()
{
$subObjects = parent::GetSubObjects();

$subObjects['Currencies'] = '\MangoPay\CurrencyIso';

return $subObjects;
}
}
}
8 changes: 4 additions & 4 deletions MangoPay/VirtualAccountCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace MangoPay;

class VirtualAccountCapabilities
class VirtualAccountCapabilities extends Libraries\Dto
{
/**
* Whether local bank wires can be made to this account.
* @var Boolean
* @var bool
*/
public $LocalPayInAvailable;

/**
* Whether international bank wires can be made to this account
* @var Boolean
* @var bool
*/
public $InternationalPayInAvailable;

Expand All @@ -21,4 +21,4 @@ class VirtualAccountCapabilities
* @var CurrencyIso[]
*/
public $Currencies;
}
}
2 changes: 1 addition & 1 deletion MangoPay/VirtualAccountOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class VirtualAccountOwner
{
const Collection = "COLLECTION";
const UserOwned = "USER_OWNED";
}
}
2 changes: 1 addition & 1 deletion MangoPay/VirtualAccountPurpose.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class VirtualAccountPurpose
{
const Collection = "COLLECTION";
const UserOwned = "USER_OWNED";
}
}
17 changes: 17 additions & 0 deletions tests/Cases/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use MangoPay\ShippingPreference;
use MangoPay\Tests\Mocks\MockStorageStrategy;
use MangoPay\Ubo;
use MangoPay\VirtualAccount;
use PHPUnit\Framework\TestCase;

set_time_limit(0);
Expand Down Expand Up @@ -52,6 +53,7 @@ abstract class Base extends TestCase
* @var \MangoPay\Wallet
*/
public static $JohnsWallet;
public static $johnsVirtualAccount;
/**
* Test Kyc Document belonging to John
* @var \MangoPay\KycDocument
Expand Down Expand Up @@ -259,6 +261,21 @@ protected function getJohnsWallet()
return self::$JohnsWallet;
}

protected function getNewVirtualAccount()
{
if (self::$johnsVirtualAccount === null) {
$wallet = $this->getJohnsWallet();
$virtualAccount = new VirtualAccount();
$virtualAccount->Country = "FR";
$virtualAccount->VirtualAccountPurpose = "Collection";
$virtualAccount->Tag = "create virtual account tag";

self::$johnsVirtualAccount = $this->_api->VirtualAccounts->Create($virtualAccount, $wallet->Id);
}

return self::$johnsVirtualAccount;
}

/**
* Creates Pay-In Card Web object
* @return \MangoPay\PayIn
Expand Down
32 changes: 15 additions & 17 deletions tests/Cases/VirtualAccountsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,33 @@ class VirtualAccountsTest extends Base
public static $johnsVirtualAccount;
public function test_VirtualAccount_Create()
{
$wallet = $this->getJohnsWallet();
$virtualAccount = new VirtualAccount();
$virtualAccount->Country = "FR";
$virtualAccount->VirtualAccountPurpose = "Collection";
$virtualAccount->Tag = "create virtual account tag";

self::$johnsVirtualAccount = $this->_api->VirtualAccounts->Create($virtualAccount, $wallet->Id);
$virtualAccount = $this->getNewVirtualAccount();
$wallet = $this -> getJohnsWallet();

$this->assertNotNull(self::$johnsVirtualAccount);
$this->assertEquals(self::$johnsVirtualAccount->WalletId, $wallet->Id);
$this->assertNotNull($virtualAccount);
$this->assertEquals($virtualAccount->WalletId, $wallet->Id);
}

public function test_VirtualAccount_Get()
{
$wallet = $this->getJohnsWallet();
$virtualAccount = $this->getNewVirtualAccount();
$wallet = $this -> getJohnsWallet();
$fetchedVirtualAccount = $this->_api->VirtualAccounts->Get($wallet->Id, $virtualAccount->Id);

$virtualAccounts = $this->_api->VirtualAccounts->GetAll($wallet->Id);

$this->assertNotNull($virtualAccounts);
$this->assertTrue(is_array($virtualAccounts), 'Expected an array');
$this->assertNotNull($fetchedVirtualAccount);
$this->assertEquals($fetchedVirtualAccount->Id, $virtualAccount->Id);
}

public function test_VirtualAccount_GetAll()
{
$this->getNewVirtualAccount();
$wallet = $this->getJohnsWallet();

$virtualAccounts = $this->_api->VirtualAccounts->GetAll($wallet->Id);

$this->assertNotNull($virtualAccounts);
$this->assertTrue(is_array($virtualAccounts), 'Expected an array');
$this->assertEquals(1, sizeof($virtualAccounts));
}

public function test_VirtualAccount_Get_Availabilities()
Expand All @@ -60,10 +57,11 @@ public function test_VirtualAccount_Get_Availabilities()

public function test_VirtualAccount_Deactivate()
{
$virtualAccount = $this->getNewVirtualAccount();
$wallet = $this->getJohnsWallet();
self::$johnsVirtualAccount->Active = false;
$deactivatedVirtualAccount = $this->_api->VirtualAccounts->Deactivate(self::$johnsVirtualAccount, $wallet->Id, self::$johnsVirtualAccount->Id);
$deactivatedVirtualAccount = $this->_api->VirtualAccounts->Deactivate($wallet->Id, $virtualAccount->Id);

$this->assertNotTrue($deactivatedVirtualAccount->Active);
$this->assertEquals('CLOSED', $deactivatedVirtualAccount->Status);
}
}
}

0 comments on commit a4a3d22

Please sign in to comment.