|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +namespace Magento\Payment\Helper; |
| 7 | + |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | +use Magento\OfflinePayments\Block\Info\Checkmo; |
| 10 | +use Magento\Payment\Model\Info; |
| 11 | +use Magento\TestFramework\Helper\Bootstrap; |
6 | 12 |
|
7 | 13 | /**
|
8 | 14 | * Test class for \Magento\Payment\Helper\Data
|
9 | 15 | */
|
10 |
| -namespace Magento\Payment\Helper; |
11 |
| - |
12 |
| -class DataTest extends \PHPUnit\Framework\TestCase |
| 16 | +class DataTest extends TestCase |
13 | 17 | {
|
| 18 | + /** |
| 19 | + * @var Data |
| 20 | + */ |
| 21 | + private $helper; |
| 22 | + |
| 23 | + /** |
| 24 | + * @inheritdoc |
| 25 | + */ |
| 26 | + protected function setUp() |
| 27 | + { |
| 28 | + parent::setUp(); |
| 29 | + |
| 30 | + $this->helper = Bootstrap::getObjectManager()->get(Data::class); |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * @return void |
| 35 | + */ |
14 | 36 | public function testGetInfoBlock()
|
15 | 37 | {
|
16 |
| - $helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Payment\Helper\Data::class); |
17 |
| - $paymentInfo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( |
18 |
| - \Magento\Payment\Model\Info::class |
| 38 | + $paymentInfo = Bootstrap::getObjectManager()->create( |
| 39 | + Info::class |
19 | 40 | );
|
20 | 41 | $paymentInfo->setMethod('checkmo');
|
21 |
| - $result = $helper->getInfoBlock($paymentInfo); |
22 |
| - $this->assertInstanceOf(\Magento\OfflinePayments\Block\Info\Checkmo::class, $result); |
| 42 | + $result = $this->helper->getInfoBlock($paymentInfo); |
| 43 | + $this->assertInstanceOf(Checkmo::class, $result); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Test to load Payment method title from store config |
| 48 | + * |
| 49 | + * @magentoConfigFixture current_store payment/cashondelivery/title Cash On Delivery Title Of The Method |
| 50 | + */ |
| 51 | + public function testPaymentMethodLabelByStore() |
| 52 | + { |
| 53 | + $result = $this->helper->getPaymentMethodList(true, true); |
| 54 | + $this->assertArrayHasKey('cashondelivery', $result, 'Payment info does not exist'); |
| 55 | + $this->assertEquals( |
| 56 | + 'Cash On Delivery Title Of The Method', |
| 57 | + $result['cashondelivery']['label'], |
| 58 | + 'Payment method title is not loaded from store config' |
| 59 | + ); |
23 | 60 | }
|
24 | 61 | }
|
0 commit comments