Skip to content

Commit c979655

Browse files
committed
MAGETWO-44174: \Magento\Payment\Model\Method\Logger::debug() fails in case Logger was initiated without config instance
1 parent 7cd9c31 commit c979655

File tree

12 files changed

+55
-48
lines changed

12 files changed

+55
-48
lines changed

app/code/Magento/Payment/Gateway/Command/CommandPool.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ class CommandPool implements CommandPoolInterface
1818
private $commands;
1919

2020
/**
21-
* @param array $commands
2221
* @param TMapFactory $tmapFactory
22+
* @param array $commands
2323
*/
2424
public function __construct(
25-
array $commands,
26-
TMapFactory $tmapFactory
25+
TMapFactory $tmapFactory,
26+
array $commands = []
2727
) {
2828
$this->commands = $tmapFactory->create(
2929
[
3030
'array' => $commands,
31-
'type' => 'Magento\Payment\Gateway\CommandInterface'
31+
'type' => CommandInterface::class
3232
]
3333
);
3434
}

app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPo
2121
private $handlers;
2222

2323
/**
24-
* @param array $handlers
2524
* @param TMapFactory $tmapFactory
25+
* @param array $handlers
2626
*/
2727
public function __construct(
28-
array $handlers,
29-
TMapFactory $tmapFactory
28+
TMapFactory $tmapFactory,
29+
array $handlers
3030
) {
3131
if (!isset($handlers[self::DEFAULT_HANDLER])) {
3232
throw new \LogicException('Default handler should be provided.');
@@ -35,7 +35,7 @@ public function __construct(
3535
$this->handlers = $tmapFactory->create(
3636
[
3737
'array' => $handlers,
38-
'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface'
38+
'type' => ValueHandlerInterface::class
3939
]
4040
);
4141
}

app/code/Magento/Payment/Gateway/Request/BuilderComposite.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ class BuilderComposite implements BuilderInterface
1919
private $builders;
2020

2121
/**
22-
* @param array $builders
2322
* @param TMapFactory $tmapFactory
23+
* @param array $builders
2424
*/
2525
public function __construct(
26-
array $builders,
27-
TMapFactory $tmapFactory
26+
TMapFactory $tmapFactory,
27+
array $builders = []
2828
) {
2929
$this->builders = $tmapFactory->create(
3030
[
3131
'array' => $builders,
32-
'type' => 'Magento\Payment\Gateway\Request\BuilderInterface'
32+
'type' => BuilderInterface::class
3333
]
3434
);
3535
}

app/code/Magento/Payment/Gateway/Response/HandlerChain.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ class HandlerChain implements HandlerInterface
1616
private $handlers;
1717

1818
/**
19-
* @param array $handlers
2019
* @param TMapFactory $tmapFactory
20+
* @param array $handlers
2121
*/
2222
public function __construct(
23-
array $handlers,
24-
TMapFactory $tmapFactory
23+
TMapFactory $tmapFactory,
24+
array $handlers = []
2525
) {
2626
$this->handlers = $tmapFactory->create(
2727
[
2828
'array' => $handlers,
29-
'type' => 'Magento\Payment\Gateway\Response\HandlerInterface'
29+
'type' => HandlerInterface::class
3030
]
3131
);
3232
}

app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ class ValidatorComposite extends AbstractValidator
1818

1919
/**
2020
* @param ResultInterfaceFactory $resultFactory
21-
* @param array $validators
2221
* @param TMapFactory $tmapFactory
22+
* @param array $validators
2323
*/
2424
public function __construct(
2525
ResultInterfaceFactory $resultFactory,
26-
array $validators,
27-
TMapFactory $tmapFactory
26+
TMapFactory $tmapFactory,
27+
array $validators = []
2828
) {
2929
$this->validators = $tmapFactory->create(
3030
[
3131
'array' => $validators,
32-
'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'
32+
'type' => ValidatorInterface::class
3333
]
3434
);
3535
parent::__construct($resultFactory);

app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ class ValidatorPool implements \Magento\Payment\Gateway\Validator\ValidatorPoolI
1717
private $validators;
1818

1919
/**
20-
* @param array $validators
2120
* @param TMapFactory $tmapFactory
21+
* @param array $validators
2222
*/
2323
public function __construct(
24-
array $validators,
25-
TMapFactory $tmapFactory
24+
TMapFactory $tmapFactory,
25+
array $validators = []
2626
) {
2727
$this->validators = $tmapFactory->create(
2828
[
2929
'array' => $validators,
30-
'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'
30+
'type' => ValidatorInterface::class
3131
]
3232
);
3333
}

app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Payment\Test\Unit\Gateway\Command;
77

88
use Magento\Payment\Gateway\Command\CommandPool;
9+
use Magento\Payment\Gateway\CommandInterface;
910

1011
class CommandPoolTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -26,7 +27,7 @@ public function testGet()
2627
->with(
2728
[
2829
'array' => ['Magento\Payment\Gateway\CommandInterface'],
29-
'type' => 'Magento\Payment\Gateway\CommandInterface'
30+
'type' => CommandInterface::class
3031
]
3132
)
3233
->willReturn($tMap);
@@ -39,7 +40,7 @@ public function testGet()
3940
->with('command')
4041
->willReturn($commandI);
4142

42-
$pool = new CommandPool(['Magento\Payment\Gateway\CommandInterface'], $tMapFactory);
43+
$pool = new CommandPool($tMapFactory, ['Magento\Payment\Gateway\CommandInterface']);
4344

4445
static::assertSame($commandI, $pool->get('command'));
4546
}
@@ -61,7 +62,7 @@ public function testGetException()
6162
->with(
6263
[
6364
'array' => [],
64-
'type' => 'Magento\Payment\Gateway\CommandInterface'
65+
'type' => CommandInterface::class
6566
]
6667
)
6768
->willReturn($tMap);
@@ -70,7 +71,7 @@ public function testGetException()
7071
->with('command')
7172
->willReturn(false);
7273

73-
$pool = new CommandPool([], $tMapFactory);
74+
$pool = new CommandPool($tMapFactory, []);
7475
$pool->get('command');
7576
}
7677
}

app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Payment\Test\Unit\Gateway\Config;
77

8+
use Magento\Payment\Gateway\Config\ValueHandlerInterface;
89
use Magento\Payment\Gateway\Config\ValueHandlerPool;
910

1011
class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase
@@ -19,7 +20,7 @@ public function testConstructorException()
1920

2021
$tMapFactory->expects(static::never())
2122
->method('create');
22-
new ValueHandlerPool([], $tMapFactory);
23+
new ValueHandlerPool($tMapFactory, []);
2324
}
2425

2526
public function testGet()
@@ -46,7 +47,7 @@ public function testGet()
4647
ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface',
4748
'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface'
4849
],
49-
'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface'
50+
'type' => ValueHandlerInterface::class
5051
]
5152
)
5253
->willReturn($tMap);
@@ -68,11 +69,11 @@ public function testGet()
6869
);
6970

7071
$pool = new ValueHandlerPool(
72+
$tMapFactory,
7173
[
7274
ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface',
7375
'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface'
74-
],
75-
$tMapFactory
76+
]
7677
);
7778
static::assertSame($someValueHandler, $pool->get('some_value'));
7879
static::assertSame($defaultHandler, $pool->get(ValueHandlerPool::DEFAULT_HANDLER));

app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Payment\Test\Unit\Gateway\Request;
77

88
use Magento\Payment\Gateway\Request\BuilderComposite;
9+
use Magento\Payment\Gateway\Request\BuilderInterface;
910

1011
class BuilderCompositeTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -24,15 +25,15 @@ public function testBuildEmpty()
2425
->with(
2526
[
2627
'array' => [],
27-
'type' => 'Magento\Payment\Gateway\Request\BuilderInterface'
28+
'type' => BuilderInterface::class
2829
]
2930
)
3031
->willReturn($tMap);
3132
$tMap->expects(static::once())
3233
->method('getIterator')
3334
->willReturn(new \ArrayIterator([]));
3435

35-
$builder = new BuilderComposite([], $tMapFactory);
36+
$builder = new BuilderComposite($tMapFactory, []);
3637
static::assertEquals([], $builder->build([]));
3738
}
3839

@@ -47,6 +48,7 @@ public function testBuild()
4748
'item' => 'gas cooker',
4849
'quantity' => 1
4950
];
51+
5052
$tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory')
5153
->disableOriginalConstructor()
5254
->setMethods(['create'])
@@ -96,7 +98,7 @@ public function testBuild()
9698
'product' => 'Magento\Payment\Gateway\Request\BuilderInterface',
9799
'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface'
98100
],
99-
'type' => 'Magento\Payment\Gateway\Request\BuilderInterface'
101+
'type' => BuilderInterface::class
100102
]
101103
)
102104
->willReturn($tMap);
@@ -105,12 +107,12 @@ public function testBuild()
105107
->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder]));
106108

107109
$builder = new BuilderComposite(
110+
$tMapFactory,
108111
[
109112
'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface',
110113
'product' => 'Magento\Payment\Gateway\Request\BuilderInterface',
111114
'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface'
112-
],
113-
$tMapFactory
115+
]
114116
);
115117

116118
static::assertEquals($expectedRequest, $builder->build([]));

app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Payment\Test\Unit\Gateway\Response;
77

88
use Magento\Payment\Gateway\Response\HandlerChain;
9+
use Magento\Payment\Gateway\Response\HandlerInterface;
910

1011
class HandlerChainTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -31,7 +32,7 @@ public function testHandle()
3132
'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface',
3233
'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface'
3334
],
34-
'type' => 'Magento\Payment\Gateway\Response\HandlerInterface'
35+
'type' => HandlerInterface::class
3536
]
3637
)
3738
->willReturn($tMap);
@@ -49,11 +50,11 @@ public function testHandle()
4950
->with($handlingSubject, $response);
5051

5152
$chain = new HandlerChain(
53+
$tMapFactory,
5254
[
5355
'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface',
5456
'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface'
55-
],
56-
$tMapFactory
57+
]
5758
);
5859
$chain->handle($handlingSubject, $response);
5960
}

0 commit comments

Comments
 (0)