Skip to content

Commit 04a81e5

Browse files
author
Alex Akimov
committed
MAGETWO-32811: GET /V1/carts/:cartId/selected-payment-methods service always return "cc_exp_year" even if it not needed
1 parent 3fe3f5c commit 04a81e5

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

app/code/Magento/Quote/Model/Quote/Payment.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ public function getCcType()
279279
*/
280280
public function getCcExpYear()
281281
{
282-
return $this->getData('cc_exp_year');
282+
$expirationYear = $this->getData('cc_exp_year') ?: null;
283+
return $expirationYear;
283284
}
284285

285286
/**
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Quote\Model\Quote;
7+
8+
use Magento\TestFramework\Helper\ObjectManager;
9+
10+
class PaymentTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var Payment
14+
*/
15+
private $model;
16+
17+
protected function setUp()
18+
{
19+
$objectManager = new ObjectManager($this);
20+
$this->model = $objectManager->getObject(
21+
'\Magento\Quote\Model\Quote\Payment'
22+
);
23+
}
24+
25+
/**
26+
* @param int|string|null $databaseValue
27+
* @param int|string|null $expectedValue
28+
* @dataProvider yearValueDataProvider
29+
*/
30+
public function testGetCcExpYearReturnsValidValue($databaseValue, $expectedValue)
31+
{
32+
$this->model->setData('cc_exp_year', $databaseValue);
33+
$this->assertEquals($expectedValue, $this->model->getCcExpYear());
34+
}
35+
36+
/**
37+
* @return array
38+
*/
39+
public function yearValueDataProvider()
40+
{
41+
return array(
42+
array(null, null),
43+
array(0, null),
44+
array('0', null),
45+
array(1939, 1939),
46+
);
47+
}
48+
}

0 commit comments

Comments
 (0)