Skip to content

Commit

Permalink
Test environment refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mschindler committed Mar 30, 2016
1 parent c0a2503 commit 12f6920
Show file tree
Hide file tree
Showing 43 changed files with 362 additions and 337 deletions.
28 changes: 18 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
language: php
php:
- 5.6
- 5.5
- 5.4
- 5.3
- hhvm


script: ant test
env:

env:
global:
- secure: "StaRWxgVW55YXMetUfL91rGDHJCBC0e3Nv9qYx5jg2aa9H0BIYhJ8vYtDXbKFEeGXWRnlLdPVclzRiIMdYQTZaBrjHxWVzE9N5stIyIq/Ik5hvkRs3h78ICSsDJB7SAun+aYv4vV/2kR44B0YiOhWZehV3IhAWO1Csd4HDjiQHY="
- API_TEST_KEY: 0dcb0c6a3dcddace93de405fb98857b7
- API_PUBLIC_TEST_KEY: 07558773223ff498c4ab0ca581551453
- 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
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,11 +20,6 @@ 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);
Expand All @@ -50,7 +37,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;

/**
* Client
*/
class Client extends PHPUnit_Framework_TestCase
class Client extends IntegrationBase
{
/**
* @var \Paymill\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
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
<?php

namespace Paymill\Test\Integration;
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(
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;

/**
* 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
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;

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

/**
* @var \Paymill\Models\Request\Preauthorization
*/
Expand All @@ -27,11 +19,6 @@ class PreauthorizationTest 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\Preauthorization();
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,23 +1,14 @@
<?php

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

use Paymill\API\Curl;
use Paymill\Models as Models;
use Paymill\Request;
use Paymill\Test\Integration\IntegrationBase;
use PHPUnit_Framework_TestCase;

/**
* RefundTest
*/
class RefundTest extends IntegrationBase
{
/**
* @var \Paymill\Request
*/
private $_service;

/**
* @var \Paymill\Models\Request\Refund
*/
Expand All @@ -28,11 +19,6 @@ class RefundTest extends IntegrationBase
*/
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\Refund();
parent::setUp();
}
Expand All @@ -42,7 +28,6 @@ protected function setUp()
*/
protected function tearDown()
{
$this->_service = null;
$this->_model = null;
parent::tearDown();
}
Expand Down
Loading

0 comments on commit 12f6920

Please sign in to comment.