/** * @cover ::createOperation */ public function testCreateOperatorOperation() { $this->operationManager->create(Argument::type('float'), Argument::type('DateTime'), Argument::type('string'), Argument::is(false))->will(function ($args) { list($amount, $cycleDate, $paymentVoucher, $miraklId) = $args; return new Operation($amount, $cycleDate, $paymentVoucher, $miraklId); })->shouldBeCalled(); $expectedOperation = new Operation(200, new DateTime(), "000001", false); $expectedOperation->setHipayId($this->operator->getHipayId()); $resultOperation = $this->cashoutInitializer->createOperation((double) 200, new DateTime(), "000001", false); $this->assertEquals($resultOperation->getHiPayId(), $this->operator->getHipayId()); $this->assertEquals($expectedOperation, $resultOperation); }
/** * @cover ::handleHiPayNotification * @throws \HiPay\Wallet\Mirakl\Exception\ChecksumFailedException * @throws \HiPay\Wallet\Mirakl\Exception\IllegalNotificationOperationException */ public function testWithdrawCancelNotification() { $xml = $this->readFile("withdrawCanceled.xml"); $operation = new Operation(2000, new DateTime(), "000001", rand()); $operation->setStatus(new Status(Status::WITHDRAW_REQUESTED)); $this->operationManager->findByWithdrawalId(Argument::type("string"))->willReturn($operation)->shouldBeCalled(); $this->operationManager->save(Argument::is($operation))->shouldBeCalled(); $this->setEventAssertion(array("withdraw", "canceled"), "Withdraw"); $this->notificationHandler->handleHiPayNotification($xml); $this->assertEquals(Status::WITHDRAW_CANCELED, $operation->getStatus()); }
/** * @cover ::withdraw * @group withdraw */ public function testWithdrawUnvalidatedBankInfo() { $amount = floatval(rand()); $vendor = new Vendor("*****@*****.**", rand(), rand()); $operation = new Operation($amount, new DateTime(), "000001", $vendor->getHipayId()); $operation->setStatus(new Status(Status::TRANSFER_SUCCESS)); /** @var VendorInterface $vendorArgument */ $vendorArgument = Argument::is($vendor); $this->vendorManager->findByMiraklId(Argument::is($operation->getMiraklId()))->willReturn($vendor); $this->hipay->isAvailable(Argument::containingString("@"), Argument::any())->willReturn(false); $this->hipay->isIdentified(Argument::containingString("@"))->willReturn(true); $this->hipay->bankInfosStatus($vendorArgument)->willReturn(BankInfo::BLANK)->shouldBeCalled(); $this->hipay->getBalance($vendorArgument)->willReturn($amount + 1); $this->hipay->withdraw(Argument::cetera())->shouldNotBeCalled(); $this->setExpectedException("\\HiPay\\Wallet\\Mirakl\\Exception\\UnconfirmedBankAccountException"); $this->cashoutProcessor->withdraw($operation); }