diff --git a/app/code/Magento/Payment/Gateway/Command/CommandPool.php b/app/code/Magento/Payment/Gateway/Command/CommandPool.php index 6b1014d5aa76d9fefb8a1efb80583147067f2853..d1fc52a72378248b3a9cc87da3fd36d133924d93 100644 --- a/app/code/Magento/Payment/Gateway/Command/CommandPool.php +++ b/app/code/Magento/Payment/Gateway/Command/CommandPool.php @@ -18,17 +18,17 @@ class CommandPool implements CommandPoolInterface private $commands; /** - * @param array $commands * @param TMapFactory $tmapFactory + * @param array $commands */ public function __construct( - array $commands, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $commands = [] ) { $this->commands = $tmapFactory->create( [ 'array' => $commands, - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php index 0364336a2ea5e42df84c190359218276bd2aa168..b23964b064274e9e4d475c46a23d3448ff32024a 100644 --- a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php +++ b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php @@ -21,12 +21,12 @@ class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPo private $handlers; /** - * @param array $handlers * @param TMapFactory $tmapFactory + * @param array $handlers */ public function __construct( - array $handlers, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $handlers ) { if (!isset($handlers[self::DEFAULT_HANDLER])) { throw new \LogicException('Default handler should be provided.'); @@ -35,7 +35,7 @@ class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPo $this->handlers = $tmapFactory->create( [ 'array' => $handlers, - 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + 'type' => ValueHandlerInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php index 66584773b638dfdc05a233ff4db10a7b1272794f..43f39b2932b40b81f06b0788f7b22827fda9f2fc 100644 --- a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php +++ b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php @@ -19,17 +19,17 @@ class BuilderComposite implements BuilderInterface private $builders; /** - * @param array $builders * @param TMapFactory $tmapFactory + * @param array $builders */ public function __construct( - array $builders, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $builders = [] ) { $this->builders = $tmapFactory->create( [ 'array' => $builders, - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php index 1425514e7e3fb87054fdb09690d49d53c0b52a72..6a45311d5eb897b0ec15794cccc838995b747c04 100644 --- a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php +++ b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php @@ -16,17 +16,17 @@ class HandlerChain implements HandlerInterface private $handlers; /** - * @param array $handlers * @param TMapFactory $tmapFactory + * @param array $handlers */ public function __construct( - array $handlers, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $handlers = [] ) { $this->handlers = $tmapFactory->create( [ 'array' => $handlers, - 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'type' => HandlerInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php index 6e7c5c8c0ab5cecf0031ebc87519306289ea40e2..b36ceed14bdfa991d9fad107e120bb4b312a5316 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php @@ -18,18 +18,18 @@ class ValidatorComposite extends AbstractValidator /** * @param ResultInterfaceFactory $resultFactory - * @param array $validators * @param TMapFactory $tmapFactory + * @param array $validators */ public function __construct( ResultInterfaceFactory $resultFactory, - array $validators, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $validators = [] ) { $this->validators = $tmapFactory->create( [ 'array' => $validators, - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ); parent::__construct($resultFactory); diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php index e2b746ea7334f480ef5fa3a83358081cea3289db..6697dd86c3d883ae85293b0307435820fb069e0e 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php @@ -17,17 +17,17 @@ class ValidatorPool implements \Magento\Payment\Gateway\Validator\ValidatorPoolI private $validators; /** - * @param array $validators * @param TMapFactory $tmapFactory + * @param array $validators */ public function __construct( - array $validators, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $validators = [] ) { $this->validators = $tmapFactory->create( [ 'array' => $validators, - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ); } diff --git a/app/code/Magento/Payment/Model/Method/Logger.php b/app/code/Magento/Payment/Model/Method/Logger.php index 7e7331b77df73d9f87624d733167eed0b9cdff08..47c91a25968ccb5560280e78659eebd892787308 100644 --- a/app/code/Magento/Payment/Model/Method/Logger.php +++ b/app/code/Magento/Payment/Model/Method/Logger.php @@ -41,21 +41,21 @@ class Logger /** * Logs payment related information used for debug * - * @param array $debugData - * @param array|null $debugReplaceKeys - * @param bool|null $debugFlag + * @param array $data + * @param array|null $maskKeys + * @param bool|null $forceDebug * @return void */ - public function debug(array $debugData, array $debugReplaceKeys = null, $debugFlag = null) + public function debug(array $data, array $maskKeys = null, $forceDebug = null) { - $debugReplaceKeys = $debugReplaceKeys !== null ? $debugReplaceKeys : $this->getDebugReplaceFields(); - $debugFlag = $debugFlag !== null ? $debugFlag : $this->isDebugOn(); - if ($debugFlag === true && !empty($debugData) && !empty($debugReplaceKeys)) { - $debugData = $this->filterDebugData( - $debugData, - $debugReplaceKeys + $maskKeys = $maskKeys !== null ? $maskKeys : $this->getDebugReplaceFields(); + $debugOn = $forceDebug !== null ? $forceDebug : $this->isDebugOn(); + if ($debugOn === true) { + $data = $this->filterDebugData( + $data, + $maskKeys ); - $this->logger->debug(var_export($debugData, true)); + $this->logger->debug(var_export($data, true)); } } @@ -66,7 +66,7 @@ class Logger */ private function getDebugReplaceFields() { - if ($this->config->getValue('debugReplaceKeys')) { + if ($this->config and $this->config->getValue('debugReplaceKeys')) { return explode(',', $this->config->getValue('debugReplaceKeys')); } return []; @@ -79,7 +79,7 @@ class Logger */ private function isDebugOn() { - return (bool)$this->config->getValue('debug'); + return $this->config and (bool)$this->config->getValue('debug'); } /** diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php index 92394d8bb330ed66ed9fb6dc98f49666fb725155..7ab96f4474e497d197f4c91298e2e44430e5ccef 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Command; use Magento\Payment\Gateway\Command\CommandPool; +use Magento\Payment\Gateway\CommandInterface; class CommandPoolTest extends \PHPUnit_Framework_TestCase { @@ -26,7 +27,7 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase ->with( [ 'array' => ['Magento\Payment\Gateway\CommandInterface'], - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ) ->willReturn($tMap); @@ -39,7 +40,7 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase ->with('command') ->willReturn($commandI); - $pool = new CommandPool(['Magento\Payment\Gateway\CommandInterface'], $tMapFactory); + $pool = new CommandPool($tMapFactory, ['Magento\Payment\Gateway\CommandInterface']); static::assertSame($commandI, $pool->get('command')); } @@ -61,7 +62,7 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ) ->willReturn($tMap); @@ -70,7 +71,7 @@ class CommandPoolTest extends \PHPUnit_Framework_TestCase ->with('command') ->willReturn(false); - $pool = new CommandPool([], $tMapFactory); + $pool = new CommandPool($tMapFactory, []); $pool->get('command'); } } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php index 266128b42f6f9ee21b26c83e5e3caf0187163998..cac2d6c1c9d21b030c57b9cde07b8452b7b47e4b 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Payment\Test\Unit\Gateway\Config; +use Magento\Payment\Gateway\Config\ValueHandlerInterface; use Magento\Payment\Gateway\Config\ValueHandlerPool; class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase @@ -19,7 +20,7 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase $tMapFactory->expects(static::never()) ->method('create'); - new ValueHandlerPool([], $tMapFactory); + new ValueHandlerPool($tMapFactory, []); } public function testGet() @@ -46,7 +47,7 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' ], - 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + 'type' => ValueHandlerInterface::class ] ) ->willReturn($tMap); @@ -68,11 +69,11 @@ class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase ); $pool = new ValueHandlerPool( + $tMapFactory, [ ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' - ], - $tMapFactory + ] ); static::assertSame($someValueHandler, $pool->get('some_value')); static::assertSame($defaultHandler, $pool->get(ValueHandlerPool::DEFAULT_HANDLER)); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php index e1e5ea547456a76f23629322b483718b5cf98e61..2c31c318db6780e30a087305e770fad38e181436 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Request; use Magento\Payment\Gateway\Request\BuilderComposite; +use Magento\Payment\Gateway\Request\BuilderInterface; class BuilderCompositeTest extends \PHPUnit_Framework_TestCase { @@ -24,7 +25,7 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ) ->willReturn($tMap); @@ -32,7 +33,7 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase ->method('getIterator') ->willReturn(new \ArrayIterator([])); - $builder = new BuilderComposite([], $tMapFactory); + $builder = new BuilderComposite($tMapFactory, []); static::assertEquals([], $builder->build([])); } @@ -47,6 +48,7 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase 'item' => 'gas cooker', 'quantity' => 1 ]; + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') ->disableOriginalConstructor() ->setMethods(['create']) @@ -96,7 +98,7 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' ], - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ) ->willReturn($tMap); @@ -105,12 +107,12 @@ class BuilderCompositeTest extends \PHPUnit_Framework_TestCase ->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder])); $builder = new BuilderComposite( + $tMapFactory, [ 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' - ], - $tMapFactory + ] ); static::assertEquals($expectedRequest, $builder->build([])); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php index c65a826a2624d79adff61fac919ce47385fac6ac..78891068b4cc07fd7a10aa9d80d333f65012cc83 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Response; use Magento\Payment\Gateway\Response\HandlerChain; +use Magento\Payment\Gateway\Response\HandlerInterface; class HandlerChainTest extends \PHPUnit_Framework_TestCase { @@ -31,7 +32,7 @@ class HandlerChainTest extends \PHPUnit_Framework_TestCase 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' ], - 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'type' => HandlerInterface::class ] ) ->willReturn($tMap); @@ -49,11 +50,11 @@ class HandlerChainTest extends \PHPUnit_Framework_TestCase ->with($handlingSubject, $response); $chain = new HandlerChain( + $tMapFactory, [ 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' - ], - $tMapFactory + ] ); $chain->handle($handlingSubject, $response); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php index 8528b65ac6cecf91bd5603009334a0b47f216137..27b589b02900d45d480fc32db141e075251dad92 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Validator; use Magento\Payment\Gateway\Validator\ValidatorComposite; +use Magento\Payment\Gateway\Validator\ValidatorInterface; class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase { @@ -32,7 +33,7 @@ class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' ], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -82,11 +83,11 @@ class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase $validatorComposite = new ValidatorComposite( $resultFactory, + $tMapFactory, [ 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' - ], - $tMapFactory + ] ); static::assertSame($compositeResult, $validatorComposite->validate($validationSubject)); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php index becc387fab2d91b86cc6ba3b13954c8c0c29ae05..dc6ed060ab7bf2d86895d15b27a04e2d7638efcd 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Payment\Test\Unit\Gateway\Validator; +use Magento\Payment\Gateway\Validator\ValidatorInterface; use Magento\Payment\Gateway\Validator\ValidatorPool; class ValidatorPoolTest extends \PHPUnit_Framework_TestCase @@ -26,7 +27,7 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase ->with( [ 'array' => ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -40,8 +41,8 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase ->willReturn($commandI); $pool = new ValidatorPool( - ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], - $tMapFactory + $tMapFactory, + ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'] ); static::assertSame($commandI, $pool->get('validator')); @@ -64,7 +65,7 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -73,7 +74,7 @@ class ValidatorPoolTest extends \PHPUnit_Framework_TestCase ->with('validator') ->willReturn(false); - $pool = new ValidatorPool([], $tMapFactory); + $pool = new ValidatorPool($tMapFactory, []); $pool->get('validator'); } } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php index b56caf5903208f67a51713cef223b8602387a608..36cd63d8c6db69461de3d1a11b25f942cb36e505 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php @@ -45,6 +45,20 @@ class LoggerTest extends \PHPUnit_Framework_TestCase $this->logger->debug($debugData, $debugReplaceKeys, true); } + public function testDebugOnNoReplaceKeys() + { + $debugData = + [ + 'request' => ['data1' => '123', 'data2' => '123'] + ]; + + $this->loggerMock->expects(static::once()) + ->method('debug') + ->with(var_export($debugData, true)); + + $this->logger->debug($debugData, [], true); + } + public function testDebugOff() { $debugData =