Skip to content

Commit

Permalink
SUPPORT-84787 Remove create() method from Paysera_WalletApi_Entity_Cl…
Browse files Browse the repository at this point in the history
…ientPermissionsToWallet
  • Loading branch information
Dmytro Panchenko authored and dzmitrybitsiutski committed Feb 8, 2024
1 parent 43c0870 commit d35bebd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
8 changes: 0 additions & 8 deletions src/Paysera/WalletApi/Entity/ClientPermissionsToWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ class Paysera_WalletApi_Entity_ClientPermissionsToWallet
*/
private $scopes = [];

/**
* @return self
*/
public static function create()
{
return new self();
}

/**
* @param Paysera_WalletApi_Entity_Wallet $wallet
* @return self
Expand Down
2 changes: 1 addition & 1 deletion src/Paysera/WalletApi/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,7 @@ public function decodeClientPermissionsToWallets(array $clientPermissionsToWalle
*/
public function decodeClientPermissionsToWallet(array $clientPermissionsToWallet)
{
return Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
return (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->decodeWallet($clientPermissionsToWallet['wallet']))
->setScopes($clientPermissionsToWallet['scopes'])
;
Expand Down
46 changes: 23 additions & 23 deletions tests/Paysera/WalletApi/MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ public function testDecodeClientDataProvider()
->setMainProjectId(1)
->setPermissionsToWallets(
[
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(1, 1, $this->createAccount('EVP1')))
->setScopes(['balance']),
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(2, 2, $this->createAccount('EVP2')))
->setScopes(['statements']),
]
Expand Down Expand Up @@ -422,10 +422,10 @@ public function testDecodeClientDataProvider()
->setMainProjectId(1)
->setPermissionsToWallets(
[
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(1, 1, $this->createAccount('EVP1')))
->setScopes(['balance']),
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(2, 2, $this->createAccount('EVP2')))
->setScopes(['statements']),
]
Expand Down Expand Up @@ -517,10 +517,10 @@ public function testDecodeClientDataProvider()
->setMainProjectId(1)
->setPermissionsToWallets(
[
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(1, 1, $this->createAccount('EVP1')))
->setScopes(['balance']),
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(2, 2, $this->createAccount('EVP2')))
->setScopes(['statements']),
]
Expand Down Expand Up @@ -631,10 +631,10 @@ public function testEncodeClientDataProvider()
)
->setPermissionsToWallets(
[
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(1, 1, $this->createAccount('EVP1')))
->setScopes(['balance']),
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(2, 2, $this->createAccount('EVP2')))
->setScopes(['statements']),
]
Expand Down Expand Up @@ -685,10 +685,10 @@ public function testEncodeClientDataProvider()
)
->setPermissionsToWallets(
[
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(1, 1, $this->createAccount('EVP1')))
->setScopes(['balance']),
Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
(new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->createWallet(2, 2, $this->createAccount('EVP2')))
->setScopes(['statements']),
]
Expand Down Expand Up @@ -790,7 +790,7 @@ public function decodeClientPermissionsToWalletDataProvider()
],
'scopes' => [],
],
'expectedPermission' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'expectedPermission' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(1, $this->getAccount('EVP1')))
->setScopes([]),
'isBalanceGranted' => false,
Expand All @@ -809,7 +809,7 @@ public function decodeClientPermissionsToWalletDataProvider()
'balance'
],
],
'expectedPermission' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'expectedPermission' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(2, $this->getAccount('EVP2')))
->setScopes([Paysera_WalletApi_OAuth_Consumer::SCOPE_BALANCE]),
'isBalanceGranted' => true,
Expand All @@ -828,7 +828,7 @@ public function decodeClientPermissionsToWalletDataProvider()
'statements'
],
],
'expectedPermission' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'expectedPermission' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(3, $this->getAccount('EVP3')))
->setScopes([Paysera_WalletApi_OAuth_Consumer::SCOPE_STATEMENTS]),
'isBalanceGranted' => false,
Expand All @@ -848,7 +848,7 @@ public function decodeClientPermissionsToWalletDataProvider()
'statements',
],
],
'expectedPermission' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'expectedPermission' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(4, $this->getAccount('EVP4')))
->setScopes([
Paysera_WalletApi_OAuth_Consumer::SCOPE_BALANCE,
Expand All @@ -870,7 +870,7 @@ public function decodeClientPermissionsToWalletDataProvider()
'unknown'
],
],
'expectedPermission' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'expectedPermission' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(5, $this->getAccount('EVP5')))
->setScopes([
'unknown'
Expand All @@ -885,30 +885,30 @@ public function encodeClientPermissionsToWalletDataProvider()
{
return [
'Case 1 Expect empty wallet exception' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setScopes([]),
'expected' => new Paysera_WalletApi_Exception_LogicException('Wallet must be provided'),
],
'Case 2 Expect empty wallet ID exception' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(null, null))
->setScopes([]),
'expected' => new Paysera_WalletApi_Exception_LogicException('Wallet ID must be provided'),
],
'Case 3 Expect empty account exception' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(1, null))
->setScopes([]),
'expected' => new Paysera_WalletApi_Exception_LogicException('Account must be provided'),
],
'Case 4 Expect empty account number exception' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(1, $this->getAccount(null)))
->setScopes([]),
'expected' => new Paysera_WalletApi_Exception_LogicException('Account number must be provided'),
],
'Case 3 No scopes' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(2, $this->getAccount('EVP2')))
->setScopes([]),
'expected' => [
Expand All @@ -918,7 +918,7 @@ public function encodeClientPermissionsToWalletDataProvider()
],
],
'Case 4 Balance only' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(3, $this->getAccount('EVP3')))
->setScopes([Paysera_WalletApi_OAuth_Consumer::SCOPE_BALANCE]),
'expected' => [
Expand All @@ -928,7 +928,7 @@ public function encodeClientPermissionsToWalletDataProvider()
],
],
'Case 5 Statements only' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(4, $this->getAccount('EVP4')))
->setScopes([Paysera_WalletApi_OAuth_Consumer::SCOPE_STATEMENTS]),
'expected' => [
Expand All @@ -938,7 +938,7 @@ public function encodeClientPermissionsToWalletDataProvider()
],
],
'Case 6 Both balance and statements' => [
'input' => Paysera_WalletApi_Entity_ClientPermissionsToWallet::create()
'input' => (new Paysera_WalletApi_Entity_ClientPermissionsToWallet())
->setWallet($this->getWallet(5, $this->getAccount('EVP5')))
->setScopes([
Paysera_WalletApi_OAuth_Consumer::SCOPE_BALANCE,
Expand Down

0 comments on commit d35bebd

Please sign in to comment.