Skip to content

Commit

Permalink
Merge pull request #128 from mschindler83/test-env-refactoring
Browse files Browse the repository at this point in the history
Test env refactoring and smaller BC code changes
  • Loading branch information
pm-alexander-serbe committed Apr 1, 2016
2 parents 887658b + dda4e70 commit 37fb0c2
Show file tree
Hide file tree
Showing 44 changed files with 437 additions and 343 deletions.
32 changes: 22 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
- hhvm

script: ant test
env:

script:
- ant test
- ant test-integration

env:
global:
secure: "StaRWxgVW55YXMetUfL91rGDHJCBC0e3Nv9qYx5jg2aa9H0BIYhJ8vYtDXbKFEeGXWRnlLdPVclzRiIMdYQTZaBrjHxWVzE9N5stIyIq/Ik5hvkRs3h78ICSsDJB7SAun+aYv4vV/2kR44B0YiOhWZehV3IhAWO1Csd4HDjiQHY="
- secure: "StaRWxgVW55YXMetUfL91rGDHJCBC0e3Nv9qYx5jg2aa9H0BIYhJ8vYtDXbKFEeGXWRnlLdPVclzRiIMdYQTZaBrjHxWVzE9N5stIyIq/Ik5hvkRs3h78ICSsDJB7SAun+aYv4vV/2kR44B0YiOhWZehV3IhAWO1Csd4HDjiQHY="
- PAYMILL_API_TEST_KEY: 0dcb0c6a3dcddace93de405fb98857b7
- PAYMILL_API_PUBLIC_TEST_KEY: 07558773223ff498c4ab0ca581551453

matrix:
include:
- php: 5.6
env: PAYMILL_WH_1=transaction.succeeded PAYMILL_WH_2=subscription.created
- php: 5.5
env: PAYMILL_WH_1=chargeback.executed PAYMILL_WH_2=transaction.created
- php: 5.4
env: PAYMILL_WH_1=transaction.pending PAYMILL_WH_2=transaction.failed
- php: 5.3
env: PAYMILL_WH_1=client.updated PAYMILL_WH_2=subscription.updated
- php: hhvm
env: PAYMILL_WH_1=subscription.deleted PAYMILL_WH_2=subscription.succeeded

before_install: composer self-update
install: composer install
6 changes: 6 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
</exec>
</target>

<target name="test-integration" description="Run unit tests using PHPUnit">
<exec executable="phpunit" dir="tests" failonerror="true">
<arg line="--testsuite=integration" />
</exec>
</target>

<target name="phploc" description="Generate phploc.csv">
<exec executable="phploc">
<arg line="--log-csv ${basedir}/build/logs/phploc.csv ${source}" />
Expand Down
19 changes: 19 additions & 0 deletions lib/Paymill/Models/Internal/AbstractAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,23 @@ public function setPhone($phone)

return $this;
}

/**
* Converts model to array.
*
* @return array
*/
public function toArray()
{
return array(
static::FIELD_NAME => $this->_name,
static::FIELD_STREET_ADDRESS => $this->_streetAddress,
static::FIELD_STREET_ADDRESS_ADDITION => $this->_streetAddressAddition,
static::FIELD_CITY => $this->_city,
static::FIELD_POSTAL_CODE => $this->_postalCode,
static::FIELD_COUNTRY => $this->_country,
static::FIELD_STATE => $this->_state,
static::FIELD_PHONE => $this->_phone,
);
}
}
17 changes: 17 additions & 0 deletions lib/Paymill/Models/Internal/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,21 @@ public function setQuantity($quantity)

return $this;
}

/**
* Converts model to array.
*
* @return array
*/
public function toArray()
{
return array(
static::FIELD_NAME => $this->_name,
static::FIELD_DESCRIPTION => $this->_description,
static::FIELD_ITEM_NUMBER => $this->_itemNumber,
static::FIELD_AMOUNT => $this->_amount,
static::FIELD_QUANTITY => $this->_quantity,
static::FIELD_URL => $this->_url,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<?php

namespace Paymill\Test\Integration;
namespace Paymill\Tests\Integration;

use Paymill\API\Curl;
use Paymill\Models as Models;
use Paymill\Models\Request\Checksum;
use Paymill\Request;
use PHPUnit_Framework_TestCase;

/**
* ChecksumTest
*/
class ChecksumTest extends PHPUnit_Framework_TestCase
class ChecksumTest extends IntegrationBase
{
/**
* @var Request
*/
private $_service;

/**
* @var Checksum
*/
Expand All @@ -28,17 +20,14 @@ class ChecksumTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->_service = new Request();
$this->_service->setConnectionClass(
new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
);

$this->_model = new Checksum();
$this->_model->setChecksumType(Checksum::TYPE_PAYPAL);
$this->_model->setChecksumAction(Checksum::ACTION_TRANSACTION);
$this->_model->setAmount('200');
$this->_model->setCurrency('EUR');
$this->_model->setDescription('Dummy description');
$this->_model->setReturnUrl('http://dummy.url');
$this->_model->setCancelUrl('http://dummy.url');

parent::setUp();
}
Expand All @@ -48,7 +37,6 @@ protected function setUp()
*/
protected function tearDown()
{
$this->_service = null;
$this->_model = null;
parent::tearDown();
}
Expand All @@ -59,7 +47,7 @@ protected function tearDown()
*/
public function createChecksum()
{
$result = $this->_service->getOne($this->_model);
$result = $this->_service->create($this->_model);
$this->assertInstanceOf('Paymill\Models\Response\Checksum', $result, var_export($result, true));

return $result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?php

namespace Paymill\Test\Integration;
namespace Paymill\Tests\Integration;

use Paymill\API\Curl;
use Paymill\Models as Models;
use Paymill\Request;
use PHPUnit_Framework_TestCase;

/**
* Client
*/
class Client extends PHPUnit_Framework_TestCase
class Client extends IntegrationBase
{
/**
* @var \Paymill\Services\Request
*/
private $_service;

/**
* @var \Paymill\Models\Request\Client
*/
Expand All @@ -27,11 +19,6 @@ class Client extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->_service = new Request();
$this->_service->setConnectionClass(
new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
);

$this->_model = new Models\Request\Client();
parent::setUp();
}
Expand All @@ -41,7 +28,6 @@ protected function setUp()
*/
protected function tearDown()
{
$this->_service = null;
$this->_model = null;
parent::tearDown();
}
Expand Down Expand Up @@ -114,7 +100,6 @@ public function getAllClient()
/**
* @test
* @codeCoverageIgnore
* @depends createClient
*/
public function getAllClientAsModel()
{
Expand Down
55 changes: 55 additions & 0 deletions tests/Integration/IntegrationBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Paymill\Tests\Integration;

use Paymill\API\Curl;
use Paymill\Request;

class IntegrationBase extends \PHPUnit_Framework_TestCase
{
/**
* @var Request
*/
protected $_service;

/**
* Prepares the environment before running a test.
*/
protected function setUp()
{
$this->_service = new Request();
$this->_service->setConnectionClass(
new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
);

parent::setUp();
}

/**
* Cleans up the environment after running a test.
*/
protected function tearDown()
{
$this->_service = null;
parent::tearDown();
}

public function createToken()
{
$params = array(
'channel_id' => API_PUBLIC_TEST_KEY,
'transaction_mode' => 'CONNECTOR_TEST',
'account_number' => '4111111111111111',
'account_holder' => 'Max Muster',
'account_expiry_month' => '12',
'account_expiry_year' => date('Y', strtotime('+1 year')),

);
$token = json_decode(file_get_contents(TOKEN_HOST . '?' . http_build_query($params)), true);
if (isset($token['transaction']['identification']['uniqueId'])) {
return $token['transaction']['identification']['uniqueId'];
}

return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?php

namespace Paymill\Test\Integration;
namespace Paymill\Tests\Integration;

use Paymill\API\Curl;
use Paymill\Models as Models;
use Paymill\Request;
use PHPUnit_Framework_TestCase;

/**
* OfferTest
*/
class OfferTest extends PHPUnit_Framework_TestCase
class OfferTest extends IntegrationBase
{
/**
* @var \Paymill\Services\Request
*/
private $_service;

/**
* @var \Paymill\Models\Request\Offer
*/
Expand All @@ -27,11 +19,6 @@ class OfferTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->_service = new Request();
$this->_service->setConnectionClass(
new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
);

$this->_model = new Models\Request\Offer();
parent::setUp();
}
Expand All @@ -41,7 +28,6 @@ protected function setUp()
*/
protected function tearDown()
{
$this->_service = null;
$this->_model = null;
parent::tearDown();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?php

namespace Paymill\Test\Integration;
namespace Paymill\Tests\Integration;

use Paymill\API\Curl;
use Paymill\Models as Models;
use Paymill\Request;
use PHPUnit_Framework_TestCase;

/**
* PaymentTest
*/
class PaymentTest extends PHPUnit_Framework_TestCase
class PaymentTest extends IntegrationBase
{
/**
* @var \Paymill\Services\Request
*/
private $_service;

/**
* @var \Paymill\Models\Request\Payment
*/
Expand All @@ -27,11 +19,6 @@ class PaymentTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->_service = new Request();
$this->_service->setConnectionClass(
new Curl(API_TEST_KEY, API_HOST, array(CURLOPT_SSL_VERIFYPEER => SSL_VERIFY_PEER))
);

$this->_model = new Models\Request\Payment();
parent::setUp();
}
Expand All @@ -41,7 +28,6 @@ protected function setUp()
*/
protected function tearDown()
{
$this->_service = null;
$this->_model = null;
parent::tearDown();
}
Expand Down
Loading

0 comments on commit 37fb0c2

Please sign in to comment.