diff --git a/app/code/Magento/Customer/Controller/Account/Confirmation.php b/app/code/Magento/Customer/Controller/Account/Confirmation.php index e7d23cac8d62a6b0dfd8e777fe22ccec8a1980f1..a3e2db0207630d7ecdea0e3d78eef99e70ed1ebb 100644 --- a/app/code/Magento/Customer/Controller/Account/Confirmation.php +++ b/app/code/Magento/Customer/Controller/Account/Confirmation.php @@ -6,8 +6,10 @@ */ namespace Magento\Customer\Controller\Account; +use Magento\Customer\Model\Url; use Magento\Framework\App\Action\Context; use Magento\Customer\Model\Session; +use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Result\PageFactory; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\AccountManagementInterface; @@ -35,24 +37,32 @@ class Confirmation extends \Magento\Customer\Controller\AbstractAccount */ protected $resultPageFactory; + /** + * @var Url + */ + private $customerUrl; + /** * @param Context $context * @param Session $customerSession * @param PageFactory $resultPageFactory * @param StoreManagerInterface $storeManager * @param AccountManagementInterface $customerAccountManagement + * @param Url $customerUrl */ public function __construct( Context $context, Session $customerSession, PageFactory $resultPageFactory, StoreManagerInterface $storeManager, - AccountManagementInterface $customerAccountManagement + AccountManagementInterface $customerAccountManagement, + Url $customerUrl = null ) { $this->session = $customerSession; $this->resultPageFactory = $resultPageFactory; $this->storeManager = $storeManager; $this->customerAccountManagement = $customerAccountManagement; + $this->customerUrl = $customerUrl ?: ObjectManager::getInstance()->get(Url::class); parent::__construct($context); } @@ -98,6 +108,8 @@ class Confirmation extends \Magento\Customer\Controller\AbstractAccount $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('accountConfirmation')->setEmail( $this->getRequest()->getParam('email', $email) + )->setLoginUrl( + $this->customerUrl->getLoginUrl() ); return $resultPage; } diff --git a/app/code/Magento/Customer/Model/Checkout/ConfigProvider.php b/app/code/Magento/Customer/Model/Checkout/ConfigProvider.php index a333fe8df594a97e239aefd65469fcf1b16f42aa..36eabe3571ceb267cb2cf4bafad1c7b0431ddcd9 100644 --- a/app/code/Magento/Customer/Model/Checkout/ConfigProvider.php +++ b/app/code/Magento/Customer/Model/Checkout/ConfigProvider.php @@ -7,6 +7,7 @@ namespace Magento\Customer\Model\Checkout; use Magento\Checkout\Model\ConfigProviderInterface; use Magento\Customer\Model\Url; +use Magento\Framework\App\ObjectManager; use Magento\Framework\UrlInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -22,6 +23,7 @@ class ConfigProvider implements ConfigProviderInterface /** * @var UrlInterface + * @deprecated */ protected $urlBuilder; @@ -30,19 +32,28 @@ class ConfigProvider implements ConfigProviderInterface */ protected $scopeConfig; + /** + * @var Url + */ + private $customerUrl; + /** * @param UrlInterface $urlBuilder * @param StoreManagerInterface $storeManager * @param ScopeConfigInterface $scopeConfig + * @param Url|null $customerUrl */ public function __construct( UrlInterface $urlBuilder, StoreManagerInterface $storeManager, - ScopeConfigInterface $scopeConfig + ScopeConfigInterface $scopeConfig, + Url $customerUrl = null ) { $this->urlBuilder = $urlBuilder; $this->storeManager = $storeManager; $this->scopeConfig = $scopeConfig; + $this->customerUrl = $customerUrl ?? ObjectManager::getInstance() + ->get(Url::class); } /** @@ -78,7 +89,7 @@ class ConfigProvider implements ConfigProviderInterface */ protected function getLoginUrl() { - return $this->urlBuilder->getUrl(Url::ROUTE_ACCOUNT_LOGIN); + return $this->customerUrl->getLoginUrl(); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmationTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..113f8c104a4ea62e26a9add25f847259611c5cbc --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmationTest.php @@ -0,0 +1,116 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Customer\Test\Unit\Controller\Account; + +use Magento\Customer\Controller\Account\Confirmation; +use Magento\Framework\App\Request\Http; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +class ConfirmationTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var Confirmation + */ + private $model; + + /** + * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject + */ + private $customerSessionMock; + + /** + * @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject + */ + private $contextMock; + + /** + * @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $resultPageFactoryMock; + + /** + * @var \Magento\Customer\Model\Url|\PHPUnit_Framework_MockObject_MockObject + */ + private $customerUrlMock; + + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + public function setUp() + { + $this->customerSessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class) + ->disableOriginalConstructor() + ->setMethods(['isLoggedIn']) + ->getMock(); + $this->contextMock = $this->getMockBuilder(\Magento\Framework\App\Action\Context::class) + ->disableOriginalConstructor() + ->setMethods(['getRequest']) + ->getMock(); + $this->requestMock = $this->getMockBuilder(Http::class) + ->disableOriginalConstructor() + ->setMethods(['getPost', 'getParam']) + ->getMock(); + $this->contextMock->expects($this->any()) + ->method('getRequest') + ->willReturn($this->requestMock); + + $this->resultPageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->customerUrlMock = $this->getMockBuilder(\Magento\Customer\Model\Url::class) + ->disableOriginalConstructor() + ->setMethods(['getLoginUrl']) + ->getMock(); + $this->model = (new ObjectManagerHelper($this))->getObject( + Confirmation::class, + [ + 'context' => $this->contextMock, + 'customerSession' => $this->customerSessionMock, + 'resultPageFactory' => $this->resultPageFactoryMock, + 'customerUrl' => $this->customerUrlMock, + ] + ); + } + + public function testGetLoginUrl() + { + $this->customerSessionMock->expects($this->once()) + ->method('isLoggedIn') + ->willReturn(false); + + $this->requestMock->expects($this->once())->method('getPost')->with('email')->willReturn(null); + + $resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) + ->disableOriginalConstructor() + ->setMethods(['getLayout']) + ->getMock(); + + $this->resultPageFactoryMock->expects($this->once())->method('create')->willReturn($resultPageMock); + + $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class) + ->disableOriginalConstructor() + ->setMethods(['getBlock']) + ->getMock(); + + $resultPageMock->expects($this->once())->method('getLayout')->willReturn($layoutMock); + + $blockMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template::class) + ->disableOriginalConstructor() + ->setMethods(['setEmail', 'setLoginUrl']) + ->getMock(); + + $layoutMock->expects($this->once())->method('getBlock')->with('accountConfirmation')->willReturn($blockMock); + + $blockMock->expects($this->once())->method('setEmail')->willReturnSelf(); + $blockMock->expects($this->once())->method('setLoginUrl')->willReturnSelf(); + + $this->model->execute(); + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php index 011ba9091eaf2f24b4ed26466524ee3780d81b7b..58b099a1d387d2229cab1dba2d9ec90377c743d5 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Checkout/ConfigProviderTest.php @@ -41,6 +41,11 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase */ protected $store; + /** + * @var Url|\PHPUnit_Framework_MockObject_MockObject + */ + private $customerUrl; + protected function setUp() { $this->storeManager = $this->getMockForAbstractClass( @@ -49,12 +54,14 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase '', false ); + $this->urlBuilder = $this->getMockForAbstractClass( \Magento\Framework\UrlInterface::class, [], '', false ); + $this->scopeConfig = $this->getMockForAbstractClass( \Magento\Framework\App\Config\ScopeConfigInterface::class, [], @@ -71,10 +78,13 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase ['getBaseUrl'] ); + $this->customerUrl = $this->createMock(\Magento\Customer\Model\Url::class); + $this->provider = new ConfigProvider( $this->urlBuilder, $this->storeManager, - $this->scopeConfig + $this->scopeConfig, + $this->customerUrl ); } @@ -83,9 +93,8 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase $loginUrl = 'http://url.test/customer/login'; $baseUrl = 'http://base-url.test'; - $this->urlBuilder->expects($this->exactly(2)) - ->method('getUrl') - ->with(Url::ROUTE_ACCOUNT_LOGIN) + $this->customerUrl->expects($this->exactly(2)) + ->method('getLoginUrl') ->willReturn($loginUrl); $this->storeManager->expects($this->once()) ->method('getStore') @@ -112,9 +121,8 @@ class ConfigProviderTest extends \PHPUnit\Framework\TestCase $loginUrl = 'http://base-url.test/customer/login'; $baseUrl = 'http://base-url.test'; - $this->urlBuilder->expects($this->exactly(2)) - ->method('getUrl') - ->with(Url::ROUTE_ACCOUNT_LOGIN) + $this->customerUrl->expects($this->exactly(2)) + ->method('getLoginUrl') ->willReturn($loginUrl); $this->storeManager->expects($this->once()) ->method('getStore') diff --git a/app/code/Magento/Directory/Model/PriceCurrency.php b/app/code/Magento/Directory/Model/PriceCurrency.php index a211242d377f3de055fe9a4023b97e9fbf1ae6d7..07d2e60d61335da7848956e165c0da3676876c49 100644 --- a/app/code/Magento/Directory/Model/PriceCurrency.php +++ b/app/code/Magento/Directory/Model/PriceCurrency.php @@ -77,8 +77,7 @@ class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface $scope = null, $currency = null ) { - return $this->getCurrency($scope, $currency) - ->formatPrecision($amount, $precision, [], $includeContainer); + return $this->createCurrency($scope, $currency)->formatPrecision($amount, $precision, [], $includeContainer); } /** @@ -101,20 +100,7 @@ class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface */ public function getCurrency($scope = null, $currency = null) { - if ($currency instanceof Currency) { - $currentCurrency = $currency; - } elseif (is_string($currency)) { - $currency = $this->currencyFactory->create() - ->load($currency); - $baseCurrency = $this->getStore($scope) - ->getBaseCurrency(); - $currentCurrency = $baseCurrency->getRate($currency) ? $currency : $baseCurrency; - } else { - $currentCurrency = $this->getStore($scope) - ->getCurrentCurrency(); - } - - return $currentCurrency; + return $this->createCurrency($scope, $currency, true); } /** @@ -157,4 +143,30 @@ class PriceCurrency implements \Magento\Framework\Pricing\PriceCurrencyInterface { return round($price, 2); } + + /** + * Get currency considering currency rate configuration. + * + * @param null|string|bool|int|\Magento\Framework\App\ScopeInterface $scope + * @param \Magento\Framework\Model\AbstractModel|string|null $currency + * @param bool $includeRate + * + * @return Currency + */ + private function createCurrency($scope, $currency, bool $includeRate = false) + { + if ($currency instanceof Currency) { + $currentCurrency = $currency; + } elseif (is_string($currency)) { + $currentCurrency = $this->currencyFactory->create()->load($currency); + if ($includeRate) { + $baseCurrency = $this->getStore($scope)->getBaseCurrency(); + $currentCurrency = $baseCurrency->getRate($currentCurrency) ? $currentCurrency : $baseCurrency; + } + } else { + $currentCurrency = $this->getStore($scope)->getCurrentCurrency(); + } + + return $currentCurrency; + } } diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php index cc68709cd3b038151e85c2495be00ee6a0e6fe27..0eecca21b0d542982e3dcfe09a88529f3c1c9e22 100644 --- a/app/code/Magento/Eav/Model/Config.php +++ b/app/code/Magento/Eav/Model/Config.php @@ -503,6 +503,7 @@ class Config } if (isset($this->attributes[$entityTypeCode][$code])) { + \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__); return $this->attributes[$entityTypeCode][$code]; } diff --git a/app/code/Magento/Shipping/Helper/Data.php b/app/code/Magento/Shipping/Helper/Data.php index 78e23cb4aeac266b753c44a3838dacd2d017a168..dd0933b5a340e80a2727a208c66c32304cf09ead 100644 --- a/app/code/Magento/Shipping/Helper/Data.php +++ b/app/code/Magento/Shipping/Helper/Data.php @@ -11,6 +11,10 @@ */ namespace Magento\Shipping\Helper; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\UrlInterface; +use Magento\Store\Model\StoreManagerInterface; + class Data extends \Magento\Framework\App\Helper\AbstractHelper { /** @@ -21,19 +25,28 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected $_allowedHashKeys = ['ship_id', 'order_id', 'track_id']; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $_storeManager; + /** + * @var UrlInterface|null + */ + private $url; + /** * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param StoreManagerInterface $storeManager + * @param UrlInterface|null $url */ public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Store\Model\StoreManagerInterface $storeManager + StoreManagerInterface $storeManager, + UrlInterface $url = null ) { $this->_storeManager = $storeManager; + $this->url = $url ?: ObjectManager::getInstance()->get(UrlInterface::class); + parent::__construct($context); } @@ -64,12 +77,13 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper { $urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}"; $params = [ + '_scope' => $model->getStoreId(), + '_nosid' => true, '_direct' => 'shipping/tracking/popup', '_query' => ['hash' => $this->urlEncoder->encode($urlPart)] ]; - $storeModel = $this->_storeManager->getStore($model->getStoreId()); - return $storeModel->getUrl('', $params); + return $this->url->getUrl('', $params); } /** diff --git a/app/code/Magento/Shipping/etc/adminhtml/di.xml b/app/code/Magento/Shipping/etc/adminhtml/di.xml index 54d5d9664e66f7ec06032e8c847f29336138adf9..36bd1ae9d35055444b9196ad2a6a788a04f87193 100644 --- a/app/code/Magento/Shipping/etc/adminhtml/di.xml +++ b/app/code/Magento/Shipping/etc/adminhtml/di.xml @@ -7,4 +7,11 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Shipping\Model\Shipping" type="Magento\Shipping\Model\Shipping\Labels" /> + + <type name="Magento\Shipping\Helper\Data"> + <arguments> + <!-- Use frontend URL model--> + <argument name="url" xsi:type="object">Magento\Framework\Url</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml index cc3ea276e2230c3daa639ca0e0fecf49b4bdc13d..58548a0ba268a1916fe503ae4e3b6da1e1871590 100644 --- a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml +++ b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml @@ -15,7 +15,7 @@ $welcomeMessage = $block->getWelcome(); case 'welcome': ?> <li class="greet welcome" data-bind="scope: 'customer'"> <!-- ko if: customer().fullname --> - <span data-bind="text: new String('<?= $block->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().firstname)"> + <span data-bind="text: new String('<?= $block->escapeHtml(__('Welcome, %1!', '%1')) ?>').replace('%1', customer().fullname)"> </span> <!-- /ko --> <!-- ko ifnot: customer().fullname --> diff --git a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js index 01a15755414088e21a010e08b8b5e5212d8d1a46..0ffd65c47d4cf67639992a976a00b1b59352ebd7 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js @@ -84,8 +84,10 @@ define([ ], 'range-words': [ function (value, params) { - return utils.stripHtml(value).match(/\b\w+\b/g).length >= params[0] && - value.match(/bw+b/g).length < params[1]; + var match = utils.stripHtml(value).match(/\b\w+\b/g) || []; + + return match.length >= params[0] && + match.length <= params[1]; }, $.mage.__('Please enter between {0} and {1} words.') ], diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartPerCustomer.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartPerCustomer.php index 2442bd8fe1f5f7a04f05410f57b90e8c0f8dffab..1aee48ad307adf1f9ecc5775c8b23c606706ae99 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartPerCustomer.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertCartPerCustomer.php @@ -53,7 +53,10 @@ class AssertCartPerCustomer extends AbstractConstraint ['customer' => $customer] )->run(); \PHPUnit_Framework_Assert::assertEquals( - sprintf(self::WELCOME_MESSAGE, $customer->getFirstname()), + sprintf( + self::WELCOME_MESSAGE, + $customer->getFirstname() . ' ' . $customer->getLastname() + ), $cmsIndex->getLinksBlock()->getWelcomeText(), 'Customer welcome message is wrong.' ); diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/PriceCurrencyTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/PriceCurrencyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fd6b8577eaf9809da9b71b04c5904fa138ca414b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/PriceCurrencyTest.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Directory\Model; + +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Provide tests for PriceCurrency model. + */ +class PriceCurrencyTest extends TestCase +{ + /** + * Test subject. + * + * @var PriceCurrency + */ + private $priceCurrency; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->priceCurrency = Bootstrap::getObjectManager()->get(PriceCurrency::class); + } + + /** + * Check PriceCurrency::format() doesn't depend on currency rate configuration. + * @return void + */ + public function testFormat() + { + self::assertSame( + '<span class="price">AFN10.00</span>', + $this->priceCurrency->format(10, true, 2, null, 'AFN') + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php index eaac89cc6851beec44e52b46bffa51373cd51fc0..99a28812a12d5737d0bb876f45df49c15c0226f6 100644 --- a/dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Shipping/Helper/DataTest.php @@ -5,16 +5,18 @@ */ namespace Magento\Shipping\Helper; +use Magento\Store\Model\StoreManagerInterface; + class DataTest extends \PHPUnit\Framework\TestCase { /** * @var \Magento\Shipping\Helper\Data */ - protected $_helper = null; + private $helper; protected function setUp() { - $this->_helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $this->helper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( \Magento\Shipping\Helper\Data::class ); } @@ -31,33 +33,77 @@ class DataTest extends \PHPUnit\Framework\TestCase { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $constructArgs = []; - if (\Magento\Sales\Model\Order\Shipment::class == $modelName) { - $orderRepository = $this->_getMockOrderRepository($code); + if (\Magento\Sales\Model\Order\Shipment::class === $modelName) { + $orderRepository = $this->getMockOrderRepository($code); + $constructArgs['orderRepository'] = $orderRepository; + } elseif (\Magento\Sales\Model\Order\Shipment\Track::class === $modelName) { + $shipmentRepository = $this->getMockShipmentRepository($code); + $constructArgs['shipmentRepository'] = $shipmentRepository; + } + + $model = $objectManager->create($modelName, $constructArgs); + $model->{$getIdMethod}($entityId); + + if (\Magento\Sales\Model\Order::class === $modelName) { + $model->setProtectCode($code); + } + if (\Magento\Sales\Model\Order\Shipment\Track::class === $modelName) { + $model->setParentId(1); + } + + $actual = $this->helper->getTrackingPopupUrlBySalesModel($model); + $this->assertEquals($expected, $actual); + } + + /** + * From the admin panel with custom URL we should have generated frontend URL + * + * @param string $modelName + * @param string $getIdMethod + * @param int $entityId + * @param string $code + * @param string $expected + * @magentoAppArea adminhtml + * @magentoConfigFixture admin_store web/unsecure/base_link_url http://admin.localhost/ + * @dataProvider getTrackingPopupUrlBySalesModelDataProvider + */ + public function testGetTrackingPopupUrlBySalesModelFromAdmin($modelName, $getIdMethod, $entityId, $code, $expected) + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + /** @var StoreManagerInterface $storeManager */ + $storeManager = $objectManager->create(StoreManagerInterface::class); + $storeManager->reinitStores(); + + $constructArgs = []; + if (\Magento\Sales\Model\Order\Shipment::class === $modelName) { + $orderRepository = $this->getMockOrderRepository($code); $constructArgs['orderRepository'] = $orderRepository; - } elseif (\Magento\Sales\Model\Order\Shipment\Track::class == $modelName) { - $shipmentRepository = $this->_getMockShipmentRepository($code); + } elseif (\Magento\Sales\Model\Order\Shipment\Track::class === $modelName) { + $shipmentRepository = $this->getMockShipmentRepository($code); $constructArgs['shipmentRepository'] = $shipmentRepository; } $model = $objectManager->create($modelName, $constructArgs); $model->{$getIdMethod}($entityId); - if (\Magento\Sales\Model\Order::class == $modelName) { + if (\Magento\Sales\Model\Order::class === $modelName) { $model->setProtectCode($code); } - if (\Magento\Sales\Model\Order\Shipment\Track::class == $modelName) { + if (\Magento\Sales\Model\Order\Shipment\Track::class === $modelName) { $model->setParentId(1); } - $actual = $this->_helper->getTrackingPopupUrlBySalesModel($model); + //Frontend URL should be used there + $actual = $this->helper->getTrackingPopupUrlBySalesModel($model); $this->assertEquals($expected, $actual); } /** * @param $code - * @return \Magento\Sales\Api\OrderRepositoryInterface + * @return \Magento\Sales\Api\OrderRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected function _getMockOrderRepository($code) + private function getMockOrderRepository($code) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $order = $objectManager->create(\Magento\Sales\Model\Order::class); @@ -71,10 +117,10 @@ class DataTest extends \PHPUnit\Framework\TestCase * @param $code * @return \Magento\Sales\Model\Order\ShipmentRepository|\PHPUnit_Framework_MockObject_MockObject */ - protected function _getMockShipmentRepository($code) + private function getMockShipmentRepository($code) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $orderRepository = $this->_getMockOrderRepository($code); + $orderRepository = $this->getMockOrderRepository($code); $shipmentArgs = ['orderRepository' => $orderRepository]; $shipment = $objectManager->create(\Magento\Sales\Model\Order\Shipment::class, $shipmentArgs); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js new file mode 100644 index 0000000000000000000000000000000000000000..334bf94892b792d02001e63f5ccd3d6e65175b01 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js @@ -0,0 +1,43 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint-disable max-nested-callbacks */ +define([ + 'Magento_Ui/js/lib/validation/rules' +], function (rules) { + 'use strict'; + + describe('Magento_Ui/js/lib/validation/rules', function () { + describe('"range-words" method', function () { + it('Check on empty value', function () { + var value = '', + params = [1,3]; + + expect(rules['range-words'].handler(value, params)).toBe(false); + }); + + it('Check on redundant words', function () { + var value = 'a b c d', + params = [1,3]; + + expect(rules['range-words'].handler(value, params)).toBe(false); + }); + + it('Check with three words', function () { + var value = 'a b c', + params = [1,3]; + + expect(rules['range-words'].handler(value, params)).toBe(true); + }); + + it('Check with one word', function () { + var value = 'a', + params = [1,3]; + + expect(rules['range-words'].handler(value, params)).toBe(true); + }); + }); + }); +}); diff --git a/lib/internal/Magento/Framework/Event/Test/Unit/Config/_files/valid_events.xml b/lib/internal/Magento/Framework/Event/Test/Unit/Config/_files/valid_events.xml index 5cf120adb6b9944fae021bafe59bb76015e83efd..a9f445339e3dcbd81ed6f0344a7f19515fac27d3 100644 --- a/lib/internal/Magento/Framework/Event/Test/Unit/Config/_files/valid_events.xml +++ b/lib/internal/Magento/Framework/Event/Test/Unit/Config/_files/valid_events.xml @@ -12,4 +12,7 @@ <event name="authorization_roles_save_before"> <observer name="second_name" instance="Some_Test_Value_Two" /> </event> + <event name="authorization_roles_save_before123"> + <observer name="second_name" instance="Some_Test_Value_Two" /> + </event> </config> diff --git a/lib/internal/Magento/Framework/Event/etc/events.xsd b/lib/internal/Magento/Framework/Event/etc/events.xsd index ad7c5e59da99c7952e4d387051468697d49a92b5..d656b7fdb6ed66aedfd5dab0863017ab16e9d717 100644 --- a/lib/internal/Magento/Framework/Event/etc/events.xsd +++ b/lib/internal/Magento/Framework/Event/etc/events.xsd @@ -60,11 +60,11 @@ <xs:simpleType name="eventName"> <xs:annotation> <xs:documentation> - Event name can contain only [a-zA-Z_]. + Event name can contain only [a-zA-Z0-9_]. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> - <xs:pattern value="[a-zA-Z_]+" /> + <xs:pattern value="[a-zA-Z0-9_]+" /> </xs:restriction> </xs:simpleType> </xs:schema> diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php index c94de1534b29e8f70a8723f2d000862266bc9878..b57755ed7eafa51bc3361aad0f5adf0b6584916d 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php @@ -496,9 +496,9 @@ abstract class AbstractCollection extends AbstractDb implements SourceProviderIn /** * Join table to collection select * - * @param string $table + * @param string|array $table * @param string $cond - * @param string $cols + * @param string|array $cols * @return $this */ public function join($table, $cond, $cols = '*')