|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Payment\Test\Unit\Block\Transparent; |
| 9 | + |
| 10 | +use Magento\Payment\Block\Transparent\Redirect; |
| 11 | +use PHPUnit\Framework\TestCase; |
| 12 | +use PHPUnit\Framework\MockObject\MockObject; |
| 13 | + |
| 14 | +class RedirectTest extends TestCase |
| 15 | +{ |
| 16 | + /** |
| 17 | + * @var \Magento\Framework\View\Element\Context|MockObject |
| 18 | + */ |
| 19 | + private $context; |
| 20 | + /** |
| 21 | + * @var \Magento\Framework\UrlInterface|MockObject |
| 22 | + */ |
| 23 | + private $url; |
| 24 | + /** |
| 25 | + * @var Redirect |
| 26 | + */ |
| 27 | + private $model; |
| 28 | + /** |
| 29 | + * @var \Magento\Framework\App\RequestInterface|MockObject |
| 30 | + */ |
| 31 | + private $request; |
| 32 | + |
| 33 | + /** |
| 34 | + * @inheritDoc |
| 35 | + */ |
| 36 | + protected function setUp(): void |
| 37 | + { |
| 38 | + parent::setUp(); |
| 39 | + $this->context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class); |
| 40 | + $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); |
| 41 | + $this->context->method('getRequest') |
| 42 | + ->willReturn($this->request); |
| 43 | + $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); |
| 44 | + $this->model = new Redirect( |
| 45 | + $this->context, |
| 46 | + $this->url |
| 47 | + ); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @param array $postData |
| 52 | + * @param array $expected |
| 53 | + * @dataProvider getPostParamsDataProvider |
| 54 | + */ |
| 55 | + public function testGetPostParams(array $postData, array $expected): void |
| 56 | + { |
| 57 | + $this->request->method('getPostValue') |
| 58 | + ->willReturn($postData); |
| 59 | + $this->assertEquals($expected, $this->model->getPostParams()); |
| 60 | + } |
| 61 | + |
| 62 | + /** |
| 63 | + * @return array |
| 64 | + */ |
| 65 | + public function getPostParamsDataProvider(): array |
| 66 | + { |
| 67 | + return [ |
| 68 | + [ |
| 69 | + [ |
| 70 | + 'BILLTOEMAIL' => '[email protected]', |
| 71 | + 'BILLTOSTREET' => '3640 Holdrege Ave', |
| 72 | + 'BILLTOZIP' => '90016', |
| 73 | + 'BILLTOLASTNAME' => 'Ãtienne', |
| 74 | + 'BILLTOFIRSTNAME' => 'Ãillin', |
| 75 | + ], |
| 76 | + [ |
| 77 | + 'BILLTOEMAIL' => '[email protected]', |
| 78 | + 'BILLTOSTREET' => '3640 Holdrege Ave', |
| 79 | + 'BILLTOZIP' => '90016', |
| 80 | + 'BILLTOLASTNAME' => 'Ãtienne', |
| 81 | + 'BILLTOFIRSTNAME' => 'Ãillin', |
| 82 | + ] |
| 83 | + ], |
| 84 | + [ |
| 85 | + [ |
| 86 | + 'BILLTOEMAIL' => '[email protected]', |
| 87 | + 'BILLTOSTREET' => '3640 Holdrege Ave', |
| 88 | + 'BILLTOZIP' => '90016', |
| 89 | + 'BILLTOLASTNAME' => mb_convert_encoding('Ãtienne', 'ISO-8859-1'), |
| 90 | + 'BILLTOFIRSTNAME' => mb_convert_encoding('Ãillin', 'ISO-8859-1'), |
| 91 | + ], |
| 92 | + [ |
| 93 | + 'BILLTOEMAIL' => '[email protected]', |
| 94 | + 'BILLTOSTREET' => '3640 Holdrege Ave', |
| 95 | + 'BILLTOZIP' => '90016', |
| 96 | + 'BILLTOLASTNAME' => 'Ãtienne', |
| 97 | + 'BILLTOFIRSTNAME' => 'Ãillin', |
| 98 | + ] |
| 99 | + ] |
| 100 | + ]; |
| 101 | + } |
| 102 | +} |
0 commit comments