diff --git a/.gitignore b/.gitignore index 1dc24183ad30092742a351bd094b4ae5573052be..12af626be05dba61c6b6f5a223a6b4a1ed2c6926 100644 --- a/.gitignore +++ b/.gitignore @@ -46,5 +46,5 @@ atlassian* /var/* !/var/.htaccess -/vendor +/vendor/* !/vendor/.htaccess diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php index 1a8e68b81e18caa48191f48d7933dcd624314311..ee8807700fe5416dbf707db6df2d5a81f667264d 100644 --- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php +++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php @@ -41,14 +41,14 @@ class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Abstrac { $readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' . __( 'Read Details' - ) . '</a>' : ''; + ) . '</a> | ' : ''; $markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl( '*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()] ) . '">' . __( 'Mark as Read' - ) . '</a>' : ''; + ) . '</a> | ' : ''; $encodedUrl = $this->_urlHelper->getEncodedUrl(); return sprintf( diff --git a/app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html b/app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html index 8c1e10d56fa2304077c030f1329bb009e2b1beaf..b88fd4ee09d42926349bb819187e113542105dfc 100644 --- a/app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html +++ b/app/code/Magento/Authorizenet/view/frontend/web/template/payment/authorizenet-directpost.html @@ -29,7 +29,7 @@ allowtransparency="true" frameborder="0" name="iframeTransparent" - style="display:none;width:100%;background-color:transparent"> + class="payment-method-iframe"> </iframe> <form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: { diff --git a/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml b/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml index 378e72e42d8ab582d5b97a9af035c9198b46a863..dfe18c014599d674067c3a84c7b16a9c36f08cea 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/system/search.phtml @@ -28,16 +28,16 @@ <script data-template="search-suggest" type="text/x-magento-template"> <ul class="search-global-menu"> <li class="item"> - <a href="<?php /* @escapeNotVerified */ echo $block->getURL('catalog/product/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Products</a> + <a id="searchPreviewProducts" href="<?php /* @escapeNotVerified */ echo $block->getURL('catalog/product/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Products</a> </li> <li class="item"> - <a href="<?php /* @escapeNotVerified */ echo $block->getURL('sales/order/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Orders</a> + <a id="searchPreviewOrders" href="<?php /* @escapeNotVerified */ echo $block->getURL('sales/order/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Orders</a> </li> <li class="item"> - <a href="<?php /* @escapeNotVerified */ echo $block->getURL('customer/index/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Customers</a> + <a id="searchPreviewCustomers" href="<?php /* @escapeNotVerified */ echo $block->getURL('customer/index/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Customers</a> </li> <li class="item"> - <a href="<?php /* @escapeNotVerified */ echo $block->getURL('cms/page/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Pages</a> + <a id="searchPreviewPages" href="<?php /* @escapeNotVerified */ echo $block->getURL('cms/page/index/'); ?>?search=<%- data.term%>" class="title">"<%- data.term%>" in Pages</a> </li> <% if (data.items.length) { %> <% _.each(data.items, function(value){ %> diff --git a/app/code/Magento/Backup/Helper/Data.php b/app/code/Magento/Backup/Helper/Data.php index 7448f7e520c135a31f1012f4e582a07b66aec294..4a35c12de46c2c8357bdd4d03182f74967faa9a1 100644 --- a/app/code/Magento/Backup/Helper/Data.php +++ b/app/code/Magento/Backup/Helper/Data.php @@ -122,7 +122,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper \Magento\Framework\Backup\Factory::TYPE_SYSTEM_SNAPSHOT => 'tgz', \Magento\Framework\Backup\Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => 'tgz', \Magento\Framework\Backup\Factory::TYPE_MEDIA => 'tgz', - \Magento\Framework\Backup\Factory::TYPE_DB => 'gz' + \Magento\Framework\Backup\Factory::TYPE_DB => 'sql' ]; } diff --git a/app/code/Magento/BraintreeTwo/Block/Paypal/Button.php b/app/code/Magento/BraintreeTwo/Block/Paypal/Button.php index b8876f4d1ee5d743d46efbb99b633676fac98ca3..2b5113fe586cf5170d33e260ded224b754274449 100644 --- a/app/code/Magento/BraintreeTwo/Block/Paypal/Button.php +++ b/app/code/Magento/BraintreeTwo/Block/Paypal/Button.php @@ -12,6 +12,7 @@ use Magento\Framework\Locale\ResolverInterface; use Magento\BraintreeTwo\Model\Ui\ConfigProvider; use Magento\Framework\View\Element\Template\Context; use Magento\BraintreeTwo\Gateway\Config\PayPal\Config; +use Magento\Payment\Model\MethodInterface; /** * Class Button @@ -42,6 +43,11 @@ class Button extends Template implements ShortcutInterface */ private $configProvider; + /** + * @var MethodInterface + */ + private $payment; + /** * Constructor * @@ -50,6 +56,7 @@ class Button extends Template implements ShortcutInterface * @param Session $checkoutSession * @param Config $config * @param ConfigProvider $configProvider + * @param MethodInterface $payment * @param array $data */ public function __construct( @@ -58,6 +65,7 @@ class Button extends Template implements ShortcutInterface Session $checkoutSession, Config $config, ConfigProvider $configProvider, + MethodInterface $payment, array $data = [] ) { parent::__construct($context, $data); @@ -66,6 +74,7 @@ class Button extends Template implements ShortcutInterface $this->checkoutSession = $checkoutSession; $this->config = $config; $this->configProvider = $configProvider; + $this->payment = $payment; } /** @@ -125,7 +134,8 @@ class Button extends Template implements ShortcutInterface */ public function isActive() { - return $this->config->isActive() && $this->config->isDisplayShoppingCart(); + return $this->payment->isAvailable($this->checkoutSession->getQuote()) && + $this->config->isDisplayShoppingCart(); } /** diff --git a/app/code/Magento/BraintreeTwo/etc/frontend/di.xml b/app/code/Magento/BraintreeTwo/etc/frontend/di.xml index d8ae2b9c3e14143d5cdc85876494208d25f7db48..599251dd98a713eb0efcdcd1b43def27d830773f 100644 --- a/app/code/Magento/BraintreeTwo/etc/frontend/di.xml +++ b/app/code/Magento/BraintreeTwo/etc/frontend/di.xml @@ -49,6 +49,7 @@ <item name="alias" xsi:type="string">braintree.paypal.mini-cart</item> <item name="button_id" xsi:type="string">braintree-paypal-mini-cart</item> </argument> + <argument name="payment" xsi:type="object">BraintreeTwoPayPalFacade</argument> </arguments> </type> </config> diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php index a4e8d7e3d77c61b1205dcc802f88b96f703c7caf..4477f7bc25f63c8e3db6003a692be7ba74f9a419 100644 --- a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php @@ -173,7 +173,7 @@ class LayoutProcessor implements \Magento\Checkout\Block\Checkout\LayoutProcesso 'telephone' => [ 'config' => [ 'tooltip' => [ - 'description' => 'For delivery questions.', + 'description' => __('For delivery questions.'), ], ], ], diff --git a/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml b/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml index 5c2157d83a930d48abe35f3d969ae25550bc3676..45db26ae45fa8ac4e80d1aa65f6a7e613739c0b0 100644 --- a/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml +++ b/app/code/Magento/Config/view/adminhtml/templates/system/config/edit.phtml @@ -29,6 +29,7 @@ require([ "jquery/jquery.hashchange", "mage/mage", "prototype", + "mage/adminhtml/form", "domReady!" ], function(jQuery, registry){ diff --git a/app/code/Magento/Developer/Console/Command/SourceThemeDeployCommand.php b/app/code/Magento/Developer/Console/Command/SourceThemeDeployCommand.php index 2993ca5b6126560d81cf4c85791923705c06a02f..3b8a0513b418aafcb0b636543dd840aa64f83936 100644 --- a/app/code/Magento/Developer/Console/Command/SourceThemeDeployCommand.php +++ b/app/code/Magento/Developer/Console/Command/SourceThemeDeployCommand.php @@ -87,47 +87,49 @@ class SourceThemeDeployCommand extends Command { parent::configure(); $this->setDescription('Collects and publishes source files for theme.') - ->setDefinition([ - new InputArgument( - self::FILE_ARGUMENT, - InputArgument::IS_ARRAY, - 'Files to pre-process (file should be specified without extension)', - ['css/styles-m', 'css/styles-l'] - ), - new InputOption( - self::TYPE_ARGUMENT, - null, - InputOption::VALUE_REQUIRED, - 'Type of source files: [less]', - 'less' - ), - new InputOption( - self::LOCALE_OPTION, - null, - InputOption::VALUE_REQUIRED, - 'Locale: [en_US]', - 'en_US' - ), - new InputOption( - self::AREA_OPTION, - null, - InputOption::VALUE_REQUIRED, - 'Area: [frontend|adminhtml]', - 'frontend' - ), - new InputOption( - self::THEME_OPTION, - null, - InputOption::VALUE_REQUIRED, - 'Theme: [Vendor/theme]', - 'Magento/luma' - ), - - ]); + ->setDefinition( + [ + new InputArgument( + self::FILE_ARGUMENT, + InputArgument::IS_ARRAY, + 'Files to pre-process (file should be specified without extension)', + ['css/styles-m', 'css/styles-l'] + ), + new InputOption( + self::TYPE_ARGUMENT, + null, + InputOption::VALUE_REQUIRED, + 'Type of source files: [less]', + 'less' + ), + new InputOption( + self::LOCALE_OPTION, + null, + InputOption::VALUE_REQUIRED, + 'Locale: [en_US]', + 'en_US' + ), + new InputOption( + self::AREA_OPTION, + null, + InputOption::VALUE_REQUIRED, + 'Area: [frontend|adminhtml]', + 'frontend' + ), + new InputOption( + self::THEME_OPTION, + null, + InputOption::VALUE_REQUIRED, + 'Theme: [Vendor/theme]', + 'Magento/luma' + ), + + ] + ); } /** - * @inheritdoc + * {@inheritdoc} * @throws \InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) @@ -144,6 +146,14 @@ class SourceThemeDeployCommand extends Command $locale . ' argument has invalid value, please run info:language:list for list of available locales' ); } + + if (!preg_match('#^[\w\-]+\/[\w\-]+$#', $theme)) { + throw new \InvalidArgumentException( + 'Value "' . $theme . '" of the option "' . self::THEME_OPTION . + '" has invalid format. The format should be "Vendor/theme".' + ); + } + $message = sprintf( '<info>Processed Area: %s, Locale: %s, Theme: %s, File type: %s.</info>', $area, @@ -164,7 +174,14 @@ class SourceThemeDeployCommand extends Command ] ); - $this->assetPublisher->publish($asset); + try { + $this->assetPublisher->publish($asset); + } catch (\Magento\Framework\View\Asset\File\NotFoundException $e) { + throw new \InvalidArgumentException( + 'Verify entered values of the argument and options. ' . $e->getMessage() + ); + } + $output->writeln('<comment>-> ' . $asset->getFilePath() . '</comment>'); } diff --git a/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php b/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php index cc66a9830f20e6eba578de4eb49b416673e5d115..3a233c8c6308fe77c6a9272694bdf82251ccdf4d 100644 --- a/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php +++ b/app/code/Magento/Developer/Test/Unit/Console/Command/SourceThemeDeployCommandTest.php @@ -24,7 +24,11 @@ class SourceThemeDeployCommandTest extends \PHPUnit_Framework_TestCase const LOCALE_TEST_VALUE = 'locale-test-value'; - const THEME_TEST_VALUE = 'theme-test-value'; + const THEME_TEST_VALUE = 'Vendor/theme'; + + const THEME_INCORRECT_FORMAT_VALUE = 'theme-value'; + + const THEME_NONEXISTING_VALUE = 'NonExistentVendor/theme'; const TYPE_TEST_VALUE = 'type-test-value'; @@ -128,23 +132,103 @@ class SourceThemeDeployCommandTest extends \PHPUnit_Framework_TestCase $this->sourceThemeDeployCommand->run($this->getInputMock(), $outputMock); } + /** + * Run test for execute method with incorrect theme value + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Value "theme-value" of the option "theme" has invalid format. The format should be + */ + public function testExecuteIncorrectThemeFormat() + { + /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */ + $outputMock = $this->getMockBuilder(OutputInterface::class) + ->getMockForAbstractClass(); + $this->validatorMock->expects(self::once()) + ->method('isValid') + ->with(self::LOCALE_TEST_VALUE) + ->willReturn(true); + + $valueMap = [ + ['area', self::AREA_TEST_VALUE], + ['locale', self::LOCALE_TEST_VALUE], + ['theme', self::THEME_INCORRECT_FORMAT_VALUE], + ['type', self::TYPE_TEST_VALUE] + ]; + + $this->sourceThemeDeployCommand->run( + $this->getInputMock($valueMap), + $outputMock + ); + } + + /** + * Run test for execute method with non existing theme + * + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Verify entered values of the argument and options. + */ + public function testExecuteNonExistingValue() + { + /** @var OutputInterface|\PHPUnit_Framework_MockObject_MockObject $outputMock */ + $outputMock = $this->getMockBuilder(OutputInterface::class) + ->getMockForAbstractClass(); + $assetMock = $this->getMockBuilder(LocalInterface::class) + ->getMockForAbstractClass(); + + $this->validatorMock->expects(self::once()) + ->method('isValid') + ->with(self::LOCALE_TEST_VALUE) + ->willReturn(true); + + $this->assetRepositoryMock->expects(self::once()) + ->method('createAsset') + ->with( + 'file-test-value/test' . DIRECTORY_SEPARATOR . 'file' . '.' . self::TYPE_TEST_VALUE, + [ + 'area' => self::AREA_TEST_VALUE, + 'theme' => self::THEME_NONEXISTING_VALUE, + 'locale' => self::LOCALE_TEST_VALUE, + ] + )->willReturn($assetMock); + + $this->assetPublisherMock->expects(self::once()) + ->method('publish') + ->with($assetMock) + ->willThrowException(new \Magento\Framework\View\Asset\File\NotFoundException); + + $valueMap = [ + ['area', self::AREA_TEST_VALUE], + ['locale', self::LOCALE_TEST_VALUE], + ['theme', self::THEME_NONEXISTING_VALUE], + ['type', self::TYPE_TEST_VALUE] + ]; + + $this->sourceThemeDeployCommand->run( + $this->getInputMock($valueMap), + $outputMock + ); + } + /** * @return InputInterface|\PHPUnit_Framework_MockObject_MockObject */ - private function getInputMock() + private function getInputMock(array $valueMap = []) { $inputMock = $this->getMockBuilder(InputInterface::class) ->getMockForAbstractClass(); + $defaultValueMap = [ + ['area', self::AREA_TEST_VALUE], + ['locale', self::LOCALE_TEST_VALUE], + ['theme', self::THEME_TEST_VALUE], + ['type', self::TYPE_TEST_VALUE] + ]; + $valueMap = empty($valueMap) ? $defaultValueMap : $valueMap; + $inputMock->expects(self::exactly(4)) ->method('getOption') ->willReturnMap( - [ - ['area', self::AREA_TEST_VALUE], - ['locale', self::LOCALE_TEST_VALUE], - ['theme', self::THEME_TEST_VALUE], - ['type', self::TYPE_TEST_VALUE] - ] + $valueMap ); $inputMock->expects(self::once()) ->method('getArgument') diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 2920d0e847d9659fc6cce8145740a1cadf3b8b54..635df511e0eb525dbad1ab322877fac71335244b 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -192,6 +192,13 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin */ protected $_httpClientFactory; + /** + * @inheritdoc + */ + protected $_debugReplacePrivateDataKeys = [ + 'SiteID', 'Password' + ]; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -904,17 +911,15 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin { $responseBody = ''; try { - $debugData = []; for ($offset = 0; $offset <= self::UNAVAILABLE_DATE_LOOK_FORWARD; $offset++) { - $debugData['try-' . $offset] = []; - $debugPoint = &$debugData['try-' . $offset]; + $debugPoint = []; $requestXml = $this->_buildQuotesRequestXml(); $date = date(self::REQUEST_DATE_FORMAT, strtotime($this->_getShipDate() . " +{$offset} days")); $this->_setQuotesRequestXmlDate($requestXml, $date); $request = $requestXml->asXML(); - $debugPoint['request'] = $request; + $debugPoint['request'] = $this->filterDebugData($request); $responseBody = $this->_getCachedQuotes($request); $debugPoint['from_cache'] = $responseBody === null; @@ -922,19 +927,20 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin $responseBody = $this->_getQuotesFromServer($request); } - $debugPoint['response'] = $responseBody; + $debugPoint['response'] = $this->filterDebugData($responseBody); $bodyXml = $this->_xmlElFactory->create(['data' => $responseBody]); $code = $bodyXml->xpath('//GetQuoteResponse/Note/Condition/ConditionCode'); if (isset($code[0]) && (int)$code[0] == self::CONDITION_CODE_SERVICE_DATE_UNAVAILABLE) { $debugPoint['info'] = sprintf(__("DHL service is not available at %s date"), $date); } else { + $this->_debug($debugPoint); break; } $this->_setCachedQuotes($request, $responseBody); + $this->_debug($debugPoint); } - $this->_debug($debugData); } catch (\Exception $e) { $this->_errors[$e->getCode()] = $e->getMessage(); } @@ -1308,7 +1314,6 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin return $this; } - /** * Return container types of carrier * diff --git a/app/code/Magento/Directory/Model/Currency/Import/Webservicex.php b/app/code/Magento/Directory/Model/Currency/Import/Webservicex.php index 2a5a84d5e0d27acad7b204ef3d79c38dd9ba4e80..cca944fad69bd681a4b0a96d4a65aa60e9fb8a8a 100644 --- a/app/code/Magento/Directory/Model/Currency/Import/Webservicex.php +++ b/app/code/Magento/Directory/Model/Currency/Import/Webservicex.php @@ -12,10 +12,11 @@ namespace Magento\Directory\Model\Currency\Import; class Webservicex extends \Magento\Directory\Model\Currency\Import\AbstractImport { /** - * @var string + * Currency converter url */ - const CURRENCY_CONVERTER_URL = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?' . - 'FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}'; + // @codingStandardsIgnoreStart + const CURRENCY_CONVERTER_URL = 'http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency={{CURRENCY_FROM}}&ToCurrency={{CURRENCY_TO}}'; + // @codingStandardsIgnoreEnd /** * Http Client Factory diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php index 7d285c36ee96d7db237c89966882b1135cbd219a..59ec3324eba850328435005ad3a7251619068067 100644 --- a/app/code/Magento/Email/Model/Template/Filter.php +++ b/app/code/Magento/Email/Model/Template/Filter.php @@ -893,6 +893,8 @@ class Filter extends \Magento\Framework\Filter\Template } } catch (ContentProcessorException $exception) { $css = $exception->getMessage(); + } catch (\Magento\Framework\View\Asset\File\NotFoundException $exception) { + $css = ''; } return $css; diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 90275b764741db6a9c67f22ccdf63fd3bac2cdea..b23e2a0d8a177f62df8a45024bec7e8c289e57e1 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -119,6 +119,13 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C */ protected $_productCollectionFactory; + /** + * @inheritdoc + */ + protected $_debugReplacePrivateDataKeys = [ + 'Key', 'Password', 'MeterNumber' + ]; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -454,7 +461,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C $ratesRequest = $this->_formRateRequest($purpose); $requestString = serialize($ratesRequest); $response = $this->_getCachedQuotes($requestString); - $debugData = ['request' => $ratesRequest]; + $debugData = ['request' => $this->filterDebugData($ratesRequest)]; if ($response === null) { try { $client = $this->_createRateSoapClient(); @@ -1560,4 +1567,21 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C { return $this->getCode('delivery_confirmation_types'); } + + /** + * Recursive replace sensitive fields in debug data by the mask + * @param string $data + * @return string + */ + protected function filterDebugData($data) + { + foreach (array_keys($data) as $key) { + if (is_array($data[$key])) { + $data[$key] = $this->filterDebugData($data[$key]); + } elseif (in_array($key, $this->_debugReplacePrivateDataKeys)) { + $data[$key] = self::DEBUG_KEYS_MASK; + } + } + return $data; + } } diff --git a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php index 811abf4a83879ac6dd7c5c539517d869a723b2e2..aff6ade34ddff06ac65b8afa505cd6af6672faac 100644 --- a/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php @@ -5,9 +5,10 @@ */ namespace Magento\Fedex\Test\Unit\Model; -use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Fedex\Model\Carrier; use Magento\Framework\DataObject; use Magento\Framework\Xml\Security; +use Magento\Quote\Model\Quote\Address\RateRequest; /** * Class CarrierTest @@ -212,4 +213,59 @@ class CarrierTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->error, $this->_model->collectRates($request)); } + + /** + * @param string $data + * @param array $maskFields + * @param string $expected + * @dataProvider logDataProvider + */ + public function testFilterDebugData($data, array $maskFields, $expected) + { + $refClass = new \ReflectionClass(Carrier::class); + $property = $refClass->getProperty('_debugReplacePrivateDataKeys'); + $property->setAccessible(true); + $property->setValue($this->_model, $maskFields); + + $refMethod = $refClass->getMethod('filterDebugData'); + $refMethod->setAccessible(true); + $result = $refMethod->invoke($this->_model, $data); + static::assertEquals($expected, $result); + } + + /** + * Get list of variations + */ + public function logDataProvider() + { + return [ + [ + [ + 'WebAuthenticationDetail' => [ + 'UserCredential' => [ + 'Key' => 'testKey', + 'Password' => 'testPassword' + ] + ], + 'ClientDetail' => [ + 'AccountNumber' => 4121213, + 'MeterNumber' => 'testMeterNumber' + ] + ], + ['Key', 'Password', 'MeterNumber'], + [ + 'WebAuthenticationDetail' => [ + 'UserCredential' => [ + 'Key' => '****', + 'Password' => '****' + ] + ], + 'ClientDetail' => [ + 'AccountNumber' => 4121213, + 'MeterNumber' => '****' + ] + ], + ], + ]; + } } diff --git a/app/code/Magento/MediaStorage/Model/File/Storage/Database.php b/app/code/Magento/MediaStorage/Model/File/Storage/Database.php index a2fa8f11bd4f0810d31999a5634a3a24012cdb05..aeff2c2b266058d8f31f921e1a943b2b152865c7 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage/Database.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage/Database.php @@ -41,6 +41,13 @@ class Database extends \Magento\MediaStorage\Model\File\Storage\Database\Abstrac */ protected $_mediaHelper; + /** + * Store media base directory path + * + * @var string + */ + protected $mediaBaseDirectory = null; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -352,4 +359,17 @@ class Database extends \Magento\MediaStorage\Model\File\Storage\Database\Abstrac return $this; } + + /** + * Retrieve media base directory path + * + * @return string + */ + public function getMediaBaseDirectory() + { + if ($this->mediaBaseDirectory === null) { + $this->mediaBaseDirectory = $this->_coreFileStorageDb->getMediaBaseDir(); + } + return $this->mediaBaseDirectory; + } } diff --git a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php index d8e0a912c72cecc9575d6ced2b89075fab36250d..4dbf514ea1341355702d93fdbc5bbf67b2ed9621 100644 --- a/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php +++ b/app/code/Magento/Paypal/Block/Express/InContext/Minicart/Button.php @@ -5,6 +5,8 @@ */ namespace Magento\Paypal\Block\Express\InContext\Minicart; +use Magento\Checkout\Model\Session; +use Magento\Payment\Model\MethodInterface; use Magento\Paypal\Model\Config; use Magento\Paypal\Model\ConfigFactory; use Magento\Paypal\Block\Express\InContext; @@ -41,18 +43,31 @@ class Button extends Template implements ShortcutInterface */ private $config; + /** + * @var MethodInterface + */ + private $payment; + + /** + * @var Session + */ + private $session; + /** * Constructor - * * @param Context $context * @param ResolverInterface $localeResolver * @param ConfigFactory $configFactory + * @param MethodInterface $payment + * @param Session $session * @param array $data */ public function __construct( Context $context, ResolverInterface $localeResolver, ConfigFactory $configFactory, + Session $session, + MethodInterface $payment, array $data = [] ) { parent::__construct($context, $data); @@ -60,6 +75,8 @@ class Button extends Template implements ShortcutInterface $this->localeResolver = $localeResolver; $this->config = $configFactory->create(); $this->config->setMethod(Config::METHOD_EXPRESS); + $this->payment = $payment; + $this->session = $session; } /** @@ -75,7 +92,9 @@ class Button extends Template implements ShortcutInterface */ protected function shouldRender() { - return $this->isMiniCart && $this->isInContext(); + return $this->payment->isAvailable($this->session->getQuote()) + && $this->isMiniCart + && $this->isInContext(); } /** diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml index c1e69c55a070e5ebad5c538ae0b2dc7ad3dd7fbd..9aa45888f7d5a2ad456da57dbce32ac894949ca6 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml @@ -32,8 +32,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="paypal_payflowpro_au">paypal_payflowpro_au</argument> <argument name="payments_pro_hosted_solution_au">payments_pro_hosted_solution_au</argument> @@ -62,8 +62,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="payments_pro_hosted_solution_au">payments_pro_hosted_solution_au</argument> @@ -91,8 +91,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="paypal_payflowpro_au">paypal_payflowpro_au</argument> @@ -120,15 +120,14 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_ca.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_ca.xml index d238ce296c1a072d5316fed0c6f8d7267e3b62f6..00d8a67cf766146652d637c55988fb6bc75cfdaf 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_ca.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_ca.xml @@ -36,8 +36,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wpp_ca">wpp_ca</argument> <argument name="paypal_payflowpro_ca">paypal_payflowpro_ca</argument> @@ -71,8 +71,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="paypal_payflowpro_ca">paypal_payflowpro_ca</argument> @@ -105,8 +105,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="wpp_ca">wpp_ca</argument> @@ -139,22 +139,22 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target="express_checkout_other"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/disable" event="activate-rule"/> - <rule type="paypal/express/lock-configuration" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressDisable" event="activate-rule"/> + <rule type="paypalExpressLockConfiguration" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="payflow_link_ca">payflow_link_ca</argument> </rule> - <rule type="paypal/express/unlock-configuration" event="deactivate-rule"> + <rule type="paypalExpressUnlockConfiguration" event="deactivate-rule"> <argument name="payflow_link_ca">payflow_link_ca</argument> </rule> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="payflow/express/enable" event="activate-rule"/> - <rule type="payflow/express/disable" event="deactivate-rule"/> - <rule type="payflow/express/lock-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="payflowExpressEnable" event="activate-rule"/> + <rule type="payflowExpressDisable" event="deactivate-rule"/> + <rule type="payflowExpressLockConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="wpp_ca">wpp_ca</argument> @@ -184,23 +184,23 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> <argument name="payflow_link_ca">payflow_link_ca</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> <argument name="payflow_link_ca">payflow_link_ca</argument> </rule> - <rule type="paypal/express/lock-configuration-conditional" event=":load"> + <rule type="paypalExpressLockConfigurationConditional" event=":load"> <argument name="payflow_link_ca">payflow_link_ca</argument> </rule> </relation> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_de.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_de.xml index abb1bedfdb1db1b6dcaadf1d82b9208d3f109405..21e06ec25d688ca300ddf8d892624e06420add50 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_de.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_de.xml @@ -17,15 +17,15 @@ <event value="1" name="activate-in-context-api"/> </events> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> </relation> </payment> </rules> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_es.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_es.xml index a6a6faaeaecf8a2c3094d95996fbaf823c1a50f3..1b8f5d67c3168851027541613763a5ef5b3bc060 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_es.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_es.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_es">payments_pro_hosted_solution_es</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_fr.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_fr.xml index 61793ed7ab5c29e45092a97f269def51d69c9fe5..f312a5e020232f68faed2a2ec3db1409d72afc62 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_fr.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_fr.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_fr">payments_pro_hosted_solution_fr</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_gb.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_gb.xml index 2532cc8391d18a0180cdade7718463601e021239..4137153977b82345c2e6468e9acd90608a665b9a 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_gb.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_gb.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_express">wps_express</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_with_express_checkout">payments_pro_hosted_solution_with_express_checkout</argument> <argument name="express_checkout_us">express_checkout_us</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_express">wps_express</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_express">wps_express</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_hk.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_hk.xml index 6884048d05cca968f15200a36daed48604bdf7a6..d45184783555ce770eaf66c905d3d61c8eef88ed 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_hk.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_hk.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_hk">payments_pro_hosted_solution_hk</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_it.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_it.xml index adc2a8d193542d9ee7e95fdac183f44324081f61..6aa5a015768763636597c7d3738a32c1ac3b8592 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_it.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_it.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_it">payments_pro_hosted_solution_it</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_jp.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_jp.xml index 2ff60e1dd05523c39807b9160abb1193726837ce..1267239d3e4f811e8e39855f926f2c10aebfbc85 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_jp.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_jp.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="payments_pro_hosted_solution_jp">payments_pro_hosted_solution_jp</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_nz.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_nz.xml index a63e67dc2551b9d27714c63dd836704e0fdd7ea5..f44bfe8492200d1dc62ecdc7de0063ce554f0ba8 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_nz.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_nz.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> @@ -52,8 +52,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="paypal_payflowpro_nz">paypal_payflowpro_nz</argument> <argument name="express_checkout_other">express_checkout_other</argument> @@ -81,17 +81,17 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wps_other">wps_other</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_other.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_other.xml index 44bbce7c4b0b46f834af97644211050666af8b50..1aaee2dbdd04ddc26798ee0879f67c53b24bdd07 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_other.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_other.xml @@ -24,8 +24,8 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> <rule type="conflict" event=":load"> <argument name="express_checkout_other">express_checkout_other</argument> </rule> @@ -52,15 +52,15 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wps_other">wps_other</argument> </rule> diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_us.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_us.xml index 4fb978f4a5d202f76491007e589b2be955d40559..c3f684adb98ec3f69f76ba107cad178d0f9e3529 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_us.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_us.xml @@ -38,35 +38,43 @@ </relation> <relation target="payflow_link_us"> <rule type="disable" event="activate-rule"/> - <rule type="payflow/express/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/bml/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/bml/enable-conditional" event="activate-bml"> + <rule type="payflowExpressDisableConditional" event="deactivate-rule"> + <argument name="wpp_usuk">wpp_usuk</argument> + <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowBmlDisableConditional" event="deactivate-rule"> + <argument name="wpp_usuk">wpp_usuk</argument> + <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowBmlEnableConditional" event="activate-bml"> <argument name="payflow_advanced">payflow_advanced</argument> </rule> - <rule type="payflow/bml/disable-conditional" event="deactivate-bml"/> + <rule type="payflowBmlDisableConditional" event="deactivate-bml"/> </relation> <relation target="express_checkout_us"> - <rule type="paypal/express/disable" event="activate-rule"/> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/lock-configuration" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="paypalExpressDisable" event="activate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressLockConfiguration" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> - <rule type="paypal/express/unlock-configuration" event="deactivate-rule"> + <rule type="paypalExpressUnlockConfiguration" event="deactivate-rule"> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="payflow/bml/enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="payflow/bml/disable" event="deactivate-rule"/> - <rule type="payflow/express/disable-conditional" event=":load"/> - <rule type="payflow/bml/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="payflowBmlEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="payflowBmlDisable" event="deactivate-rule"/> + <rule type="payflowExpressDisableConditional" event=":load"/> + <rule type="payflowBmlDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="wps_express">wps_express</argument> @@ -111,37 +119,45 @@ </relation> <relation target="payflow_link_us"> <rule type="disable" event="activate-rule"/> - <rule type="payflow/express/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/express/usedefault-disable" event="usedefault-off"/> - <rule type="payflow/express/usedefault-enable" event="usedefault-on"/> - <rule type="payflow/bml/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/bml/enable-conditional" event="activate-bml"> + <rule type="payflowExpressDisableConditional" event="deactivate-rule"> + <argument name="payflow_advanced">payflow_advanced</argument> + <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowExpressUsedefaultDisable" event="usedefault-off"/> + <rule type="payflowExpressUsedefaultEnable" event="usedefault-on"/> + <rule type="payflowBmlDisableConditional" event="deactivate-rule"> + <argument name="payflow_advanced">payflow_advanced</argument> + <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowBmlEnableConditional" event="activate-bml"> <argument name="wpp_usuk">wpp_usuk</argument> </rule> - <rule type="payflow/bml/disable-conditional" event="deactivate-bml"/> + <rule type="payflowBmlDisableConditional" event="deactivate-bml"/> </relation> <relation target="express_checkout_us"> - <rule type="paypal/express/disable" event="activate-rule"/> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/lock-configuration" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="paypalExpressDisable" event="activate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressLockConfiguration" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> - <rule type="paypal/express/unlock-configuration" event="deactivate-rule"> + <rule type="paypalExpressUnlockConfiguration" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="payflow/bml/enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="payflow/bml/disable" event="deactivate-rule"/> - <rule type="payflow/express/disable-conditional" event=":load"/> - <rule type="payflow/bml/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="payflowBmlEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="payflowBmlDisable" event="deactivate-rule"/> + <rule type="payflowExpressDisableConditional" event=":load"/> + <rule type="payflowBmlDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wps_express">wps_express</argument> @@ -184,11 +200,11 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/bml/enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="paypal/bml/disable" event="deactivate-rule"/> - <rule type="paypal/bml/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalBmlEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="paypalBmlDisable" event="deactivate-rule"/> + <rule type="paypalBmlDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> @@ -229,35 +245,43 @@ </relation> <relation target="payflow_link_us"> <rule type="disable" event="activate-rule"/> - <rule type="payflow/express/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/bml/disable-conditional" event="deactivate-rule"/> - <rule type="payflow/bml/enable-conditional" event="activate-bml"> + <rule type="payflowExpressDisableConditional" event="deactivate-rule"> + <argument name="payflow_advanced">payflow_advanced</argument> + <argument name="wpp_usuk">wpp_usuk</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowBmlDisableConditional" event="deactivate-rule"> + <argument name="payflow_advanced">payflow_advanced</argument> + <argument name="wpp_usuk">wpp_usuk</argument> + <argument name="payflow_link_us">payflow_link_us</argument> + </rule> + <rule type="payflowBmlEnableConditional" event="activate-bml"> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> </rule> - <rule type="payflow/bml/disable-conditional" event="deactivate-bml"/> + <rule type="payflowBmlDisableConditional" event="deactivate-bml"/> </relation> <relation target="express_checkout_us"> - <rule type="paypal/express/disable" event="activate-rule"/> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/lock-configuration" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="paypalExpressDisable" event="activate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressLockConfiguration" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> - <rule type="paypal/express/unlock-configuration" event="deactivate-rule"> + <rule type="paypalExpressUnlockConfiguration" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="payflow/bml/enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="payflow/bml/disable" event="deactivate-rule"/> - <rule type="payflow/express/disable-conditional" event=":load"/> - <rule type="payflow/bml/disable-conditional" event=":load"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="payflowBmlEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="payflowBmlDisable" event="deactivate-rule"/> + <rule type="payflowExpressDisableConditional" event=":load"/> + <rule type="payflowBmlDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> @@ -300,40 +324,40 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target="express_checkout_us"> - <rule type="paypal/express/disable" event="activate-rule"/> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/express/lock-configuration" event="activate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="paypalExpressDisable" event="activate-rule"/> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalExpressLockConfiguration" event="activate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> </rule> - <rule type="paypal/express/unlock-configuration" event="deactivate-rule"> + <rule type="paypalExpressUnlockConfiguration" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> </rule> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="payflow/express/enable" event="activate-rule"/> - <rule type="payflow/bml/enable" event="activate-rule"/> - <rule type="simple/disable" event="deactivate-rule"/> - <rule type="payflow/express/enable-conditional" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="payflowExpressEnable" event="activate-rule"/> + <rule type="payflowBmlEnable" event="activate-rule"/> + <rule type="simpleDisable" event="deactivate-rule"/> + <rule type="payflowExpressEnableConditional" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> </rule> - <rule type="payflow/bml/enable-conditional" event="deactivate-rule"> + <rule type="payflowBmlEnableConditional" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> </rule> - <rule type="payflow/bml/disable-conditional-express" event="deactivate-express"/> - <rule type="payflow/bml/disable-conditional-express" event=":load"/> - <rule type="payflow/bml/enable" event="activate-express"/> - <rule type="payflow/express/lock-conditional" event=":load"/> - <rule type="payflow/bml/lock-conditional" event=":load"/> + <rule type="payflowBmlDisableConditionalExpress" event="deactivate-express"/> + <rule type="payflowBmlDisableConditionalExpress" event=":load"/> + <rule type="payflowBmlEnable" event="activate-express"/> + <rule type="payflowExpressLockConditional" event=":load"/> + <rule type="payflowBmlLockConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> @@ -364,24 +388,24 @@ <rule type="disable" event="activate-rule"/> </relation> <relation target=":self"> - <rule type="simple/mark-enable" event="activate-rule"/> - <rule type="paypal/bml/enable" event="activate-rule"/> - <rule type="paypal/bml/disable" event="deactivate-rule"/> - <rule type="paypal/express/mark-disable" event="deactivate-rule"> + <rule type="simpleMarkEnable" event="activate-rule"/> + <rule type="paypalBmlEnable" event="activate-rule"/> + <rule type="paypalBmlDisable" event="deactivate-rule"/> + <rule type="paypalExpressMarkDisable" event="deactivate-rule"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="wps_express">wps_express</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> - <rule type="paypal/in-context/enable" event="activate-rule"/> - <rule type="paypal/in-context/disable" event="deactivate-rule"/> - <rule type="paypal/in-context/show-merchant-id" event="activate-rule"/> - <rule type="paypal/in-context/hide-merchant-id" event="deactivate-rule"/> - <rule type="paypal/in-context/activate" event="activate-in-context-api"/> - <rule type="paypal/in-context/deactivate" event="deactivate-in-context-api"/> - <rule type="paypal/in-context/disable-conditional" event=":load"/> - <rule type="paypal/bml/disable-conditional" event=":load"/> + <rule type="inContextEnable" event="activate-rule"/> + <rule type="inContextDisable" event="deactivate-rule"/> + <rule type="inContextShowMerchantId" event="activate-rule"/> + <rule type="inContextHideMerchantId" event="deactivate-rule"/> + <rule type="inContextActivate" event="activate-in-context-api"/> + <rule type="inContextDeactivate" event="deactivate-in-context-api"/> + <rule type="inContextDisableConditional" event=":load"/> + <rule type="paypalBmlDisableConditional" event=":load"/> <rule type="conflict" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> @@ -389,7 +413,7 @@ <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> <argument name="payflow_link_us">payflow_link_us</argument> </rule> - <rule type="paypal/express/lock-configuration-conditional" event=":load"> + <rule type="paypalExpressLockConfigurationConditional" event=":load"> <argument name="payflow_advanced">payflow_advanced</argument> <argument name="wpp_usuk">wpp_usuk</argument> <argument name="paypal_payflowpro_with_express_checkout">paypal_payflowpro_with_express_checkout</argument> diff --git a/app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml b/app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml index 9309c49436eafe450773ee367ff3b41aba826c12..8a0a2ced72957b646c4c5b9ac868198eaed0b05f 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/system/express_checkout.xml @@ -151,6 +151,7 @@ <depends> <field id="enable_in_context_checkout">1</field> </depends> + <validate>required-entry</validate> </field> <field id="enable_express_checkout_bml" translate="label comment" type="select" sortOrder="23" showInDefault="1" showInWebsite="1"> <label>Enable PayPal Credit</label> diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index ea54af994ca87ba50845f1b9757dec6dd19e9851..6617801489373cee709f988c0605644ab3ac96e2 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -93,6 +93,7 @@ <item name="alias" xsi:type="string">paypal.express-in-context.mini-cart</item> <item name="button_id" xsi:type="string">paypal-express-in-context-mini-cart</item> </argument> + <argument name="payment" xsi:type="object">Magento\Paypal\Model\Express</argument> </arguments> </type> diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js index c1c12344cc54c15ededbd2bb0b80184b09be19fd..11a54a2db30e748e399f91ab979433d0c291fa56 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js @@ -3,8 +3,9 @@ * See COPYING.txt for license details. */ define([ - 'uiClass' -], function (Class) { + 'uiClass', + 'Magento_Paypal/js/rules' +], function (Class, Rules) { 'use strict'; return Class.extend({ @@ -16,6 +17,7 @@ define([ * @returns {exports.initialize} */ initialize: function (config) { + this.rules = new Rules(); this.initConfig(config); return this; @@ -25,11 +27,7 @@ define([ * To apply the rule */ apply: function () { - require([ - 'Magento_Paypal/js/rules/' + this.name - ], function (applicableRule) { - applicableRule(this.$target, this.$owner, this.data); - }.bind(this)); + this.rules[this.name](this.$target, this.$owner, this.data); } }); }); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules.js new file mode 100644 index 0000000000000000000000000000000000000000..b986b340f4fa577eff0299409f81e1c780a5ab51 --- /dev/null +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rules.js @@ -0,0 +1,513 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'underscore', + 'uiClass', + 'Magento_Ui/js/modal/alert' +], function (_, Class, alert) { + 'use strict'; + + return Class.extend({ + defaults: { + + /** + * Payment conflicts checker + */ + executed: false + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + simpleDisable: function ($target, $owner, data) { + $target.find(data.enableButton + ' option[value="0"]').prop('selected', true); + $target.find('label.enabled').removeClass('enabled'); + $target.find('.section-config').removeClass('enabled'); + }, + + /** + * @param {*} $target + */ + simpleMarkEnable: function ($target) { + $target.find('.section-config').addClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + disable: function ($target, $owner, data) { + this.simpleDisable($target, $owner, data); + $target.find(data.enableButton).change(); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + conflict: function ($target, $owner, data) { + var isDisabled = true, + newLine = String.fromCharCode(10, 13); + + if ($owner.find(data.enableButton).val() === '1') { + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (!isDisabled && !this.executed) { + this.executed = true; + alert({ + content: 'The following error(s) occurred:' + + newLine + + 'Some PayPal solutions conflict.' + + newLine + + 'Please re-enable the previously enabled payment solutions.' + }); + } + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalExpressDisable: function ($target, $owner, data) { + $target.find(data.enableButton + ' option[value="0"]').prop('selected', true); + $target.find('label.enabled').removeClass('enabled'); + $target.find(data.enableButton).change(); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalExpressLockConfiguration: function ($target, $owner, data) { + $target.find(data.buttonConfiguration).addClass('disabled') + .attr('disabled', 'disabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalExpressLockConfigurationConditional: function ($target, $owner, data) { + var isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (!isDisabled && + $target.find(data.enableInContextPayPal).val() === '0') { + this.paypalExpressLockConfiguration($target, $owner, data); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalExpressMarkDisable: function ($target, $owner, data) { + var isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (isDisabled) { + this.simpleDisable($target, $owner, data); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalExpressUnlockConfiguration: function ($target, $owner, data) { + var isUnlock = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isUnlock = false; + + return isUnlock; + } + + return isUnlock; + }, this); + + if (isUnlock) { + $target.find(data.buttonConfiguration).removeClass('disabled') + .removeAttr('disabled'); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalBmlDisable: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableBmlPayPal).attr('id') + '"]').removeClass('enabled'); + $target.find(data.enableBmlPayPal + ' option[value="0"]').prop('selected', true); + $target.find(data.enableBmlPayPal).prop('disabled', true); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalBmlDisableConditional: function ($target, $owner, data) { + if ($target.find(data.enableButton).val() === '0') { + this.paypalBmlDisable($target, $owner, data); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + paypalBmlEnable: function ($target, $owner, data) { + $target.find(data.enableBmlPayPal).prop('disabled', false); + $target.find(data.enableBmlPayPal + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableBmlPayPal).attr('id') + '"]').addClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressDisable: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled'); + $target.find(data.enableExpress + ' option[value="0"]').prop('selected', true); + $target.find(data.enableExpress).prop('disabled', true); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressDisableConditional: function ($target, $owner, data) { + var isDisabled; + + if (data.argument) { + isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (isDisabled) { + this.payflowExpressDisable($target, $owner, data); + } + } else if ($target.find(data.enableButton).val() === '0') { + this.payflowExpressDisable($target, $owner, data); + $target.find(data.enableExpress).change(); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressEnable: function ($target, $owner, data) { + $target.find(data.enableExpress).prop('disabled', false); + $target.find(data.enableExpress + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').addClass('enabled'); + $target.find(data.enableExpress).change(); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressEnableConditional: function ($target, $owner, data) { + var isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (!isDisabled) { + $target.find(data.enableExpress).prop('disabled', true); + $target.find(data.enableExpress + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').addClass('enabled'); + } else { + $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled'); + $target.find(data.enableExpress + ' option[value="0"]').prop('selected', true); + $target.find(data.enableExpress).prop('disabled', true); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressLockConditional: function ($target, $owner, data) { + if ($target.find(data.enableButton).val() === '0') { + $target.find(data.enableExpress).prop('disabled', true); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressUsedefaultDisable: function ($target, $owner, data) { + $target.find('input[id="' + $target.find(data.enableExpress).attr('id') + '_inherit"]') + .prop('checked', false); + this.payflowExpressEnable($target, $owner, data); + $target.find(data.enableExpress).change(); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowExpressUsedefaultEnable: function ($target, $owner, data) { + $target.find('input[id="' + $target.find(data.enableExpress).attr('id') + '_inherit"]') + .prop('checked', true); + this.payflowExpressDisable($target, $owner, data); + $target.find(data.enableExpress).change(); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlDisable: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled'); + $target.find(data.enableBml + ' option[value="0"]').prop('selected', true); + $target.find(data.enableBml).prop('disabled', true); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlDisableConditional: function ($target, $owner, data) { + var isDisabled; + + if (data.argument) { + isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (isDisabled) { + this.payflowBmlDisable($target, $owner, data); + } + } else if ($target.find(data.enableButton).val() === '0') { + this.payflowBmlDisable($target, $owner, data); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlDisableConditionalExpress: function ($target, $owner, data) { + if ($target.find(data.enableExpress).val() === '0') { + this.payflowBmlDisable($target, $owner, data); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlEnable: function ($target, $owner, data) { + $target.find(data.enableBml).prop('disabled', false); + $target.find(data.enableBml + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').addClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlEnableConditional: function ($target, $owner, data) { + var isDisabled = true; + + _.every(data.argument, function (name) { + if (data.solutionsElements[name] && + data.solutionsElements[name].find(data.enableButton).val() === '1' + ) { + isDisabled = false; + + return isDisabled; + } + + return isDisabled; + }, this); + + if (!isDisabled) { + $target.find(data.enableBml).prop('disabled', true); + $target.find(data.enableBml + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').addClass('enabled'); + } else { + $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled'); + $target.find(data.enableBml + ' option[value="0"]').prop('selected', true); + $target.find(data.enableBml).prop('disabled', true); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + payflowBmlLockConditional: function ($target, $owner, data) { + if ($target.find(data.enableButton).val() === '0') { + $target.find(data.enableBml).prop('disabled', true); + } + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + inContextEnable: function ($target, $owner, data) { + $target.find(data.enableInContextPayPal).prop('disabled', false); + $target.find(data.enableInContextPayPal + ' option[value="1"]').prop('selected', true); + $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]') + .addClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + inContextDisable: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]') + .removeClass('enabled'); + $target.find(data.enableInContextPayPal + ' option[value="0"]').prop('selected', true); + $target.find(data.enableInContextPayPal).prop('disabled', true); + }, + + /** + * @param {*} $target + */ + inContextShowMerchantId: function ($target) { + $target.find('tr[id$="_merchant_id"], input[id$="_merchant_id"]').show(); + $target.find('input[id$="_merchant_id"]').attr('disabled', false); + }, + + /** + * @param {*} $target + */ + inContextHideMerchantId: function ($target) { + $target.find('tr[id$="_merchant_id"], input[id$="_merchant_id"]').hide(); + $target.find('input[id$="_merchant_id"]').attr('disabled', true); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + inContextActivate: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]') + .addClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + inContextDeactivate: function ($target, $owner, data) { + $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]') + .removeClass('enabled'); + }, + + /** + * @param {*} $target + * @param {*} $owner + * @param {String} data + */ + inContextDisableConditional: function ($target, $owner, data) { + if ($target.find(data.enableButton).val() === '0') { + this.inContextDisable($target, $owner, data); + } + } + }); +}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js deleted file mode 100644 index 54b263be6421dcdd7534f811c7ef80a02be12e99..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -(function () { - 'use strict'; - - var executed = false; - - define([ - 'Magento_Ui/js/modal/alert', - 'underscore' - ], function (alert, _) { - - return function ($target, $owner, data) { - - var isDisabled = true, - newLine = String.fromCharCode(10, 13); - - if ($owner.find(data.enableButton).val() === '1') { - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isDisabled = false; - - return isDisabled; - } - - return isDisabled; - }, this); - - if (!isDisabled && !executed) { - executed = true; - alert({ - content: 'The following error(s) occurred:' + - newLine + - 'Some PayPal solutions conflict.' + - newLine + - 'Please re-enable the previously enabled payment solutions.' - }); - } - } - }; - }); -})(); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/disable.js deleted file mode 100644 index 54e355580394b5437fb79b6d2ecc6e20be54e184..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/disable.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/simple/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - disable($target, $owner, data); - $target.find(data.enableButton).change(); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-express.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-express.js deleted file mode 100644 index e3d95340b8bfe534f1da36452b36dcc63bc2e4db..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-express.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/bml/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableExpress).val() === '0') { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-in-context.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-in-context.js deleted file mode 100644 index 4f4f648c226b33f25926908b7603b73b97bfd949..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional-in-context.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/bml/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableInContext).val() === '1') { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional.js deleted file mode 100644 index 20182ef0205f4135e853b77b3c937d17f59c66bc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable-conditional.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/bml/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable.js deleted file mode 100644 index 01d241a0e36197981029a2cfa63eaf1399193967..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableBml + ' option[value="0"]').prop('selected', true); - $target.find(data.enableBml).prop('disabled', true); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable-conditional.js deleted file mode 100644 index 9770d463f45fc676eeda339a9d7849368822f93f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable-conditional.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define(['underscore'], function (_) { - 'use strict'; - - return function ($target, $owner, data) { - var isDisabled = true; - - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isDisabled = false; - - return isDisabled; - } - - return isDisabled; - }, this); - - if (!isDisabled) { - $target.find(data.enableBml).prop('disabled', true); - $target.find(data.enableBml + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').addClass('enabled'); - } else { - $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableBml + ' option[value="0"]').prop('selected', true); - $target.find(data.enableBml).prop('disabled', true); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable.js deleted file mode 100644 index 3ddfc3b0f60446334670836e98fffcf2cdac2dd4..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/enable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableBml).prop('disabled', false); - $target.find(data.enableBml + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableBml).attr('id') + '"]').addClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/lock-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/lock-conditional.js deleted file mode 100644 index 607c56984e7dc6f4047a20a55b8a262442bd69ba..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/bml/lock-conditional.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - $target.find(data.enableBml).prop('disabled', true); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable-conditional.js deleted file mode 100644 index 94b178c071642e09b80771094946ba7522541815..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable-conditional.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/express/disable' -], function (disableExpress) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - disableExpress($target, $owner, data); - $target.find(data.enableExpress).change(); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable.js deleted file mode 100644 index 77649695f3c11394c98f95d7e50bd57d4857971a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableExpress + ' option[value="0"]').prop('selected', true); - $target.find(data.enableExpress).prop('disabled', true); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable-conditional.js deleted file mode 100644 index ea9fc5f2d0ccbe6741615fed4bb9cd5cb0c85b74..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable-conditional.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define(['underscore'], function (_) { - 'use strict'; - - return function ($target, $owner, data) { - var isDisabled = true; - - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isDisabled = false; - - return isDisabled; - } - - return isDisabled; - }, this); - - if (!isDisabled) { - $target.find(data.enableExpress).prop('disabled', true); - $target.find(data.enableExpress + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').addClass('enabled'); - } else { - $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableExpress + ' option[value="0"]').prop('selected', true); - $target.find(data.enableExpress).prop('disabled', true); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable.js deleted file mode 100644 index 6dc1a0a49cfba72168b9e0d69b067b9dab2fa380..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/enable.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableExpress).prop('disabled', false); - $target.find(data.enableExpress + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableExpress).attr('id') + '"]').addClass('enabled'); - $target.find(data.enableExpress).change(); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/lock-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/lock-conditional.js deleted file mode 100644 index c07a0b5cf713e2b7c65bda537e331e47980f6e37..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/lock-conditional.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - $target.find(data.enableExpress).prop('disabled', true); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-disable.js deleted file mode 100644 index f217b55ecbbb9d2a28d97d875cc5b584fc89ec51..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-disable.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/express/enable' -], function (enableExpress) { - 'use strict'; - - return function ($target, $owner, data) { - - $target.find('input[id="' + $target.find(data.enableExpress).attr('id') + '_inherit"]').prop('checked', false); - enableExpress($target, $owner, data); - $target.find(data.enableExpress).change(); - }; -}); - diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-enable.js deleted file mode 100644 index 9993fb21c55fe44c05b7ce7e27f0a2cbff3be8c2..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/payflow/express/usedefault-enable.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/payflow/express/disable' -], function (disableExpress) { - 'use strict'; - - return function ($target, $owner, data) { - - $target.find('input[id="' + $target.find(data.enableExpress).attr('id') + '_inherit"]').prop('checked', true); - disableExpress($target, $owner, data); - $target.find(data.enableExpress).change(); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable-conditional.js deleted file mode 100644 index d4b8d4100e56d5e9e5e2ffc134ae79e6a5445859..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable-conditional.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/paypal/bml/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable.js deleted file mode 100644 index c6ef93d332fb64b102a4ec2ba30370e5cc61d384..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableBmlPayPal).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableBmlPayPal + ' option[value="0"]').prop('selected', true); - $target.find(data.enableBmlPayPal).prop('disabled', true); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/enable.js deleted file mode 100644 index 90f7561734f14f34d21e126ba7df9d2d9926dadc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/bml/enable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableBmlPayPal).prop('disabled', false); - $target.find(data.enableBmlPayPal + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableBmlPayPal).attr('id') + '"]').addClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/disable.js deleted file mode 100644 index 25e7b611a24692ed05b544bb8bcf8e80b05862b3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableButton + ' option[value="0"]').prop('selected', true); - $target.find('label.enabled').removeClass('enabled'); - $target.find(data.enableButton).change(); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration-conditional.js deleted file mode 100644 index 0bea44359cef2c6c7a83e8b6265e22d27b90c9e3..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration-conditional.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/paypal/express/lock-configuration', - 'underscore' -], function (lockConfiguration, _) { - 'use strict'; - - return function ($target, $owner, data) { - var isDisabled = true; - - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isDisabled = false; - - return isDisabled; - } - - return isDisabled; - }, this); - - if (!isDisabled && - $target.find(data.enableInContextPayPal).val() === '0') { - lockConfiguration($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration.js deleted file mode 100644 index 351f799b57b28a3739d23f37cb46bc0afaedafe8..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/lock-configuration.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.buttonConfiguration).addClass('disabled') - .attr('disabled', 'disabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/mark-disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/mark-disable.js deleted file mode 100644 index 7943c843b13cde484d9d0baf1149110ac4885754..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/mark-disable.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/simple/disable', - 'underscore' -], function (disable, _) { - 'use strict'; - - return function ($target, $owner, data) { - var isDisabled = true; - - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isDisabled = false; - - return isDisabled; - } - - return isDisabled; - }, this); - - if (isDisabled) { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/unlock-configuration.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/unlock-configuration.js deleted file mode 100644 index fda160c6d94f4babe5257180db769a37aa667537..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/express/unlock-configuration.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define(['underscore'], function (_) { - 'use strict'; - - return function ($target, $owner, data) { - var isUnlock = true; - - _.every(data.argument, function (name) { - if (data.solutionsElements[name] && - data.solutionsElements[name].find(data.enableButton).val() === '1' - ) { - isUnlock = false; - - return isUnlock; - } - - return isUnlock; - }, this); - - if (isUnlock) { - $target.find(data.buttonConfiguration).removeClass('disabled') - .removeAttr('disabled'); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/activate.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/activate.js deleted file mode 100644 index 41a9c30ed8b7ed98126d2b8624da401bc9bbceef..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/activate.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]').addClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/deactivate.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/deactivate.js deleted file mode 100644 index eb64ec4cecf994346e9946661de703d05baace0f..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/deactivate.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]').removeClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable-conditional.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable-conditional.js deleted file mode 100644 index 383ae9d750b9140e61463f9cfcc44bff2b7bc635..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable-conditional.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([ - 'Magento_Paypal/js/rules/paypal/in-context/disable' -], function (disable) { - 'use strict'; - - return function ($target, $owner, data) { - if ($target.find(data.enableButton).val() === '0') { - disable($target, $owner, data); - } - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable.js deleted file mode 100644 index ebd56a28d24fcdab207cd17bc897d996d6e8bddf..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]').removeClass('enabled'); - $target.find(data.enableInContextPayPal + ' option[value="0"]').prop('selected', true); - $target.find(data.enableInContextPayPal).prop('disabled', true); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/enable.js deleted file mode 100644 index e88c606818dcad3a77dd57e08af57b43e01bdef6..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/enable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableInContextPayPal).prop('disabled', false); - $target.find(data.enableInContextPayPal + ' option[value="1"]').prop('selected', true); - $target.find('label[for="' + $target.find(data.enableInContextPayPal).attr('id') + '"]').addClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/hide-merchant-id.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/hide-merchant-id.js deleted file mode 100644 index 7dd54976ca09144a756f0e74beba2e4e32192c6a..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/hide-merchant-id.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target) { - $target.find('tr[id$="_merchant_id"], input[id$="_merchant_id"]').hide(); - $target.find('input[id$="_merchant_id"]').attr('disabled', true); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/show-merchant-id.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/show-merchant-id.js deleted file mode 100644 index d075871c4a5ecb9a8bae52559a13280573f5a4dc..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/paypal/in-context/show-merchant-id.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target) { - $target.find('tr[id$="_merchant_id"], input[id$="_merchant_id"]').show(); - $target.find('input[id$="_merchant_id"]').attr('disabled', false); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/disable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/disable.js deleted file mode 100644 index 7531d4fae1aaab06dc14f3ffd611b7bc63508e53..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/disable.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target, $owner, data) { - $target.find(data.enableButton + ' option[value="0"]').prop('selected', true); - $target.find('label.enabled').removeClass('enabled'); - $target.find('.section-config').removeClass('enabled'); - }; -}); diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/mark-enable.js b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/mark-enable.js deleted file mode 100644 index 1dec21bb5b4931c2109fe2c3ab4adec651c06c3d..0000000000000000000000000000000000000000 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/simple/mark-enable.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -define([], function () { - 'use strict'; - - return function ($target) { - $target.find('.section-config').addClass('enabled'); - }; -}); diff --git a/app/code/Magento/Sales/Model/Order/Address.php b/app/code/Magento/Sales/Model/Order/Address.php index f1eaae85c532297d9e51a0e58a9f9c5764a59a2c..e7ce9deeee296eb98bb313a8cf24dd83a6a82344 100644 --- a/app/code/Magento/Sales/Model/Order/Address.php +++ b/app/code/Magento/Sales/Model/Order/Address.php @@ -122,14 +122,14 @@ class Address extends AbstractModel implements OrderAddressInterface, AddressMod */ public function getRegionCode() { - if (is_string($this->getRegion())) { - return $this->getRegion(); - } - $model = $this->regionFactory->create()->load( - ((!$this->getRegionId() && is_numeric($this->getRegion())) ? $this->getRegion() : $this->getRegionId()) - ); + $regionId = (!$this->getRegionId() && is_numeric($this->getRegion())) ? + $this->getRegion() : + $this->getRegionId(); + $model = $this->regionFactory->create()->load($regionId); if ($model->getCountryId() == $this->getCountryId()) { return $model->getCode(); + } elseif (is_string($this->getRegion())) { + return $this->getRegion(); } else { return null; } @@ -257,6 +257,7 @@ class Address extends AbstractModel implements OrderAddressInterface, AddressMod } //@codeCoverageIgnoreStart + /** * Returns address_type * diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php index 3a3318311511f384a5ee2e9885b01608abb6b2be..5fb031ea1513a68b00ad0ef646b57c0e2b7a20ff 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/AddressTest.php @@ -19,14 +19,17 @@ class AddressTest extends \PHPUnit_Framework_TestCase * @var \Magento\Sales\Model\Order\Address */ protected $address; + /** * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject */ protected $orderMock; + /** * @var \Magento\Directory\Model\RegionFactory|\PHPUnit_Framework_MockObject_MockObject */ protected $regionFactoryMock; + /** * @var \Magento\Directory\Model\Region|\PHPUnit_Framework_MockObject_MockObject */ @@ -78,9 +81,23 @@ class AddressTest extends \PHPUnit_Framework_TestCase public function testGetRegionCodeRegionIsSet() { + $regionId = 1; $this->address->setData('region', 'region'); - $this->regionFactoryMock->expects($this->never()) - ->method('create'); + $this->address->setData('region_id', $regionId); + $this->address->setData('country_id', 2); + + $this->regionMock->expects(static::once()) + ->method('load') + ->with($regionId) + ->willReturnSelf(); + + $this->regionMock->expects(static::once()) + ->method('getCountryId') + ->willReturn(1); + + $this->regionFactoryMock->expects(static::once()) + ->method('create') + ->willReturn($this->regionMock); $this->assertEquals('region', $this->address->getRegionCode()); } diff --git a/app/code/Magento/Search/view/adminhtml/ui_component/search_synonyms_form.xml b/app/code/Magento/Search/view/adminhtml/ui_component/search_synonyms_form.xml index 35e94ba04c30d9bade627fb34bdb4139fb7454be..004f6bd99960f4a9a5a0889d5ec74234127007c2 100644 --- a/app/code/Magento/Search/view/adminhtml/ui_component/search_synonyms_form.xml +++ b/app/code/Magento/Search/view/adminhtml/ui_component/search_synonyms_form.xml @@ -102,7 +102,6 @@ <item name="config" xsi:type="array"> <item name="additionalClasses" xsi:type="string">admin__field-no-label</item> <item name="description" xsi:type="string" translate="true">Merge existing synonyms</item> - <item name="dataType" xsi:type="string">boolean</item> <item name="default" xsi:type="boolean">false</item> <item name="formElement" xsi:type="string">checkbox</item> <item name="dataScope" xsi:type="string">mergeOnConflict</item> @@ -110,6 +109,10 @@ <item name="tooltip" xsi:type="array"> <item name="description" xsi:type="string" translate="true">Automatically merges synonyms in groups that share the same scope. If you check this box and you add one or more of the same terms to different synonym groups in the same scope, automatically merges all the terms to one group. If this isn't what you want, uncheck the box and an error displays if you try to add the same terms.</item> </item> + <item name="valueMap" xsi:type="array"> + <item name="true" xsi:type="boolean">true</item> + <item name="false" xsi:type="boolean">false</item> + </item> </item> </argument> </field> diff --git a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php index 33afc7b395f7db2953b461e1bd5d567a013e85cb..67cd6fc0db31d3b5e70c8952e2a0f439bc6cceea 100644 --- a/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php +++ b/app/code/Magento/Shipping/Model/Carrier/AbstractCarrier.php @@ -16,6 +16,8 @@ use Magento\Shipping\Model\Shipment\Request; */ abstract class AbstractCarrier extends \Magento\Framework\DataObject implements AbstractCarrierInterface { + const DEBUG_KEYS_MASK = '****'; + /** * Carrier's code * @@ -620,4 +622,48 @@ abstract class AbstractCarrier extends \Magento\Framework\DataObject implements { return []; } + + /** + * Recursive replace sensitive fields of XML document. + * + * For example if xml document has the following structure: + * ```xml + * <Request> + * <LicenseNumber>E437FJFD</LicenseNumber> + * <UserId>testUser1</UserId> + * <Password>userPassword</Password> + * </Request> + * ``` + * and sensitive fields are specified as `['UserId', 'Password']`, then sensitive fields + * will be replaced by the mask(by default it is '****') + * + * @param string $data + * @return string + */ + protected function filterDebugData($data) + { + try { + $xml = new \SimpleXMLElement($data); + $this->filterXmlData($xml); + $data = $xml->asXML(); + } catch (\Exception $e) {} + return $data; + } + + /** + * Recursive replace sensitive xml nodes values by specified mask + * @param \SimpleXMLElement $xml + * @return void + */ + private function filterXmlData(\SimpleXMLElement $xml) + { + /** @var \SimpleXMLElement $child */ + foreach ($xml->children() as $child) { + if ($child->count()) { + $this->filterXmlData($child); + } else if (in_array((string) $child->getName(), $this->_debugReplacePrivateDataKeys)) { + $child[0] = self::DEBUG_KEYS_MASK; + } + } + } } diff --git a/app/code/Magento/Shipping/Model/Shipping/Labels.php b/app/code/Magento/Shipping/Model/Shipping/Labels.php index 4b697f3ba15bed0635408ba2708faa34176d7a1f..1382979d05c31c87c87d51dab48668cc9d6c4430 100644 --- a/app/code/Magento/Shipping/Model/Shipping/Labels.php +++ b/app/code/Magento/Shipping/Model/Shipping/Labels.php @@ -228,8 +228,6 @@ class Labels extends \Magento\Shipping\Model\Shipping */ protected function setRecipientDetails(Request $request, Address $address) { - $recipientRegionCode = $this->_regionFactory->create()->load($address->getRegionId())->getCode(); - $request->setRecipientContactPersonName(trim($address->getFirstname() . ' ' . $address->getLastname())); $request->setRecipientContactPersonFirstName($address->getFirstname()); $request->setRecipientContactPersonLastName($address->getLastname()); @@ -240,8 +238,8 @@ class Labels extends \Magento\Shipping\Model\Shipping $request->setRecipientAddressStreet1($address->getStreetLine(1)); $request->setRecipientAddressStreet2($address->getStreetLine(2)); $request->setRecipientAddressCity($address->getCity()); - $request->setRecipientAddressStateOrProvinceCode($recipientRegionCode ?: $address->getRegionCode()); - $request->setRecipientAddressRegionCode($recipientRegionCode); + $request->setRecipientAddressStateOrProvinceCode($address->getRegionCode() ?: $address->getRegion()); + $request->setRecipientAddressRegionCode($address->getRegionCode()); $request->setRecipientAddressPostalCode($address->getPostcode()); $request->setRecipientAddressCountryCode($address->getCountryId()); } diff --git a/app/code/Magento/Shipping/Test/Unit/Model/Shipping/LabelsTest.php b/app/code/Magento/Shipping/Test/Unit/Model/Shipping/LabelsTest.php index 9e4d8eede79b28f08f4ffea9f8fdddf6b02baa66..9654136cafdeec43c6f7987d8108927ce9fae09b 100644 --- a/app/code/Magento/Shipping/Test/Unit/Model/Shipping/LabelsTest.php +++ b/app/code/Magento/Shipping/Test/Unit/Model/Shipping/LabelsTest.php @@ -21,14 +21,17 @@ class LabelsTest extends \PHPUnit_Framework_TestCase * @var \Magento\Shipping\Model\Shipping\Labels */ protected $labels; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $request; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ protected $scopeConfig; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -128,13 +131,6 @@ class LabelsTest extends \PHPUnit_Framework_TestCase [Shipment::XML_PATH_STORE_ADDRESS2, ScopeInterface::SCOPE_STORE, $storeId, '1st Park Avenue'], ]); - $this->region->expects(static::once()) - ->method('load') - ->willReturnSelf(); - $this->region->expects(static::once()) - ->method('getCode') - ->willReturn('CO'); - $this->labels->requestToShipment($shipment); } @@ -213,9 +209,9 @@ class LabelsTest extends \PHPUnit_Framework_TestCase $address = $this->getMockBuilder('Magento\Sales\Model\Order\Address') ->disableOriginalConstructor() ->getMock(); - $address->expects(static::once()) - ->method('getRegionId') - ->willReturn(23); + $address->expects(static::exactly(2)) + ->method('getRegionCode') + ->willReturn('CO'); $address->expects(static::exactly(2)) ->method('getFirstname') ->willReturn('Chimi'); diff --git a/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php b/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php index 39338fe309e5377edcdf0e6523c940898c1ec52b..a650daff703d672e57fc34a8ddb19468abdb41d1 100644 --- a/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php +++ b/app/code/Magento/Store/Ui/Component/Listing/Column/Store.php @@ -93,12 +93,13 @@ class Store extends Column protected function prepareItem(array $item) { $content = ''; + if (!empty($item[$this->storeKey])) { + $origStores = $item[$this->storeKey]; + } - if (empty($item[$this->storeKey])) { + if (empty($origStores)) { return ''; } - $origStores = $item[$this->storeKey]; - if (!is_array($origStores)) { $origStores = [$origStores]; } diff --git a/app/code/Magento/Theme/Model/Theme/Registration.php b/app/code/Magento/Theme/Model/Theme/Registration.php index add61132ffafae4e6ee9f729f7eda6ebae725b03..d19cb2071aff1ea094d395a5e9ae088348eef947 100644 --- a/app/code/Magento/Theme/Model/Theme/Registration.php +++ b/app/code/Magento/Theme/Model/Theme/Registration.php @@ -68,6 +68,7 @@ class Registration public function register() { $this->_themeCollection->clear(); + foreach ($this->_themeCollection as $theme) { $this->_registerThemeRecursively($theme); } diff --git a/app/code/Magento/Theme/Observer/ThemeRegistrationObserver.php b/app/code/Magento/Theme/Observer/ThemeRegistrationObserver.php deleted file mode 100644 index 5c647753eaddc4cde5e77eb3c8629b7fd503f839..0000000000000000000000000000000000000000 --- a/app/code/Magento/Theme/Observer/ThemeRegistrationObserver.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Theme\Observer; - -use Magento\Framework\Event\Observer as EventObserver; -use Magento\Framework\Event\ObserverInterface; -use Magento\Theme\Model\Theme; - -class ThemeRegistrationObserver implements ObserverInterface -{ - /** - * @var \Magento\Theme\Model\Theme\Registration - */ - protected $registration; - - /** - * @var \Psr\Log\LoggerInterface - */ - protected $logger; - - /** - * @param Theme\Registration $registration - * @param \Psr\Log\LoggerInterface $logger - */ - public function __construct( - \Magento\Theme\Model\Theme\Registration $registration, - \Psr\Log\LoggerInterface $logger - ) { - $this->registration = $registration; - $this->logger = $logger; - } - - /** - * Theme registration - * - * @param \Magento\Framework\Event\Observer $observer - * @return $this - */ - public function execute(\Magento\Framework\Event\Observer $observer) - { - $pathPattern = $observer->getEvent()->getPathPattern(); - try { - $this->registration->register($pathPattern); - } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->logger->critical($e); - } - return $this; - } -} diff --git a/app/code/Magento/Theme/Setup/InstallData.php b/app/code/Magento/Theme/Setup/InstallData.php deleted file mode 100644 index 32503c78fc70f353c5f74a7aeddce6536fc05e37..0000000000000000000000000000000000000000 --- a/app/code/Magento/Theme/Setup/InstallData.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Theme\Setup; - -use Magento\Framework\Setup\InstallDataInterface; -use Magento\Framework\Setup\ModuleContextInterface; -use Magento\Framework\Setup\ModuleDataSetupInterface; - -/** - * @codeCoverageIgnore - */ -class InstallData implements InstallDataInterface -{ - /** - * Theme resource factory - * - * @var \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory - */ - private $themeResourceFactory; - - /** - * Theme collection factory - * - * @var \Magento\Theme\Model\Theme\CollectionFactory - */ - private $themeFactory; - - /** - * Init - * - * @param \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $themeResourceFactory - * @param \Magento\Theme\Model\Theme\CollectionFactory $themeFactory - */ - public function __construct( - \Magento\Theme\Model\ResourceModel\Theme\CollectionFactory $themeResourceFactory, - \Magento\Theme\Model\Theme\CollectionFactory $themeFactory - ) { - $this->themeResourceFactory = $themeResourceFactory; - $this->themeFactory = $themeFactory; - } - - /** - * {@inheritdoc} - */ - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) - { - /* - * Register themes - */ - $setup->getEventManager()->dispatch('theme_registration_from_filesystem'); - - /** - * Update theme's data - */ - $fileCollection = $this->createTheme(); - $fileCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data'); - - $resourceCollection = $this->createThemeResource(); - $resourceCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data'); - - /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ - foreach ($resourceCollection as $theme) { - $themeType = $fileCollection->hasTheme($theme) - ? \Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL - : \Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL; - $theme->setType($themeType)->save(); - } - - $fileCollection = $this->createTheme(); - $fileCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data'); - - $themeDbCollection = $this->createThemeResource(); - $themeDbCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data'); - - /** @var $theme \Magento\Framework\View\Design\ThemeInterface */ - foreach ($fileCollection as $theme) { - $dbTheme = $themeDbCollection->getThemeByFullPath($theme->getFullPath()); - $dbTheme->setCode($theme->getCode()); - $dbTheme->save(); - } - - /** - * Update rows in theme - */ - $setup->getConnection()->update( - $setup->getTable('theme'), - ['area' => 'frontend'], - ['area = ?' => ''] - ); - } - - /** - * @return \Magento\Theme\Model\ResourceModel\Theme\Collection - */ - public function createThemeResource() - { - return $this->themeResourceFactory->create(); - } - - /** - * @return \Magento\Theme\Model\Theme\Collection - */ - public function createTheme() - { - return $this->themeFactory->create(); - } -} diff --git a/app/code/Magento/Theme/Setup/RecurringData.php b/app/code/Magento/Theme/Setup/RecurringData.php new file mode 100644 index 0000000000000000000000000000000000000000..309e62ab09b9a868cac2f78cd4597a7ef3290525 --- /dev/null +++ b/app/code/Magento/Theme/Setup/RecurringData.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Theme\Setup; + +use Magento\Framework\Setup\InstallDataInterface; +use Magento\Framework\Setup\ModuleContextInterface; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Theme\Model\Theme\Registration; + +/** + * Upgrade registered themes + */ +class RecurringData implements InstallDataInterface +{ + /** + * Theme registration + * + * @var Registration + */ + private $themeRegistration; + + /** + * Init + * + * @param Registration $themeRegistration + */ + public function __construct(Registration $themeRegistration) + { + $this->themeRegistration = $themeRegistration; + } + + /** + * {@inheritdoc} + */ + public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) + { + $this->themeRegistration->register(); + } +} diff --git a/app/code/Magento/Theme/Test/Unit/Observer/ThemeRegistrationObserverTest.php b/app/code/Magento/Theme/Test/Unit/Observer/ThemeRegistrationObserverTest.php deleted file mode 100644 index b27f8cede5c2d7a6040b77f8dd6546ec6542af73..0000000000000000000000000000000000000000 --- a/app/code/Magento/Theme/Test/Unit/Observer/ThemeRegistrationObserverTest.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Theme\Test\Unit\Observer; - -class ThemeRegistrationObserverTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $logger; - - /** - * @var \Magento\Theme\Model\Theme\Registration|\PHPUnit_Framework_MockObject_MockObject - */ - protected $registration; - - /** - * @var \Magento\Theme\Observer\ThemeRegistrationObserver - */ - protected $themeObserver; - - protected function setUp() - { - $this->registration = $this->getMockBuilder('Magento\Theme\Model\Theme\Registration') - ->disableOriginalConstructor() - ->getMock(); - $this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock(); - - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->themeObserver = $objectManagerHelper->getObject( - 'Magento\Theme\Observer\ThemeRegistrationObserver', - [ - 'registration' => $this->registration, - 'logger' => $this->logger, - ] - ); - } - - public function testThemeRegistration() - { - $pattern = 'some pattern'; - $eventMock = $this->getMockBuilder('Magento\Framework\Event') - ->setMethods(['getPathPattern']) - ->disableOriginalConstructor() - ->getMock(); - $eventMock->expects($this->any())->method('getPathPattern')->willReturn($pattern); - $observerMock = $this->getMockBuilder('Magento\Framework\Event\Observer') - ->disableOriginalConstructor() - ->getMock(); - $observerMock->expects($this->any())->method('getEvent')->willReturn($eventMock); - $this->registration->expects($this->once()) - ->method('register') - ->with($pattern) - ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('exception'))); - $this->logger->expects($this->once()) - ->method('critical'); - - /** @var $observerMock \Magento\Framework\Event\Observer */ - $this->themeObserver->execute($observerMock); - } -} diff --git a/app/code/Magento/Theme/etc/events.xml b/app/code/Magento/Theme/etc/events.xml index 2f6155eeade189bad071d27a50cfa808f2244c1d..709f64eaf91ae50fc4b696b5494e8e13712eb44a 100644 --- a/app/code/Magento/Theme/etc/events.xml +++ b/app/code/Magento/Theme/etc/events.xml @@ -12,8 +12,4 @@ <event name="theme_save_after"> <observer name="check_theme_is_assigned" instance="Magento\Theme\Observer\CheckThemeIsAssignedObserver" /> </event> - <event name="theme_registration_from_filesystem"> - <observer name="theme_registration_observer" instance="Magento\Theme\Observer\ThemeRegistrationObserver" - /> - </event> </config> diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 5d5f159d3d233bdd826f3b73d84fe4fe6c4f56f7..394f5583fe263bf858bec0a01caf8896379d099f 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -122,6 +122,13 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface */ protected $configHelper; + /** + * @inheritdoc + */ + protected $_debugReplacePrivateDataKeys = [ + 'UserId', 'Password' + ]; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -586,6 +593,7 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface $this->setXMLAccessRequest(); $xmlRequest = $this->_xmlAccessRequest; + $debugData['accessRequest'] = $this->filterDebugData($xmlRequest); $rowRequest = $this->_rawRequest; if (self::USA_COUNTRY_ID == $rowRequest->getDestCountry()) { @@ -619,7 +627,7 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface } $serviceDescription = $serviceCode ? $this->getShipmentByCode($serviceCode) : ''; - $xmlRequest .= <<<XMLRequest + $xmlParams = <<<XMLRequest <?xml version="1.0"?> <RatingServiceSelectionRequest xml:lang="en-US"> <Request> @@ -639,18 +647,18 @@ class Carrier extends AbstractCarrierOnline implements CarrierInterface XMLRequest; if ($serviceCode !== null) { - $xmlRequest .= "<Service>" . + $xmlParams .= "<Service>" . "<Code>{$serviceCode}</Code>" . "<Description>{$serviceDescription}</Description>" . "</Service>"; } - $xmlRequest .= <<<XMLRequest + $xmlParams .= <<<XMLRequest <Shipper> XMLRequest; if ($this->getConfigFlag('negotiated_active') && ($shipper = $this->getConfigData('shipper_number'))) { - $xmlRequest .= "<ShipperNumber>{$shipper}</ShipperNumber>"; + $xmlParams .= "<ShipperNumber>{$shipper}</ShipperNumber>"; } if ($rowRequest->getIsReturn()) { @@ -665,7 +673,7 @@ XMLRequest; $shipperStateProvince = $params['origRegionCode']; } - $xmlRequest .= <<<XMLRequest + $xmlParams .= <<<XMLRequest <Address> <City>{$shipperCity}</City> <PostalCode>{$shipperPostalCode}</PostalCode> @@ -682,10 +690,10 @@ XMLRequest; XMLRequest; if ($params['49_residential'] === '01') { - $xmlRequest .= "<ResidentialAddressIndicator>{$params['49_residential']}</ResidentialAddressIndicator>"; + $xmlParams .= "<ResidentialAddressIndicator>{$params['49_residential']}</ResidentialAddressIndicator>"; } - $xmlRequest .= <<<XMLRequest + $xmlParams .= <<<XMLRequest </Address> </ShipTo> @@ -708,17 +716,19 @@ XMLRequest; XMLRequest; if ($this->getConfigFlag('negotiated_active')) { - $xmlRequest .= "<RateInformation><NegotiatedRatesIndicator/></RateInformation>"; + $xmlParams .= "<RateInformation><NegotiatedRatesIndicator/></RateInformation>"; } - $xmlRequest .= <<<XMLRequest + $xmlParams .= <<<XMLRequest </Shipment> </RatingServiceSelectionRequest> XMLRequest; + $xmlRequest .= $xmlParams; + $xmlResponse = $this->_getCachedQuotes($xmlRequest); if ($xmlResponse === null) { - $debugData = ['request' => $xmlRequest]; + $debugData['request'] = $xmlParams; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); diff --git a/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php index ec696bc84960cc559f78df4168a04bc6b9fc8741..b6533bf00b67ce83b122507186fa9ab8283a417a 100644 --- a/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Ups/Test/Unit/Model/CarrierTest.php @@ -6,6 +6,7 @@ namespace Magento\Ups\Test\Unit\Model; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Ups\Model\Carrier; class CarrierTest extends \PHPUnit_Framework_TestCase { @@ -19,10 +20,12 @@ class CarrierTest extends \PHPUnit_Framework_TestCase * @var \Magento\Quote\Model\Quote\Address\RateResult\Error|\PHPUnit_Framework_MockObject_MockObject */ protected $error; + /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ protected $helper; + /** * Model under test * @@ -233,4 +236,74 @@ class CarrierTest extends \PHPUnit_Framework_TestCase $this->assertSame($this->rate, $this->model->collectRates($request)); } + + /** + * @param string $data + * @param array $maskFields + * @param string $expected + * @dataProvider logDataProvider + */ + public function testFilterDebugData($data, array $maskFields, $expected) + { + $refClass = new \ReflectionClass(Carrier::class); + $property = $refClass->getProperty('_debugReplacePrivateDataKeys'); + $property->setAccessible(true); + $property->setValue($this->model, $maskFields); + + $refMethod = $refClass->getMethod('filterDebugData'); + $refMethod->setAccessible(true); + $result = $refMethod->invoke($this->model, $data); + $expectedXml = new \SimpleXMLElement($expected); + $resultXml = new \SimpleXMLElement($result); + static::assertEquals($expectedXml->asXML(), $resultXml->asXML()); + } + + /** + * Get list of variations + */ + public function logDataProvider() + { + return [ + [ + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest> + <UserId>42121</UserId> + <Password>TestPassword</Password> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ['UserId', 'Password'], + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest> + <UserId>****</UserId> + <Password>****</Password> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ], + [ + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest> + <Auth> + <UserId>1231</UserId> + </Auth> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ['UserId'], + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest> + <Auth> + <UserId>****</UserId> + </Auth> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ] + ]; + } } diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index ae5b4ecaecc6b505373980a21199b673996d6ec1..3444b8731da8e70527fcdb6bfe87680c25d5ae32 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -112,6 +112,13 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C */ protected $_httpClientFactory; + /** + * @inheritdoc + */ + protected $_debugReplacePrivateDataKeys = [ + 'USERID' + ]; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -467,7 +474,7 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C $responseBody = $this->_getCachedQuotes($request); if ($responseBody === null) { - $debugData = ['request' => $request]; + $debugData = ['request' => $this->filterDebugData($request)]; try { $url = $this->getConfigData('gateway_url'); if (!$url) { @@ -2040,4 +2047,37 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C } return false; } + + /** + * Replace sensitive fields. + * + * Replace sensitive fields, which specified as attributes of xml node. + * For followed xml: + * ```xml + * <RateV4Request USERID="1"> + * <Revision>2</Revision> + * </RateV4Request> + * ```xml + * the `USERID` attribute value will be replaced by specified mask + * + * @param string $data + * @return string + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + protected function filterDebugData($data) + { + try { + $xml = new \SimpleXMLElement($data); + $attributes = $xml->attributes(); + /** @var \SimpleXMLElement $attribute */ + foreach ($attributes as $key => $attribute) { + if (in_array((string) $key, $this->_debugReplacePrivateDataKeys)) { + $attributes[$key] = self::DEBUG_KEYS_MASK; + } + } + $data = $xml->asXML(); + } catch (\Exception $e) {} + + return $data; + } } diff --git a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php index b6048f5882521d6248bb7e7644937cc6c8135cd8..dd93972ddc2365bf4f5b97b32568a0b066e876b6 100644 --- a/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Usps/Test/Unit/Model/CarrierTest.php @@ -6,6 +6,7 @@ namespace Magento\Usps\Test\Unit\Model; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Usps\Model\Carrier; class CarrierTest extends \PHPUnit_Framework_TestCase { @@ -275,4 +276,49 @@ class CarrierTest extends \PHPUnit_Framework_TestCase $this->assertNotEmpty($this->carrier->collectRates($request)); } + + /** + * @param string $data + * @param array $maskFields + * @param string $expected + * @dataProvider logDataProvider + */ + public function testFilterDebugData($data, array $maskFields, $expected) + { + $refClass = new \ReflectionClass(Carrier::class); + $property = $refClass->getProperty('_debugReplacePrivateDataKeys'); + $property->setAccessible(true); + $property->setValue($this->carrier, $maskFields); + + $refMethod = $refClass->getMethod('filterDebugData'); + $refMethod->setAccessible(true); + $result = $refMethod->invoke($this->carrier, $data); + $expectedXml = new \SimpleXMLElement($expected); + $resultXml = new \SimpleXMLElement($result); + static::assertEquals($expectedXml->asXML(), $resultXml->asXML()); + } + + /** + * Get list of variations + */ + public function logDataProvider() + { + return [ + [ + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest USERID="12312"> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ['USERID'], + '<?xml version="1.0" encoding="UTF-8"?> + <RateRequest USERID="****"> + <Package ID="0"> + <Service>ALL</Service> + </Package> + </RateRequest>', + ], + ]; + } } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/CurlClient.php b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/CurlClient.php new file mode 100644 index 0000000000000000000000000000000000000000..8c4dddd9580c92f795a1c30d2d3d32bf55950c0f --- /dev/null +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/CurlClient.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\TestFramework\Authentication\Rest; + +use OAuth\Common\Http\Uri\UriInterface; + +/** + * Custom Client implementation for cURL + */ +class CurlClient extends \OAuth\Common\Http\Client\CurlClient +{ + /** + * {@inheritdoc} + */ + public function retrieveResponse( + UriInterface $endpoint, + $requestBody, + array $extraHeaders = [], + $method = 'POST' + ) { + $this->setCurlParameters([CURLOPT_FAILONERROR => true]); + return parent::retrieveResponse($endpoint, $requestBody, $extraHeaders, $method); + } +} diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php index 158a3ef5a771179f7fca114d3eaaf2c5f3d41fcc..d6bae44298ae53ec3f0a1a7405ad887c5e079b07 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Authentication/Rest/OauthClient.php @@ -40,7 +40,7 @@ class OauthClient extends AbstractService UriInterface $baseApiUri = null ) { if (!isset($httpClient)) { - $httpClient = new \OAuth\Common\Http\Client\StreamClient(); + $httpClient = new \Magento\TestFramework\Authentication\Rest\CurlClient(); $httpClient->setTimeout(self::DEFAULT_TIMEOUT); } if (!isset($storage)) { diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php b/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php index 56936fa716784c7ea003afd93e87ab31da048817..c7414d717eb270857d3b2ea292eb8bb0c27d689e 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/WebApiApplication.php @@ -33,7 +33,7 @@ class WebApiApplication extends Application /* Install application */ if ($installOptions) { - $installCmd = 'php -f ' . BP . '/bin/magento setup:install'; + $installCmd = 'php -f ' . BP . '/bin/magento setup:install -vvv'; $installArgs = []; foreach ($installOptions as $optionName => $optionValue) { if (is_bool($optionValue)) { diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Authentication/RestTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Authentication/RestTest.php index 29b5f27cad3771c4de65cf15698cca9d6e479f27..a75b6cd4bd8375196f8da1d215ea93034cfc19d1 100644 --- a/dev/tests/api-functional/testsuite/Magento/Webapi/Authentication/RestTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Authentication/RestTest.php @@ -85,7 +85,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 401 + * @expectedExceptionMessage 401 Unauthorized */ public function testGetRequestTokenExpiredConsumer() { @@ -97,7 +97,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 401 + * @expectedExceptionMessage 401 Unauthorized */ public function testGetRequestTokenInvalidConsumerKey() { @@ -107,7 +107,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 401 + * @expectedExceptionMessage 401 Unauthorized */ public function testGetRequestTokenInvalidConsumerSecret() { @@ -141,7 +141,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 401 + * @expectedExceptionMessage 401 Unauthorized */ public function testGetAccessTokenInvalidVerifier() { @@ -156,7 +156,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 401 + * @expectedExceptionMessage 401 Unauthorized */ public function testGetAccessTokenConsumerMismatch() { @@ -176,7 +176,7 @@ class RestTest extends \Magento\TestFramework\TestCase\WebapiAbstract /** * @expectedException \Exception - * @expectedExceptionMessage HTTP/1.1 400 + * @expectedExceptionMessage 400 Bad Request */ public function testAccessApiInvalidAccessToken() { diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php index 0a3bc1d10f2dcf684ca74f68a3ec251cd5933a9f..b74d57bf8815cfdd1169f3dc5dd5c9a41dbbb159 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Factory/AbstractFactory.php @@ -8,6 +8,7 @@ namespace Magento\Mtf\Util\Generate\Factory; use Magento\Framework\Filesystem\DriverInterface; +use Magento\Framework\Filesystem\Glob; /** * Class AbstractFactory @@ -25,11 +26,10 @@ abstract class AbstractFactory protected $_checkList = []; - /** - * @return mixed - */ /** * Generate Blocks + * + * @return void */ public function launch() { @@ -156,7 +156,7 @@ abstract class AbstractFactory $pattern = $this->_getPattern($type, $location); - $filesIterator = glob($pattern, GLOB_BRACE); + $filesIterator = Glob::glob($pattern, Glob::GLOB_BRACE); foreach ($filesIterator as $filePath) { if (!is_dir($filePath)) { diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml old mode 100644 new mode 100755 index a85c77c0323a41654496774747acc715f87a0cda..abefec5cc1c9f7b56e839c86e0a2de284e51a8e6 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/Block/Form/Cc.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<mapping strict="1"> +<mapping strict="0"> <wrapper>payment</wrapper> <fields> <cc_number /> diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Page/Header.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Page/Header.php index cbe0c75b7d923176473dc55456345d4fee719b1f..21d8d2e3735f4cca250d21b9fb06c9b7e7d16fc7 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Page/Header.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Page/Header.php @@ -85,4 +85,28 @@ class Header extends Block $search = $this->_rootElement->find($this->searchSelector, Locator::SELECTOR_CSS, 'globalsearch'); return $search->isExistValueInSearchResult($query); } + + /** + * Is admin search preview visible in suggestion dropdown. + * + * @param string $query + * @param string $type + * @return bool + */ + public function isAdminSearchPreviewVisible($query, $type) + { + /** @var GlobalsearchElement $search */ + $search = $this->_rootElement->find('searchPreview' . $type, Locator::SELECTOR_ID); + return $search->getText() === $query; + } + + /** + * Navigate to grid of specified type + * + * @param string $type + */ + public function navigateToGrid($type) + { + $this->_rootElement->find('searchPreview' . $type, Locator::SELECTOR_ID)->click(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchCustomerName.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchCustomerName.php index 6ab4e17f0f8e58df9f527d9d81f7d7abd015e76a..2fcf933a4567b42d1c9616edb08faa99effafd2b 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchCustomerName.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchCustomerName.php @@ -8,6 +8,7 @@ namespace Magento\Backend\Test\Constraint; use Magento\Backend\Test\Fixture\GlobalSearch; use Magento\Backend\Test\Page\Adminhtml\Dashboard; +use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Mtf\Constraint\AbstractConstraint; /** @@ -21,9 +22,10 @@ class AssertGlobalSearchCustomerName extends AbstractConstraint * * @param Dashboard $dashboard * @param GlobalSearch $search + * @param CustomerIndex $customerIndex * @return void */ - public function processAssert(Dashboard $dashboard, GlobalSearch $search) + public function processAssert(Dashboard $dashboard, GlobalSearch $search, CustomerIndex $customerIndex) { $customer = $search->getDataFieldConfig('query')['source']->getEntity(); $customerName = $customer->getFirstname() . " " . $customer->getLastname(); @@ -32,6 +34,19 @@ class AssertGlobalSearchCustomerName extends AbstractConstraint $isVisibleInResult, 'Customer name ' . $customerName . ' is absent in search results' ); + + $dashboard->getAdminPanelHeader()->navigateToGrid("Customers"); + $isCustomerGridVisible = $customerIndex->getCustomerGridBlock()->isVisible(); + \PHPUnit_Framework_Assert::assertTrue( + $isCustomerGridVisible, + 'Customer grid is not visible' + ); + \PHPUnit_Framework_Assert::assertContains( + (string) $customer->getId(), + $customerIndex->getCustomerGridBlock()->getAllIds(), + 'Customer grid does not have ' . $customerName . ' in search results' + ); + } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchOrderId.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchOrderId.php index ed988ab79a3303de4646ade7b952cd485d1626ed..5d6fac04237fc25231ff8340458064e2cb17bc67 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchOrderId.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchOrderId.php @@ -9,6 +9,7 @@ namespace Magento\Backend\Test\Constraint; use Magento\Backend\Test\Fixture\GlobalSearch; use Magento\Backend\Test\Page\Adminhtml\Dashboard; use Magento\Mtf\Constraint\AbstractConstraint; +use Magento\Sales\Test\Page\Adminhtml\OrderIndex; /** * Class AssertGlobalSearchOrderId @@ -21,9 +22,10 @@ class AssertGlobalSearchOrderId extends AbstractConstraint * * @param Dashboard $dashboard * @param GlobalSearch $search + * @param OrderIndex $orderIndex * @return void */ - public function processAssert(Dashboard $dashboard, GlobalSearch $search) + public function processAssert(Dashboard $dashboard, GlobalSearch $search, OrderIndex $orderIndex) { $order = $search->getDataFieldConfig('query')['source']->getEntity(); $orderId = "Order #" . $order->getId(); @@ -32,6 +34,19 @@ class AssertGlobalSearchOrderId extends AbstractConstraint $isVisibleInResult, 'Order Id ' . $order->getId() . ' is absent in search results' ); + + $dashboard->getAdminPanelHeader()->navigateToGrid("Orders"); + $isOrderGridVisible = $orderIndex->getSalesOrderGrid()->isVisible(); + + \PHPUnit_Framework_Assert::assertTrue( + $isOrderGridVisible, + 'Order grid is not visible' + ); + \PHPUnit_Framework_Assert::assertContains( + (string) $order->getId(), + $orderIndex->getSalesOrderGrid()->getAllIds(), + 'Order grid does not have ' . $order->getId() . ' in search results' + ); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchPreview.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchPreview.php new file mode 100644 index 0000000000000000000000000000000000000000..890eee983083db3b48054dec9030ec8269f2b5a2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertGlobalSearchPreview.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Backend\Test\Constraint; + +use Magento\Backend\Test\Fixture\GlobalSearch; +use Magento\Backend\Test\Page\Adminhtml\Dashboard; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertGlobalSearchPreview + * Assert that admin search preview is present in search results + */ +class AssertGlobalSearchPreview extends AbstractConstraint +{ + /** + * Assert that admin search preview is present in search results + * + * @param Dashboard $dashboard + * @param GlobalSearch $search + * @return void + */ + public function processAssert(Dashboard $dashboard, GlobalSearch $search) + { + $types = ['Products', 'Customers', 'Orders', 'Pages']; + foreach ($types as $type) { + $this->adminSearchAssert($dashboard, $search, $type); + } + } + + /** + * Assert value of item in admin search preview + * + * @param Dashboard $dashboard + * @param GlobalSearch $search + * @param string $type + */ + private function adminSearchAssert($dashboard, $search, $type) + { + $adminSearchPreview = '"' . $search->getQuery() . '" in '. $type; + $isVisibleInResult = $dashboard->getAdminPanelHeader()->isAdminSearchPreviewVisible($adminSearchPreview, $type); + \PHPUnit_Framework_Assert::assertTrue( + $isVisibleInResult, + 'Search Preview for ' . $type . ' is not in search results' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Search preview is present in search results'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml index c4341095b42b3eed2e6a68aeefc40d671499c364..87eccf18b69b5ea50c9bed1b314305d80dcf6b34 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/GlobalSearchEntityTest.xml @@ -7,6 +7,11 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Backend\Test\TestCase\GlobalSearchEntityTest" summary="Global Search Backend " ticketId="MAGETWO-28457"> + <variation name="GlobalSearchEntityTestVariation1"> + <data name="description" xsi:type="string">search shows admin preview</data> + <data name="search/data/query" xsi:type="string">Some search term</data> + <constraint name="Magento\Backend\Test\Constraint\AssertGlobalSearchPreview" /> + </variation> <variation name="GlobalSearchEntityTestVariation2"> <data name="description" xsi:type="string">search with 2 sign return no results</data> <data name="search/data/query" xsi:type="string">:)</data> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Paypal/PopupWindow.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Paypal/PopupWindow.php old mode 100644 new mode 100755 index f2eae0a9870ed8e1dc667bcdc373450d04bf05a2..80d5c5a831437f4af47a2511164e83da56e8bd7d --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Paypal/PopupWindow.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Block/Paypal/PopupWindow.php @@ -47,7 +47,14 @@ class PopupWindow extends Block $this->browser->selectWindow(); $this->waitForFormLoaded(); $this->browser->find($this->submitButton)->click(); - $this->waitForElementNotVisible($this->selector); + /** + * This try/catch is intended as workaround in case if popup window is closed instantly and #login-preview + * selector cannot be found. + */ + try { + $this->waitForElementNotVisible($this->selector); + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + } $this->browser->selectWindow(); $this->waitForElementNotVisible($this->loader); } diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..0da522038acf64a6651a8f2df01605e2bdc23b30 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/DeleteSavedCreditCardTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Vault\Test\TestCase\DeleteSavedCreditCardTest" summary="Delete saved with Braintree credit card from customer account"> + <variation name="DeleteSavedCreditCardTestVariation2" summary="Delete saved with Braintree credit card from customer account" ticketId="MAGETWO-38487"> + <data name="products" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">login</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">braintreetwo</data> + <data name="creditCardClass" xsi:type="string">credit_card_braintree</data> + <data name="creditCard/dataset" xsi:type="string">visa_braintree</data> + <data name="creditCardSave" xsi:type="string">Yes</data> + <data name="configData" xsi:type="string">braintreetwo, braintreetwo_use_vault</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test</data> + <constraint name="Magento\Vault\Test\Constraint\AssertCreditCardNotPresentOnCheckout" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e6a1241d0b880f01eba23c555c9423dc712df6d4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePayPalBraintreeTest.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Braintree\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Order 1 is placed with Braintree PayPal. + * + * Steps: + * 1. Log in to Admin. + * 2. Go to Sales > Orders page. + * 3. Open order 1. + * 4. Click Invoice button. + * 5. Ensure Capture Online is selected, click Submit Invoice button. + * 6. Open Invoices tab. + * 7. Perform assertions. + * + * @group Braintree_(CS) + * @ZephyrId MAGETWO-48614, MAGETWO-48615 + */ +class InvoicePayPalBraintreeTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TEST_TYPE = '3rd_party_test'; + /* end tags */ + + /** + * Runs one page checkout test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..313cfff4a2dcf4d397bc63023265117dcaf7d89f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/InvoicePaypalBraintreeTest.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Braintree\Test\TestCase\InvoicePayPalBraintreeTest" summary="Capture for order placed within PayPal Braintree"> + <variation name="InvoicePayPalBraintreeTestVariation1" summary="Full capture of order placed within Braintree PayPal" ticketId="MAGETWO-48614"> + <data name="description" xsi:type="string">Full capture of order placed within Braintree PayPal</data> + <data name="products" xsi:type="string">catalogProductSimple::product_10_dollar, bundleProduct::bundle_fixed_100_dollar_product</data> + <data name="taxRule" xsi:type="string">us_illinois_tax_rule</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">139.9</item> + </data> + <data name="capturedPrices" xsi:type="array"> + <item name="0" xsi:type="string">139.9</item> + </data> + <data name="payment/method" xsi:type="string">braintreetwo_paypal</data> + <data name="configData" xsi:type="string">braintreetwo, braintreetwo_paypal</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship</data> + <data name="data/items_data/0/qty" xsi:type="string">-</data> + <data name="data/form_data/do_shipment" xsi:type="string">No</data> + <data name="data/form_data/comment_text" xsi:type="string">comments</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test</data> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + </variation> + <variation name="InvoicePayPalBraintreeTestVariation2" summary="Partial capture for order placed within Braintree PayPal" ticketId="MAGETWO-48615"> + <data name="description" xsi:type="string">Partial capture for order placed within Braintree PayPal</data> + <data name="products" xsi:type="string">catalogProductSimple::product_100_dollar</data> + <data name="taxRule" xsi:type="string">us_illinois_tax_rule</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="isInvoicePartial" xsi:type="string">Yes</data> + <data name="prices" xsi:type="array"> + <item name="grandTotal" xsi:type="string">226.50</item> + </data> + <data name="capturedPrices" xsi:type="array"> + <item name="0" xsi:type="string">118.25</item> + <item name="1" xsi:type="string">108.25</item> + </data> + <data name="payment/method" xsi:type="string">braintreetwo_paypal</data> + <data name="configData" xsi:type="string">braintreetwo, braintreetwo_paypal</data> + <data name="orderButtonsAvailable" xsi:type="string">Back, Send Email, Credit Memo, Hold, Ship</data> + <data name="data/items_data/0/qty" xsi:type="string">1</data> + <data name="data/form_data/do_shipment" xsi:type="string">No</data> + <data name="data/form_data/comment_text" xsi:type="string">comments</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test</data> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceSuccessCreateMessage" /> + <constraint name="Magento\Sales\Test\Constraint\AssertOrderButtonsAvailable" /> + <constraint name="Magento\Sales\Test\Constraint\AssertInvoiceItems" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml index fd4564dc136740bc4a1399d0aff332be57ed4aa8..3b9ec335640e527505477f8db34b0c7517254bf1 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml @@ -62,4 +62,13 @@ <step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder"/> <step name="placeOrder" module="Magento_Checkout"/> </scenario> + <scenario name="InvoicePayPalBraintreeTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createTaxRule" /> + <step name="createTaxRule" module="Magento_Tax" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="checkoutWithPaypalFromCart" /> + <step name="checkoutWithPaypalFromCart" module="Magento_Braintree" next="expressCheckoutOrderPlace" /> + <step name="expressCheckoutOrderPlace" module="Magento_Paypal" next="createInvoice" /> + <step name="createInvoice" module="Magento_Sales" /> + </scenario> </config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressSuccessfullyCancelledMessage.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressCancelledMessage.php similarity index 63% rename from dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressSuccessfullyCancelledMessage.php rename to dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressCancelledMessage.php index 53214e11e0ebcec5ce8463991c3a2abd7ae96a62..c0a0e0f92ae0d058bd5479a0be0194b4e86758d7 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressSuccessfullyCancelledMessage.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Constraint/AssertExpressCancelledMessage.php @@ -10,18 +10,19 @@ use Magento\Checkout\Test\Page\CheckoutCart; use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertOrderSuccessPlacedMessage + * Class AssertExpressCancelledMessage * Assert that success message is correct */ -class AssertExpressSuccessfullyCancelledMessage extends AbstractConstraint +class AssertExpressCancelledMessage extends AbstractConstraint { /** - * Message of success checkout + * Message of cancelled PayPal Express checkout. */ const SUCCESS_MESSAGE = 'Express Checkout has been canceled.'; /** - * Assert that success message is correct + * Assert that success message is correct. + * * @param CheckoutCart $checkoutCart */ public function processAssert(CheckoutCart $checkoutCart) @@ -29,17 +30,17 @@ class AssertExpressSuccessfullyCancelledMessage extends AbstractConstraint \PHPUnit_Framework_Assert::assertEquals( self::SUCCESS_MESSAGE, $checkoutCart->getMessagesBlock()->getSuccessMessage(), - 'Wrong success message is displayed.' + 'Success message about Express Checkout cancellation is not present or wrong.' ); } /** - * Returns string representation of successful assertion + * Returns string representation of successful assertion. * * @return string */ public function toString() { - return 'Success message on Shopping Cart page is correct.'; + return 'Success message about Express Checkout cancellation is present.'; } } diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..f24ab2e5d09cc4464dad6793126aab47cd56098f --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/DeleteSavedCreditCardTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Vault\Test\TestCase\DeleteSavedCreditCardTest" summary="Delete saved with Payflow Pro credit card from customer account"> + <variation name="DeleteSavedCreditCardTestVariation1" summary="Delete saved with Payflow Pro credit card from customer account" ticketId="MAGETWO-48086"> + <data name="products" xsi:type="string">catalogProductSimple::product_10_dollar</data> + <data name="customer/dataset" xsi:type="string">default</data> + <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> + <data name="checkoutMethod" xsi:type="string">login</data> + <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> + <data name="shipping/shipping_method" xsi:type="string">Fixed</data> + <data name="payment/method" xsi:type="string">payflowpro</data> + <data name="creditCardClass" xsi:type="string">credit_card</data> + <data name="creditCard/dataset" xsi:type="string">visa_default</data> + <data name="creditCardSave" xsi:type="string">Yes</data> + <data name="configData" xsi:type="string">payflowpro, payflowpro_use_vault</data> + <data name="tag" xsi:type="string">test_type:3rd_party_test</data> + <constraint name="Magento\Vault\Test\Constraint\AssertCreditCardNotPresentOnCheckout" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressCheckoutFromShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressCheckoutFromShoppingCartTest.xml index b96e2bb70c8d26d841403ae9dd82bc1dcc00c2f8..af3b879d56cc1e502ef63804f19deb74ff6ac144 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressCheckoutFromShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressCheckoutFromShoppingCartTest.xml @@ -11,7 +11,7 @@ <data name="products" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="configData" xsi:type="string">paypal_express, paypal_express_in_context</data> <data name="tag" xsi:type="string">test_type:3rd_party_test</data> - <constraint name="Magento\Paypal\Test\Constraint\AssertExpressSuccessfullyCancelledMessage" /> + <constraint name="Magento\Paypal\Test\Constraint\AssertExpressCancelledMessage" /> </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressOnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressOnePageCheckoutTest.xml index cc6f8afbee2f8bee59c44f0d6ceba93780c52700..bebf047b5b792f85955c7e55430f76e1c8dcf4d7 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressOnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/InContextExpressOnePageCheckoutTest.xml @@ -19,7 +19,7 @@ <data name="payment/method" xsi:type="string">paypal_express</data> <data name="configData" xsi:type="string">paypal_express_in_context, paypal_express, freeshipping</data> <data name="tag" xsi:type="string">test_type:3rd_party_test</data> - <constraint name="Magento\Paypal\Test\Constraint\AssertExpressSuccessfullyCancelledMessage" /> + <constraint name="Magento\Paypal\Test\Constraint\AssertExpressCancelledMessage" /> </variation> </testCase> </config> diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php index af0a09304a398195622f370264f23da6541a145d..36327c9864fe1ad9fd83ded385f06332cc7432db 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php @@ -6,6 +6,7 @@ namespace Magento\Paypal\Test\TestStep; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\ObjectManager; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Paypal\Test\Page\OrderReviewExpress; @@ -59,12 +60,24 @@ class ExpressCheckoutOrderPlaceStep implements TestStepInterface */ protected $prices; + /** + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * @var array + */ + private $products; + /** * @constructor * @param ObjectManager $objectManager * @param OrderReviewExpress $orderReviewExpress * @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepageSuccess $checkoutOnepageSuccess + * @param FixtureFactory $fixtureFactory + * @param array $products * @param array $shipping * @param array $prices */ @@ -73,6 +86,8 @@ class ExpressCheckoutOrderPlaceStep implements TestStepInterface OrderReviewExpress $orderReviewExpress, CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, + FixtureFactory $fixtureFactory, + array $products, array $shipping = [], array $prices = [] ) { @@ -82,6 +97,8 @@ class ExpressCheckoutOrderPlaceStep implements TestStepInterface $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; $this->shipping = $shipping; $this->prices = $prices; + $this->fixtureFactory = $fixtureFactory; + $this->products = $products; } /** @@ -98,8 +115,17 @@ class ExpressCheckoutOrderPlaceStep implements TestStepInterface $assert->processAssert($this->checkoutOnepage, $value); } $this->orderReviewExpress->getReviewBlock()->placeOrder(); + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); return [ - 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId() + 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), + 'order' => $order ]; } } diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.php b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.php new file mode 100644 index 0000000000000000000000000000000000000000..000fd9895e821be57340082ce203a18a55d4429e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Block\Adminhtml\Block\Edit; + +use Magento\Mtf\Block\Form; +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Mtf\Fixture\FixtureInterface; + +/** + * Form for Synonym Group creation. + */ +class SynonymGroupForm extends Form +{ + /** + * Content Editor toggle button id. + * + * @var string + */ + protected $toggleButton = "#toggleblock_content"; + + /** + * Synonym Group Content area. + * + * @var string + */ + protected $contentForm = '[name="content"]'; + + /** + * Fill the page form. + * + * @param FixtureInterface $fixture + * @param SimpleElement $element + * @return $this + */ + public function fill(FixtureInterface $fixture, SimpleElement $element = null) + { + return parent::fill($fixture, $element); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.xml b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.xml new file mode 100644 index 0000000000000000000000000000000000000000..761af98e1918e4383fbe8718682e6dc0c539fbd5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/Edit/SynonymGroupForm.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<mapping strict="0"> + <fields> + <scope_id> + <selector>[name="scope_id"]</selector> + <input>selectstore</input> + </scope_id> + <mergeOnConflict> + <input>checkbox</input> + </mergeOnConflict> + </fields> +</mapping> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/SynonymGroupGrid.php b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/SynonymGroupGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..1a1bc5732d9fe460c61422e5cd546b9e076e5117 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Block/Adminhtml/Block/SynonymGroupGrid.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Block\Adminhtml\Block; + +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Ui\Test\Block\Adminhtml\DataGrid; + +/** + * Backend Data Grid for managing "SynonymGroup" entities. + */ +class SynonymGroupGrid extends DataGrid +{ + /** + * Select action toggle. + * + * @var string + */ + protected $selectAction = '.action-select'; + + /** + * Filters array mapping. + * + * @var array + */ + protected $filters = [ + 'synonyms' => [ + 'selector' => '[name="synonyms"]', + ], + 'scope_id' => [ + 'selector' => '[name="scope_id"]', + 'input' => 'simplifiedselect' + ], + ]; + + /** + * Click on "Edit" link. + * + * @param SimpleElement $rowItem + * @return void + */ + protected function clickEditLink(SimpleElement $rowItem) + { + $rowItem->find($this->selectAction)->click(); + $rowItem->find($this->editLink)->click(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupDeleteMessage.php b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupDeleteMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..b445887cf411bceb615ddf3b5c953fd47ec98eed --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupDeleteMessage.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Constraint; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that after delete synonym group successful delete message appears. + */ +class AssertSynonymGroupDeleteMessage extends AbstractConstraint +{ + const DELETE_MESSAGE = 'The synonym group has been deleted.'; + + /** + * Assert that after delete Synonym Group successful delete message appears. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @return void + */ + public function processAssert(SynonymGroupIndex $synonymGroupIndex) + { + $actualMessage = $synonymGroupIndex->getMessagesBlock()->getSuccessMessage(); + \PHPUnit_Framework_Assert::assertEquals( + self::DELETE_MESSAGE, + $actualMessage, + 'Wrong success message is displayed.' + . "\nExpected: " . self::DELETE_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Synonym Group success delete message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupInGrid.php b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupInGrid.php new file mode 100644 index 0000000000000000000000000000000000000000..642b366830e095f8c129887cddf90b52cbd49507 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupInGrid.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Constraint; + +use Magento\Search\Test\Fixture\SynonymGroup; +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that created Synonym Group can be found in grid. + */ +class AssertSynonymGroupInGrid extends AbstractConstraint +{ + /** + * Assert that created Synonym Group can be found in grid via: synonyms. + * + * @param SynonymGroup $synonymGroup + * @param SynonymGroupIndex $synonymGroupIndex + * @return void + * + */ + public function processAssert(SynonymGroup $synonymGroup, SynonymGroupIndex $synonymGroupIndex) + { + $synonymGroupIndex->open(); + $data = $synonymGroup->getData(); + $filter = [ + 'synonyms' => $data['synonyms'], + ]; + + $synonymGroupIndex->getSynonymGroupGrid()->search($filter); + + \PHPUnit_Framework_Assert::assertTrue( + $synonymGroupIndex->getSynonymGroupGrid()->isRowVisible($filter, false, false), + 'Synonym Group with ' + . 'synonyms \'' . $filter['synonyms'] . '\', ' + . 'is absent in Synonym grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Synonym Group is present in grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupSuccessSaveMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..b2102d2ae6050e90472d27e3c00bc77e3cae590d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymGroupSuccessSaveMessage.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Constraint; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that after save block successful message appears. + */ +class AssertSynonymGroupSuccessSaveMessage extends AbstractConstraint +{ + const SUCCESS_SAVE_MESSAGE = 'You saved the synonym group.'; + + /** + * Assert that after save Synonym Group successful message appears. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @return void + */ + public function processAssert(SynonymGroupIndex $synonymGroupIndex) + { + $actualMessage = $synonymGroupIndex->getMessagesBlock()->getSuccessMessage(); + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_SAVE_MESSAGE, + $actualMessage, + 'Wrong success message is displayed.' + . "\nExpected: " . self::SUCCESS_SAVE_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Synonym Group success create message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymMergeErrorMessage.php b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymMergeErrorMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..b953caffe3914845d17a6b0c085a358dcd75a4e0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Constraint/AssertSynonymMergeErrorMessage.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Constraint; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupNew; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Assert that after save block successful message appears. + */ +class AssertSynonymMergeErrorMessage extends AbstractConstraint +{ + const ERROR_MESSAGE = 'The terms you entered'; + + /** + * Assert that after save Synonym Group successful message appears. + * + * @param SynonymGroupNew $synonymGroupNew + * @return void + */ + public function processAssert(SynonymGroupNew $synonymGroupNew) + { + $actualMessage = $synonymGroupNew->getMessagesBlock()->getErrorMessage(); + \PHPUnit_Framework_Assert::assertContains( + self::ERROR_MESSAGE, + $actualMessage, + 'Wrong success message is displayed.' + . "\nExpected: " . self::ERROR_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Synonym Group error message is present.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup.xml b/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup.xml new file mode 100644 index 0000000000000000000000000000000000000000..7cc67f87b3d6639902a4fbc97a524edb29350aa4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/fixture.xsd"> + <fixture name="synonymGroup" + module="Magento_Search" + type="flat" + entity_type="synonym_group" + collection="Magento\Search\Model\ResourceModel\Block\Grid\Collection" + handler_interface="Magento\Search\Test\Handler\SynonymGroup\SynonymGroupInterface" + repository_class="Magento\Search\Test\Repository\SynonymGroup" class="Magento\Search\Test\Fixture\SynonymGroup"> + <field name="group_id" is_required="1 "/> + <field name="synonyms" is_required="0" /> + <field name="scope_id" is_required="0" source="Magento\Search\Test\Fixture\SynonymGroup\ScopeId" /> + <field name="mergeOnConflict" is_required="0" /> + </fixture> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup/ScopeId.php b/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup/ScopeId.php new file mode 100644 index 0000000000000000000000000000000000000000..5dd92e9774a6de93be45d3db8a6a5cfa55ce3770 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Fixture/SynonymGroup/ScopeId.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Fixture\SynonymGroup; + +use Magento\Store\Test\Fixture\Store; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\DataSource; + +/** + * Class ScopeId + */ +class ScopeId extends DataSource +{ + /** + * Return store. + * + * @var Store + */ + protected $store = null; + + /** + * @constructor + * @param FixtureFactory $fixtureFactory + * @param array $params + * @param array $data + */ + public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = []) + { + $this->params = $params; + if (isset($data['dataset'])) { + $store = $fixtureFactory->createByCode('store', ['dataset' => $data['dataset']]); + if (!$store->hasData('store_id')) { + $store->persist(); + } + $this->store = $store; + $this->data = $store->getName(); + } else { + $this->data = null; + } + } + + /** + * Return store. + * + * @return Store + */ + public function getStore() + { + return $this->store; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/Curl.php b/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/Curl.php new file mode 100644 index 0000000000000000000000000000000000000000..1e56a656783792336c3ec46b1f5e6558fadbf0b8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/Curl.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Handler\SynonymGroup; + +use Magento\Mtf\Fixture\FixtureInterface; +use Magento\Mtf\Handler\Curl as AbstractCurl; +use Magento\Mtf\Util\Protocol\CurlTransport; +use Magento\Mtf\Util\Protocol\CurlTransport\BackendDecorator; + +/** + * Curl handler for creating Synonym Group. + */ +class Curl extends AbstractCurl implements SynonymGroupInterface +{ + /** + * Url for saving data. + * + * @var string + */ + protected $saveUrl = 'search/synonyms/save/'; + + /** + * Mapping values for data. + * + * @var array + */ + protected $mappingData = [ + 'mergeOnConflict' => [ + 'Yes' => 1, + 'No' => 0, + ], + 'scope_id' => [ + 'All Websites' => '0:0', + 'All Store Views' => '1:0', + 'Default Store View' => '1:1', + ], + ]; + + /** + * POST request for creating Synonym Group. + * + * @param FixtureInterface|null $fixture [optional] + * @return array + * @throws \Exception + */ + public function persist(FixtureInterface $fixture = null) + { + $data = $this->replaceMappingData($fixture->getData()); + + $url = $_ENV['app_backend_url'] . $this->saveUrl; + $curl = new BackendDecorator(new CurlTransport(), $this->_configuration); + $curl->write($url, $data); + $response = $curl->read(); + $curl->close(); + if (!strpos($response, 'data-ui-id="messages-message-success"')) { + throw new \Exception( + "Synonym Group entity creation by curl handler was not successful! Response: $response" + ); + } + + preg_match("`group_id\/(\d*?)\/`", $response, $matches); + $id = isset($matches[1]) ? $matches[1] : null; + + return ['group_id' => $id]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/SynonymGroupInterface.php b/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/SynonymGroupInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..3681f06378633191285f6b66fc6ae90be7289ba0 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Handler/SynonymGroup/SynonymGroupInterface.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\Handler\SynonymGroup; + +use Magento\Mtf\Handler\HandlerInterface; + +/** + * Interface SynonymGroupInterface + */ +interface SynonymGroupInterface extends HandlerInterface +{ + // +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupIndex.xml b/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupIndex.xml new file mode 100644 index 0000000000000000000000000000000000000000..03bf60bdd17c1b539e2e81fa88be467dc5ac3cf6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupIndex.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="synonymGroupIndex" area="Adminhtml" mca="search/synonyms/index" module="Magento_Search"> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".messages .message" strategy="css selector" /> + <block name="gridPageActions" class="Magento\Backend\Test\Block\GridPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="synonymGroupGrid" class="Magento\Search\Test\Block\Adminhtml\Block\SynonymGroupGrid" locator=".admin__data-grid-outer-wrap" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupNew.xml b/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupNew.xml new file mode 100644 index 0000000000000000000000000000000000000000..bac3cb7422f69b31f8dff74ca78ed1d386eb4276 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Page/Adminhtml/SynonymGroupNew.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="synonymGroupNew" area="Adminhtml" mca="search/synonyms/new" module="Magento_Search"> + <block name="formPageActions" class="Magento\Backend\Test\Block\FormPageActions" locator=".page-main-actions" strategy="css selector" /> + <block name="synonymGroupForm" class="Magento\Search\Test\Block\Adminhtml\Block\Edit\SynonymGroupForm" locator="[id='page:main-container']" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator="#messages" strategy="css selector" /> + <block name="modalBlock" class="Magento\Ui\Test\Block\Adminhtml\Modal" locator="._show[data-role=modal]" strategy="css selector"/> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/Repository/SynonymGroup.xml b/dev/tests/functional/tests/app/Magento/Search/Test/Repository/SynonymGroup.xml new file mode 100644 index 0000000000000000000000000000000000000000..347d364d57a032df9f91bd6125d1e4fd7a10fb34 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/Repository/SynonymGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd"> + <repository class="Magento\Search\Test\Repository\SynonymGroup"> + <dataset name="prepareMerge"> + <field name="scope_id" xsi:type="array"> + <item name="dataset" xsi:type="string">default_store_view</item> + </field> + <field name="synonyms" xsi:type="string">test_synonym_%isolation%,test_synonym_2_test_synonym_%isolation%</field> + <field name="mergeOnConflict" xsi:type="string">Yes</field> + </dataset> + </repository> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..bba88a54b5e8991da23641bb821ca6c3b819f931 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\TestCase; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Search\Test\Page\Adminhtml\SynonymGroupNew; +use Magento\Mtf\TestCase\Injectable; +use Magento\Search\Test\Fixture\SynonymGroup; + +/** + * Preconditions: + * 1. Create store view. + * + * Steps: + * 1. Open Backend. + * 2. Go to Marketing > Search Synonyms. + * 3. Click "New Synonym Group" button. + * 4. Fill data according to dataset. + * 5. Perform all assertions. + * + * @group Search_(MX) + * @ZephyrId MAGETWO-47681 + */ +class CreateSynonymGroupEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'MX'; + const TEST_TYPE = 'extended_acceptance_test'; + /* end tags */ + + /** + * Page Index. + * + * @var synonymGroupIndex + */ + protected $synonymGroupIndex; + + /** + * Page synonymGroupNew. + * + * @var SynonymGroupNew + */ + protected $synonymGroupNew; + + /** + * Injection data. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @param SynonymGroupNew $synonymGroupNew + * @return void + */ + public function __inject( + SynonymGroupIndex $synonymGroupIndex, + SynonymGroupNew $synonymGroupNew + ) { + $this->synonymGroupIndex = $synonymGroupIndex; + $this->synonymGroupNew = $synonymGroupNew; + } + + /** + * Create Synonym Group. + * + * @param SynonymGroup $synonymGroup + * @return void + */ + public function test(SynonymGroup $synonymGroup) + { + // Steps + $this->synonymGroupIndex->open(); + $this->synonymGroupIndex->getGridPageActions()->addNew(); + $this->synonymGroupNew->getSynonymGroupForm()->fill($synonymGroup); + $this->synonymGroupNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..557a64118d5a22ac4d1ffa14a422e78c8b60fff9 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/CreateSynonymGroupEntityTest.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Search\Test\TestCase\CreateSynonymGroupEntityTest" summary="Create Synonym Group" ticketId="MAGETWO-47681"> + <variation name="CreateSynonymGroupEntityTestVariation1"> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">synonym_%isolation%</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage" /> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupInGrid" /> + </variation> + </testCase> + <testCase name="Magento\Search\Test\TestCase\CreateSynonymGroupEntityTest" summary="Create Synonym Group with few synonyms and Default Store View" ticketId="MAGETWO-47681"> + <variation name="CreateSynonymGroupEntityTestVariation2"> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">shoes_%isolation%,foot wear_%isolation%,mens shoes_%isolation%,women shoes_%isolation%</data> + <data name="synonymGroup/data/scope_id/dataset" xsi:type="string">default_store_view</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage" /> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupInGrid" /> + </variation> + </testCase> + <testCase name="Magento\Search\Test\TestCase\CreateSynonymGroupEntityTest" summary="Create Synonym Group with custom Website and Store View" ticketId="MAGETWO-47681"> + <variation name="CreateSynonymGroupEntityTestVariation3"> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">synonym_%isolation%</data> + <data name="synonymGroup/data/scope_id/dataset" xsi:type="string">custom_store</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage" /> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupInGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.php new file mode 100755 index 0000000000000000000000000000000000000000..2ae9974a39e74a618abcc853ed594e06b2390851 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\TestCase; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Search\Test\Page\Adminhtml\SynonymGroupNew; +use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Search\Test\Fixture\SynonymGroup; + +/** + * Preconditions: + * 1. Create Synonym Group view. + * + * Steps: + * 1. Open Backend. + * 2. Go to Marketing > Search Synonyms. + * 3. Delete created Synonym Group + * 4. Perform all assertions. + * + * @group Search_(MX) + * @ZephyrId MAGETWO-47683 + */ +class DeleteSynonymGroupEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'MX'; + const TEST_TYPE = 'extended_acceptance_test'; + /* end tags */ + + /** + * Page Index. + * + * @var synonymGroupIndex + */ + protected $synonymGroupIndex; + + /** + * Page synonymGroupNew. + * + * @var SynonymGroupNew + */ + protected $synonymGroupNew; + + /** + * Injection data. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @param SynonymGroupNew $synonymGroupNew + * @return void + */ + public function __inject( + SynonymGroupIndex $synonymGroupIndex, + SynonymGroupNew $synonymGroupNew + ) { + $this->synonymGroupIndex = $synonymGroupIndex; + $this->synonymGroupNew = $synonymGroupNew; + } + + /** + * Update Synonym Group. + * + * @param SynonymGroup $initialSynonymGroup + * @return void + */ + public function test(SynonymGroup $initialSynonymGroup) + { + //precondition + $initialSynonymGroup->persist(); + + $initialData = ($initialSynonymGroup->getData()); + $synonyms = $initialData['synonyms']; + + // Steps + $this->synonymGroupIndex->open(); + $this->synonymGroupIndex->getSynonymGroupGrid()->searchAndOpen(['synonyms' => $synonyms]); + $this->synonymGroupNew->getFormPageActions()->delete(); + $this->synonymGroupNew->getModalBlock()->acceptAlert(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.xml new file mode 100755 index 0000000000000000000000000000000000000000..e3c5140605307a8508675e0ef6f86a90796e577c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/DeleteSynonymGroupEntityTest.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Search\Test\TestCase\DeleteSynonymGroupEntityTest" summary="Delete Synonym Groups" ticketId="MAGETWO-47683"> + <variation name="DeleteSynonymGroupEntityTestVariation1"> + <data name="initialSynonymGroup/dataset" xsi:type="string">prepareMerge</data> + <data name="description" xsi:type="string">Delete Synonym Groups Successfully</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupDeleteMessage" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2927856876a059bbbcb7e2c580c997ff67df6ed7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\TestCase; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Search\Test\Page\Adminhtml\SynonymGroupNew; +use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Search\Test\Fixture\SynonymGroup; + +/** + * Preconditions: + * 1. Create Synonym Group view. + * + * Steps: + * 1. Open Backend. + * 2. Go to Marketing > Search Synonyms. + * 3. Click "New Synonym Group" button. + * 4. Fill data according to dataset. + * 5. Perform all assertions. + * + * @group Search_(MX) + * @ZephyrId MAGETWO-47684 + */ +class MergeSynonymGroupEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'MX'; + const TEST_TYPE = 'extended_acceptance_test'; + /* end tags */ + + /** + * Page Index. + * + * @var synonymGroupIndex + */ + protected $synonymGroupIndex; + + /** + * Page synonymGroupNew. + * + * @var SynonymGroupNew + */ + protected $synonymGroupNew; + + /** + * Fixture Factory. + * + * @var FixtureFactory + */ + protected $factory; + + /** + * Injection data. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @param SynonymGroupNew $synonymGroupNew + * @param FixtureFactory $factory + * @return void + */ + public function __inject( + SynonymGroupIndex $synonymGroupIndex, + SynonymGroupNew $synonymGroupNew, + FixtureFactory $factory + ) { + $this->synonymGroupIndex = $synonymGroupIndex; + $this->synonymGroupNew = $synonymGroupNew; + $this->factory = $factory; + } + + /** + * Merge Synonym Group. + * + * @param SynonymGroup $initialSynonymGroup + * @param SynonymGroup $synonymGroup + * @return void + */ + public function test(SynonymGroup $initialSynonymGroup, SynonymGroup $synonymGroup) + { + //precondition + $initialSynonymGroup->persist(); + + $initialData = ($initialSynonymGroup->getData()); + $synonyms = $initialData['synonyms']; + $synonyms = explode(',', $synonyms); + $data = $synonymGroup->getData(); + $data['synonyms'] = $synonyms[0] . ',' . $data['synonyms']; + $data['scope_id'] = [ + 'dataset' => 'default_store_view' + ]; + + $synonymGroup = $this->factory->createByCode('synonymGroup', ['data' => $data]); + + // Steps + $this->synonymGroupIndex->open(); + $this->synonymGroupIndex->getGridPageActions()->addNew(); + $this->synonymGroupNew->getSynonymGroupForm()->fill($synonymGroup); + $this->synonymGroupNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..9c9d886d494653f56779876fb9c72b26c917e59c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/MergeSynonymGroupEntityTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Search\Test\TestCase\MergeSynonymGroupEntityTest" summary="Merge Synonym Groups" ticketId="MAGETWO-47684"> + <variation name="MergeSynonymGroupEntityTestVariation1"> + <data name="initialSynonymGroup/dataset" xsi:type="string">prepareMerge</data> + <data name="description" xsi:type="string">Merge Synonym Groups Not Successfully</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">synonym_test_%isolation%</data> + <data name="synonymGroup/data/scope_id/dataset" xsi:type="string">default_store_view</data> + <data name="synonymGroup/data/mergeOnConflict" xsi:type="string">No</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymMergeErrorMessage" /> + </variation> + <variation name="MergeSynonymGroupEntityTestVariation2"> + <data name="initialSynonymGroup/dataset" xsi:type="string">prepareMerge</data> + <data name="description" xsi:type="string">Merge Synonym Groups Successfully</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">shoes_%isolation%,foot wear_%isolation%,mens shoes_%isolation%,women shoes_%isolation%</data> + <data name="synonymGroup/data/scope_id/dataset" xsi:type="string">default_store_view</data> + <data name="synonymGroup/data/mergeOnConflict" xsi:type="string">Yes</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..de0a52e459582130e9315ea0738ddea9fff4f397 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Search\Test\TestCase; + +use Magento\Search\Test\Page\Adminhtml\SynonymGroupIndex; +use Magento\Search\Test\Page\Adminhtml\SynonymGroupNew; +use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Search\Test\Fixture\SynonymGroup; + +/** + * Preconditions: + * 1. Create Synonym Group view. + * + * Steps: + * 1. Open Backend. + * 2. Go to Marketing > Search Synonyms. + * 3. Open created Synonym Group. + * 4. Fill data according to dataset. + * 5. Perform all assertions. + * + * @group Search_(MX) + * @ZephyrId MAGETWO-49412 + */ +class UpdateSynonymGroupEntityTest extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'MX'; + const TEST_TYPE = 'extended_acceptance_test'; + /* end tags */ + + /** + * Page Index. + * + * @var synonymGroupIndex + */ + protected $synonymGroupIndex; + + /** + * Page synonymGroupNew. + * + * @var SynonymGroupNew + */ + protected $synonymGroupNew; + + /** + * Fixture Factory. + * + * @var FixtureFactory + */ + protected $factory; + + /** + * Injection data. + * + * @param SynonymGroupIndex $synonymGroupIndex + * @param SynonymGroupNew $synonymGroupNew + * @param FixtureFactory $factory + * @return void + */ + public function __inject( + SynonymGroupIndex $synonymGroupIndex, + SynonymGroupNew $synonymGroupNew, + FixtureFactory $factory + ) { + $this->synonymGroupIndex = $synonymGroupIndex; + $this->synonymGroupNew = $synonymGroupNew; + $this->factory = $factory; + } + + /** + * Update Synonym Group. + * + * @param SynonymGroup $initialSynonymGroup + * @param SynonymGroup $synonymGroup + * @return void + */ + public function test(SynonymGroup $initialSynonymGroup, SynonymGroup $synonymGroup) + { + //precondition + $initialSynonymGroup->persist(); + + $initialData = ($initialSynonymGroup->getData()); + $synonyms = $initialData['synonyms']; + + // Steps + $this->synonymGroupIndex->open(); + $this->synonymGroupIndex->getSynonymGroupGrid()->searchAndOpen(['synonyms' => $synonyms]); + $this->synonymGroupNew->getSynonymGroupForm()->fill($synonymGroup); + $this->synonymGroupNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.xml new file mode 100644 index 0000000000000000000000000000000000000000..d59e0e919fbc6095dc990f38e358b4e1a06d7b76 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/UpdateSynonymGroupEntityTest.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> + <testCase name="Magento\Search\Test\TestCase\UpdateSynonymGroupEntityTest" summary="Update Synonym Groups" ticketId="MAGETWO-49412"> + <variation name="UpdateSynonymGroupEntityTestVariation1"> + <data name="initialSynonymGroup/dataset" xsi:type="string">prepareMerge</data> + <data name="description" xsi:type="string">Update Synonym Groups Successfully</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> + <data name="synonymGroup/data/synonyms" xsi:type="string">new_synonym_%isolation%</data> + <data name="synonymGroup/data/scope_id/dataset" xsi:type="string">all_store_views</data> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage" /> + <constraint name="Magento\Search\Test\Constraint\AssertSynonymGroupInGrid" /> + </variation> + </testCase> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/etc/curl/di.xml b/dev/tests/functional/tests/app/Magento/Search/Test/etc/curl/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..5dad85c0b7ec68e2abdf2120c91f525f42675563 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/etc/curl/di.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <preference for="\Magento\Search\Test\Handler\SynonymGroup\SynonymGroupInterface" type="\Magento\Search\Test\Handler\SynonymGroup\Curl" /> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Search/Test/etc/di.xml new file mode 100644 index 0000000000000000000000000000000000000000..9d651d917789f38e8c34a6eb903b18613f888657 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Search/Test/etc/di.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\Search\Test\Constraint\AssertSynonymGroupSuccessSaveMessage"> + <arguments> + <argument name="severity" xsi:type="string">high</argument> + </arguments> + </type> + <type name="Magento\Search\Test\Constraint\AssertSynonymGroupDeleteMessage"> + <arguments> + <argument name="severity" xsi:type="string">high</argument> + </arguments> + </type> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml index f14e959ce90cb0b427f74598ca9db7459259c828..672fd79994df8bb3e983f116d73bab3f42a69f03 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/Store.xml @@ -44,5 +44,13 @@ <field name="code" xsi:type="string">de%isolation%</field> <field name="is_active" xsi:type="string">Enabled</field> </dataset> + <dataset name="custom_store"> + <field name="group_id" xsi:type="array"> + <item name="dataset" xsi:type="string">custom_new_group</item> + </field> + <field name="name" xsi:type="string">Store_%isolation%</field> + <field name="code" xsi:type="string">store_%isolation%</field> + <field name="is_active" xsi:type="string">Enabled</field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.xml b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.xml index b04cb4b8af12cd7d61dcd23f704dde49b78037ed..c7c2083d9bc0aefbf38fd6062178c7f971add39c 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/Repository/StoreGroup.xml @@ -27,5 +27,15 @@ <item name="dataset" xsi:type="string">default_category</item> </field> </dataset> + + <dataset name="custom_new_group"> + <field name="website_id" xsi:type="array"> + <item name="dataset" xsi:type="string">custom_website</item> + </field> + <field name="name" xsi:type="string">store_name_%isolation%</field> + <field name="root_category_id" xsi:type="array"> + <item name="dataset" xsi:type="string">default_category</item> + </field> + </dataset> </repository> </config> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRate.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRate.xml index d7372e891138a93cda2ba1e3d7e71f12745cd123..de06122b9db946fa11a5c52e3b85f53432d145f0 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRate.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRate.xml @@ -29,6 +29,14 @@ <field name="mtf_dataset_name" xsi:type="string">US-CA-*-Rate 1</field> </dataset> + <dataset name="US-IL-Rate_1"> + <field name="code" xsi:type="string">Tax Rate %isolation%</field> + <field name="rate" xsi:type="string">8.25</field> + <field name="tax_country_id" xsi:type="string">United States</field> + <field name="tax_postcode" xsi:type="string">*</field> + <field name="tax_region_id" xsi:type="string">23</field> + </dataset> + <dataset name="US-NY-Rate_1"> <field name="tax_calculation_rate_id" xsi:type="string">2</field> <field name="tax_country_id" xsi:type="string">US</field> diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml index 26d4869dbaff39e325128723044e04b15d743001..e9297a7185a4e231846cd2591a5b804e43419c45 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Repository/TaxRule.xml @@ -63,6 +63,27 @@ <field name="position" xsi:type="string">0</field> </dataset> + <dataset name="us_illinois_tax_rule"> + <field name="code" xsi:type="string">TaxIdentifier%isolation%</field> + <field name="tax_rate" xsi:type="array"> + <item name="dataset" xsi:type="array"> + <item name="0" xsi:type="string">US-IL-Rate_1</item> + </item> + </field> + <field name="tax_customer_class" xsi:type="array"> + <item name="dataset" xsi:type="array"> + <item name="0" xsi:type="string">retail_customer</item> + </item> + </field> + <field name="tax_product_class" xsi:type="array"> + <item name="dataset" xsi:type="array"> + <item name="0" xsi:type="string">taxable_goods</item> + </item> + </field> + <field name="priority" xsi:type="string">0</field> + <field name="position" xsi:type="string">0</field> + </dataset> + <dataset name="tax_rule_default"> <field name="code" xsi:type="string">TaxIdentifier%isolation%</field> <field name="tax_rate" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php new file mode 100644 index 0000000000000000000000000000000000000000..14c05cc17cc29991a42b09db538afc8efc45c937 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\Block; + +use Magento\Mtf\Block\Block; +use Magento\Mtf\Client\ElementInterface; +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\InjectableFixture; + +class CreditCards extends Block +{ + /** + * Delete button locator for popup window. + * + * @var string + */ + private $deleteButton = './/*[@data-type="popup"]//span[text()="Delete"]'; + + /** + * Delete saved credit card. + * + * @param ElementInterface $creditCard + */ + public function deleteCreditCard(ElementInterface $creditCard) + { + $creditCard->click(); + $this->browser->selectWindow(); + $this->browser->find($this->deleteButton, Locator::SELECTOR_XPATH)->click(); + $this->browser->selectWindow(); + } + + /** + * Get saved credit cards on My Credit Cards page. + * + * @return array + */ + public function getCreditCards() + { + $result = []; + $elements = $this->_rootElement->getElements('./tbody/tr', Locator::SELECTOR_XPATH); + foreach ($elements as $row) { + $number = substr($row->find('./td[@data-th="Card Number"]', Locator::SELECTOR_XPATH)->getText(), -4, 4); + $deleteButton = $row->find( + "./td[contains(text(), '{$number}')]/following-sibling::td[@data-th='Actions']//span[text()='Delete']", + Locator::SELECTOR_XPATH + ); + $result[$number] = $deleteButton; + } + return $result; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Block/VaultPayment.php b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/VaultPayment.php new file mode 100644 index 0000000000000000000000000000000000000000..98d10821d87a125c1313b3588a1f484013b3a9dd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/VaultPayment.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\Block; + +use Magento\Mtf\Block\Block; +use Magento\Mtf\Client\ElementInterface; +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\InjectableFixture; + +class VaultPayment extends Block +{ + /** + * Credit card selector. + */ + private $creditCardSelector = './/*[contains(@for, "_vault_item")]/span[text()="%s"]'; + + /** + * Verify if saved credit card is present as a payment option. + * + * @param string $creditCard + * @return bool + */ + public function isSavedCreditCardPresent($creditCard) + { + $paymentLabelSelector = sprintf($this->creditCardSelector, $creditCard); + return $this->browser->find($paymentLabelSelector, Locator::SELECTOR_XPATH)->isVisible(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardDeletedMessage.php b/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardDeletedMessage.php new file mode 100644 index 0000000000000000000000000000000000000000..93987ecfb437fc983939a5882674c00466d60baf --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardDeletedMessage.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\Constraint; + +use Magento\Vault\Test\Page\MyCreditCards; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertCreditCardDeletedMessage + * Assert that success message is correct + */ +class AssertCreditCardDeletedMessage extends AbstractConstraint +{ + /** + * Message of success deletion of credit card. + */ + const SUCCESS_MESSAGE = 'Credit Card was successfully removed'; + + /** + * Assert that message of success deletion of credit card is present. + * + * @param MyCreditCards $myCreditCards + */ + public function processAssert(MyCreditCards $myCreditCards) + { + \PHPUnit_Framework_Assert::assertEquals( + self::SUCCESS_MESSAGE, + $myCreditCards->getMessagesBlock()->getSuccessMessage(), + 'Message of success deletion of credit card is not present or wrong.' + ); + } + + /** + * Returns string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return 'Success message on My Credit Cards page is correct.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardNotPresentOnCheckout.php b/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardNotPresentOnCheckout.php new file mode 100644 index 0000000000000000000000000000000000000000..8b1bcd0260b90b1277ea6fba45b6737cef22ba08 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Constraint/AssertCreditCardNotPresentOnCheckout.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\Constraint; + +use Magento\Checkout\Test\Page\CheckoutOnepage; +use Magento\Mtf\Constraint\AbstractConstraint; + +/** + * Class AssertCreditCardNotPresentOnCheckout + * Assert that success message is correct + */ +class AssertCreditCardNotPresentOnCheckout extends AbstractConstraint +{ + /** + * Assert that credit card is not present on checkout. + * + * @param CheckoutOnepage $checkoutOnepage + * @param $deletedCreditCard + */ + public function processAssert( + CheckoutOnepage $checkoutOnepage, + $deletedCreditCard + ) { + \PHPUnit_Framework_Assert::assertFalse( + $checkoutOnepage->getVaultPaymentBlock()->isSavedCreditCardPresent($deletedCreditCard), + 'Credit card is present on checkout.' + ); + } + + /** + * Returns string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return 'Credit card is not present on checkout.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Page/CheckoutOnepage.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/Page/CheckoutOnepage.xml new file mode 100644 index 0000000000000000000000000000000000000000..2e66b9153b7625c81442868c7056cd0a868582df --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Page/CheckoutOnepage.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="CheckoutOnepage" mca="checkout" module="Magento_Checkout"> + <block name="vaultPaymentBlock" class="Magento\Vault\Test\Block\VaultPayment" locator="#checkout-step-payment" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Page/MyCreditCards.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/Page/MyCreditCards.xml new file mode 100644 index 0000000000000000000000000000000000000000..a3d83dad8f732e7cf4b3cf27f86884b03c1dd4a8 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Page/MyCreditCards.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + --> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/pages.xsd"> + <page name="MyCreditCards" mca="vault/cards/listaction" module="Magento_Vault"> + <block name="creditCardsBlock" class="Magento\Vault\Test\Block\CreditCards" locator=".table-credit-cards" strategy="css selector" /> + <block name="messagesBlock" class="Magento\Backend\Test\Block\Messages" locator=".page.messages" strategy="css selector" /> + </page> +</config> diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6964feb2533ed8093abe31f9e3aaa7241c809447 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestCase/DeleteSavedCreditCardTest.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\TestCase; + +use Magento\Mtf\TestCase\Scenario; + +/** + * Preconditions: + * 1. Credit card is saved during checkout + * + * Steps: + * 1. Log in Storefront. + * 2. Click 'My Account' link. + * 3. Click 'My Credit Cards' tab. + * 4. Click the 'Delete' button next to stored credit card. + * 5. Click 'Delete' button. + * 6. Go to One page Checkout + * 7. Perform assertions. + * + * @group Vault_(CS) + * @ZephyrId MAGETWO-48086 + */ +class DeleteSavedCreditCardTest extends Scenario +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + const TEST_TYPE = '3rd_party_test'; + /* end tags */ + + /** + * Runs delete saved credit card test. + * + * @return void + */ + public function test() + { + $this->executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php new file mode 100644 index 0000000000000000000000000000000000000000..e1927de90f7380df870bb425d98d2c57e264f319 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/TestStep/DeleteCreditCardFromMyAccountStep.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Vault\Test\TestStep; + +use Magento\Customer\Test\Fixture\Customer; +use Magento\Customer\Test\Page\CustomerAccountIndex; +use Magento\Mtf\Fixture\FixtureFactory; +use Magento\Mtf\Fixture\InjectableFixture; +use Magento\Mtf\ObjectManager; +use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Vault\Test\Constraint\AssertCreditCardDeletedMessage; +use Magento\Vault\Test\Page\MyCreditCards; + +class DeleteCreditCardFromMyAccountStep implements TestStepInterface +{ + /** + * @var Customer + */ + private $customer; + + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var CustomerAccountIndex + */ + private $customerAccountIndex; + + /** + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * @var \Magento\Mtf\Fixture\FixtureInterface + */ + private $creditCard; + + /** + * @var AssertCreditCardDeletedMessage + */ + private $assertCreditCardDeletedMessage; + + /** + * @var $myCreditCardsPage + */ + private $myCreditCardsPage; + + /** + * DeleteCreditCardFromMyAccountStep constructor. + * + * @param MyCreditCards $myCreditCardsPage + * @param Customer $customer + * @param ObjectManager $objectManager + * @param CustomerAccountIndex $customerAccountIndex + * @param FixtureFactory $fixtureFactory + * @param AssertCreditCardDeletedMessage $assertCreditCardDeletedMessage + * @param array $creditCard + * @param string $creditCardClass + */ + public function __construct( + MyCreditCards $myCreditCardsPage, + Customer $customer, + ObjectManager $objectManager, + CustomerAccountIndex $customerAccountIndex, + FixtureFactory $fixtureFactory, + AssertCreditCardDeletedMessage $assertCreditCardDeletedMessage, + array $creditCard, + $creditCardClass = 'credit_card' + ) { + $this->myCreditCardsPage = $myCreditCardsPage; + $this->customer = $customer; + $this->objectManager = $objectManager; + $this->customerAccountIndex = $customerAccountIndex; + $this->fixtureFactory = $fixtureFactory; + $this->assertCreditCardDeletedMessage = $assertCreditCardDeletedMessage; + $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]); + } + + /** + * @inheritdoc + * + * @return array + */ + public function run() + { + $this->objectManager->create( + 'Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep', + ['customer' => $this->customer] + )->run(); + $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards'); + $myCreditCardsBlock = $this->myCreditCardsPage->getCreditCardsBlock(); + + $creditCardData = $this->creditCard->getData(); + $creditCardNumber = preg_grep('/([a-z]+)_number/', array_flip($creditCardData)); + $lastFourDigits = substr(key($creditCardNumber), -4, 4); + + $availableCreditCards = $myCreditCardsBlock->getCreditCards(); + if (key_exists($lastFourDigits, $availableCreditCards)) { + $myCreditCardsBlock->deleteCreditCard($availableCreditCards[$lastFourDigits]); + } + $this->assertCreditCardDeletedMessage->processAssert($this->myCreditCardsPage); + + return ['deletedCreditCard' => $lastFourDigits]; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml index 5277e5aa4c02e7e55a2c59cac1390262dee61997..5ff49112a62ee207287d3fc7ffce19e67c97e067 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/etc/testcase.xml @@ -6,6 +6,25 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd"> + <scenario name="DeleteSavedCreditCardTest" firstStep="setupConfiguration"> + <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> + <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> + <step name="addProductsToTheCart" module="Magento_Checkout" next="proceedToCheckout" /> + <step name="proceedToCheckout" module="Magento_Checkout" next="createCustomer" /> + <step name="createCustomer" module="Magento_Customer" next="selectCheckoutMethod" /> + <step name="selectCheckoutMethod" module="Magento_Checkout" next="fillShippingAddress" /> + <step name="fillShippingAddress" module="Magento_Checkout" next="fillShippingMethod" /> + <step name="fillShippingMethod" module="Magento_Checkout" next="selectPaymentMethod" /> + <step name="selectPaymentMethod" module="Magento_Checkout" next="saveCreditCard" /> + <step name="saveCreditCard" module="Magento_Vault" next="fillBillingInformation" /> + <step name="fillBillingInformation" module="Magento_Checkout" next="placeOrder" /> + <step name="placeOrder" module="Magento_Checkout" next="deleteCreditCardFromMyAccount" /> + <step name="deleteCreditCardFromMyAccount" module="Magento_Vault" next="addProductsToTheCartVault" /> + <step name="addProductsToTheCartVault" alias="addProductsToTheCart" module="Magento_Checkout" next="estimateShippingAndTaxVault" /> + <step name="estimateShippingAndTaxVault" alias="estimateShippingAndTax" module="Magento_Checkout" next="clickProceedToCheckoutVault" /> + <step name="clickProceedToCheckoutVault" alias="clickProceedToCheckout" module="Magento_Checkout" next="fillShippingMethodVault" /> + <step name="fillShippingMethodVault" alias="fillShippingMethod" module="Magento_Checkout" /> + </scenario> <scenario name="UseVaultOnCheckoutTest" firstStep="setupConfiguration"> <step name="setupConfiguration" module="Magento_Config" next="createProducts" /> <step name="createProducts" module="Magento_Catalog" next="addProductsToTheCart" /> diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index b87cea882de1840af576939ed75fca516f75e85f..2c38a3e724eb357d8c6ea1c09fe3ac70f753e340 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -12,6 +12,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Config\ConfigOptionsListConstants; use Magento\Framework\App\DeploymentConfig\Reader; +use Magento\Framework\Filesystem\Glob; /** * Encapsulates application installation, initialization and uninstall @@ -426,7 +427,7 @@ class Application * @see \Magento\Setup\Mvc\Bootstrap\InitParamListener::BOOTSTRAP_PARAM */ $this->_shell->execute( - 'php -f %s setup:uninstall -n --magento-init-params=%s', + PHP_BINARY . ' -f %s setup:uninstall -vvv -n --magento-init-params=%s', [BP . '/bin/magento', $this->getInitParamsQuery()] ); } @@ -459,15 +460,18 @@ class Application // run install script $this->_shell->execute( - 'php -f %s setup:install ' . implode(' ', array_keys($installParams)), + PHP_BINARY . ' -f %s setup:install -vvv ' . implode(' ', array_keys($installParams)), array_merge([BP . '/bin/magento'], array_values($installParams)) ); // enable only specified list of caches $initParamsQuery = $this->getInitParamsQuery(); - $this->_shell->execute('php -f %s cache:disable --bootstrap=%s', [BP . '/bin/magento', $initParamsQuery]); $this->_shell->execute( - 'php -f %s cache:enable %s %s %s %s --bootstrap=%s', + PHP_BINARY . ' -f %s cache:disable -vvv --bootstrap=%s', + [BP . '/bin/magento', $initParamsQuery] + ); + $this->_shell->execute( + PHP_BINARY . ' -f %s cache:enable -vvv %s %s %s %s --bootstrap=%s', [ BP . '/bin/magento', \Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER, @@ -491,9 +495,9 @@ class Application */ private function copyAppConfigFiles() { - $globalConfigFiles = glob( + $globalConfigFiles = Glob::glob( $this->_globalConfigDir . '/{di.xml,*/di.xml,vendor_path.php}', - GLOB_BRACE + Glob::GLOB_BRACE ); foreach ($globalConfigFiles as $file) { $targetFile = $this->_configDir . str_replace($this->_globalConfigDir, '', $file); diff --git a/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Settings.php b/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Settings.php index df65d4dd37d6ad68d66a19d7904cc0ea82ec3852..b69b9f7c6ef3abb98c3865dcdd085cc72df7108a 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Settings.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Bootstrap/Settings.php @@ -4,11 +4,13 @@ * See COPYING.txt for license details. */ +namespace Magento\TestFramework\Bootstrap; + +use Magento\Framework\Filesystem\Glob; + /** * Convenient access to the bootstrap settings */ -namespace Magento\TestFramework\Bootstrap; - class Settings { /** @@ -142,7 +144,7 @@ class Settings $allPatterns = preg_split('/\s*;\s*/', trim($pattern), -1, PREG_SPLIT_NO_EMPTY); foreach ($allPatterns as $onePattern) { $onePattern = $this->_resolvePath($onePattern); - $files = glob($onePattern, GLOB_BRACE); + $files = Glob::glob($onePattern, Glob::GLOB_BRACE); $result = array_merge($result, $files); } return $result; diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml index 5099d50bca6438c3db7cdea5eafc91a7047771d1..2ed98036e608663cae7b5eca3ba63355c732dce9 100644 --- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml +++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/_files/expected/config.xml @@ -683,6 +683,7 @@ <depends> <field id="enable_in_context_checkout">1</field> </depends> + <validate>required-entry</validate> </field> <field id="enable_express_checkout_bml" translate="label comment" type="select" sortOrder="23" showInDefault="1" showInWebsite="1"> <label>Enable PayPal Credit</label> diff --git a/dev/tests/integration/testsuite/Magento/Theme/Observer/ThemeRegistrationObserverTest.php b/dev/tests/integration/testsuite/Magento/Theme/Observer/ThemeRegistrationObserverTest.php deleted file mode 100644 index d4f7b8f2a8a2674ce92068153648d8fe9070504e..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Theme/Observer/ThemeRegistrationObserverTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -/** - * Test theme observer - */ -namespace Magento\Theme\Observer; - -class ThemeRegistrationObserverTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Magento\Framework\Event\Observer - */ - protected $_eventObserver; - - /** - * @var \Magento\TestFramework\ObjectManager - */ - protected $_objectManager; - - protected function setUp() - { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_eventObserver = $this->_createEventObserverForThemeRegistration(); - } - - /** - * Theme registration test - * - * @magentoDbIsolation enabled - * @magentoAppIsolation enabled - */ - public function testThemeRegistration() - { - $themeRegistration = $this->getMock( - 'Magento\Theme\Model\Theme\Registration', - ['register'], - [ - $this->_objectManager->create('Magento\Theme\Model\ResourceModel\Theme\Data\CollectionFactory'), - $this->_objectManager->create('Magento\Theme\Model\Theme\Data\Collection'), - $this->_objectManager->create('Magento\Framework\Filesystem') - ] - ); - $themeRegistration->expects($this->once())->method('register'); - $this->_objectManager->addSharedInstance($themeRegistration, 'Magento\Theme\Model\Theme\Registration'); - - /** @var $observer \Magento\Theme\Observer\ThemeRegistrationObserver */ - $observer = $this->_objectManager->create('Magento\Theme\Observer\ThemeRegistrationObserver'); - $observer->execute($this->_eventObserver); - } - - /** - * Create event observer for theme registration - * - * @return \Magento\Framework\Event\Observer - */ - protected function _createEventObserverForThemeRegistration() - { - $response = $this->_objectManager->create( - 'Magento\Framework\DataObject', - ['data' => ['additional_options' => []]] - ); - $event = $this->_objectManager->create( - 'Magento\Framework\Event', - ['data' => ['response_object' => $response]] - ); - return $this->_objectManager->create( - 'Magento\Framework\Event\Observer', - ['data' => ['event' => $event]] - ); - } -} diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/ConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/ConfigTest.php index 92b03596d4b3598e350b5669fb7cd25f7e8099f3..e03e8e46d9df9202844093b5b0a2706bdbd3af8d 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/ConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/ConfigTest.php @@ -13,8 +13,8 @@ class ConfigTest extends \Magento\TestFramework\Integrity\AbstractConfig $expectedErrors = [ "Element 'code': [facet 'pattern'] The value 'e_GB' is not accepted by the pattern", "Element 'code': 'e_GB' is not a valid value of the atomic type 'codeType'", - "Element 'vendor': [facet 'pattern'] The value 'Magento' is not accepted by the pattern", - "Element 'vendor': 'Magento' is not a valid value of the atomic type", + "Element 'vendor': [facet 'pattern'] The value 'Magento1' is not accepted by the pattern", + "Element 'vendor': 'Magento1' is not a valid value of the atomic type", "Element 'sort_odrer': This element is not expected. Expected is", ]; parent::testSchemaUsingInvalidXml($expectedErrors); diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/_files/known_invalid.xml b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/_files/known_invalid.xml index be5388b2959259ebe40a82442a6d39a49c7561b2..e6908e8a3845304630a618ab0e38764831517ab4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/_files/known_invalid.xml +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/App/Language/_files/known_invalid.xml @@ -7,7 +7,7 @@ --> <language xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/Language/package.xsd"> <code>e_GB</code> - <vendor>Magento</vendor> + <vendor>Magento1</vendor> <sort_odrer>100</sort_odrer> <use code="en_GB"/> </language> diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php index 085270afadeabd18bcb57fcbb4e752b9cfbb4ee6..cb7c70c581392fc2ceccb2a95f4f77bcba457107 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php @@ -5,26 +5,15 @@ */ namespace Magento\Test\Integrity; +use Magento\Framework\App\Bootstrap; use Magento\Framework\Component\ComponentRegistrar; use Magento\Framework\Composer\MagentoComponent; -use Magento\Framework\App\Utility\Files; -use Magento\Framework\Shell; -use Magento\Framework\Exception\LocalizedException; /** * A test that enforces validity of composer.json files and any other conventions in Magento components */ class ComposerTest extends \PHPUnit_Framework_TestCase { - /** - * @var \Magento\Framework\Shell - */ - private static $shell; - - /** - * @var bool - */ - private static $isComposerAvailable; /** * @var string @@ -42,20 +31,16 @@ class ComposerTest extends \PHPUnit_Framework_TestCase private static $dependencies; /** - * @var string + * @var \Magento\Framework\ObjectManagerInterface */ - private static $composerPath = 'composer'; + private static $objectManager; public static function setUpBeforeClass() { - if (defined('TESTS_COMPOSER_PATH')) { - self::$composerPath = TESTS_COMPOSER_PATH; - } - self::$shell = self::createShell(); - self::$isComposerAvailable = self::isComposerAvailable(); self::$root = BP; self::$rootJson = json_decode(file_get_contents(self::$root . '/composer.json'), true); self::$dependencies = []; + self::$objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager(); } public function testValidComposerJson() @@ -111,9 +96,10 @@ class ComposerTest extends \PHPUnit_Framework_TestCase */ private function validateComposerJsonFile($path) { - if (self::$isComposerAvailable) { - self::$shell->execute(self::$composerPath . ' validate --working-dir=%s', [$path]); - } + /** @var \Magento\Framework\Composer\MagentoComposerApplicationFactory $appFactory */ + $appFactory = self::$objectManager->get('Magento\Framework\Composer\MagentoComposerApplicationFactory'); + $app = $appFactory->create(); + $app->runComposerCommand(['command' => 'validate'], $path); } /** @@ -333,31 +319,6 @@ class ComposerTest extends \PHPUnit_Framework_TestCase return strtolower("{$vendor}/{$package}"); } - /** - * Create shell wrapper - * - * @return \Magento\Framework\Shell - */ - private static function createShell() - { - return new Shell(new Shell\CommandRenderer, null); - } - - /** - * Check if composer command is available in the environment - * - * @return bool - */ - private static function isComposerAvailable() - { - try { - self::$shell->execute(self::$composerPath . ' --version'); - } catch (LocalizedException $e) { - return false; - } - return true; - } - public function testComponentPathsInRoot() { if (!isset(self::$rootJson['extra']) || !isset(self::$rootJson['extra']['component_paths'])) { diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/FilesystemTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/FilesystemTest.php index bb025beb6f4444213cfffbe9c388e43023fe5d69..1f9056f3fa3913e8fc81b52574153e3487e03bc4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/FilesystemTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/FilesystemTest.php @@ -8,6 +8,7 @@ namespace Magento\Test\Legacy; use Magento\Framework\Component\ComponentRegistrar; +use Magento\Framework\Filesystem\Glob; class FilesystemTest extends \PHPUnit_Framework_TestCase { @@ -115,7 +116,7 @@ class FilesystemTest extends \PHPUnit_Framework_TestCase foreach ($pathsToCheck as $path => $allowed) { $allowedFiles = $allowed['allowed_files']; $allowedDirs = $allowed['allowed_dirs']; - $foundFiles = glob($path, GLOB_BRACE); + $foundFiles = Glob::glob($path, Glob::GLOB_BRACE); if (!$foundFiles) { continue; } diff --git a/lib/internal/Magento/Framework/App/Language/package.xsd b/lib/internal/Magento/Framework/App/Language/package.xsd index d1f98609cc607b41b9ac227532247628bd53f3d8..d90f6ea172f14317ee4e5318585496c70c4e83b8 100644 --- a/lib/internal/Magento/Framework/App/Language/package.xsd +++ b/lib/internal/Magento/Framework/App/Language/package.xsd @@ -35,7 +35,7 @@ <xs:simpleType name="vendorType"> <xs:restriction base="xs:string"> - <xs:pattern value="[a-z\-_]+"/> + <xs:pattern value="[a-zA-Z\-_]+"/> </xs:restriction> </xs:simpleType> diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index f2cf5b781687e249c6bd9f8cc18a5b138bdf9597..157ff51467ac8b9695c11da5770c08ee4796aa0c 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -9,6 +9,7 @@ namespace Magento\Framework\App\Utility; use Magento\Framework\Component\ComponentRegistrar; use Magento\Framework\Component\DirSearch; use Magento\Framework\View\Design\Theme\ThemePackageList; +use Magento\Framework\Filesystem\Glob; /** * A helper to gather specific kind of files in Magento application @@ -235,8 +236,8 @@ class Files { if ($flags & self::INCLUDE_PUB_CODE) { return array_merge( - glob(BP . '/*.php', GLOB_NOSORT), - glob(BP . '/pub/*.php', GLOB_NOSORT) + Glob::glob(BP . '/*.php', Glob::GLOB_NOSORT), + Glob::glob(BP . '/pub/*.php', Glob::GLOB_NOSORT) ); } return []; @@ -1191,9 +1192,9 @@ class Files { $result = []; foreach ($dirPatterns as $oneDirPattern) { - $oneDirPattern = str_replace('\\', '/', $oneDirPattern); - $entriesInDir = glob("{$oneDirPattern}/{$fileNamePattern}", GLOB_NOSORT | GLOB_BRACE); - $subDirs = glob("{$oneDirPattern}/*", GLOB_ONLYDIR | GLOB_NOSORT | GLOB_BRACE); + $oneDirPattern = str_replace('\\', '/', $oneDirPattern); + $entriesInDir = Glob::glob("{$oneDirPattern}/{$fileNamePattern}", Glob::GLOB_NOSORT | Glob::GLOB_BRACE); + $subDirs = Glob::glob("{$oneDirPattern}/*", Glob::GLOB_ONLYDIR | Glob::GLOB_NOSORT | Glob::GLOB_BRACE); $filesInDir = array_diff($entriesInDir, $subDirs); if ($recursive) { @@ -1212,10 +1213,13 @@ class Files */ public function getDiConfigs($asDataSet = false) { - $primaryConfigs = glob(BP . '/app/etc/{di.xml,*/di.xml}', GLOB_BRACE); + $primaryConfigs = Glob::glob(BP . '/app/etc/{di.xml,*/di.xml}', Glob::GLOB_BRACE); $moduleConfigs = []; foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) { - $moduleConfigs = array_merge($moduleConfigs, glob($moduleDir . '/etc/{di,*/di}.xml', GLOB_BRACE)); + $moduleConfigs = array_merge( + $moduleConfigs, + Glob::glob($moduleDir . '/etc/{di,*/di}.xml', Glob::GLOB_BRACE) + ); } $configs = array_merge($primaryConfigs, $moduleConfigs); @@ -1383,7 +1387,7 @@ class Files $key = __METHOD__ . "/{$module}"; if (!isset(self::$_cache[$key])) { $files = self::getFiles( - [$this->componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_'. $module)], + [$this->componentRegistrar->getPath(ComponentRegistrar::MODULE, 'Magento_' . $module)], '*.php' ); self::$_cache[$key] = $files; @@ -1456,7 +1460,7 @@ class Files * Note that glob() for directories will be returned as is, * but passing directory is supported by the tools (phpcpd, phpmd, phpcs) */ - $files = glob(BP . '/' . $pattern, GLOB_BRACE); + $files = Glob::glob(BP . '/' . $pattern, Glob::GLOB_BRACE); } else { throw new \UnexpectedValueException( "Incorrect pattern record '$pattern'. Supported formats: " @@ -1501,7 +1505,7 @@ class Files } else { $componentDir = $this->componentRegistrar->getPath($type, $componentName); if (!empty($componentDir)) { - $files = array_merge($files, glob($componentDir . '/' . $pathPattern, GLOB_BRACE)); + $files = array_merge($files, Glob::glob($componentDir . '/' . $pathPattern, Glob::GLOB_BRACE)); } } } diff --git a/lib/internal/Magento/Framework/Backup/Snapshot.php b/lib/internal/Magento/Framework/Backup/Snapshot.php index f01a1a874f8ecec8bad3cc64624ef9c820046e14..091c3830f5d06ed811a143f35b648318416e1d5e 100644 --- a/lib/internal/Magento/Framework/Backup/Snapshot.php +++ b/lib/internal/Magento/Framework/Backup/Snapshot.php @@ -113,7 +113,7 @@ class Snapshot extends Filesystem protected function _createDbBackupInstance() { return $this->_backupFactory->create(Factory::TYPE_DB) - ->setBackupExtension('gz') + ->setBackupExtension('sql') ->setTime($this->getTime()) ->setBackupsDir($this->_filesystem->getDirectoryWrite(DirectoryList::VAR_DIR)->getAbsolutePath()) ->setResourceModel($this->getResourceModel()); diff --git a/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php b/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php index ce941c3ee90b601ca841bb335dd3c244f46b0573..e725fa0d1c17491eb37d67bff2d10a89550762a5 100644 --- a/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php +++ b/lib/internal/Magento/Framework/Backup/Test/Unit/SnapshotTest.php @@ -17,7 +17,7 @@ class SnapshotTest extends \PHPUnit_Framework_TestCase [$filesystem, $backupFactory] ); - $file = 'var/backup/2.gz'; + $file = 'var/backup/2.sql'; $manager->expects($this->once())->method('getBackupFilename')->will($this->returnValue($file)); $model = new \Magento\Framework\Backup\Snapshot($filesystem, $backupFactory); diff --git a/lib/internal/Magento/Framework/Currency.php b/lib/internal/Magento/Framework/Currency.php index 94fc8d579d373ade20b5dd90b634a390038426e5..26c1acaf295f754e68e864f0c4d3fc04bc0595be 100644 --- a/lib/internal/Magento/Framework/Currency.php +++ b/lib/internal/Magento/Framework/Currency.php @@ -5,6 +5,25 @@ */ namespace Magento\Framework; -class Currency extends \Zend_Currency implements \Magento\Framework\CurrencyInterface +use Magento\Framework\App\CacheInterface; + +class Currency extends \Zend_Currency implements CurrencyInterface { + /** + * Creates a currency instance. + * + * @param CacheInterface $appCache + * @param string|array $options Options array or currency short name when string is given + * @param string $locale Locale name + */ + public function __construct( + CacheInterface $appCache, + $options = null, + $locale = null + ) { + // set Zend cache to low level frontend app cache + $lowLevelFrontendCache = $appCache->getFrontend()->getLowLevelFrontend(); + \Zend_Currency::setCache($lowLevelFrontendCache); + parent::__construct($options, $locale); + } } diff --git a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php index a74447f2a91ead39b437aa8ad05cabf4fffe8e51..66b44fce6e6bfd486f005bb9fb69e9dc22fbdfe0 100644 --- a/lib/internal/Magento/Framework/Filesystem/Directory/Write.php +++ b/lib/internal/Magento/Framework/Filesystem/Directory/Write.php @@ -67,7 +67,7 @@ class Write extends Read implements WriteInterface $absolutePath = $this->driver->getAbsolutePath($this->path, $path); if (!$this->driver->isFile($absolutePath)) { throw new FileSystemException( - new \Magento\Framework\Phrase('The "%1" file doesn\'t exist or not a file', [$absolutePath]) + new \Magento\Framework\Phrase('The file "%1" doesn\'t exist or not a file', [$absolutePath]) ); } } diff --git a/lib/internal/Magento/Framework/Filesystem/Driver/File.php b/lib/internal/Magento/Framework/Filesystem/Driver/File.php index c95edc52d76fb783e64116b28cd11d2fefab55da..8cc4cacb9bbd46db2aa99904441da46017978be8 100644 --- a/lib/internal/Magento/Framework/Filesystem/Driver/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Driver/File.php @@ -9,6 +9,7 @@ namespace Magento\Framework\Filesystem\Driver; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Filesystem\DriverInterface; +use Magento\Framework\Filesystem\Glob; /** * Class File @@ -268,7 +269,7 @@ class File implements DriverInterface { clearstatcache(); $globPattern = rtrim($path, '/') . '/' . ltrim($pattern, '/'); - $result = @glob($globPattern, GLOB_BRACE); + $result = Glob::glob($globPattern, Glob::GLOB_BRACE); return is_array($result) ? $result : []; } @@ -296,7 +297,7 @@ class File implements DriverInterface if (!$result) { throw new FileSystemException( new \Magento\Framework\Phrase( - 'The "%1" path cannot be renamed into "%2" %3', + 'The path "%1" cannot be renamed into "%2" %3', [$oldPath, $newPath, $this->getWarningMessage()] ) ); diff --git a/lib/internal/Magento/Framework/Filesystem/Glob.php b/lib/internal/Magento/Framework/Filesystem/Glob.php new file mode 100644 index 0000000000000000000000000000000000000000..eda65c158b4adc8c71782a3f62c71fe20c1d67c2 --- /dev/null +++ b/lib/internal/Magento/Framework/Filesystem/Glob.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Filesystem; + +use Zend\Stdlib\Glob as ZendGlob; +use Zend\Stdlib\Exception\RuntimeException as ZendRuntimeException; + +/** + * Wrapper for Zend\Stdlib\Glob + */ +class Glob extends ZendGlob +{ + /** + * Find pathnames matching a pattern. + * + * @param string $pattern + * @param int $flags + * @param bool $forceFallback + * @return array + */ + public static function glob($pattern, $flags = 0, $forceFallback = false) + { + try { + $result = ZendGlob::glob($pattern, $flags, $forceFallback); + } catch (ZendRuntimeException $e) { + $result = []; + } + return $result; + } +} diff --git a/lib/internal/Magento/Framework/Locale/Config.php b/lib/internal/Magento/Framework/Locale/Config.php index 7f935c0b75413748932c7256532ba5dc07aaa86f..1a08970bae9cffba54edb4e5a8a81ff367bf68a6 100644 --- a/lib/internal/Magento/Framework/Locale/Config.php +++ b/lib/internal/Magento/Framework/Locale/Config.php @@ -50,6 +50,7 @@ class Config implements \Magento\Framework\Locale\ConfigInterface 'fa_IR', /*Persian (Iran)*/ 'fi_FI', /*Finnish (Finland)*/ 'fil_PH', /*Filipino (Philippines)*/ + 'fr_BE', /*French (Belgium)*/ 'fr_CA', /*French (Canada)*/ 'fr_FR', /*French (France)*/ 'gu_IN', /*Gujarati (India)*/ @@ -71,6 +72,7 @@ class Config implements \Magento\Framework\Locale\ConfigInterface 'mk_MK', /*Macedonian (Macedonia)*/ 'mn_Cyrl_MN', /*Mongolian (Mongolia)*/ 'ms_Latn_MY', /*Malaysian (Malaysia)*/ + 'nl_BE', /*Dutch (Belgium)*/ 'nl_NL', /*Dutch (Netherlands)*/ 'nb_NO', /*Norwegian BokmГ_l (Norway)*/ 'nn_NO', /*Norwegian Nynorsk (Norway)*/ diff --git a/lib/internal/Magento/Framework/Setup/BackupRollback.php b/lib/internal/Magento/Framework/Setup/BackupRollback.php index 92b7a127112778a72cc74149848bf83fc59e17d4..fff94707ba7bbb695f02dcf317e3378e3984bc7c 100644 --- a/lib/internal/Magento/Framework/Setup/BackupRollback.php +++ b/lib/internal/Magento/Framework/Setup/BackupRollback.php @@ -204,14 +204,11 @@ class BackupRollback $this->file->createDirectory($this->backupsDir, DriverInterface::WRITEABLE_DIRECTORY_MODE); } $dbBackup->setBackupsDir($this->backupsDir); - $dbBackup->setBackupExtension('gz'); + $dbBackup->setBackupExtension('sql'); $dbBackup->setTime($time); $this->log->log('DB backup is starting...'); $dbBackup->create(); - $this->log->log( - 'DB backup filename: ' . $dbBackup->getBackupFilename() - . ' (The archive can be uncompressed with 7-Zip on Windows systems)' - ); + $this->log->log('DB backup filename: ' . $dbBackup->getBackupFilename()); $this->log->log('DB backup path: ' . $dbBackup->getBackupPath()); $this->log->logSuccess('DB backup completed successfully.'); return $dbBackup->getBackupPath(); @@ -226,7 +223,7 @@ class BackupRollback */ public function dbRollback($rollbackFile) { - if (preg_match('/[0-9]_(db)(.*?).(gz)$/', $rollbackFile) !== 1) { + if (preg_match('/[0-9]_(db)(.*?).(sql)$/', $rollbackFile) !== 1) { throw new LocalizedException(new Phrase('Invalid rollback file.')); } if (!$this->file->isExists($this->backupsDir . '/' . $rollbackFile)) { @@ -236,7 +233,7 @@ class BackupRollback $dbRollback = $this->objectManager->create('Magento\Framework\Backup\Db'); $dbRollback->setRootDir($this->directoryList->getRoot()); $dbRollback->setBackupsDir($this->backupsDir); - $dbRollback->setBackupExtension('gz'); + $dbRollback->setBackupExtension('sql'); $time = explode('_', $rollbackFile); if (count($time) === 3) { $thirdPart = explode('.', $time[2]); diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php index 3a5a6b838b0f0fb1607b017e1a0e80a3e5e45da8..cb9682b52d1d609234e2800f8303395a606ce5a0 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/BackupRollbackTest.php @@ -188,9 +188,9 @@ class BackupRollbackTest extends \PHPUnit_Framework_TestCase $this->database->expects($this->once())->method('rollback'); $this->file->expects($this->once()) ->method('isExists') - ->with($this->path . '/backups/12345_db.gz') + ->with($this->path . '/backups/12345_db.sql') ->willReturn(true); - $this->model->dbRollback('12345_db.gz'); + $this->model->dbRollback('12345_db.sql'); } private function setupCodeBackupRollback() @@ -226,7 +226,7 @@ class BackupRollbackTest extends \PHPUnit_Framework_TestCase ->willReturn('RollbackFile_A.gz'); $this->database->expects($this->atLeastOnce()) ->method('getBackupPath') - ->willReturn('pathToFile/12345_db.tgz'); + ->willReturn('pathToFile/12345_db.sql'); $this->log->expects($this->once()) ->method('logSuccess'); } diff --git a/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php b/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..28b71773244dd30d35ffc78c9fd84a0c9ad2d676 --- /dev/null +++ b/lib/internal/Magento/Framework/Test/Unit/CurrencyTest.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\Test\Unit; + +use Magento\Framework\Currency; + +/** + * Test for Magento\Framework\Currency + */ +class CurrencyTest extends \PHPUnit_Framework_TestCase +{ + public function testConstruct() + { + $frontendCache = $this->getMock('Magento\Framework\Cache\FrontendInterface', [], [], '', false, false); + $lowLevelFrontend = $this->getMock('Zend_Cache_Core', [], [], '', false, false); + /** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject $appCache */ + $appCache = $this->getMock('Magento\Framework\App\CacheInterface', [], [], '', false, false); + $frontendCache->expects($this->once())->method('getLowLevelFrontend')->willReturn($lowLevelFrontend); + $appCache->expects($this->once()) + ->method('getFrontend') + ->willReturn($frontendCache); + + // Create new currency object + $currency = new Currency($appCache, null, 'en_US'); + $this->assertEquals($lowLevelFrontend, $currency->getCache()); + $this->assertEquals('USD', $currency->getShortName()); + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/Source.php b/lib/internal/Magento/Framework/View/Asset/Source.php index b6af6e7d897d3c041339b9b9497badaf843df143..80e9eb4f43eb8aa3258e19d059623d3ca4549f8d 100644 --- a/lib/internal/Magento/Framework/View/Asset/Source.php +++ b/lib/internal/Magento/Framework/View/Asset/Source.php @@ -148,7 +148,11 @@ class Source $path = DirectoryList::TMP_MATERIALIZATION_DIR . '/source/' . $chain->getTargetAssetPath(); $this->varDir->writeFile($path, $chain->getContent()); } - $result = [$dir, $path]; + if (empty($path)) { + $result = false; + } else { + $result = [$dir, $path]; + } return $result; } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php index c4a9e916c87dfbbbd72407c5b49fb206337d922d..5c9eb5c2509c562f1803c19a6fd614cb42fdbc36 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php @@ -37,11 +37,11 @@ class FulltextFilter implements FilterApplierInterface * Add table alias to columns * * @param array $columns - * @param DbCollection $collection + * @param AbstractDb $collection * @param string $indexTable * @return array */ - protected function addTableAliasToColumns(array $columns, DbCollection $collection, $indexTable) + protected function addTableAliasToColumns(array $columns, AbstractDb $collection, $indexTable) { $alias = ''; foreach ($collection->getSelect()->getPart('from') as $tableAlias => $data) { @@ -75,13 +75,14 @@ class FulltextFilter implements FilterApplierInterface throw new \InvalidArgumentException('Database collection required.'); } + $mainTable = $collection->getResource()->getMainTable(); /** @var AbstractDb $collection */ - $columns = $this->getFulltextIndexColumns($collection, $collection->getResource()->getMainTable()); + $columns = $this->getFulltextIndexColumns($collection, $mainTable); if (!$columns) { return; } - $columns = $this->addTableAliasToColumns($columns, $collection, $collection->getMainTable()); + $columns = $this->addTableAliasToColumns($columns, $collection, $mainTable); $collection->getSelect() ->where( 'MATCH(' . implode(',', $columns) . ') AGAINST(?)', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/FulltextFilterTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/FulltextFilterTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c11d8a3d1e92a031d81934aafdc1bf6b40ff8173 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/FulltextFilterTest.php @@ -0,0 +1,143 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Test for full test filter + */ +namespace Magento\Framework\View\Test\Unit\Element\UiComponent\DataProvider; + +use Magento\Framework\Data\Collection\AbstractDb as CollectionAbstractDb; +use Magento\Framework\View\Element\UiComponent\DataProvider\FulltextFilter; +use Magento\Framework\Data\Collection\EntityFactoryInterface; +use Psr\Log\LoggerInterface; +use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Select; +use Magento\Framework\Data\Collection\EntityFactory; +use Magento\Framework\DB\Adapter\Pdo\Mysql; +use Magento\Framework\Api\Filter; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb as ResourceModelAbstractDb; +use Magento\Framework\Mview\View\Collection as MviewCollection; + +/** + * Class FulltextFilterTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class FulltextFilterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var FulltextFilter + */ + protected $fulltextFilter; + + /** + * @var EntityFactoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $entityFactoryMock; + + /** + * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $loggerMock; + + /** + * @var FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $fetchStrategyMock; + + /** + * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $connectionMock; + + /** + * @var Select|\PHPUnit_Framework_MockObject_MockObject + */ + protected $selectMock; + + /** + * @var CollectionAbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $collectionAbstractDbMock; + + /** + * @var ResourceModelAbstractDb|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceModelAbstractDb; + + protected function setUp() + { + $this->entityFactoryMock = $this->getMock(EntityFactory::class, [], [], '', false); + $this->loggerMock = $this->getMock(LoggerInterface::class); + $this->fetchStrategyMock = $this->getMock(FetchStrategyInterface::class, [], [], '', false); + $this->resourceModelAbstractDb = $this->getMock(FetchStrategyInterface::class, [], [], '', false); + $this->connectionMock = $this->getMock(Mysql::class, ['select', 'getIndexList'], [], '', false); + $this->selectMock = $this->getMock(Select::class, ['getPart', 'where'], [], '', false); + + $this->resourceModelAbstractDb = $this->getMockBuilder(ResourceModelAbstractDb::class) + ->setMethods(['getMainTable']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->collectionAbstractDbMock = $this->getMockBuilder(CollectionAbstractDb::class) + ->setMethods(['getConnection', 'getResource', 'getSelect']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->fulltextFilter = new FulltextFilter(); + } + + public function testApply() + { + $filter = new Filter(); + $filter->setValue('test'); + + $this->resourceModelAbstractDb->expects($this->any()) + ->method('getMainTable') + ->willReturn('testTable'); + + $this->collectionAbstractDbMock->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->any()) + ->method('select') + ->willReturn($this->selectMock); + $this->connectionMock->expects($this->once()) + ->method('getIndexList') + ->willReturn([['INDEX_TYPE' => 'FULLTEXT', 'COLUMNS_LIST' => ['col1', 'col2']]]); + + $this->selectMock->expects($this->once()) + ->method('getPart') + ->willReturn([]); + $this->selectMock->expects($this->once()) + ->method('where') + ->willReturn(null); + + $this->collectionAbstractDbMock->expects($this->once()) + ->method('getResource') + ->willReturn($this->resourceModelAbstractDb); + $this->collectionAbstractDbMock->expects($this->exactly(2)) + ->method('getSelect') + ->willReturn($this->selectMock); + + $this->fulltextFilter->apply($this->collectionAbstractDbMock, $filter); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testApplyWrongCollectionType() + { + /** @var MviewCollection $mviewCollection */ + $mviewCollection = $this->getMockBuilder(MviewCollection::class) + ->setMethods([]) + ->disableOriginalConstructor() + ->getMock(); + + $this->fulltextFilter->apply($mviewCollection, new Filter()); + } +} diff --git a/phpserver/README.md b/phpserver/README.md index 2c783f05603f952e7651a05bb27f982462119ebe..1dcccffb549be918d7cdcac9d917a2bc3cd2ebaa 100644 --- a/phpserver/README.md +++ b/phpserver/README.md @@ -1,35 +1,60 @@ PHP Built-in webserver ====================== -php has a Built-in webserver since version 5.4 -https://secure.php.net/manual/en/features.commandline.webserver.php +PHP has had a <a href="https://secure.php.net/manual/en/features.commandline.webserver.php" target="_blank">built-in web sever</a> since version 5.4. -As many applications and frameworks rely on rewrites on webserver side, -the same as Magento does, it offers an argument for a router script. -Either the script returns false which means, it should try to deliver the file -as usual via file system lookup, or it executes the specific php scripts via include. +PHP's web server provides a router script for use with server rewrites. Magento, like many other applications and frameworks, requires server rewrites. The router script either: +- The web server executes the requested PHP script using a server-side include +- Returns `false`, which means the web server returns the file using file system lookup Example: requests to `/static/frontend/Magento/blank/en_US/mage/calendar.css` should deliver the file if it exists, or execute `/static.php` if not. Without a router script, that is not possible via the php built-in server. -### How to use it +### How to install Magento -example usage: ```php -S 127.0.0.41:8082 -t ./pub/ ./phpserver/router.php``` +Magento's web-based Setup Wizard runs from the `setup` subdirectory, which PHP's built-in web server cannot route. Therefore, you must install Magento using the <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/cli/install-cli.html" target="_blank">command line</a>. An example follows: + +``` +php bin/magento setup:install --base-url=http://127.0.0.1:8082 +--db-host=localhost --db-name=magento --db-user=magento --db-password=magento +--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com +--admin-user=admin --admin-password=admin123 --language=en_US +--currency=USD --timezone=America/Chicago --use-rewrites=0 +``` + +It's important to note that the router is not able to work with rewrite urls, that's why the flag `use-rewrites` is set to `0`. + +Notes: +- You must use `--use-rewrites=0` because the web server cannot rewrite URLs +- By default, Magento creates a random Admin URI for you. Make sure to write this value down because it's how you access the Magento Admin later. For example : ```http://127.0.0.1:8082/index.php/admin_1vpn01```. + +For more informations about the installation process using the CLI, you can consult the dedicated documentation that can found in [the developer documentation](https://github.com/magento/devdocs/blob/develop/guides/v2.0/install-gde/install/cli/install-cli-install.md). + +### How to run Magento + +Example usage: ```php -S 127.0.0.1:8082 -t ./pub/ ./phpserver/router.php``` ### What exactly the script does -first we have an low level `$debug` closure, for the case you need to debug execution. +The `$debug` option provides low-level logging for debugging purposes. -If the request path starts with index.php, get.php, static.php, we return to normal request flow. -If we notice a favicon.ico request, the same. +Forwarding rules: +- Any request for `favicon.ico` or for any path that starts with `index.php`, `get.php`, `static.php` are processed normally. +- Requests for the path `pub/errors/default` are rewritten as `errors/default`. This is provided for compatibility with older versions. +- Files under request paths `media`, `opt`, or `static` are tested; if the file exists, the file is served. If the file does not exist, `static` files are forwarded to `static.php` and `media` files are forwarded to `get.php` ((How about `opt`?)) +- If no rules are matched, return a 404 (Not Found). Then rewrite paths for `pub/errors/default/` by removing the `pub/` part. (was at least needed for older versions) -Request starting with `media/`, `opt/`, `static/` test if the file exists. -If Yes, then handle it, if not "forward" `static` to `static.php` and `media` to `get.php` +Request starting with `media/`, `opt/`, `static/` test if the file exists. If Yes, then handle it, if not "forward" `static` to `static.php` and `media` to `get.php` + +If none of the rules matched, return 404. You may instead include the index.php, if 404 should be handled by Magento or you want urls without `index.php/`. + +### How to access to the admin dashboard + +When the installation is finished, you can access Magento as follows: +- Storefront: `<your Magento base URL>` +- Magento Admin: `<your Magento base URL>/<admin URI>` -If none of the rules matched, return 404. -You may instead include the index.php, if 404 should be handled by Magento or you want -urls without `index.php/`. diff --git a/setup/src/Magento/Setup/Model/FilePermissions.php b/setup/src/Magento/Setup/Model/FilePermissions.php index f187859907872c2e90e693ec276a8f8618da7db6..77b746e0f156ccf9ca5fc1313778cedc195e8695 100644 --- a/setup/src/Magento/Setup/Model/FilePermissions.php +++ b/setup/src/Magento/Setup/Model/FilePermissions.php @@ -151,7 +151,7 @@ class FilePermissions try { foreach ($directoryIterator as $subDirectory) { - if (!$subDirectory->isWritable()) { + if (!$subDirectory->isWritable() && !$subDirectory->isLink()) { $this->nonWritablePathsInDirectories[$directory][] = $subDirectory; $foundNonWritable = true; } diff --git a/setup/src/Magento/Setup/Model/Installer.php b/setup/src/Magento/Setup/Model/Installer.php index 63606fdc811fa3930cee1c1b4ff60b96f70d301b..43a2c3a836294a9e644f3c6132de169805d0f869 100644 --- a/setup/src/Magento/Setup/Model/Installer.php +++ b/setup/src/Magento/Setup/Model/Installer.php @@ -95,7 +95,7 @@ class Installer /** * Deployment configuration reader * - * @var Writer + * @var Reader */ private $deploymentConfigReader; @@ -321,7 +321,7 @@ class Installer $script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []]; $estimatedModules = $this->createModulesConfig($request, true); - $total = count($script) + 3 * count(array_filter($estimatedModules)); + $total = count($script) + 4 * count(array_filter($estimatedModules)); $this->progress = new Installer\Progress($total, 0); $this->log->log('Starting Magento installation:'); @@ -815,15 +815,19 @@ class Installer if ($type === 'schema') { $this->log->log('Schema post-updates:'); - foreach ($moduleNames as $moduleName) { - $this->log->log("Module '{$moduleName}':"); - $modulePostUpdater = $this->getSchemaDataHandler($moduleName, 'schema-recurring'); - if ($modulePostUpdater) { - $this->log->logInline("Running recurring.. "); - $modulePostUpdater->install($setup, $moduleContextList[$moduleName]); - } - $this->logProgress(); + $handlerType = 'schema-recurring'; + } else if ($type === 'data') { + $this->log->log('Data post-updates:'); + $handlerType = 'data-recurring'; + } + foreach ($moduleNames as $moduleName) { + $this->log->log("Module '{$moduleName}':"); + $modulePostUpdater = $this->getSchemaDataHandler($moduleName, $handlerType); + if ($modulePostUpdater) { + $this->log->logInline('Running ' + str_replace('-', ' ', $handlerType) + '...'); + $modulePostUpdater->install($setup, $moduleContextList[$moduleName]); } + $this->logProgress(); } } @@ -1166,6 +1170,10 @@ class Installer $className .= '\UpgradeData'; $interface = self::DATA_UPGRADE; break; + case 'data-recurring': + $className .= '\RecurringData'; + $interface = self::DATA_INSTALL; + break; default: throw new \Magento\Setup\Exception("$className does not exist"); } diff --git a/setup/src/Magento/Setup/Module.php b/setup/src/Magento/Setup/Module.php index be45abbb9dcd18c858712f2d781b02d98b7cf262..8ff27d9d9fafd74cb14a6a172a52c8c8b7d7da8a 100644 --- a/setup/src/Magento/Setup/Module.php +++ b/setup/src/Magento/Setup/Module.php @@ -6,6 +6,7 @@ namespace Magento\Setup; +use Magento\Framework\App\Response\HeaderProvider\XssProtection; use Magento\Setup\Mvc\View\Http\InjectTemplateListener; use Zend\EventManager\EventInterface; use Zend\ModuleManager\Feature\BootstrapListenerInterface; @@ -50,6 +51,10 @@ class Module implements $headers->addHeaderLine('Pragma', 'no-cache'); $headers->addHeaderLine('Expires', '1970-01-01'); $headers->addHeaderLine('X-Frame-Options: SAMEORIGIN'); + $headers->addHeaderLine('X-Content-Type-Options: nosniff'); + $xssHeaderValue = strpos($_SERVER['HTTP_USER_AGENT'], XssProtection::IE_8_USER_AGENT) === false + ? XssProtection::HEADER_ENABLED : XssProtection::HEADER_DISABLED; + $headers->addHeaderLine('X-XSS-Protection: ' . $xssHeaderValue); } } } diff --git a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php index f415c5c19dbddc462a2efdeacb2c4bf6aa19a3ab..442002004a00359e7190f655407bafd26488cf5e 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/InstallerTest.php @@ -292,12 +292,15 @@ class InstallerTest extends \PHPUnit_Framework_TestCase $this->logger->expects($this->at(26))->method('log')->with('Data install/update:'); $this->logger->expects($this->at(27))->method('log')->with("Module 'Foo_One':"); $this->logger->expects($this->at(29))->method('log')->with("Module 'Bar_Two':"); - $this->logger->expects($this->at(32))->method('log')->with('Installing admin user...'); - $this->logger->expects($this->at(34))->method('log')->with('Caches clearing:'); - $this->logger->expects($this->at(37))->method('log')->with('Disabling Maintenance Mode:'); - $this->logger->expects($this->at(39))->method('log')->with('Post installation file permissions check...'); - $this->logger->expects($this->at(41))->method('logSuccess')->with('Magento installation complete.'); - $this->logger->expects($this->at(43))->method('log') + $this->logger->expects($this->at(31))->method('log')->with('Data post-updates:'); + $this->logger->expects($this->at(32))->method('log')->with("Module 'Foo_One':"); + $this->logger->expects($this->at(34))->method('log')->with("Module 'Bar_Two':"); + $this->logger->expects($this->at(37))->method('log')->with('Installing admin user...'); + $this->logger->expects($this->at(39))->method('log')->with('Caches clearing:'); + $this->logger->expects($this->at(42))->method('log')->with('Disabling Maintenance Mode:'); + $this->logger->expects($this->at(44))->method('log')->with('Post installation file permissions check...'); + $this->logger->expects($this->at(46))->method('logSuccess')->with('Magento installation complete.'); + $this->logger->expects($this->at(48))->method('log') ->with('Sample Data is installed with errors. See log file for details'); $this->object->install($request); } diff --git a/setup/view/magento/setup/landing.phtml b/setup/view/magento/setup/landing.phtml index f8fa886f73bc3fe3145c46973a55aabdc0147b2f..ffc77d1b8b73a778fd2ab8ade700b2d4749bd3cf 100644 --- a/setup/view/magento/setup/landing.phtml +++ b/setup/view/magento/setup/landing.phtml @@ -15,7 +15,7 @@ <p class="text-welcome"> Welcome to Magento Admin, your online store headquarters. <br> - Click 'Agree and Set Up Magento' or read <a href="http://devdocs.magento.com/guides/v1.0/install-gde/install/install-web.html" target="_blank">Getting Started</a> to learn more. + Click 'Agree and Set Up Magento' or read <a href="http://devdocs.magento.com/guides/v2.0/install-gde/install/web/install-web.html" target="_blank">Getting Started</a> to learn more. </p> <p class="text-terms"> <a href="" ng-click="previousState()">Terms & Agreement</a>