diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml index af60e0247169bb402d5b6d71be4576ad2ed24566..acfd1efa605c758750d1205662cbdb959e655d15 100644 --- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml +++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml @@ -149,7 +149,7 @@ <item name="source" xsi:type="string">catalog_rule</item> <item name="dataScope" xsi:type="string">customer_group_ids</item> </item> - <item name="options" xsi:type="object">\Magento\Customer\Model\Customer\Source\GroupSourceInterface</item> + <item name="options" xsi:type="object">\Magento\CatalogRule\Model\Rule\CustomerGroupsOptionsProvider</item> </argument> </field> <field name="from_date"> diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php index 45d31dc0e2764c4c41888a23ef0bb7f99836fed3..3c3fa73087e4a17a4c883b370c3a3fd44f7ad645 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Controller\Adminhtml\Index; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\SecurityViolationException; class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index { @@ -40,6 +41,8 @@ class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index $messages = $exception->getMessage(); } $this->_addSessionErrorMessages($messages); + } catch (SecurityViolationException $exception) { + $this->messageManager->addErrorMessage($exception->getMessage()); } catch (\Exception $exception) { $this->messageManager->addException( $exception, diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php index b7295fb9ceb4f19dd29fa8fe148552ebb20648e6..44444935973d43e9424242a9931b93121f314bae 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -143,7 +143,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase $this->messageManager = $this->getMockBuilder( \Magento\Framework\Message\Manager::class )->disableOriginalConstructor()->setMethods( - ['addSuccess', 'addMessage', 'addException'] + ['addSuccess', 'addMessage', 'addException', 'addErrorMessage'] )->getMock(); $this->resultRedirectFactoryMock = $this->getMockBuilder( @@ -332,6 +332,56 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase $this->_testedObject->execute(); } + public function testResetPasswordActionSecurityException() + { + $securityText = 'Security violation.'; + $exception = new \Magento\Framework\Exception\SecurityViolationException(__($securityText)); + $customerId = 1; + $email = 'some@example.com'; + $websiteId = 1; + + $this->_request->expects( + $this->once() + )->method( + 'getParam' + )->with( + $this->equalTo('customer_id'), + $this->equalTo(0) + )->will( + $this->returnValue($customerId) + ); + $customer = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\CustomerInterface::class, + ['getId', 'getEmail', 'getWebsiteId'] + ); + $customer->expects($this->once())->method('getEmail')->will($this->returnValue($email)); + $customer->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId)); + $this->_customerRepositoryMock->expects( + $this->once() + )->method( + 'getById' + )->with( + $customerId + )->will( + $this->returnValue($customer) + ); + $this->_customerAccountManagementMock->expects( + $this->once() + )->method( + 'initiatePasswordReset' + )->willThrowException($exception); + + $this->messageManager->expects( + $this->once() + )->method( + 'addErrorMessage' + )->with( + $this->equalTo($exception->getMessage()) + ); + + $this->_testedObject->execute(); + } + public function testResetPasswordActionCoreExceptionWarn() { $warningText = 'Warning'; diff --git a/app/code/Magento/Sales/Model/OrderRepository.php b/app/code/Magento/Sales/Model/OrderRepository.php index 5c14b3fd4433e4404db3921a1fffe5b13935643f..f0477fd76014adae7fefa22c6c16966819856266 100644 --- a/app/code/Magento/Sales/Model/OrderRepository.php +++ b/app/code/Magento/Sales/Model/OrderRepository.php @@ -146,6 +146,16 @@ class OrderRepository implements \Magento\Sales\Api\OrderRepositoryInterface */ public function save(\Magento\Sales\Api\Data\OrderInterface $entity) { + /** @var \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes */ + $extensionAttributes = $entity->getExtensionAttributes(); + if ($entity->getIsNotVirtual() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) { + $shippingAssignments = $extensionAttributes->getShippingAssignments(); + if (!empty($shippingAssignments)) { + $shipping = array_shift($shippingAssignments)->getShipping(); + $entity->setShippingAddress($shipping->getAddress()); + $entity->setShippingMethod($shipping->getMethod()); + } + } $this->metadata->getMapper()->save($entity); $this->registry[$entity->getEntityId()] = $entity; return $this->registry[$entity->getEntityId()]; diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php index 5535ac85095c57e40420e47fa427e0205ebc6aff..f6bc3459c0cc354dd10a945613be75dcefed999d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php @@ -110,4 +110,40 @@ class OrderRepositoryTest extends \PHPUnit_Framework_TestCase $this->assertEquals($collectionMock, $this->model->getList($searchCriteriaMock)); } + + public function testSave() + { + $mapperMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order::class) + ->disableOriginalConstructor() + ->getMock(); + $orderEntity = $this->getMock(\Magento\Sales\Model\Order::class, [], [], '', false); + $extensionAttributes = $this->getMock( + \Magento\Sales\Api\Data\OrderExtension::class, + ['getShippingAssignments'], + [], + '', + false + ); + $shippingAssignment = $this->getMockBuilder(\Magento\Sales\Model\Order\ShippingAssignment::class) + ->disableOriginalConstructor() + ->setMethods(['getShipping']) + ->getMock(); + $shippingMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Shipping::class) + ->disableOriginalConstructor() + ->setMethods(['getAddress', 'getMethod']) + ->getMock(); + $orderEntity->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes); + $orderEntity->expects($this->once())->method('getIsNotVirtual')->willReturn(true); + $extensionAttributes + ->expects($this->any()) + ->method('getShippingAssignments') + ->willReturn([$shippingAssignment]); + $shippingAssignment->expects($this->once())->method('getShipping')->willReturn($shippingMock); + $shippingMock->expects($this->once())->method('getAddress'); + $shippingMock->expects($this->once())->method('getMethod'); + $this->metadata->expects($this->once())->method('getMapper')->willReturn($mapperMock); + $mapperMock->expects($this->once())->method('save'); + $orderEntity->expects($this->any())->method('getEntityId')->willReturn(1); + $this->model->save($orderEntity); + } } diff --git a/app/code/Magento/SalesRule/Observer/SalesOrderAfterPlaceObserver.php b/app/code/Magento/SalesRule/Observer/SalesOrderAfterPlaceObserver.php index e352ede867a69638c00598d59fde6455be46c05a..a75947629db5d5a97b054306e7908b74cca300d4 100644 --- a/app/code/Magento/SalesRule/Observer/SalesOrderAfterPlaceObserver.php +++ b/app/code/Magento/SalesRule/Observer/SalesOrderAfterPlaceObserver.php @@ -57,7 +57,7 @@ class SalesOrderAfterPlaceObserver implements ObserverInterface { $order = $observer->getEvent()->getOrder(); - if (!$order || $order->getDiscountAmount() == 0) { + if (!$order || !$order->getAppliedRuleIds()) { return $this; } diff --git a/app/code/Magento/SalesRule/Test/Unit/Observer/SalesOrderAfterPlaceObserverTest.php b/app/code/Magento/SalesRule/Test/Unit/Observer/SalesOrderAfterPlaceObserverTest.php index 0546dce56a3f6d6a27849708daf987c801e14a3c..c3d7e41acdf2801e3a6aaae7eb3f3db24d3a992c 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Observer/SalesOrderAfterPlaceObserverTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Observer/SalesOrderAfterPlaceObserverTest.php @@ -121,10 +121,10 @@ class SalesOrderAfterPlaceObserverTest extends \PHPUnit_Framework_TestCase { $observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false); $order = $this->initOrderFromEvent($observer); - $discountAmount = 10; + $ruleIds = null; $order->expects($this->once()) - ->method('getDiscountAmount') - ->will($this->returnValue($discountAmount)); + ->method('getAppliedRuleIds') + ->will($this->returnValue($ruleIds)); $this->ruleFactory->expects($this->never()) ->method('create'); @@ -158,14 +158,10 @@ class SalesOrderAfterPlaceObserverTest extends \PHPUnit_Framework_TestCase $ruleId = 1; $couponId = 1; $customerId = 1; - $discountAmount = 10; - $order->expects($this->once()) + $order->expects($this->exactly(2)) ->method('getAppliedRuleIds') ->will($this->returnValue($ruleId)); - $order->expects($this->once()) - ->method('getDiscountAmount') - ->will($this->returnValue($discountAmount)); $order->expects($this->once()) ->method('getCustomerId') ->will($this->returnValue($customerId)); diff --git a/app/code/Magento/Security/Model/Plugin/AccountManagement.php b/app/code/Magento/Security/Model/Plugin/AccountManagement.php index ba1d4af5618b706bbf2bf009568c526364c47108..c65442ec400209c8c789a7f3103cba6a6db01540 100644 --- a/app/code/Magento/Security/Model/Plugin/AccountManagement.php +++ b/app/code/Magento/Security/Model/Plugin/AccountManagement.php @@ -25,18 +25,26 @@ class AccountManagement */ protected $securityManager; + /** + * @var int + */ + protected $passwordRequestEvent; + /** * AccountManagement constructor. * * @param \Magento\Framework\App\RequestInterface $request * @param SecurityManager $securityManager + * @param int $passwordRequestEvent */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Security\Model\SecurityManager $securityManager + \Magento\Security\Model\SecurityManager $securityManager, + $passwordRequestEvent = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST ) { $this->request = $request; $this->securityManager = $securityManager; + $this->passwordRequestEvent = $passwordRequestEvent; } /** @@ -56,7 +64,7 @@ class AccountManagement $websiteId = null ) { $this->securityManager->performSecurityCheck( - PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, + $this->passwordRequestEvent, $email ); return [$email, $template, $websiteId]; diff --git a/app/code/Magento/Security/etc/adminhtml/di.xml b/app/code/Magento/Security/etc/adminhtml/di.xml index 4cbd3c3adc567188fef3b0b487d064264d5a1c12..c134638d1266e50442a7bb17b5ea2e7bb6bb42c8 100644 --- a/app/code/Magento/Security/etc/adminhtml/di.xml +++ b/app/code/Magento/Security/etc/adminhtml/di.xml @@ -15,6 +15,11 @@ <type name="Magento\Backend\Controller\Adminhtml\Auth\Login"> <plugin name="security_login_form" type="Magento\Security\Model\Plugin\LoginController" /> </type> + <type name="Magento\Security\Model\Plugin\AccountManagement"> + <arguments> + <argument name="passwordRequestEvent" xsi:type="const">Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST</argument> + </arguments> + </type> <type name="Magento\Security\Model\SecurityManager"> <arguments> <argument name="securityCheckers" xsi:type="array"> diff --git a/app/code/Magento/Theme/view/frontend/web/js/view/messages.js b/app/code/Magento/Theme/view/frontend/web/js/view/messages.js index 48507343fe28dc928edf9e6af2038bfe29577216..b707659fb3f4c790eef6df14fd8e6c9d68eeef1d 100644 --- a/app/code/Magento/Theme/view/frontend/web/js/view/messages.js +++ b/app/code/Magento/Theme/view/frontend/web/js/view/messages.js @@ -32,7 +32,7 @@ define([ customerData.set('messages', {}); } - $.cookieStorage.setConf({path: '/', expires: -1}).set('mage-messages', null); + $.cookieStorage.set('mage-messages', ''); } }); }); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/provider.js b/app/code/Magento/Ui/view/base/web/js/grid/provider.js index 92a4a6fd38cc52ce93f4cce45dc823f5fa15d64e..7bca45d0253d047b056e7915d10a7ede491f93b6 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/provider.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/provider.js @@ -43,6 +43,10 @@ define([ .initStorage() .clearData(); + // Load data when there will + // be no more pending assets. + resolver(this.reload, this); + return this; }, @@ -122,9 +126,11 @@ define([ * Handles changes of 'params' object. */ onParamsChange: function () { - this.firstLoad ? - resolver(this.reload, this) : + // It's necessary to make a reload only + // after the initial loading has been made. + if (!this.firstLoad) { this.reload(); + } }, /** diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php index 1bee8cdfa17804a7eb91db20d4400717aca50080..1279057089918c2154a42731799063dffc91f329 100755 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderCreateTest.php @@ -31,6 +31,9 @@ class OrderCreateTest extends WebapiAbstract $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); } + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function prepareOrder() { /** @var \Magento\Sales\Model\Order $orderBuilder */ @@ -41,6 +44,8 @@ class OrderCreateTest extends WebapiAbstract $orderPaymentFactory = $this->objectManager->get(\Magento\Sales\Model\Order\PaymentFactory::class); /** @var \Magento\Sales\Model\Order\AddressRepository $orderAddressRepository */ $orderAddressRepository = $this->objectManager->get(\Magento\Sales\Model\Order\AddressRepository::class); + /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ + $storeManager = $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); $order = $orderFactory->create( ['data' => $this->getDataStructure(\Magento\Sales\Api\Data\OrderInterface::class)] @@ -68,6 +73,32 @@ class OrderCreateTest extends WebapiAbstract $order->setCustomerEmail($email); $order->setBaseGrandTotal(100); $order->setGrandTotal(100); + $order->setShippingDescription('Flat Rate - Fixed'); + $order->setIsVirtual(0); + $order->setStoreId($storeManager->getDefaultStoreView()->getId()); + $order->setBaseDiscountAmount(0); + $order->setBaseShippingAmount(5); + $order->setBaseShippingTaxAmount(0); + $order->setBaseSubtotal(100); + $order->setBaseTaxAmount(0); + $order->setBaseToGlobalRate(1); + $order->setBaseToOrderRate(1); + $order->setDiscountAmount(0); + $order->setShippingAmount(0); + $order->setShippingTaxAmount(0); + $order->setStoreToOrderRate(0); + $order->setBaseToOrderRate(0); + $order->setSubtotal(100); + $order->setTaxAmount(0); + $order->setTotalQtyOrdered(1); + $order->setCustomerIsGuest(1); + $order->setCustomerNoteNotify(0); + $order->setCustomerGroupId(0); + $order->setBaseSubtotalInclTax(100); + $order->setWeight(1); + $order->setBaseCurrencyCode('USD'); + $order->setShippingInclTax(5); + $order->setBaseShippingInclTax(5); $this->addProductOption($orderItem); @@ -82,12 +113,39 @@ class OrderCreateTest extends WebapiAbstract $orderAddressBilling->setFirstname('First Name'); $orderAddressBilling->setTelephone('+00(000)-123-45-57'); $orderAddressBilling->setStreet(['Street']); - $orderAddressBilling->setCountryId(1); + $orderAddressBilling->setCountryId('US'); + $orderAddressBilling->setRegion('California'); $orderAddressBilling->setAddressType('billing'); + $orderAddressBilling->setRegionId(12); + + $orderAddressShipping = $orderAddressRepository->create(); + $orderAddressShipping->setCity('City2'); + $orderAddressShipping->setPostcode('12345'); + $orderAddressShipping->setLastname('Last Name2'); + $orderAddressShipping->setFirstname('First Name2'); + $orderAddressShipping->setTelephone('+00(000)-123-45-57'); + $orderAddressShipping->setStreet(['Street']); + $orderAddressShipping->setCountryId('US'); + $orderAddressShipping->setRegion('California'); + $orderAddressShipping->setAddressType('shipping'); + $orderAddressShipping->setRegionId(12); $orderData = $order->getData(); $orderData['billing_address'] = $orderAddressBilling->getData(); $orderData['billing_address']['street'] = ['Street']; + $address = $orderAddressShipping->getData(); + $address['street'] = ['Street']; + $orderData['extension_attributes']['shipping_assignments'] = + [ + [ + 'shipping' => [ + 'address' => $address, + 'method' => 'Flat Rate - Fixed' + ], + 'items' => [$orderItem->getData()], + 'stock_id' => null, + ] + ]; return $orderData; } @@ -172,5 +230,8 @@ class OrderCreateTest extends WebapiAbstract $this->assertTrue((bool)$model->getId()); $this->assertEquals($order['base_grand_total'], $model->getBaseGrandTotal()); $this->assertEquals($order['grand_total'], $model->getGrandTotal()); + $this->assertNotNull($model->getShippingAddress()); + $this->assertTrue((bool)$model->getShippingAddress()->getId()); + $this->assertEquals('Flat Rate - Fixed', $model->getShippingMethod()); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f3571c17ddffe72511037e07af3617244831f66b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Controller\Adminhtml\Index; + +/** + * ResetPassword controller test. + * + * @magentoAppArea adminhtml + */ +class ResetPasswordTest extends \Magento\TestFramework\TestCase\AbstractBackendController +{ + /** + * Base controller URL + * + * @var string + */ + protected $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/'; + + /** + * Checks reset password functionality with default settings and customer reset request event. + * + * @magentoConfigFixture current_store admin/security/limit_password_reset_requests_method 1 + * @magentoConfigFixture current_store admin/security/min_time_between_password_reset_requests 10 + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testResetPasswordSuccess() + { + $this->passwordResetRequestEventCreate( + \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST + ); + $this->getRequest()->setPostValue(['customer_id' => '1']); + $this->dispatch('backend/customer/index/resetPassword'); + $this->assertSessionMessages( + $this->equalTo(['The customer will receive an email with a link to reset password.']), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit')); + } + + /** + * Checks reset password functionality with default settings, customer and admin reset request events. + * + * @magentoConfigFixture current_store admin/security/limit_password_reset_requests_method 1 + * @magentoConfigFixture current_store admin/security/min_time_between_password_reset_requests 10 + * @magentoConfigFixture current_store contact/email/recipient_email hello@example.com + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testResetPasswordWithSecurityViolationException() + { + $this->passwordResetRequestEventCreate( + \Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST + ); + $this->passwordResetRequestEventCreate( + \Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST + ); + $this->getRequest()->setPostValue(['customer_id' => '1']); + $this->dispatch('backend/customer/index/resetPassword'); + $this->assertSessionMessages( + $this->equalTo( + ['Too many password reset requests. Please wait and try again or contact hello@example.com.'] + ), + \Magento\Framework\Message\MessageInterface::TYPE_ERROR + ); + $this->assertRedirect($this->stringStartsWith($this->baseControllerUrl . 'edit')); + } + + /** + * Create and save reset request event with provided request type. + * + * @param int $requestType + */ + private function passwordResetRequestEventCreate($requestType) + { + $passwordResetRequestEventFactory = $this->_objectManager->get( + \Magento\Security\Model\PasswordResetRequestEventFactory::class + ); + $passwordResetRequestEvent = $passwordResetRequestEventFactory->create(); + $passwordResetRequestEvent + ->setRequestType($requestType) + ->setAccountReference('customer@example.com') + ->setCreatedAt(strtotime('now')) + ->setIp('3232249856') + ->save(); + } +} diff --git a/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php b/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php index 4048f2d105ac0f1d455e2a07f9ecc4acdc9bd962..ddf14cdc659a26533a60f4e79a25b39e5b94fddd 100644 --- a/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php +++ b/lib/internal/Magento/Framework/Pricing/Render/PriceBox.php @@ -86,7 +86,7 @@ class PriceBox extends Template implements PriceBoxRenderInterface, IdentityInte */ protected function getCacheLifetime() { - return parent::hasCacheLifetime() ? parent::getCacheLifetime() : self::DEFAULT_LIFETIME; + return parent::hasCacheLifetime() ? parent::getCacheLifetime() : null; } /** diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php index 86e2dde6359d8a9f759905042d86521c135da04d..9a0dfcd7099ee94718f38f18c4af3ab3ed521109 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Render/PriceBoxTest.php @@ -241,4 +241,17 @@ class PriceBoxTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($this->rendererPool, $this->model->getRendererPool()); } + + /** + * This tests ensures that protected method getCacheLifetime() returns a null value when cacheLifeTime is not + * explicitly set in the parent block + */ + public function testCacheLifetime() + { + $reflectionClass = new \ReflectionClass(get_class($this->model)); + $methodReflection = $reflectionClass->getMethod('getCacheLifetime'); + $methodReflection->setAccessible(true); + $cacheLifeTime = $methodReflection->invoke($this->model); + $this->assertNull($cacheLifeTime, 'Expected null cache lifetime'); + } }