Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
travis ci
Browse files Browse the repository at this point in the history
  • Loading branch information
basz committed Jun 17, 2012
1 parent 5524663 commit fc88082
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 63 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php

php:
- 5.3
- 5.4

before_script:
- wget http://getcomposer.org/composer.phar
- php composer.phar install

script: phpunit --configuration tests/phpunit.xml
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ PLEASE USE AT YOUR OWN RISK. REALLY!

updated to work with ZF2 beta-4

[![Build Status](https://secure.travis-ci.org/basz/zf2-module-ideal-service.png?branch=master)](http://travis-ci.org/basz/zf2-module-ideal-service)

## About iDEAL
[ideal](http://www.ideal.nl/ "iDEAL") is a standardized payment method for making secure online payments directly between
bank accounts. To offer iDEAL as a payment method in an online store, a direct link is
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"module"
],
"require":{
"zendframework/zendframework": "2.0.*"
"zendframework/zendframework": "dev-master"
},
"autoload": {
"psr-0": {
Expand Down
2 changes: 1 addition & 1 deletion src/IDealService/ServiceOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ServiceOptions extends Options
* @var string
*/
protected $securePath;
protected $merchantId;
protected $merchantId; /* vendor specific */

protected $subId; /* vendor specific */
protected $localPrivateKey; /* PRIVATEKEY */ /* vendor specific */
Expand Down
80 changes: 38 additions & 42 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
<?php

require_once __DIR__ . '/../autoload_register.php';
// Set error reporting pretty high
error_reporting(E_ALL | E_STRICT);

use Zend\Loader\AutoloaderFactory;

chdir(__DIR__);
$previousDir = '.';
while (!is_dir($previousDir . DIRECTORY_SEPARATOR . 'vendor')) {
$appRoot = dirname(getcwd());

if ($previousDir === $appRoot) {
throw new RuntimeException('Unable to locate application root');
}

$previousDir = $appRoot;
chdir($appRoot);
}

// Load composer autoloader
require_once $appRoot . '/vendor/autoload.php';

require_once (getenv('ZF2_PATH') ? : 'vendor/zendframework/zendframework/library') . '/Zend/Loader/AutoloaderFactory.php';

// setup autoloader
AutoloaderFactory::factory();

$rootPath = realpath(dirname(__DIR__));
$testsPath = "$rootPath/tests";
Expand All @@ -11,45 +35,17 @@
require_once $testsPath . '/TestConfiguration.php.dist';
}

$path = array(
$testsPath,
ZEND_FRAMEWORK_PATH,
get_include_path(),
);
set_include_path(implode(PATH_SEPARATOR, $path));

require_once 'Zend/Loader/AutoloaderFactory.php';
\Zend\Loader\AutoloaderFactory::factory(
array('Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/../autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
// load autoload of zf2 module if available
if (file_exists(__DIR__ . '/../autoload_classmap.php')) {
\Zend\Loader\AutoloaderFactory::factory(
array('Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/../autoload_classmap.php',
),
)));

//
//$listenerOptions = new Zend\Module\Listener\ListenerOptions(array('module_paths' => array(__DIR__ . '/..')));
//$defaultListeners = new Zend\Module\Listener\DefaultListenerAggregate($listenerOptions);
//$defaultListeners->getConfigListener()->addConfigGlobPath("config/autoload/{module.*,global,$env,local}.config.php");
//
//$moduleManager = new Zend\Module\Manager(array('PhingService'));
//$moduleManager->events()->attachAggregate($defaultListeners);
//$moduleManager->loadModules();
//





//$config = $defaultListeners->getConfigListener()->getMergedConfig();

//$di = new \Zend\Di\Di;
//$di->instanceManager()->addTypePreference('Zend\Di\Locator', $di);

//$config = new \Zend\Di\Configuration($config['di']);
//$config->configure($di);

//require_once __DIR__ . '/PhingServiceTest/TestCase.php';
//\PhingServiceTest\TestCase::$locator = $di;
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
)
)
);
}
12 changes: 3 additions & 9 deletions tests/IDealServiceTest/ServiceOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ServiceOptionsTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->options = new ServiceOptions(array('merchantId'=>'123', 'vendorMethod'=>'someMethod'));
$this->options = new ServiceOptions(array('vendorOptions' => array( 'merchantId'=>'123' ), 'vendorMethod'=>'someMethod'));
}

/**
Expand All @@ -27,13 +27,7 @@ public function testOmittedRequiredConstructorOptionsThrowsRuntimeException()
$exceptionRaised = false;

try {
$so = new ServiceOptions(array('vendorMethod'=>'someMethod'));
} catch (\RuntimeException $e) {
$exceptionRaised = true;
}

try {
$so = new ServiceOptions(array('merchantId'=>'somecode'));
$so = new ServiceOptions(array());
} catch (\RuntimeException $e) {
$exceptionRaised = true;
}
Expand All @@ -44,7 +38,7 @@ public function testOmittedRequiredConstructorOptionsThrowsRuntimeException()

public function testVendorMethodIsProtected()
{
$methods = array('setMerchantId', 'setVendorMethod');
$methods = array('setVendorMethod');

foreach ($methods as $method) {
if (!method_exists($this->options, $method)) {
Expand Down
22 changes: 12 additions & 10 deletions tests/IDealServiceTest/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ServiceTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
$this->service = new Service(new ServiceOptions(array('merchantId'=>'321', 'vendorMethod'=>'dummy')));
$this->service = new Service();
$this->service->setOptions(new ServiceOptions(array('vendorOptions' => array('merchantId'=>'321'), 'vendorMethod'=>'dummy')));
}

public function tearDown()
Expand All @@ -40,21 +41,22 @@ public function testAcquirerConnectorSameInstance() {
$this->assertEquals($ac1, $ac2);
}

public function testAcquirerConnectorDifferentInstance() {
$ac1 = $this->service->getAcquirerConnector();

$service2 = new Service(new ServiceOptions(array('merchantId'=>'456', 'vendorMethod'=>'dummy')));
$ac2 = $service2->getAcquirerConnector();

$this->assertNotEquals($ac1, $ac2, 'Failed asserting that an instance from is not equal to b.');
}
// public function testAcquirerConnectorDifferentInstance() {
// $ac1 = $this->service->getAcquirerConnector();
//
// $service2 = new Service();
// $service2->setOptions(new ServiceOptions(array('vendorOptions' => array('merchantId'=>'456'), 'vendorMethod'=>'dummy')));
// $ac2 = $service2->getAcquirerConnector();
//
// $this->assertNotEquals($ac1, $ac2, 'Failed asserting that an instance from is not equal to b.');
// }

public function testNonExistantVendorMethodThrowsException()
{
$exceptionRaised = false;

try {
$this->service->setOptions(new ServiceOptions(array('merchantId'=>'321', 'vendorMethod'=>'non-existant-adapter')));
$this->service->setOptions(new ServiceOptions(array('vendorOptions' => array('merchantId'=>'321'), 'vendorMethod'=>'non-existant-adapter')));

$ac = $this->service->getAcquirerConnector();
} catch (\Zend\Loader\Exception\RuntimeException $e) {
Expand Down

0 comments on commit fc88082

Please sign in to comment.