Exemplo n.º 1
0
 /**
  * @param  Beneficiary               $beneficiary
  * @throws \InvalidArgumentException If $beneficiary is not valid
  */
 public function __construct(Beneficiary $beneficiary)
 {
     if ($beneficiary->isValid() === false) {
         throw new \InvalidArgumentException("Beneficiary::isValid() returned false");
     }
     $this->setModel($beneficiary);
 }
 public function testFetch()
 {
     $entity = new Beneficiary();
     $entity->setBankAccountOwnerName('Mark Zuckerberg');
     $entity->setBankAccountOwnerAddress('1 bis Cité Paradis, 75010 Paris');
     $entity->setBankAccountIBAN('FR3020041010124530725S03383');
     $entity->setBankAccountBIC('CRLYFRPP');
     $response = $this->getClient()->request(new CreateBeneficiary($entity));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     $responseEntity = $response->getModel();
     $id = $response->getModel()->getID();
     $response = $this->getClient()->request(new FetchBeneficiary($id));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     $responseEntity = $response->getModel();
     $responseEntity = $response->getModel();
     $this->assertFalse($entity === $responseEntity);
     $this->assertSame($id, $responseEntity->getID());
     $this->assertSame($entity->getBankAccountOwnerName(), $responseEntity->getBankAccountOwnerName());
     $this->assertSame($entity->getBankAccountOwnerAddress(), $responseEntity->getBankAccountOwnerAddress());
     $this->assertSame($entity->getBankAccountIBAN(), $responseEntity->getBankAccountIBAN());
     $this->assertSame($entity->getBankAccountBIC(), $responseEntity->getBankAccountBIC());
     $this->assertGreaterThan(0, $responseEntity->getCreationDate());
     $this->assertGreaterThan(0, $responseEntity->getUpdateDate());
     $this->assertNull($responseEntity->getTag());
     $this->assertSame(0, $responseEntity->getUserID());
 }