Skip to content

Commit

Permalink
Remove config for URLs that are injected automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Oct 17, 2017
1 parent d416b36 commit ee60dad
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 137 deletions.
59 changes: 2 additions & 57 deletions lib/mshoplib/src/MShop/Service/Provider/Payment/Base.php
Expand Up @@ -42,46 +42,6 @@ abstract class Base
const FEAT_REFUND = 4;


private $beConfig = array(
'payment.url-success' => array(
'code' => 'payment.url-success',
'internalcode' => 'payment.url-success',
'label' => 'Shop URL customers are redirected to after successful payments',
'type' => 'string',
'internaltype' => 'string',
'default' => '',
'required' => false,
),
'payment.url-failure' => array(
'code' => 'payment.url-failure',
'internalcode' => 'payment.url-failure',
'label' => 'Shop URL customers are redirected to after failed payments',
'type' => 'string',
'internaltype' => 'string',
'default' => '',
'required' => false,
),
'payment.url-cancel' => array(
'code' => 'payment.url-cancel',
'internalcode' => 'payment.url-cancel',
'label' => 'Shop URL customers are redirected to after canceled payments',
'type' => 'string',
'internaltype' => 'string',
'default' => '',
'required' => false,
),
'payment.url-update' => array(
'code' => 'payment.url-update',
'internalcode' => 'payment.url-update',
'label' => 'Shop URL payment status updates from payment providers are sent to',
'type' => 'string',
'internaltype' => 'string',
'default' => '',
'required' => false,
),
);


/**
* Checks the backend configuration attributes for validity.
*
Expand All @@ -91,16 +51,7 @@ abstract class Base
*/
public function checkConfigBE( array $attributes )
{
$error = $this->checkConfig( $this->beConfig, $attributes );

foreach( $this->beConfig as $key => $value )
{
if( isset( $attributes[$key] ) && $value['type'] != gettype( $attributes[$key] ) ) {
$error[$key] = sprintf( 'The type of the configuration option with key "%1$s" must be "%2$s"', $key, $value['type'] );
}
}

return $error;
return [];
}


Expand All @@ -112,13 +63,7 @@ public function checkConfigBE( array $attributes )
*/
public function getConfigBE()
{
$list = [];

foreach( $this->beConfig as $key => $config ) {
$list[$key] = new \Aimeos\MW\Criteria\Attribute\Standard( $config );
}

return $list;
return [];
}


Expand Down
22 changes: 7 additions & 15 deletions lib/mshoplib/tests/MShop/Service/Provider/Payment/BaseTest.php
@@ -1,12 +1,14 @@
<?php

namespace Aimeos\MShop\Service\Provider\Payment;


/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015-2017
*/


namespace Aimeos\MShop\Service\Provider\Payment;


class BaseTest extends \PHPUnit\Framework\TestCase
{
private $object;
Expand All @@ -30,12 +32,6 @@ protected function setUp()
}


/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown()
{
unset( $this->object );
Expand All @@ -46,20 +42,16 @@ public function testCheckConfigBE()
{
$result = $this->object->checkConfigBE( array( 'payment.url-success' => true ) );

$this->assertInternalType( 'array', $result );
$this->assertArrayHasKey( 'payment.url-success', $result );
$this->assertEquals( 0, count( $result ) );
}


public function testGetConfigBE()
{
$result = $this->object->getConfigBE();

$this->assertEquals( 0, count( $result ) );
$this->assertInternalType( 'array', $result );
$this->assertArrayHasKey( 'payment.url-success', $result );
$this->assertArrayHasKey( 'payment.url-failure', $result );
$this->assertArrayHasKey( 'payment.url-cancel', $result );
$this->assertArrayHasKey( 'payment.url-update', $result );
}


Expand Down
Expand Up @@ -10,21 +10,12 @@
namespace Aimeos\MShop\Service\Provider\Payment;


/**
* Test class for \Aimeos\MShop\Service\Provider\Payment\DirectDebit.
*/
class DirectDebitTest extends \PHPUnit\Framework\TestCase
{
private $object;
private $ordServItem;


/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$context = \TestHelperMShop::getContext();
Expand All @@ -40,12 +31,6 @@ protected function setUp()
}


/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown()
{
unset( $this->object );
Expand All @@ -54,20 +39,15 @@ protected function tearDown()

public function testGetConfigBE()
{
$this->assertEquals( 4, count( $this->object->getConfigBE() ) );
$this->assertEquals( 0, count( $this->object->getConfigBE() ) );
}


public function testCheckConfigBE()
{
$attributes = array(
'payment.url-success' => 'http://returnUrl'
);

$result = $this->object->checkConfigBE( $attributes );
$result = $this->object->checkConfigBE( array( 'payment.url-success' => 'http://returnUrl' ) );

$this->assertEquals( 4, count( $result ) );
$this->assertEquals( null, $result['payment.url-success'] );
$this->assertEquals( 0, count( $result ) );
}


Expand Down
Expand Up @@ -93,7 +93,7 @@ public function testCheckConfigBE()

$result = $this->object->checkConfigBE( $attributes );

$this->assertEquals( 16, count( $result ) );
$this->assertEquals( 12, count( $result ) );
$this->assertEquals( null, $result['paypalexpress.ApiUsername'] );
$this->assertEquals( null, $result['paypalexpress.AccountEmail'] );
$this->assertEquals( null, $result['paypalexpress.ApiPassword'] );
Expand Down
20 changes: 2 additions & 18 deletions lib/mshoplib/tests/MShop/Service/Provider/Payment/PostPayTest.php
Expand Up @@ -10,20 +10,11 @@
namespace Aimeos\MShop\Service\Provider\Payment;


/**
* Test class for \Aimeos\MShop\Service\Provider\Payment\PostPay.
*/
class PostPayTest extends \PHPUnit\Framework\TestCase
{
private $object;


/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$context = \TestHelperMShop::getContext();
Expand All @@ -39,12 +30,6 @@ protected function setUp()
}


/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown()
{
unset( $this->object );
Expand All @@ -53,16 +38,15 @@ protected function tearDown()

public function testGetConfigBE()
{
$this->assertEquals( 4, count( $this->object->getConfigBE() ) );
$this->assertEquals( 0, count( $this->object->getConfigBE() ) );
}


public function testCheckConfigBE()
{
$result = $this->object->checkConfigBE( array( 'payment.url-success' => 'testurl' ) );

$this->assertEquals( 4, count( $result ) );
$this->assertEquals( null, $result['payment.url-success'] );
$this->assertEquals( 0, count( $result ) );
}


Expand Down
26 changes: 3 additions & 23 deletions lib/mshoplib/tests/MShop/Service/Provider/Payment/PrePayTest.php
Expand Up @@ -10,20 +10,11 @@
namespace Aimeos\MShop\Service\Provider\Payment;


/**
* Test class for \Aimeos\MShop\Service\Provider\Payment\PrePay.
*/
class PrePayTest extends \PHPUnit\Framework\TestCase
{
private $object;


/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$context = \TestHelperMShop::getContext();
Expand All @@ -39,12 +30,6 @@ protected function setUp()
}


/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
*/
protected function tearDown()
{
unset( $this->object );
Expand All @@ -53,20 +38,15 @@ protected function tearDown()

public function testGetConfigBE()
{
$this->assertEquals( 4, count( $this->object->getConfigBE() ) );
$this->assertEquals( 0, count( $this->object->getConfigBE() ) );
}


public function testCheckConfigBE()
{
$attributes = array(
'payment.url-success' => 'http://returnUrl'
);

$result = $this->object->checkConfigBE( $attributes );
$result = $this->object->checkConfigBE( array( 'payment.url-success' => 'http://returnUrl' ) );

$this->assertEquals( 4, count( $result ) );
$this->assertEquals( null, $result['payment.url-success'] );
$this->assertEquals( 0, count( $result ) );
}


Expand Down

0 comments on commit ee60dad

Please sign in to comment.