diff --git a/app/code/Magento/Quote/Model/Quote/Payment.php b/app/code/Magento/Quote/Model/Quote/Payment.php index a6b5657263d4d2227d2ff929b4ab1cb58ee47dc9..6eedc8b892530a2ec09c2cc6b7cbd1d00d0a8c5b 100644 --- a/app/code/Magento/Quote/Model/Quote/Payment.php +++ b/app/code/Magento/Quote/Model/Quote/Payment.php @@ -279,7 +279,8 @@ class Payment extends \Magento\Payment\Model\Info implements \Magento\Quote\Api\ */ public function getCcExpYear() { - return $this->getData('cc_exp_year'); + $expirationYear = $this->getData('cc_exp_year') ?: null; + return $expirationYear; } /** diff --git a/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6d0bc8694a523958f96a6cccd0b9de17c3bf5888 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Quote/Model/Quote/PaymentTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Quote\Model\Quote; + +use Magento\TestFramework\Helper\ObjectManager; + +class PaymentTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var Payment + */ + private $model; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->model = $objectManager->getObject( + '\Magento\Quote\Model\Quote\Payment' + ); + } + + /** + * @param int|string|null $databaseValue + * @param int|string|null $expectedValue + * @dataProvider yearValueDataProvider + */ + public function testGetCcExpYearReturnsValidValue($databaseValue, $expectedValue) + { + $this->model->setData('cc_exp_year', $databaseValue); + $this->assertEquals($expectedValue, $this->model->getCcExpYear()); + } + + /** + * @return array + */ + public function yearValueDataProvider() + { + return array( + array(null, null), + array(0, null), + array('0', null), + array(1939, 1939), + ); + } +}