-
Notifications
You must be signed in to change notification settings - Fork 132
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
1 parent
490af3e
commit c4a6a2c
Showing
8 changed files
with
163 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace MangoPay; | ||
|
||
/** | ||
* Class represents an address. | ||
*/ | ||
class Address extends Libraries\Dto { | ||
|
||
/** | ||
* Address line 1. | ||
* @var String | ||
*/ | ||
public $AddressLine1; | ||
|
||
/** | ||
* Address line 2. | ||
* @var String | ||
*/ | ||
public $AddressLine2; | ||
|
||
/** | ||
* City. | ||
* @var String | ||
*/ | ||
public $City; | ||
|
||
/** | ||
* Region. | ||
* @var String | ||
*/ | ||
public $Region; | ||
|
||
/** | ||
* Postal code. | ||
* @var String | ||
*/ | ||
public $PostalCode; | ||
|
||
/** | ||
* Country. | ||
* @var String | ||
*/ | ||
public $Country; | ||
} |
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
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
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
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
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
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 |
---|---|---|
|
@@ -95,6 +95,23 @@ protected function buildNewMangoPayApi() { | |
|
||
return $api; | ||
} | ||
|
||
/** | ||
* Creates new address | ||
* @return \MangoPay\Address | ||
*/ | ||
protected function getNewAddress() { | ||
$result = new \MangoPay\Address(); | ||
|
||
$result->AddressLine1 = 'Address line 1'; | ||
$result->AddressLine2 = 'Address line 2'; | ||
$result->City = 'City'; | ||
$result->Country = 'FR'; | ||
$result->PostalCode = '11222'; | ||
$result->Region = 'Region'; | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Creates self::$John (test natural user) if not created yet | ||
|
@@ -106,7 +123,7 @@ protected function getJohn() { | |
$user->FirstName = "John"; | ||
$user->LastName = "Doe"; | ||
$user->Email = "[email protected]"; | ||
$user->Address = "Some Address"; | ||
$user->Address = $this->getNewAddress(); | ||
$user->Birthday = mktime(0, 0, 0, 12, 21, 1975); | ||
$user->Nationality = "FR"; | ||
$user->CountryOfResidence = "FR"; | ||
|
@@ -126,7 +143,7 @@ protected function getNewJohn() { | |
$user->FirstName = "John"; | ||
$user->LastName = "Doe"; | ||
$user->Email = "[email protected]"; | ||
$user->Address = "Some Address"; | ||
$user->Address = $this->getNewAddress(); | ||
$user->Birthday = mktime(0, 0, 0, 12, 21, 1975); | ||
$user->Nationality = "FR"; | ||
$user->CountryOfResidence = "FR"; | ||
|
@@ -146,7 +163,7 @@ protected function getMatrix() { | |
$user->Name = "MartixSampleOrg"; | ||
$user->Email = "[email protected]"; | ||
$user->LegalPersonType = "BUSINESS"; | ||
$user->HeadquartersAddress = "Some Address"; | ||
$user->HeadquartersAddress = $this->getNewAddress(); | ||
$user->LegalRepresentativeFirstName = $john->FirstName; | ||
$user->LegalRepresentativeLastName = $john->LastName; | ||
$user->LegalRepresentativeAddress = $john->Address; | ||
|
@@ -607,7 +624,14 @@ protected function assertIdenticalInputProps($entity1, $entity2) { | |
$this->assertIdentical($entity1->FirstName, $entity2->FirstName); | ||
$this->assertIdentical($entity1->LastName, $entity2->LastName); | ||
$this->assertIdentical($entity1->Email, $entity2->Email); | ||
$this->assertIdentical($entity1->Address, $entity2->Address); | ||
$this->assertNotNull($entity1->Address); | ||
$this->assertNotNull($entity2->Address); | ||
$this->assertEqual($entity1->Address->AddressLine1, $entity1->Address->AddressLine1); | ||
$this->assertEqual($entity1->Address->AddressLine2, $entity1->Address->AddressLine2); | ||
$this->assertEqual($entity1->Address->City, $entity1->Address->City); | ||
$this->assertEqual($entity1->Address->Country, $entity1->Address->Country); | ||
$this->assertEqual($entity1->Address->PostalCode, $entity1->Address->PostalCode); | ||
$this->assertEqual($entity1->Address->Region, $entity1->Address->Region); | ||
$this->assertIdentical($entity1->Birthday, $entity2->Birthday); | ||
$this->assertIdentical($entity1->Nationality, $entity2->Nationality); | ||
$this->assertIdentical($entity1->CountryOfResidence, $entity2->CountryOfResidence); | ||
|
@@ -617,10 +641,29 @@ protected function assertIdenticalInputProps($entity1, $entity2) { | |
$this->assertIdentical($entity1->Tag, $entity2->Tag); | ||
$this->assertIdentical($entity1->PersonType, $entity2->PersonType); | ||
$this->assertIdentical($entity1->Name, $entity2->Name); | ||
$this->assertIdentical($entity1->HeadquartersAddress, $entity2->HeadquartersAddress); | ||
$this->assertNotNull($entity1->HeadquartersAddress); | ||
$this->assertNotNull($entity2->HeadquartersAddress); | ||
$this->assertEqual($entity1->HeadquartersAddress->AddressLine1, $entity1->HeadquartersAddress->AddressLine1); | ||
$this->assertEqual($entity1->HeadquartersAddress->AddressLine2, $entity1->HeadquartersAddress->AddressLine2); | ||
$this->assertEqual($entity1->HeadquartersAddress->City, $entity1->HeadquartersAddress->City); | ||
$this->assertEqual($entity1->HeadquartersAddress->Country, $entity1->HeadquartersAddress->Country); | ||
$this->assertEqual($entity1->HeadquartersAddress->PostalCode, $entity1->HeadquartersAddress->PostalCode); | ||
$this->assertEqual($entity1->HeadquartersAddress->Region, $entity1->HeadquartersAddress->Region); | ||
$this->assertIdentical($entity1->LegalRepresentativeFirstName, $entity2->LegalRepresentativeFirstName); | ||
$this->assertIdentical($entity1->LegalRepresentativeLastName, $entity2->LegalRepresentativeLastName); | ||
|
||
|
||
//$this->assertIdentical($entity1->LegalRepresentativeAddress, $entity2->LegalRepresentativeAddress, "***** TEMPORARY API ISSUE: RETURNED OBJECT MISSES THIS PROP AFTER CREATION *****"); | ||
$this->assertNotNull($entity1->LegalRepresentativeAddress); | ||
$this->assertNotNull($entity2->LegalRepresentativeAddress); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->AddressLine1, $entity1->LegalRepresentativeAddress->AddressLine1); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->AddressLine2, $entity1->LegalRepresentativeAddress->AddressLine2); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->City, $entity1->LegalRepresentativeAddress->City); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->Country, $entity1->LegalRepresentativeAddress->Country); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->PostalCode, $entity1->LegalRepresentativeAddress->PostalCode); | ||
$this->assertEqual($entity1->LegalRepresentativeAddress->Region, $entity1->LegalRepresentativeAddress->Region); | ||
|
||
|
||
$this->assertIdentical($entity1->LegalRepresentativeEmail, $entity2->LegalRepresentativeEmail); | ||
$this->assertIdentical($entity1->LegalRepresentativeBirthday, $entity2->LegalRepresentativeBirthday, "***** TEMPORARY API ISSUE: RETURNED OBJECT HAS THIS PROP CHANGED FROM TIMESTAMP INTO ISO STRING AFTER CREATION *****"); | ||
$this->assertIdentical($entity1->LegalRepresentativeNationality, $entity2->LegalRepresentativeNationality); | ||
|
@@ -630,7 +673,14 @@ protected function assertIdenticalInputProps($entity1, $entity2) { | |
$this->assertIdentical($entity1->UserId, $entity2->UserId); | ||
$this->assertIdentical($entity1->Type, $entity2->Type); | ||
$this->assertIdentical($entity1->OwnerName, $entity2->OwnerName); | ||
$this->assertIdentical($entity1->OwnerAddress, $entity2->OwnerAddress); | ||
$this->assertNotNull($entity1->OwnerAddress); | ||
$this->assertNotNull($entity2->OwnerAddress); | ||
$this->assertEqual($entity1->OwnerAddress->AddressLine1, $entity1->OwnerAddress->AddressLine1); | ||
$this->assertEqual($entity1->OwnerAddress->AddressLine2, $entity1->OwnerAddress->AddressLine2); | ||
$this->assertEqual($entity1->OwnerAddress->City, $entity1->OwnerAddress->City); | ||
$this->assertEqual($entity1->OwnerAddress->Country, $entity1->OwnerAddress->Country); | ||
$this->assertEqual($entity1->OwnerAddress->PostalCode, $entity1->OwnerAddress->PostalCode); | ||
$this->assertEqual($entity1->OwnerAddress->Region, $entity1->OwnerAddress->Region); | ||
if ($entity1->Type == 'IBAN') { | ||
$this->assertIdentical($entity1->Details->IBAN, $entity2->Details->IBAN); | ||
$this->assertIdentical($entity1->Details->BIC, $entity2->Details->BIC); | ||
|
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 |
---|---|---|
|
@@ -30,12 +30,25 @@ function test_Users_CreateLegal_FailsIfRequiredPropsNotProvided() { | |
|
||
function test_Users_CreateLegal_PassesIfRequiredPropsProvided() { | ||
$user = new \MangoPay\UserLegal(); | ||
$user->HeadquartersAddress = new \MangoPay\Address(); | ||
$user->HeadquartersAddress->AddressLine1 = 'AddressLine1'; | ||
$user->HeadquartersAddress->AddressLine2 = 'AddressLine2'; | ||
$user->HeadquartersAddress->City = 'City'; | ||
$user->HeadquartersAddress->Country = 'FR'; | ||
$user->HeadquartersAddress->PostalCode = '11222'; | ||
$user->HeadquartersAddress->Region = 'Region'; | ||
$user->Name = "SomeOtherSampleOrg"; | ||
$user->Email = "[email protected]"; | ||
$user->LegalPersonType = "BUSINESS"; | ||
$user->LegalRepresentativeFirstName = "FirstName"; | ||
$user->LegalRepresentativeLastName = "LastName"; | ||
$user->LegalRepresentativeAddress = "Address"; | ||
$user->LegalRepresentativeAddress = new \MangoPay\Address(); | ||
$user->LegalRepresentativeAddress->AddressLine1 = 'AddressLine1'; | ||
$user->LegalRepresentativeAddress->AddressLine2 = 'AddressLine2'; | ||
$user->LegalRepresentativeAddress->City = 'City'; | ||
$user->LegalRepresentativeAddress->Country = 'FR'; | ||
$user->LegalRepresentativeAddress->PostalCode = '11222'; | ||
$user->LegalRepresentativeAddress->Region = 'Region'; | ||
$user->LegalRepresentativeBirthday = mktime(0, 0, 0, 12, 21, 1975); | ||
$user->LegalRepresentativeNationality = "FR"; | ||
$user->LegalRepresentativeCountryOfResidence = "FR"; | ||
|