예제 #1
0
 /**
  * @param  Wallet                    $wallet
  * @throws \InvalidArgumentException If $wallet is not valid
  */
 public function __construct(Wallet $wallet)
 {
     if ($wallet->isValid() === false) {
         throw new \InvalidArgumentException("Wallet::isValid() returned false");
     }
     $this->setModel($wallet);
 }
예제 #2
0
 /**
  * @param  User   $user defaults to null
  * @return Wallet
  */
 protected function createWallet($user = null)
 {
     if ($user === null) {
         $user = $this->createUser();
     }
     $entity = new Wallet();
     $entity->setOwners(array($user->getID()));
     $entity->setTag('tag');
     $entity->setName('wallet');
     $entity->setDescription('mangopay wallet');
     $entity->setRaisingGoalAmount(100);
     $entity->setContributionLimitDate(new \DateTime('+1 year'));
     $response = $this->getClient()->request(new CreateWallet($entity));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     return $response->getModel();
 }
예제 #3
0
 public function testRequiredFields()
 {
     $user = $this->createUser();
     $entity = new Wallet();
     $entity->setOwners(array($user->getID()));
     $entity->setTag('tag');
     $entity->setName('wallet');
     $entity->setDescription('mangopay wallet');
     $entity->setRaisingGoalAmount(100);
     $entity->setContributionLimitDate(new \DateTime('+1 year'));
     $response = $this->getClient()->request(new CreateWallet($entity));
     $this->assertInstanceOf('Gordalina\\Mangopay\\Response\\ResponseInterface', $response);
     $this->assertTrue($response->isSuccessful());
     $responseEntity = $response->getModel();
     $this->assertFalse($entity === $responseEntity);
     $this->assertSame($entity->getOwners(), $responseEntity->getOwners());
     $this->assertSame($entity->getTag(), $responseEntity->getTag());
     $this->assertSame($entity->getName(), $responseEntity->getName());
     $this->assertSame($entity->getDescription(), $responseEntity->getDescription());
     $this->assertSame($entity->getRaisingGoalAmount(), $responseEntity->getRaisingGoalAmount());
     $this->assertSame($entity->getContributionLimitDate(), $responseEntity->getContributionLimitDate());
     $this->assertSame(0, $responseEntity->getCollectedAmount());
     $this->assertSame(0, $responseEntity->getSpentAmount());
     $this->assertSame(0, $responseEntity->getAmount());
 }