예제 #1
0
파일: MoneyTest.php 프로젝트: brick/money
 /**
  * @dataProvider providerOf
  *
  * @param string $expectedResult The resulting money as a string, or an exception class.
  * @param mixed  ...$args        The arguments to the of() method.
  */
 public function testOf($expectedResult, ...$args)
 {
     if ($this->isExceptionClass($expectedResult)) {
         $this->setExpectedException($expectedResult);
     }
     $money = Money::of(...$args);
     if (!$this->isExceptionClass($expectedResult)) {
         $this->assertMoneyIs($expectedResult, $money);
     }
 }
예제 #2
0
 /**
  * @depends testNewMoneyBagIsEmpty
  *
  * @param MoneyBag $moneyBag
  *
  * @return MoneyBag
  */
 public function testAddSubtractMoney(MoneyBag $moneyBag)
 {
     $moneyBag->add(Money::of('123', 'EUR'));
     $this->assertMoneyBagContains(['EUR 123.00'], $moneyBag);
     $moneyBag->add(Money::of('234.99', 'EUR'));
     $this->assertMoneyBagContains(['EUR 357.99'], $moneyBag);
     $moneyBag->add(Money::of(3, 'JPY'));
     $this->assertMoneyBagContains(['EUR 357.99', 'JPY 3'], $moneyBag);
     $moneyBag->add(Money::parse('JPY 1.1234'));
     $this->assertMoneyBagContains(['EUR 357.99', 'JPY 4.1234'], $moneyBag);
     $moneyBag->subtract(Money::parse('EUR 3.589950'));
     $this->assertMoneyBagContains(['EUR 354.400050', 'JPY 4.1234'], $moneyBag);
     return $moneyBag;
 }
예제 #3
0
 public function testInquire()
 {
     $card = new Card('1111222233334444', '1216', '123');
     $amount = Money::of(10, 'EUR');
     $reference = __FUNCTION__ . '-' . time();
     $paybox = $this->getTestPayboxDirectInstance();
     $request = new AuthorizeAndCapture($card, $amount, $reference);
     $captureResponse = $paybox->execute($request);
     $this->assertResponseStatus($captureResponse, PayboxDirectResponse::SUCCESS);
     $request = new Inquire($captureResponse->getNumtrans());
     $response = $paybox->execute($request);
     $this->assertResponseStatus($response, PayboxDirectResponse::SUCCESS);
     $this->assertSame($captureResponse->getNumappel(), $response->getNumappel());
     $this->assertSame($captureResponse->getNumtrans(), $response->getNumtrans());
     $this->assertSame(utf8_decode('Capturé'), $response->getStatus());
 }