Skip to content

Commit

Permalink
Merge pull request #29 from alch/fix/tests
Browse files Browse the repository at this point in the history
Fix/tests
  • Loading branch information
mickaelandrieu committed Apr 23, 2015
2 parents 8e0cbe1 + 8cc0b30 commit b6c1b73
Show file tree
Hide file tree
Showing 25 changed files with 199 additions and 172 deletions.
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: php

env:
- COMPOSER_OPTIONS="--prefer-source"

php:
- 5.4
- 5.5
- 5.6
- hhvm
- 7.0

matrix:
fast_finish: true
allow_failures:
- php: 7.0
include:
- php: 5.4
env: COMPOSER_OPTIONS="--prefer-lowest"

before_install:
- sh -c "sudo mkdir vendor"
- sh -c "sudo mount -t tmpfs -o size=512M tmpfs vendor"

install:
- composer update --no-interaction ${COMPOSER_OPTIONS}

script:
- phpunit

notifications:
email: false
15 changes: 14 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,27 @@
],
"require": {
"php": ">=5.3.3",
"symfony/finder": ">=2.2.3",
"symfony/framework-bundle": ">=2.2.3",
"symfony/form": ">=2.2.3",
"symfony/config": ">=2.2.3",
"symfony/http-kernel": ">=2.2.3",
"symfony/dependency-injection": ">=2.2.3",
"sensio/framework-extra-bundle": "~3.0",
"psr/log": "~1.0",
"paymill/paymill": ">=3.0",
"stripe/stripe-php": "v1.10.1"
"stripe/stripe-php": "1.10.1.*",
"monolog/monolog": "~1.13"
},
"require-dev": {
"phpunit/phpunit": "4.6.*",
"symfony/twig-bundle": ">=2.2.3",
"symfony/monolog-bundle": ">=2.2.3",
"symfony/browser-kit": ">=2.2.3",
"symfony/css-selector": ">=2.2.3",
"symfony/twig-bundle": ">=2.2.3",
"elcodi/core-bundle": "0.5.*",
"elcodi/test-common-bundle": "0.5.*"
},
"replace": {
"paymentsuite/authorizenet-bundle": "self.version",
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
Expand All @@ -28,4 +28,4 @@
</whitelist>
</filter>

</phpunit>
</phpunit>
66 changes: 0 additions & 66 deletions split.sh

This file was deleted.

14 changes: 10 additions & 4 deletions src/PaymentSuite/BanwireBundle/Services/BanwireManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ public function processPayment(BanwireMethod $paymentMethod, $amount)
/**
* first check that amounts are the same
*/
$paymentBridgeAmount = (float) $this->paymentBridge->getAmount();
$paymentBridgeAmount = intval($this->paymentBridge->getAmount());
/**
* If both amounts are different, execute Exception
*/
if (abs($amount - $paymentBridgeAmount) > 0.00001) {
throw new PaymentAmountsNotMatchException();
if ($amount != $paymentBridgeAmount) {

throw new PaymentAmountsNotMatchException(sprintf(
'Amounts differ. Requested: [%s] but in PaymentBridge: [%s].',
$amount,
$paymentBridgeAmount
)
);
}

/**
Expand Down Expand Up @@ -133,7 +139,7 @@ public function processPayment(BanwireMethod $paymentMethod, $amount)
'user' => $this->user,
'reference' => $this->paymentBridge->getOrderId() . '#' . date('Ymdhis'),
'currency' => $this->paymentBridge->getCurrency(),
'ammount' => number_format($this->paymentBridge->getAmount(), 2),
'ammount' => number_format($this->paymentBridge->getAmount() / 100, 2),
'concept' => $this->paymentBridge->getOrderDescription(),
'card_num' => $paymentMethod->getCardNum(),
'card_name' => $paymentMethod->getCardName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class BanwireManagerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var BankwireManager paymentManager
* @var BanwireManager paymentManager
*
* The manager to be unit tested
*/
Expand All @@ -30,16 +30,16 @@ class BanwireManagerTest extends \PHPUnit_Framework_TestCase
private $paymentEventDispatcher;

/**
* @expectedException PaymentSuite\PaymentCoreBundle\Exception\PaymentException
* @expectedException \PaymentSuite\PaymentCoreBundle\Exception\PaymentException
*/
public function testProcessPaymentOk()
{
$amount = 100;
$amount = 1000;

$this->paymentBridge
->expects($this->exactly(2))
->method('getAmount')
->will($this->returnValue(1))
->will($this->returnValue(1000))
;

$this->paymentBridge
Expand Down Expand Up @@ -72,16 +72,16 @@ public function testProcessPaymentOk()
}

/**
* @expectedException PaymentSuite\PaymentCoreBundle\Exception\PaymentAmountsNotMatchException
* @expectedException \PaymentSuite\PaymentCoreBundle\Exception\PaymentAmountsNotMatchException
*/
public function testProcessPaymentAmountsNotMatch()
{
$amount = 100;
$amount = 1000;

$this->paymentBridge
->expects($this->once())
->method('getAmount')
->will($this->returnValue($amount/($amount -1)))
->will($this->returnValue($amount + 10))
;

$this->paymentEventDispatcher
Expand All @@ -93,16 +93,16 @@ public function testProcessPaymentAmountsNotMatch()
}

/**
* @expectedException PaymentSuite\PaymentCoreBundle\Exception\PaymentOrderNotFoundException
* @expectedException \PaymentSuite\PaymentCoreBundle\Exception\PaymentOrderNotFoundException
*/
public function testProcessPaymentOrderNotFound()
{
$amount = 100;
$amount = 1000;

$this->paymentBridge
->expects($this->once())
->method('getAmount')
->will($this->returnValue(1))
->will($this->returnValue(1000))
;

$this->paymentEventDispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;

use PaymentSuite\DineromailApiBundle\DineromailApiMethod;
Expand All @@ -31,7 +32,6 @@ class DineromailApiController extends Controller
*
* @return RedirectResponse
*
*
* @Method("POST")
*/
public function executeAction(Request $request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

namespace PaymentSuite\DineroMailBundle\Tests\Services;

use PaymentSuite\DineromailBundle\DineromailMethod;
use PaymentSuite\DineroMailBundle\DineromailMethod;
use PaymentSuite\DineroMailBundle\Services\DineromailManager;

class DineromailManagerTest extends PHPUnit_Framework_TestCase
class DineromailManagerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var DineromailManager paymentManager
Expand Down
4 changes: 2 additions & 2 deletions src/PaymentSuite/PayUBundle/Model/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public function getAccountId()
*/
public function setAdditionalValues(AdditionalValue $additionalValue, $type)
{
$value = [
$value = array(
$type => $additionalValue
];
);
$this->additionalValues = $value;

return $this;
Expand Down
13 changes: 9 additions & 4 deletions src/PaymentSuite/PaymillBundle/Services/PaymillManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __construct(
* Tries to process a payment through Paymill
*
* @param PaymillMethod $paymentMethod Payment method
* @param float $amount Amount
* @param integer $amount Amount
*
* @return PaymillManager Self object
*
Expand All @@ -88,9 +88,14 @@ public function processPayment(PaymillMethod $paymentMethod, $amount)
/**
* If both amounts are different, execute Exception
*/
if (abs($amount - $paymentBridgeAmount) > 0.00001) {

throw new PaymentAmountsNotMatchException();
if ($amount != $paymentBridgeAmount) {

throw new PaymentAmountsNotMatchException(sprintf(
'Amounts differ. Requested: [%s] but in PaymentBridge: [%s].',
$amount,
$paymentBridgeAmount
)
);
}

/**
Expand Down
Loading

0 comments on commit b6c1b73

Please sign in to comment.