diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 45614b1d1e22b..994d767e0d56f 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -120,11 +120,8 @@ public function getSystemMessageDialogJson() return $this->jsonHelper->jsonEncode( [ 'systemMessageDialog' => [ - 'autoOpen' => false, - 'width' => '75%', - 'modal' => true, - 'minHeight' => '0', - 'dialogClass' => 'ui-dialog-active ui-popup-message', + 'buttons' => [], + 'modalClass' => 'ui-dialog-active ui-popup-message modal-system-messages', 'ajaxUrl' => $this->_getMessagesUrl() ], ] diff --git a/app/code/Magento/AdminNotification/Model/Feed.php b/app/code/Magento/AdminNotification/Model/Feed.php index 0b4a38a7a6afd..d6b90c44cff77 100644 --- a/app/code/Magento/AdminNotification/Model/Feed.php +++ b/app/code/Magento/AdminNotification/Model/Feed.php @@ -72,7 +72,7 @@ class Feed extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\App\DeploymentConfig $deploymentConfig * @param \Magento\Framework\App\ProductMetadataInterface $productMetadata * @param \Magento\Framework\UrlInterface $urlBuilder - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -86,7 +86,7 @@ public function __construct( \Magento\Framework\App\DeploymentConfig $deploymentConfig, \Magento\Framework\App\ProductMetadataInterface $productMetadata, \Magento\Framework\UrlInterface $urlBuilder, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php index 548cb6dc44614..496e94ac27d9c 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Grid/Collection.php @@ -18,7 +18,7 @@ class Collection extends \Magento\AdminNotification\Model\ResourceModel\Inbox\Co /** * Add remove filter * - * @return \Magento\AdminNotification\Model\ResourceModel\Grid\Collection|\Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection + * @return \Magento\AdminNotification\Model\ResourceModel\Grid\Collection|\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection */ protected function _initSelect() { diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php index 76ebfa2ed614a..44b5d1d0cca4f 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Inbox extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Inbox extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * AdminNotification Resource initialization diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php index 062beee8bd9c9..f9927bd12a590 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Resource collection initialization diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php index 042f8967d42fd..bf145d654db85 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/Inbox/Collection/Critical.php @@ -7,7 +7,7 @@ */ namespace Magento\AdminNotification\Model\ResourceModel\Inbox\Collection; -class Critical extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Critical extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Resource collection initialization diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php index 986ff7ef3c042..a3b9aac430544 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Model\ResourceModel\System; -class Message extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Message extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Flag that notifies whether Primary key of table is auto-incremeted diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php index a2a5a0f490efd..d8b8bfc253332 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection.php @@ -5,7 +5,7 @@ */ namespace Magento\AdminNotification\Model\ResourceModel\System\Message; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * System message list @@ -28,7 +28,7 @@ class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\Ab * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Notification\MessageList $messageList * @param mixed $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactory $entityFactory, @@ -37,7 +37,7 @@ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Notification\MessageList $messageList, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { $this->_messageList = $messageList; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php index caaf95faa6fea..2c070d3140f3b 100644 --- a/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php +++ b/app/code/Magento/AdminNotification/Model/ResourceModel/System/Message/Collection/Synchronized.php @@ -17,7 +17,7 @@ class Synchronized extends \Magento\AdminNotification\Model\ResourceModel\System /** * Store new messages in database and remove outdated messages * - * @return $this|\Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return $this|\Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function _afterLoad() { diff --git a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml index 74b52dd3ce92c..5df9af8b4cce5 100644 --- a/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml +++ b/app/code/Magento/AdminNotification/view/adminhtml/templates/system/messages/popup.phtml @@ -9,8 +9,8 @@ ?> - diff --git a/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml b/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml index f13f2d77b1c08..5610e082e1715 100644 --- a/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml +++ b/app/code/Magento/Braintree/view/adminhtml/templates/form.phtml @@ -7,110 +7,143 @@ // @codingStandardsIgnoreFile /** @var \Magento\Braintree\Block\Form $block */ -$_form = $block; -$_code = $_form->getMethodCode(); -$_storedCards = $this->helper('\Magento\Braintree\Helper\Createorder')->getLoggedInCustomerCards(); -$_useVault = $block->useVault(); -$_useCvv = $block->useCvv(); -$clientToken = $block->getClientToken(); +$code = $block->getMethodCode(); +$storedCards = $this->helper('\Magento\Braintree\Helper\Createorder')->getLoggedInCustomerCards(); +$useVault = $block->useVault(); +$useCvv = $block->useCvv(); +$clientToken = $block->escapeHtml($block->getClientToken()); $isFraudDetectionEnabled = $block->isFraudDetectionEnabled(); $braintreeDataJs = $block->getBraintreeDataJs(); $formData = [ - "useVault" => $_useVault, - "useCvv" => $_useCvv, + "useVault" => $useVault, + "useCvv" => $useCvv, "clientToken" => $clientToken, - "code" => $_code, + "code" => $code, "isFraudDetectionEnabled" => $isFraudDetectionEnabled, "braintreeDataJs"=> $braintreeDataJs, ]; $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); +$ccType = $block->getInfoData('cc_type'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); +$ccExpYear = $block->getInfoData('cc_exp_year'); ?> - - @@ -189,13 +179,13 @@ if ($block->isEditMode()) { hasVerification()): ?>
isEditMode()) { value="" autocomplete="off" data-validate="{'required-number':true, 'validate-cc-cvn':'#credit_card_type'}"> - getViewFileUrl('Magento_Checkout::cvv.png') . - '\" alt=\"' . __('Card Verification Number Visual Reference') . '\" title=\"' . - __('Card Verification Number Visual Reference') . '\" />'; ?> + escapeUrl($block->getViewFileUrl('Magento_Checkout::cvv.png')) . + '\" alt=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" title=\"' . + $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" />'; ?>
@@ -224,58 +214,61 @@ if ($block->isEditMode()) {
> + value="1" >
- + escapeHtml(__('Billing Address')); ?>
- +
- +
+ value="escapeHtml($defaultCompany); ?>">
- helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('street'); ?>
@@ -287,95 +280,78 @@ if ($block->isEditMode()) {
+ value="escapeHtml($defaultExtendedAddress); ?>">
+ value="escapeHtml($block->getPostParam('customer.creditCard.billingAddress.region', $defaultRegion)); ?>">
- - countrySelect('credit_card' . '[billing_address][country_code_alpha2]', 'billing_address_country', $default) ?> + escapeHtml($block->countrySelect('credit_card[billing_address][country_code_alpha2]', 'billing_address_country', $default)); ?>
-getClientToken(); -$formData = [ - "clientToken" => $clientToken, - 'ajaxSaveUrl' => $block->getAjaxSaveUrl(), - 'isEditMode' => $block->isEditMode() ? true : false, - 'cardToken' => $block->isEditMode() ? $creditCard->token : '', - 'backUrl' => $block->getBackUrl(), - 'hasVerification' => $block->hasVerification(), - "countrySpecificCardTypes" => $countrySpecificCardTypeConfig, - "applicableCardTypes" => $applicableCardTypeConfig, - "cardTypes" => $block->getCcAvailableTypes(), - "isFraudDetectionEnabled" => $block->isFraudDetectionEnabled() -]; -$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); -?> \ No newline at end of file diff --git a/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml b/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml index f4cef98141bd9..467e2523e6162 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/creditcard/index.phtml @@ -7,15 +7,19 @@ // @codingStandardsIgnoreFile /** @var $block \Magento\Braintree\Block\Creditcard\Management */ - $_storedCards = $block->getCurrentCustomerStoredCards(); +$storedCards = $block->getCurrentCustomerStoredCards(); ?>
getUsesVault()): ?> - - + +
-getLayout()->getMessagesBlock()->getGroupedHtml() ?> - +getLayout()->getMessagesBlock()->getGroupedHtml(); ?> + @@ -24,23 +28,27 @@ - - - - + + + + - + - - - + + + diff --git a/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml b/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml index cbfe3dcda5f9f..14579540152c5 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/data_js.phtml @@ -14,14 +14,14 @@ $arrayData = [ $this->helper('Magento\Braintree\Helper\Data')->getKountId() : false, "formId" =>$block->getFormId(), "merchantId" => $block->getMerchantId(), - "braintreeDataJs" => $block->getJsSrc(), + "braintreeDataJs" => $block->escapeUrl($block->getJsSrc()), ]; $serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($arrayData); ?> diff --git a/app/code/Magento/Braintree/view/frontend/templates/form.phtml b/app/code/Magento/Braintree/view/frontend/templates/form.phtml index f740ad803b188..459a61568cff7 100644 --- a/app/code/Magento/Braintree/view/frontend/templates/form.phtml +++ b/app/code/Magento/Braintree/view/frontend/templates/form.phtml @@ -7,75 +7,112 @@ // @codingStandardsIgnoreFile /** @var \Magento\Braintree\Block\Form $block */ -$_code = $block->getMethodCode(); -$_loggedIn = $block->isCustomerLoggedIn(); -$_storedCards = $block->getStoredCards(); -$_useVault = $_loggedIn && $block->useVault() && count($_storedCards); -$_autoDetection = $block->isCcDetectionEnabled(); -$clientToken = $block->getClientToken(); +$code = $block->getMethodCode(); +$loggedIn = $block->isCustomerLoggedIn(); +$storedCards = $block->getStoredCards(); +$useVault = $loggedIn && $block->useVault() && count($storedCards); +$autoDetection = $block->isCcDetectionEnabled(); +$clientToken = $block->escapeHtml($block->getClientToken()); +$formData = [ + "useVault" => $useVault, + "clientToken" => $clientToken, + "autoDetection" => $autoDetection, + "loggedIn" => $loggedIn, +]; +$serializedFormData = $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($formData); +$ccType = $block->getInfoData('cc_type'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); +$ccExpYear = $block->getInfoData('cc_exp_year'); ?> - - - -
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml index 111ab842f22a9..3f192bc072f9a 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/templates/product/configurable/affected-attribute-set-selector/js.phtml @@ -33,6 +33,12 @@ newAttributeSetContainer = $('[data-role=affected-attribute-set-new-name-container]'), existingAttributeSetContainer = $('[data-role=affected-attribute-set-existing-name-container]'); + $form.find('input[type=text]').on('keypress',function(e){ + if(e.keyCode === 13){ + e.preventDefault(); + $form.closest('[data-role=modal]').find('button[data-action=confirm]').click(); + } + }); $('[data-form=edit-product]').append($('', { type: 'hidden', @@ -48,6 +54,9 @@ }, buttons: [{ text: '', + attr: { + 'data-action': 'confirm' + }, 'class': 'action-secondary', click: function() { var affectedAttributeSetId = $form.find('input[name=affected-attribute-set]:checked').val(); @@ -93,6 +102,7 @@ } },{ text: '', + id: 'getJsId('close-button') ?>', 'class': 'action-close', click: function() { $form.modal('closeModal'); diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml index 8212cbc0c4a22..7fd14ff394f9b 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/configurable_associated_product_listing.xml @@ -37,73 +37,24 @@ ui/grid/toolbar - + + configurable_associated_product_listing.configurable_associated_product_listing.product_columns - dataGridFilters - filters configurable_associated_product_listing.configurable_associated_product_listing.listing_top.listing_filters + + configurable_associated_product_listing.configurable_associated_product_listing.product_columns.${ $.index }:visible + + + + Magento\ConfigurableProduct\Ui\Component\Listing\AssociatedProduct\Filters - - - - - entity_id - Name - - - - - - - name - Name - - - - - - - sku - SKU - - - - - - - price - Price - - configurable_associated_product_listing.configurable_associated_product_listing.listing_top.listing_filters - - - - - - - from - from - From - - - - - - - to - to - To - - - - Magento\Catalog\Model\Product\Attribute\Source\Status @@ -121,29 +72,6 @@ configurable_associated_product_listing.configurable_associated_product_listing.product_columns.ids - bottom - - - 20 - 20 - - - 30 - 30 - - - 50 - 50 - - - 100 - 100 - - - 200 - 200 - - @@ -159,31 +87,22 @@ ${ $.$data.rowIndex } - true - + - - Magento_Ui/js/grid/columns/multiselect - - false entity_id 0 - + - - Magento_Ui/js/grid/columns/column - - text + textRange asc - left ID 10 @@ -191,15 +110,12 @@ - - Magento_Ui/js/grid/columns/thumbnail - + Magento_Ui/js/grid/columns/thumbnail true false name 1 - text left Thumbnail 20 @@ -208,13 +124,9 @@ - - Magento_Ui/js/grid/columns/column - + text true - text - left Name 30 @@ -222,12 +134,8 @@ - - Magento_Ui/js/grid/columns/column - - text - left + text SKU 60 @@ -235,13 +143,9 @@ - - Magento_Ui/js/grid/columns/column - + textRange true - text - left Price 70 diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml index e72edb975aede..edf1f8cae1c9e 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/ui_component/product_attributes_listing.xml @@ -40,17 +40,13 @@ - Magento_Ui/js/grid/controls/bookmarks/bookmarks - dataGridActions - - product_attributes_listing - + Magento_Ui/js/grid/controls/columns @@ -60,15 +56,14 @@ - + not-save-filter - dataGridFilters - filters + product_attributes_listing.product_attributes_listing.product_attributes_columns product_attributes_listing.product_attributes_listing.listing_top.bookmarks current.filters @@ -76,99 +71,11 @@ product_attributes_listing.product_attributes_listing.listing_top.listing_filters - product_attributes_listing.product_attributes_listing.listing_top.bookmarks:current.columns.${ $.index }.visible + product_attributes_listing.product_attributes_listing.product_attributes_columns:${ $.index }.visible - - - - attribute_code - Attribute Code - - - - - - - frontend_label - Attribute Label - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - is_required - Required - Select... - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - is_user_defined - System - Select... - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - is_visible - Visible - Select... - - - - - - Magento\Catalog\Model\Attribute\Source\Scopes - - - - is_global - Scope - Select... - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - is_searchable - Searchable - Select... - - - - - - Magento\Config\Model\Config\Source\Yesno - - - - is_comparable - Comparable - Select... - - - @@ -178,7 +85,6 @@ current.paging product_attributes_listing.product_attributes_listing.product_attributes_columns.ids - bottom @@ -191,7 +97,6 @@ current - true product_attributes_listing.product_attributes_listing.listing_top.bookmarks columns.${ $.index } @@ -200,39 +105,27 @@ - + - - Magento_Ui/js/grid/columns/multiselect - attribute_id 0 - false - + - - Magento_Ui/js/grid/columns/column - - text + text asc - left Attribute Code - - Magento_Ui/js/grid/columns/column - - text - left + text Attribute Label @@ -240,12 +133,10 @@ Magento\Config\Model\Config\Source\Yesno - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Required @@ -253,12 +144,10 @@ Magento\Config\Model\Config\Source\Yesno - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left System @@ -266,12 +155,10 @@ Magento\Config\Model\Config\Source\Yesno - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Visible @@ -279,12 +166,10 @@ Magento\Catalog\Model\Attribute\Source\Scopes - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Scope @@ -292,12 +177,10 @@ Magento\Config\Model\Config\Source\Yesno - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Searchable @@ -305,12 +188,10 @@ Magento\Config\Model\Config\Source\Yesno - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Comparable diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js index 39267f93a149e..37d52c6e14689 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/product-grid.js @@ -115,9 +115,9 @@ define([ this.callbackName = callbackName; this.productsMassAction(function (massActionComponent) { this.productsColumns().elems().each(function (rowElement) { - rowElement.disableAction(showMassActionColumn); + rowElement.disableAction = showMassActionColumn; }); - massActionComponent.visible(showMassActionColumn); + massActionComponent.visible = showMassActionColumn; }.bind(this)); this._setFilter(filterData); this._initGrid(filterData); @@ -129,10 +129,10 @@ define([ */ close: function (rowIndex) { try { - if (this.productsMassAction().selected().length) { + if (this.productsMassAction().selected.length) { this.variationsComponent()[this.callbackName](this.productsMassAction() .selected.map(this.getProductById.bind(this))); - this.productsMassAction().selected([]); + this.productsMassAction().deselectAll(); } else if (!_.isNull(rowIndex)) { this.variationsComponent()[this.callbackName]([this.getProductByIndex(rowIndex)]); } @@ -257,7 +257,7 @@ define([ _handleManualGridOpening: function (data) { if (data.items.length && this.callbackName == 'appendProducts') { this.productsColumns().elems().each(function (rowElement) { - rowElement.disableAction(true); + rowElement.disableAction = true; }); this._disableRows(data.items); @@ -314,12 +314,14 @@ define([ */ _getVariationKeyMap: function (items) { this._variationKeyMap = {}; + _.each(items, function (row) { this._variationKeyMap[row['entity_id']] = _.values( _.pick(row, this._getAttributesCodes()) ).sort().join('-'); - }.bind(this)); + }, this); + return this._variationKeyMap; }, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js index 435a7ace21418..5f4af9cd5e3e2 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js @@ -12,9 +12,10 @@ define([ 'underscore', 'Magento_Ui/js/lib/collapsible', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/file-uploader', 'mage/translate' -], function (Component, $, ko, _, Collapsible, mageTemplate) { +], function (Component, $, ko, _, Collapsible, mageTemplate, alert) { 'use strict'; return Component.extend({ @@ -365,7 +366,9 @@ define([ $('#' + data.fileId) .delay(2000) .hide('highlight'); - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } $('#' + data.fileId).remove(); }, diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index 43c040facf544..862ffe05a6cfc 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -8,8 +8,9 @@ define([ 'uiComponent', 'jquery', 'ko', - 'underscore' -], function (Component, $, ko, _) { + 'underscore', + 'Magento_Ui/js/modal/alert' +], function (Component, $, ko, _, alert) { 'use strict'; function UserException(message) { @@ -337,7 +338,9 @@ define([ parentElement.find('[name$="[image]"]').val(data.result.file); parentElement.find('[data-toggle=dropdown]').dropdown().show(); } else { - alert($.mage.__('We don\'t recognize or support this file extension type.')); + alert({ + content: $.mage.__('We don\'t recognize or support this file extension type.') + }); } }, start: function (event) { diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js index 2fd83c511c802..c2f0e189946c1 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js @@ -4,30 +4,37 @@ */ /*jshint browser:true jquery:true*/ define([ - "jquery", - "underscore", - "mage/template", - "priceUtils", - "priceBox", - "jquery/ui", - "jquery/jquery.parsequery" -], function($, _, mageTemplate, utils){ + 'jquery', + 'underscore', + 'mage/template', + 'priceUtils', + 'priceBox', + 'jquery/ui', + 'jquery/jquery.parsequery' +], function ($, _, mageTemplate) { + 'use strict'; $.widget('mage.configurable', { options: { superSelector: '.super-attribute-select', selectSimpleProduct: '[name="selected_configurable_option"]', priceHolderSelector: '.price-box', + spConfig: {}, state: {}, priceFormat: {}, optionTemplate: '<%- data.label %>' + - '<% if (data.finalPrice.value) { %>' + - ' <%- data.finalPrice.formatted %>' + - '<% } %>', - mediaGallerySelector: '[data-role=media-gallery]' + '<% if (data.finalPrice.value) { %>' + + ' <%- data.finalPrice.formatted %>' + + '<% } %>', + mediaGallerySelector: '[data-gallery-role=gallery-placeholder]', + mediaGalleryInitial: null }, - _create: function() { + /** + * Creates widget + * @private + */ + _create: function () { // Initial setting of various option values this._initializeOptions(); @@ -51,29 +58,33 @@ define([ * Initialize tax configuration, initial settings, and options values. * @private */ - _initializeOptions: function() { - var priceBoxOptions = $(this.options.priceHolderSelector).priceBox('option'); + _initializeOptions: function () { + var options = this.options, + gallery = $(options.mediaGallerySelector), + priceBoxOptions = $(this.options.priceHolderSelector).priceBox('option').priceConfig || null; - if(priceBoxOptions.priceConfig && priceBoxOptions.priceConfig.optionTemplate) { - this.options.optionTemplate = priceBoxOptions.priceConfig.optionTemplate; + if (priceBoxOptions && priceBoxOptions.optionTemplate) { + options.optionTemplate = priceBoxOptions.optionTemplate; } - if(priceBoxOptions.priceConfig && priceBoxOptions.priceConfig.priceFormat) { - this.options.priceFormat = priceBoxOptions.priceConfig.priceFormat; + if (priceBoxOptions && priceBoxOptions.priceFormat) { + options.priceFormat = priceBoxOptions.priceFormat; } - this.options.optionTemplate = mageTemplate(this.options.optionTemplate); + options.optionTemplate = mageTemplate(options.optionTemplate); + + options.settings = options.spConfig.containerId ? + $(options.spConfig.containerId).find(options.superSelector) : + $(options.superSelector); - this.options.settings = (this.options.spConfig.containerId) ? - $(this.options.spConfig.containerId).find(this.options.superSelector) : - $(this.options.superSelector); + options.values = options.spConfig.defaultValues || {}; + options.parentImage = $('[data-role=base-image-container] img').attr('src'); - this.options.values = this.options.spConfig.defaultValues || {}; - this.options.parentImage = $('[data-role=base-image-container] img').attr('src'); + this.inputSimpleProduct = this.element.find(options.selectSimpleProduct); - this.initialGalleryImages = $(this.options.mediaGallerySelector).data('mageGallery') - ? $(this.options.mediaGallerySelector).gallery('option', 'images') - : []; - this.inputSimpleProduct = this.element.find(this.options.selectSimpleProduct); + gallery.on('gallery:loaded', function () { + var galleryObject = gallery.data('gallery'); + options.mediaGalleryInitial = galleryObject.returnCurrentImages(); + }); }, /** @@ -81,11 +92,13 @@ define([ * initialized inputs values. * @private */ - _overrideDefaults: function() { + _overrideDefaults: function () { var hashIndex = window.location.href.indexOf('#'); + if (hashIndex !== -1) { this._parseQueryParams(window.location.href.substr(hashIndex + 1)); } + if (this.options.spConfig.inputsInitialized) { this._setValuesByAttribute(); } @@ -94,12 +107,15 @@ define([ /** * Parse query parameters from a query string and set options values based on the * key value pairs of the parameters. - * @param queryString URL query string containing query parameters. + * @param {*} queryString - URL query string containing query parameters. * @private */ - _parseQueryParams: function(queryString) { - var queryParams = $.parseQuery({query: queryString}); - $.each(queryParams, $.proxy(function(key, value) { + _parseQueryParams: function (queryString) { + var queryParams = $.parseQuery({ + query: queryString + }); + + $.each(queryParams, $.proxy(function (key, value) { this.options.values[key] = value; }, this)); }, @@ -109,11 +125,13 @@ define([ * identifier. * @private */ - _setValuesByAttribute: function() { + _setValuesByAttribute: function () { this.options.values = {}; - $.each(this.options.settings, $.proxy(function(index, element) { + $.each(this.options.settings, $.proxy(function (index, element) { + var attributeId; + if (element.value) { - var attributeId = element.id.replace(/[a-z]*/, ''); + attributeId = element.id.replace(/[a-z]*/, ''); this.options.values[attributeId] = element.value; } }, this)); @@ -123,8 +141,8 @@ define([ * Set up .on('change') events for each option element to configure the option. * @private */ - _setupChangeEvents: function() { - $.each(this.options.settings, $.proxy(function(index, element) { + _setupChangeEvents: function () { + $.each(this.options.settings, $.proxy(function (index, element) { $(element).on('change', this, this._configure); }, this)); }, @@ -134,9 +152,10 @@ define([ * attribute identifier. Set the state based on the attribute identifier. * @private */ - _fillState: function() { - $.each(this.options.settings, $.proxy(function(index, element) { + _fillState: function () { + $.each(this.options.settings, $.proxy(function (index, element) { var attributeId = element.id.replace(/[a-z]*/, ''); + if (attributeId && this.options.spConfig.attributes[attributeId]) { element.config = this.options.spConfig.attributes[attributeId]; element.attributeId = attributeId; @@ -150,23 +169,25 @@ define([ * an option's list of selections as needed or disable an option's setting. * @private */ - _setChildSettings: function() { - var childSettings = [], - settings = this.options.settings, - index = settings.length, + _setChildSettings: function () { + var childSettings = [], + settings = this.options.settings, + index = settings.length, option; while (index--) { option = settings[index]; - !index ? - this._fillSelect(option) : - (option.disabled = true); + if (index) { + option.disabled = true; + } else { + this._fillSelect(option); + } _.extend(option, { - childSettings: childSettings.slice(), - prevSetting: settings[index - 1], - nextSetting: settings[index + 1] + childSettings: childSettings.slice(), + prevSetting: settings[index - 1], + nextSetting: settings[index + 1] }); childSettings.push(option); @@ -178,13 +199,11 @@ define([ * the option, which sets its state, and initializes the option's choices, etc. * @private */ - _configureForValues: function() { + _configureForValues: function () { if (this.options.values) { - this.options.settings.each($.proxy(function(index, element) { + this.options.settings.each($.proxy(function (index, element) { var attributeId = element.attributeId; - element.value = (typeof(this.options.values[attributeId]) === 'undefined') ? - '' : - this.options.values[attributeId]; + element.value = this.options.values[attributeId] || ''; this._configureElement(element); }, this)); } @@ -193,9 +212,9 @@ define([ /** * Event handler for configuring an option. * @private - * @param event Event triggered to configure an option. + * @param {Object} event - Event triggered to configure an option. */ - _configure: function(event) { + _configure: function (event) { event.data._configureElement(this); }, @@ -203,20 +222,26 @@ define([ * Configure an option, initializing it's state and enabling related options, which * populates the related option's selection and resets child option selections. * @private - * @param element The element associated with a configurable option. + * @param {*} element - The element associated with a configurable option. */ - _configureElement: function(element) { + _configureElement: function (element) { + this.simpleProduct = this._getSimpleProductId(element); + if (element.value) { this.options.state[element.config.id] = element.value; + if (element.nextSetting) { element.nextSetting.disabled = false; this._fillSelect(element.nextSetting); this._resetChildren(element.nextSetting); } else { - this.inputSimpleProduct.val(element.selectedOptions[0].config.allowedProducts[0]); + if (!!document.documentMode) { + this.inputSimpleProduct.val(element.options[element.selectedIndex].config.allowedProducts[0]); + } else { + this.inputSimpleProduct.val(element.selectedOptions[0].config.allowedProducts[0]); + } } - } - else { + } else { this._resetChildren(element); } this._reloadPrice(); @@ -228,38 +253,15 @@ define([ * @private */ _changeProductImage: function () { - var images = this.options.spConfig.images, - imagesArray = null, - galleryElement = $(this.options.mediaGallerySelector); - $.each(this.options.settings, function (k, v) { - var selectValue = parseInt(v.value, 10), - attributeId = v.id.replace(/[a-z]*/, ''); - if (selectValue > 0 && attributeId) { - if (!imagesArray) { - imagesArray = images[attributeId][selectValue]; - } else { - var intersectedArray = {}; - $.each(imagesArray, function (productId) { - if (images[attributeId][selectValue][productId]) { - intersectedArray[productId] = images[attributeId][selectValue][productId]; - } - }); - imagesArray = intersectedArray; - } - } - }); - - var result = []; - $.each(imagesArray || {}, function (k, v) { - result.push({ - small: v, - medium: v, - large: v - }); - }); + var images = this.options.spConfig.images[this.simpleProduct], + galleryObject = $(this.options.mediaGallerySelector).data('gallery'); - if (galleryElement.length && galleryElement.data('mageGallery')) { - galleryElement.gallery('option', 'images', result.length > 0 ? result : this.initialGalleryImages); + if (galleryObject) { + if (images) { + galleryObject.updateData(images); + } else { + galleryObject.updateData(this.options.mediaGalleryInitial); + } } }, @@ -267,16 +269,17 @@ define([ * For a given option element, reset all of its selectable options. Clear any selected * index, disable the option choice, and reset the option's state if necessary. * @private - * @param element The element associated with a configurable option. + * @param {*} element - The element associated with a configurable option. */ - _resetChildren: function(element) { + _resetChildren: function (element) { if (element.childSettings) { - for (var i = 0; i < element.childSettings.length; i++) { - element.childSettings[i].selectedIndex = 0; - element.childSettings[i].disabled = true; - if (element.config) { - this.options.state[element.config.id] = false; - } + _.each(element.childSettings, function (set) { + set.selectedIndex = 0; + set.disabled = true; + }); + + if (element.config) { + this.options.state[element.config.id] = false; } } }, @@ -284,25 +287,32 @@ define([ /** * Populates an option's selectable choices. * @private - * @param element Element associated with a configurable option. + * @param {*} element - Element associated with a configurable option. */ - _fillSelect: function(element) { + _fillSelect: function (element) { var attributeId = element.id.replace(/[a-z]*/, ''), - options = this._getAttributeOptions(attributeId); + options = this._getAttributeOptions(attributeId), + prevConfig, + index = 1, + allowedProducts, + i, + j; + this._clearSelect(element); element.options[0] = new Option('', ''); element.options[0].innerHTML = this.options.spConfig.chooseText; + prevConfig = false; - var prevConfig = false; if (element.prevSetting) { prevConfig = element.prevSetting.options[element.prevSetting.selectedIndex]; } + if (options) { - var index = 1; - for (var i = 0; i < options.length; i++) { - var allowedProducts = []; + for (i = 0; i < options.length; i++) { + allowedProducts = []; + if (prevConfig) { - for (var j = 0; j < options[i].products.length; j++) { + for (j = 0; j < options[i].products.length; j++) { // prevConfig.config can be undefined if (prevConfig.config && prevConfig.config.allowedProducts && @@ -313,12 +323,15 @@ define([ } else { allowedProducts = options[i].products.slice(0); } + if (allowedProducts.length > 0) { options[i].allowedProducts = allowedProducts; element.options[index] = new Option(this._getOptionLabel(options[i]), options[i].id); + if (typeof options[i].price !== 'undefined') { element.options[index].setAttribute('price', options[i].prices); } + element.options[index].config = options[i]; index++; } @@ -330,21 +343,22 @@ define([ * Generate the label associated with a configurable option. This includes the option's * label or value and the option's price. * @private - * @param option A single choice among a group of choices for a configurable option. - * @param selOption Current selected option. + * @param {*} option - A single choice among a group of choices for a configurable option. * @return {String} The option label with option value and price (e.g. Black +1.99) */ - _getOptionLabel: function(option, selOption) { + _getOptionLabel: function (option) { return option.label; }, /** * Removes an option's selections. * @private - * @param element The element associated with a configurable option. + * @param {*} element - The element associated with a configurable option. */ - _clearSelect: function(element) { - for (var i = element.options.length - 1; i >= 0; i--) { + _clearSelect: function (element) { + var i; + + for (i = element.options.length - 1; i >= 0; i--) { element.remove(i); } }, @@ -352,10 +366,10 @@ define([ /** * Retrieve the attribute options associated with a specific attribute Id. * @private - * @param attributeId The id of the attribute whose configurable options are sought. + * @param {Number} attributeId - The id of the attribute whose configurable options are sought. * @return {Object} Object containing the attribute options. */ - _getAttributeOptions: function(attributeId) { + _getAttributeOptions: function (attributeId) { if (this.options.spConfig.attributes[attributeId]) { return this.options.spConfig.attributes[attributeId].options; } @@ -364,19 +378,22 @@ define([ /** * Reload the price of the configurable product incorporating the prices of all of the * configurable product's option selections. - * @private - * @return {Number} The price of the configurable product including selected options. */ - _reloadPrice: function() { + _reloadPrice: function () { $(this.options.priceHolderSelector).trigger('updatePrice', this._getPrices()); }, + /** + * Get product various prices + * @returns {{}} + * @private + */ _getPrices: function () { var prices = {}, - elements = _.toArray(this.options.settings); + elements = _.toArray(this.options.settings), + hasProductPrice = false; - var hasProductPrice = false; - _.each(elements, function(element) { + _.each(elements, function (element) { var selected = element.options[element.selectedIndex], config = selected && selected.config, priceValue = {}; @@ -392,16 +409,50 @@ define([ return prices; }, + /** + * Returns pracies for configured products + * + * @param {*} config - Products configuration + * @returns {*} + * @private + */ _calculatePrice: function (config) { - var displayPrices = $(this.options.priceHolderSelector).priceBox('option').prices; - var newPrices = this.options.spConfig.optionPrices[_.first(config.allowedProducts)]; + var displayPrices = $(this.options.priceHolderSelector).priceBox('option').prices, + newPrices = this.options.spConfig.optionPrices[_.first(config.allowedProducts)]; _.each(displayPrices, function (price, code) { if (newPrices[code]) { - displayPrices[code].amount = newPrices[code].amount - displayPrices[code].amount + displayPrices[code].amount = newPrices[code].amount - displayPrices[code].amount; } }); + return displayPrices; + }, + + /** + * Returns Simple product Id + * depending on current selected option. + * + * @private + * @param {HTMLElement} element + * @returns {String|undefined} + */ + _getSimpleProductId: function (element) { + // TODO: Rewrite algorithm. It should return ID of + // simple product based on selected options. + var allOptions = element.config.options, + value = element.value, + config; + + config = _.filter(allOptions, function (option) { + return option.id === value; + }); + config = _.first(config); + + return _.isEmpty(config) ? + undefined : + _.first(config.allowedProducts); + } }); diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php index d656941e6dad2..2f84b6d2fd067 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Domain.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Domain.php @@ -19,7 +19,7 @@ class Domain extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookieDomainValidator $configValidator - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @codeCoverageIgnore @@ -30,7 +30,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookieDomainValidator $configValidator, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php index b5b5a4d3ec3db..9d650159e4501 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Lifetime.php @@ -19,7 +19,7 @@ class Lifetime extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator $configValidator - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @codeCoverageIgnore @@ -30,7 +30,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookieLifetimeValidator $configValidator, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Cookie/Model/Config/Backend/Path.php b/app/code/Magento/Cookie/Model/Config/Backend/Path.php index bc2661e46573b..c0f104bfcff29 100644 --- a/app/code/Magento/Cookie/Model/Config/Backend/Path.php +++ b/app/code/Magento/Cookie/Model/Config/Backend/Path.php @@ -19,7 +19,7 @@ class Path extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Session\Config\Validator\CookiePathValidator $configValidator - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @codeCoverageIgnore @@ -30,7 +30,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Session\Config\Validator\CookiePathValidator $configValidator, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php index 30ff0267ea833..3e85d8a5dc984 100644 --- a/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php +++ b/app/code/Magento/Cookie/Test/Unit/Model/Config/Backend/DomainTest.php @@ -13,7 +13,7 @@ */ class DomainTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Framework\Model\ModelResource\AbstractResource | \PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Model\ResourceModel\AbstractResource | \PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; /** @var \Magento\Cookie\Model\Config\Backend\Domain */ @@ -37,7 +37,7 @@ protected function setUp() ); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\AbstractResource', + 'Magento\Framework\Model\ResourceModel\AbstractResource', [ '_construct', 'getConnection', diff --git a/app/code/Magento/Cookie/composer.json b/app/code/Magento/Cookie/composer.json index 4c1eb56566a7f..58ab73368af0c 100644 --- a/app/code/Magento/Cookie/composer.json +++ b/app/code/Magento/Cookie/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-cookie", "description": "N/A", "require": { - "php": "~5.4.11|~5.5.0|~5.6.0", + "php": "~5.5.0|~5.6.0|~7.0.0", "magento/module-store": "1.0.0-beta", "magento/framework": "1.0.0-beta" }, diff --git a/app/code/Magento/Cookie/View/adminhtml/requirejs-config.js b/app/code/Magento/Cookie/view/adminhtml/requirejs-config.js similarity index 100% rename from app/code/Magento/Cookie/View/adminhtml/requirejs-config.js rename to app/code/Magento/Cookie/view/adminhtml/requirejs-config.js diff --git a/app/code/Magento/Cookie/View/frontend/layout/default.xml b/app/code/Magento/Cookie/view/frontend/layout/default.xml similarity index 100% rename from app/code/Magento/Cookie/View/frontend/layout/default.xml rename to app/code/Magento/Cookie/view/frontend/layout/default.xml diff --git a/app/code/Magento/Cookie/View/frontend/requirejs-config.js b/app/code/Magento/Cookie/view/frontend/requirejs-config.js similarity index 100% rename from app/code/Magento/Cookie/View/frontend/requirejs-config.js rename to app/code/Magento/Cookie/view/frontend/requirejs-config.js diff --git a/app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml b/app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml similarity index 100% rename from app/code/Magento/Cookie/View/frontend/templates/html/notices.phtml rename to app/code/Magento/Cookie/view/frontend/templates/html/notices.phtml diff --git a/app/code/Magento/Cookie/View/frontend/templates/require_cookie.phtml b/app/code/Magento/Cookie/view/frontend/templates/require_cookie.phtml similarity index 100% rename from app/code/Magento/Cookie/View/frontend/templates/require_cookie.phtml rename to app/code/Magento/Cookie/view/frontend/templates/require_cookie.phtml diff --git a/app/code/Magento/Cookie/View/frontend/web/js/notices.js b/app/code/Magento/Cookie/view/frontend/web/js/notices.js similarity index 97% rename from app/code/Magento/Cookie/View/frontend/web/js/notices.js rename to app/code/Magento/Cookie/view/frontend/web/js/notices.js index 09094b971a266..5c82ce314686a 100644 --- a/app/code/Magento/Cookie/View/frontend/web/js/notices.js +++ b/app/code/Magento/Cookie/view/frontend/web/js/notices.js @@ -8,6 +8,7 @@ define([ "jquery/ui", "mage/cookies" ], function($){ + "use strict"; $.widget('mage.cookieNotices', { _create: function() { @@ -18,6 +19,7 @@ define([ } $(this.options.cookieAllowButtonSelector).on('click', $.proxy(function() { var cookieExpires = new Date(new Date().getTime() + this.options.cookieLifetime * 1000); + $.mage.cookies.set(this.options.cookieName, this.options.cookieValue, {expires: cookieExpires}); if ($.mage.cookies.get(this.options.cookieName)) { window.location.reload(); @@ -29,4 +31,4 @@ define([ }); return $.mage.cookieNotices; -}); \ No newline at end of file +}); diff --git a/app/code/Magento/Cookie/View/frontend/web/js/require-cookie.js b/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js similarity index 99% rename from app/code/Magento/Cookie/View/frontend/web/js/require-cookie.js rename to app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js index 22abfc82d56a6..6aedd8ac9b5b1 100644 --- a/app/code/Magento/Cookie/View/frontend/web/js/require-cookie.js +++ b/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js @@ -30,6 +30,7 @@ define([ */ _bind: function() { var events = {}; + $.each(this.options.triggers, function(index, value) { events['click ' + value] = '_checkCookie'; }); @@ -50,4 +51,4 @@ define([ }); return $.mage.requireCookie; -}); \ No newline at end of file +}); diff --git a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php index fc1989ef2614c..f46e58be56b8a 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php @@ -39,7 +39,7 @@ class Alert extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param string $runModelPath * @param array $data @@ -50,7 +50,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, $runModelPath = '', array $data = [] diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php index 13e59f4d73062..0fa554959191e 100644 --- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php +++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php @@ -39,7 +39,7 @@ class Sitemap extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param string $runModelPath * @param array $data @@ -50,7 +50,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, $runModelPath = '', array $data = [] diff --git a/app/code/Magento/Cron/Model/ResourceModel/Schedule.php b/app/code/Magento/Cron/Model/ResourceModel/Schedule.php index 6cad618e67894..469171d9e1543 100644 --- a/app/code/Magento/Cron/Model/ResourceModel/Schedule.php +++ b/app/code/Magento/Cron/Model/ResourceModel/Schedule.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Schedule extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Schedule extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize resource diff --git a/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php b/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php index 28bbcad12b8bc..bbb579babc472 100644 --- a/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php +++ b/app/code/Magento/Cron/Model/ResourceModel/Schedule/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize resource collection diff --git a/app/code/Magento/Cron/Model/Schedule.php b/app/code/Magento/Cron/Model/Schedule.php index 4f4308b9db601..fbcb1fe5b27c4 100644 --- a/app/code/Magento/Cron/Model/Schedule.php +++ b/app/code/Magento/Cron/Model/Schedule.php @@ -47,14 +47,14 @@ class Schedule extends \Magento\Framework\Model\AbstractModel /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Block/CustomerData.php b/app/code/Magento/Customer/Block/CustomerData.php index 66d4043f152e6..9d30a56de217b 100644 --- a/app/code/Magento/Customer/Block/CustomerData.php +++ b/app/code/Magento/Customer/Block/CustomerData.php @@ -7,24 +7,14 @@ class CustomerData extends \Magento\Framework\View\Element\Template { - /** - * Sections that can not be cached on frontend-side - * - * @var array - */ - protected $nonCachedSections = []; - /** * @param \Magento\Framework\View\Element\Template\Context $context * @param array $data - * @param array $nonCachedSections */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - array $data = [], - array $nonCachedSections = [] + array $data = [] ) { - $this->nonCachedSections = $nonCachedSections; parent::__construct($context, $data); } @@ -50,24 +40,4 @@ public function getCustomerDataUrl($route) { return $this->getUrl($route, ['_secure' => $this->getRequest()->isSecure()]); } - - /** - * Get sections that can not be cached on frontend-side - * - * @return array - */ - public function getNotCachedSections() - { - return $this->nonCachedSections; - } - - /** - * Get keys of sections that can not be cached on frontend-side - * - * @return array - */ - public function getNonCachedSectionKeys() - { - return array_keys($this->nonCachedSections); - } } diff --git a/app/code/Magento/Customer/Console/Command/UpgradeHashAlgorithmCommand.php b/app/code/Magento/Customer/Console/Command/UpgradeHashAlgorithmCommand.php index 275b185492ea5..92bfb1d5c7fac 100644 --- a/app/code/Magento/Customer/Console/Command/UpgradeHashAlgorithmCommand.php +++ b/app/code/Magento/Customer/Console/Command/UpgradeHashAlgorithmCommand.php @@ -40,7 +40,6 @@ public function __construct( ) { parent::__construct(); $this->customerCollectionFactory = $customerCollectionFactory; - $this->collection = $customerCollectionFactory->create(); $this->encryptor = $encryptor; } @@ -58,6 +57,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { + $this->collection = $this->customerCollectionFactory->create(); $this->collection->addAttributeToSelect('*'); $customerCollection = $this->collection->getItems(); /** @var $customer Customer */ diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 2faeca50ad9e1..7b6191eb2556b 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -92,15 +92,12 @@ public function execute() ); $this->messageManager->addError($message); $this->session->setUsername($login['username']); - } - catch (AuthenticationException $e) { + } catch (AuthenticationException $e) { $message = __('Invalid login or password.'); $this->messageManager->addError($message); $this->session->setUsername($login['username']); } catch (\Exception $e) { - $this->messageManager->addError( - __('Something went wrong while validating the login and password.') - ); + $this->messageManager->addError(__('Invalid login or password.')); } } else { $this->messageManager->addError(__('A login and a password are required.')); diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index a3275491f6c3e..9360ca0f7d6d3 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -106,7 +106,6 @@ protected function _extractAddress() array_merge($existingAddressData, $attributeValues), '\Magento\Customer\Api\Data\AddressInterface' ); - $addressDataObject->setCustomerId($this->_getSession()->getCustomerId()) ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false)) ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false)); @@ -118,12 +117,16 @@ protected function _extractAddress() * Retrieve existing address data * * @return array + * @throws \Exception */ protected function getExistingAddressData() { $existingAddressData = []; if ($addressId = $this->getRequest()->getParam('id')) { $existingAddress = $this->_addressRepository->getById($addressId); + if ($existingAddress->getCustomerId() !== $this->_getSession()->getCustomerId()) { + throw new \Exception(); + } $existingAddressData = $this->_dataProcessor->buildOutputDataArray( $existingAddress, '\Magento\Customer\Api\Data\AddressInterface' @@ -175,6 +178,7 @@ protected function updateRegionData(&$attributeValues) */ public function execute() { + $redirectUrl = null; if (!$this->_formKeyValidator->validate($this->getRequest())) { return $this->resultRedirectFactory->create()->setPath('*/*/'); } @@ -198,11 +202,16 @@ public function execute() $this->messageManager->addError($error->getMessage()); } } catch (\Exception $e) { + $redirectUrl = $this->_buildUrl('*/*/index'); $this->messageManager->addException($e, __('We can\'t save the address.')); } - $this->_getSession()->setAddressFormData($this->getRequest()->getPostValue()); - $url = $this->_buildUrl('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); + $url = $redirectUrl; + if (!$redirectUrl) { + $this->_getSession()->setAddressFormData($this->getRequest()->getPostValue()); + $url = $this->_buildUrl('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); + } + return $this->resultRedirectFactory->create()->setUrl($this->_redirect->error($url)); } } diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php index b20ff74c9039f..f1f638a852e2e 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php @@ -1,40 +1,45 @@ resultRawFactory = $resultRawFactory; + $this->resultJsonFactory = $resultJsonFactory; } /** * Check whether vat is valid * - * @return \Magento\Framework\Controller\Result\Raw + * @return \Magento\Framework\Controller\Result\Json */ public function execute() { $result = $this->_validate(); - /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */ - $resultRaw = $this->resultRawFactory->create(); - return $resultRaw->setContents((int)$result->getIsValid()); + + /** @var \Magento\Framework\Controller\Result\Json $resultJson */ + $resultJson = $this->resultJsonFactory->create(); + return $resultJson->setData([ + 'valid' => (int)$result->getIsValid(), + 'message' => $result->getRequestMessage(), + ]); } } diff --git a/app/code/Magento/Customer/Controller/Ajax/Login.php b/app/code/Magento/Customer/Controller/Ajax/Login.php index 8491d5b08e409..4258ebf1ef0e1 100644 --- a/app/code/Magento/Customer/Controller/Ajax/Login.php +++ b/app/code/Magento/Customer/Controller/Ajax/Login.php @@ -116,7 +116,7 @@ public function execute() } catch (\Exception $e) { $response = [ 'errors' => true, - 'message' => __('Something went wrong while validating the login and password.') + 'message' => __('Invalid login or password.') ]; } /** @var \Magento\Framework\Controller\Result\Json $resultJson */ diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php index 1195715d8bb6a..9318f0eb6a076 100644 --- a/app/code/Magento/Customer/Model/Address.php +++ b/app/code/Magento/Customer/Model/Address.php @@ -64,7 +64,7 @@ class Address extends \Magento\Customer\Model\Address\AbstractAddress * @param CustomerFactory $customerFactory * @param \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry - * @param \Magento\Framework\Model\ModelResource\AbstractResource|null $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @@ -87,7 +87,7 @@ public function __construct( CustomerFactory $customerFactory, \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Address/AbstractAddress.php b/app/code/Magento/Customer/Model/Address/AbstractAddress.php index ff3604e367bed..783b8c4001733 100644 --- a/app/code/Magento/Customer/Model/Address/AbstractAddress.php +++ b/app/code/Magento/Customer/Model/Address/AbstractAddress.php @@ -127,7 +127,7 @@ class AbstractAddress extends AbstractExtensibleModel implements AddressModelInt * @param AddressInterfaceFactory $addressDataFactory * @param RegionInterfaceFactory $regionDataFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -146,7 +146,7 @@ public function __construct( AddressInterfaceFactory $addressDataFactory, RegionInterfaceFactory $regionDataFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Attribute.php b/app/code/Magento/Customer/Model/Attribute.php index 83f861b3ea4fa..e1e56c1e78c07 100644 --- a/app/code/Magento/Customer/Model/Attribute.php +++ b/app/code/Magento/Customer/Model/Attribute.php @@ -59,7 +59,7 @@ class Attribute extends \Magento\Eav\Model\Attribute * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param DateTimeFormatterInterface $dateTimeFormatter * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry - * @param \Magento\Framework\Model\ModelResource\AbstractResource|null $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @@ -83,7 +83,7 @@ public function __construct( \Magento\Framework\Locale\ResolverInterface $localeResolver, DateTimeFormatterInterface $dateTimeFormatter, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php index dd149276adfbe..4d2204c9b71de 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Address/Street.php @@ -29,7 +29,7 @@ class Street extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php b/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php index 363fe4cd200a2..486e1ac1227b1 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php +++ b/app/code/Magento/Customer/Model/Config/Backend/CreateAccount/DisableAutoGroupAssignDefault.php @@ -18,7 +18,7 @@ class DisableAutoGroupAssignDefault extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -28,7 +28,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Eav\Model\Config $eavConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php index a4a9b336e9c56..5d614685145d9 100644 --- a/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php +++ b/app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php @@ -29,7 +29,7 @@ class Customer extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Eav\Model\Config $eavConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Config/Share.php b/app/code/Magento/Customer/Model/Config/Share.php index f7e6be108a9b0..4ff773cabc38b 100644 --- a/app/code/Magento/Customer/Model/Config/Share.php +++ b/app/code/Magento/Customer/Model/Config/Share.php @@ -43,7 +43,7 @@ class Share extends \Magento\Framework\App\Config\Value implements \Magento\Fram * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Customer\Model\ResourceModel\Customer $customerResource - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -54,7 +54,7 @@ public function __construct( \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Customer\Model\ResourceModel\Customer $customerResource, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 53cd1bcc12a9a..4516a33962aea 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -22,7 +22,7 @@ * Customer model * * @method int getWebsiteId() getWebsiteId() - * @method Customer setWebsiteId(int) + * @method Customer setWebsiteId($value) * @method int getStoreId() getStoreId() * @method string getEmail() getEmail() * @method ResourceCustomer _getResource() diff --git a/app/code/Magento/Customer/Model/Group.php b/app/code/Magento/Customer/Model/Group.php index 1f1d549a6eb95..8045a4056954e 100644 --- a/app/code/Magento/Customer/Model/Group.php +++ b/app/code/Magento/Customer/Model/Group.php @@ -64,7 +64,7 @@ class Group extends \Magento\Framework\Model\AbstractModel * @param \Magento\Store\Model\StoresConfig $storesConfig * @param \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor * @param \Magento\Tax\Model\ClassModelFactory $classModelFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -75,7 +75,7 @@ public function __construct( \Magento\Store\Model\StoresConfig $storesConfig, \Magento\Framework\Reflection\DataObjectProcessor $dataObjectProcessor, \Magento\Tax\Model\ClassModelFactory $classModelFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address.php b/app/code/Magento/Customer/Model/ResourceModel/Address.php index 5a5b476fb5ee5..53502f748395b 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address.php @@ -21,16 +21,16 @@ class Address extends \Magento\Eav\Model\Entity\VersionControl\AbstractEntity /** * @param \Magento\Eav\Model\Entity\Context $context - * @param \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot, - * @param \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite $entityRelationComposite, + * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, + * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite, * @param \Magento\Framework\Validator\Factory $validatorFactory * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param array $data */ public function __construct( \Magento\Eav\Model\Entity\Context $context, - \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot, - \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite $entityRelationComposite, + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite, \Magento\Framework\Validator\Factory $validatorFactory, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, $data = [] diff --git a/app/code/Magento/Customer/Model/ResourceModel/Address/Relation.php b/app/code/Magento/Customer/Model/ResourceModel/Address/Relation.php index b5120a99178ec..3267ab03cb61d 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Address/Relation.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Address/Relation.php @@ -7,7 +7,7 @@ */ namespace Magento\Customer\Model\ResourceModel\Address; -use Magento\Framework\Model\ModelResource\Db\VersionControl\RelationInterface; +use Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface; /** * Class represents save operations for customer address relations diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer.php b/app/code/Magento/Customer/Model/ResourceModel/Customer.php index a0125875c5484..e96b8c1b2a4df 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer.php @@ -38,8 +38,8 @@ class Customer extends \Magento\Eav\Model\Entity\VersionControl\AbstractEntity /** * @param \Magento\Eav\Model\Entity\Context $context - * @param \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot - * @param \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite $entityRelationComposite + * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot + * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Validator\Factory $validatorFactory * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -48,8 +48,8 @@ class Customer extends \Magento\Eav\Model\Entity\VersionControl\AbstractEntity */ public function __construct( \Magento\Eav\Model\Entity\Context $context, - \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot, - \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite $entityRelationComposite, + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, + \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite $entityRelationComposite, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Validator\Factory $validatorFactory, \Magento\Framework\Stdlib\DateTime $dateTime, diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php index 6d69c42c167a4..e8982afaba93c 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer/Collection.php @@ -38,7 +38,7 @@ class Collection extends \Magento\Eav\Model\Entity\Collection\VersionControl\Abs * @param \Magento\Eav\Model\EntityFactory $eavEntityFactory * @param \Magento\Eav\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory - * @param \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot + * @param \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot * @param \Magento\Framework\DataObject\Copy\Config $fieldsetConfig * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection * @param string $modelName @@ -55,7 +55,7 @@ public function __construct( \Magento\Eav\Model\EntityFactory $eavEntityFactory, \Magento\Eav\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, - \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot $entitySnapshot, + \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot $entitySnapshot, \Magento\Framework\DataObject\Copy\Config $fieldsetConfig, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, $modelName = self::CUSTOMER_MODEL_NAME diff --git a/app/code/Magento/Customer/Model/ResourceModel/Customer/Relation.php b/app/code/Magento/Customer/Model/ResourceModel/Customer/Relation.php index 20b3124bcc250..b809549ed79f3 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Customer/Relation.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Customer/Relation.php @@ -9,7 +9,7 @@ /** * Class Relation */ -class Relation implements \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationInterface +class Relation implements \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface { /** * Save relations for Customer diff --git a/app/code/Magento/Customer/Model/ResourceModel/Group.php b/app/code/Magento/Customer/Model/ResourceModel/Group.php index 395e49c2481c7..7c793f8fc9e93 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Group.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Group.php @@ -5,15 +5,15 @@ */ namespace Magento\Customer\Model\ResourceModel; -use Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot; -use Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite; +use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot; +use Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite; /** * Customer group resource model * * @author Magento Core Team */ -class Group extends \Magento\Framework\Model\ModelResource\Db\VersionControl\AbstractDb +class Group extends \Magento\Framework\Model\ResourceModel\Db\VersionControl\AbstractDb { /** * Group Management @@ -28,7 +28,7 @@ class Group extends \Magento\Framework\Model\ModelResource\Db\VersionControl\Abs protected $_customersFactory; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param Snapshot $entitySnapshot, * @param RelationComposite $entityRelationComposite, * @param \Magento\Customer\Api\GroupManagementInterface $groupManagement @@ -36,7 +36,7 @@ class Group extends \Magento\Framework\Model\ModelResource\Db\VersionControl\Abs * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, Snapshot $entitySnapshot, RelationComposite $entityRelationComposite, \Magento\Customer\Api\GroupManagementInterface $groupManagement, diff --git a/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php index bc7b863e7e0cd..52d37da5646e3 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Group/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Customer/Model/ResourceModel/Visitor.php b/app/code/Magento/Customer/Model/ResourceModel/Visitor.php index 2c65387b19675..1e3adf4d6ce6f 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Visitor.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Visitor.php @@ -10,7 +10,7 @@ * Class Visitor * @package Magento\Customer\Model\ResourceModel */ -class Visitor extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Visitor extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var \Magento\Framework\Stdlib\DateTime\DateTime @@ -23,13 +23,13 @@ class Visitor extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $dateTime; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Stdlib\DateTime $dateTime, $connectionName = null diff --git a/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php index cbad6afc46f5a..5ce707c294d9b 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Visitor/Collection.php @@ -5,7 +5,7 @@ */ namespace Magento\Customer\Model\ResourceModel\Visitor; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Resource initialization diff --git a/app/code/Magento/Customer/Model/Vat.php b/app/code/Magento/Customer/Model/Vat.php index 78fd927507f72..43c883b5d0e69 100644 --- a/app/code/Magento/Customer/Model/Vat.php +++ b/app/code/Magento/Customer/Model/Vat.php @@ -166,7 +166,8 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode = 'is_valid' => false, 'request_date' => '', 'request_identifier' => '', - 'request_success' => false + 'request_success' => false, + 'request_message' => __('Error during VAT Number verification.'), ]); if (!extension_loaded('soap')) { @@ -194,6 +195,12 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode = $gatewayResponse->setRequestDate((string)$result->requestDate); $gatewayResponse->setRequestIdentifier((string)$result->requestIdentifier); $gatewayResponse->setRequestSuccess(true); + + if ($gatewayResponse->getIsValid()) { + $gatewayResponse->setRequestMessage(__('VAT Number is valid.')); + } else { + $gatewayResponse->setRequestMessage(__('Please enter a valid VAT number.')); + } } catch (\Exception $exception) { $gatewayResponse->setIsValid(false); $gatewayResponse->setRequestDate(''); diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php index 45c8c3408b850..6f4a1d58b3b23 100644 --- a/app/code/Magento/Customer/Model/Visitor.php +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -75,7 +75,7 @@ class Visitor extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry - * @param \Magento\Framework\Model\ModelResource\AbstractResource|null $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $ignoredUserAgents * @param array $ignores @@ -91,7 +91,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $ignoredUserAgents = [], array $ignores = [], diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php index a37210bd9fb88..1f4da520fd0b2 100644 --- a/app/code/Magento/Customer/Setup/UpgradeData.php +++ b/app/code/Magento/Customer/Setup/UpgradeData.php @@ -240,6 +240,58 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface ]; $this->upgradeAttributes($entityAttributes, $customerSetup); } + if (version_compare($context->getVersion(), '2.0.6', '<')) { + $customerSetup->updateEntityType( + \Magento\Customer\Model\Customer::ENTITY, + 'entity_model', + 'Magento\Customer\Model\ResourceModel\Customer' + ); + $customerSetup->updateEntityType( + \Magento\Customer\Model\Customer::ENTITY, + 'increment_model', + 'Magento\Eav\Model\Entity\Increment\NumericValue' + ); + $customerSetup->updateEntityType( + \Magento\Customer\Model\Customer::ENTITY, + 'entity_attribute_collection', + 'Magento\Customer\Model\ResourceModel\Attribute\Collection' + ); + $customerSetup->updateEntityType( + 'customer_address', + 'entity_model', + 'Magento\Customer\Model\ResourceModel\Address' + ); + $customerSetup->updateEntityType( + 'customer_address', + 'entity_attribute_collection', + 'Magento\Customer\Model\ResourceModel\Address\Attribute\Collection' + ); + $customerSetup->updateAttribute( + 'customer_address', + 'country_id', + 'source_model', + 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country' + ); + $customerSetup->updateAttribute( + 'customer_address', + 'region', + 'backend_model', + 'Magento\Customer\Model\ResourceModel\Address\Attribute\Backend\Region' + ); + $customerSetup->updateAttribute( + 'customer_address', + 'region_id', + 'source_model', + 'Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region' + ); + } + + if (version_compare($context->getVersion(), '2.0.6', '<')) { + $setup->getConnection()->delete( + $setup->getTable('customer_form_attribute'), + ['form_code = ?' => 'checkout_register'] + ); + } $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID); $indexer->reindexAll(); diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php index 6c2d57a9f95a8..e71e413d7e117 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php @@ -423,7 +423,7 @@ protected function mockExceptions($exception, $username) case '\Exception': $this->messageManager->expects($this->once()) ->method('addError') - ->with(__('Something went wrong while validating the login and password.')) + ->with(__('Invalid login or password.')) ->willReturnSelf(); break; } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index 3b351f5160cb0..39fa2018cff7a 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -528,7 +528,10 @@ public function testExecute( ], ]); - $this->session->expects($this->once()) + $this->session->expects($this->atLeastOnce()) + ->method('getCustomerId') + ->willReturn($customerId); + $this->addressData->expects($this->once()) ->method('getCustomerId') ->willReturn($customerId); @@ -682,11 +685,11 @@ public function testExecuteException() $this->request->expects($this->once()) ->method('isPost') ->willReturn(true); - $this->request->expects($this->exactly(2)) + $this->request->expects($this->once()) ->method('getParam') ->with('id') ->willReturn($addressId); - $this->request->expects($this->once()) + $this->request->expects($this->never()) ->method('getPostValue') ->willReturn($postValue); @@ -701,7 +704,7 @@ public function testExecuteException() ->with($exception, __('We can\'t save the address.')) ->willReturnSelf(); - $this->session->expects($this->once()) + $this->session->expects($this->never()) ->method('setAddressFormData') ->with($postValue) ->willReturnSelf(); @@ -710,7 +713,7 @@ public function testExecuteException() ->getMockForAbstractClass(); $urlBuilder->expects($this->once()) ->method('getUrl') - ->with('*/*/edit', ['id' => $addressId]) + ->with('*/*/index') ->willReturn($url); $this->objectManager->expects($this->once()) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php new file mode 100644 index 0000000000000..ac5625eadef26 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php @@ -0,0 +1,130 @@ +mockResultJson(); + + $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http') + ->disableOriginalConstructor() + ->getMock(); + + $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->getMockForAbstractClass(); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->context = $objectManager->getObject( + 'Magento\Backend\App\Action\Context', + [ + 'request' => $this->request, + 'objectManager' => $this->objectManager, + ] + ); + $this->controller = $objectManager->getObject( + 'Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate', + [ + 'context' => $this->context, + 'resultJsonFactory' => $resultJsonFactory, + ] + ); + } + + public function testExecute() + { + $country = 'US'; + $vat = '123456789'; + + $isValid = true; + $requestMessage = 'test'; + + $json = '{"valid":' . (int)$isValid . ',"message":"' . $requestMessage . '"}'; + + $gatewayResponse = new \Magento\Framework\DataObject([ + 'is_valid' => $isValid, + 'request_message' => $requestMessage, + ]); + + $this->request->expects($this->any()) + ->method('getParam') + ->willReturnMap([ + ['country', null, $country], + ['vat', null, $vat], + ]); + + $vatMock = $this->getMockBuilder('Magento\Customer\Model\Vat') + ->disableOriginalConstructor() + ->getMock(); + + $vatMock->expects($this->once()) + ->method('checkVatNumber') + ->with($country, $vat) + ->willReturn($gatewayResponse); + + $this->objectManager->expects($this->once()) + ->method('get') + ->with('Magento\Customer\Model\Vat') + ->willReturn($vatMock); + + $this->resultJson->expects($this->once()) + ->method('setData') + ->with([ + 'valid' => $gatewayResponse->getIsValid(), + 'message' => $gatewayResponse->getRequestMessage() + ]) + ->willReturn($json); + + $this->assertEquals($json, $this->controller->execute()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockResultJson() + { + $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') + ->disableOriginalConstructor() + ->getMock(); + + $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') + ->setMethods(['create']) + ->disableOriginalConstructor() + ->getMock(); + + $resultJsonFactory->expects($this->any()) + ->method('create') + ->willReturn($this->resultJson); + + return $resultJsonFactory; + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php index 7907716a7f799..c779cd5d3f418 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/AttributeTest.php @@ -70,7 +70,7 @@ class AttributeTest extends \PHPUnit_Framework_TestCase protected $timezoneMock; /** - * @var \Magento\Framework\Model\ModelResource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject */ private $resourceMock; @@ -173,7 +173,7 @@ protected function setUp() ->getMock(); $this->dateTimeFormatter = $this->getMock('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface'); - $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ModelResource\AbstractResource') + $this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') ->setMethods(['_construct', 'getConnection', 'getIdFieldName', 'saveInSetIncluding']) ->getMockForAbstractClass(); $this->cacheManager = $this->getMockBuilder('Magento\Framework\App\CacheInterface') diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php index 3f8a66cfc53ed..890d19c00ad2e 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/Address/RelationTest.php @@ -69,7 +69,7 @@ public function testProcessRelation($addressId, $isDefaultBilling, $isDefaultShi false ); $customerResource = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [], '', false, diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php index 04011dd7fd43f..61f3adb3dab7a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/AddressTest.php @@ -8,8 +8,8 @@ namespace Magento\Customer\Test\Unit\Model\ResourceModel; -use Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite; -use Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot; +use Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite; +use Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; class AddressTest extends \PHPUnit_Framework_TestCase @@ -32,7 +32,7 @@ class AddressTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->entitySnapshotMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot', + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', [], [], '', @@ -41,7 +41,7 @@ protected function setUp() $this->entityRelationCompositeMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite', + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite', [], [], '', diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php index ccaa89a2061fa..2577c7fb4018f 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupTest.php @@ -53,18 +53,18 @@ protected function setUp() $this->groupModel = $this->getMock('Magento\Customer\Model\Group', [], [], '', false); - $contextMock = $this->getMock('\Magento\Framework\Model\ModelResource\Db\Context', [], [], '', false); + $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->resource); $this->relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ModelResource\Db\ObjectRelationProcessor', + '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', [], [], '', false ); - $transactionManagerMock = $this->getMock('\Magento\Framework\Model\ModelResource\Db\TransactionManagerInterface'); + $transactionManagerMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface'); $transactionManagerMock->expects($this->once()) ->method('start') ->willReturn($this->getMock('\Magento\Framework\DB\Adapter\AdapterInterface')); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php new file mode 100644 index 0000000000000..7e1b9f9d43779 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProviderTest.php @@ -0,0 +1,164 @@ +reporting = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\DataProvider\Reporting') + ->disableOriginalConstructor() + ->getMock(); + + $searchCriteriaBuilder = $this->mockSearchCriteria(); + + $this->request = $this->getMockBuilder('Magento\Framework\App\RequestInterface') + ->getMockForAbstractClass(); + + $this->filterBuilder = $this->getMockBuilder('Magento\Framework\Api\FilterBuilder') + ->disableOriginalConstructor() + ->getMock(); + + $this->attributeRepository = $this->getMockBuilder('Magento\Customer\Ui\Component\Listing\AttributeRepository') + ->disableOriginalConstructor() + ->getMock(); + + $this->model = new DataProvider( + self::TEST_REQUEST_NAME, + '', + '', + $this->reporting, + $searchCriteriaBuilder, + $this->request, + $this->filterBuilder, + $this->attributeRepository + ); + } + + public function testGetData() + { + $attributeCode = 'attribute_code'; + $attributeValue = [ + AttributeMetadataInterface::OPTIONS => [ + [ + 'label' => 'opt1_label', + 'value' => 'opt1_value', + ], + ], + ]; + + $expected = [ + [ + 'attribute_code' => ['opt1_value'], + ], + ]; + + $attributeMock = $this->getMockBuilder('Magento\Framework\Api\AttributeInterface') + ->getMockForAbstractClass(); + $attributeMock->expects($this->once()) + ->method('getAttributeCode') + ->willReturn($attributeCode); + $attributeMock->expects($this->once()) + ->method('getValue') + ->willReturn('opt1_value'); + + $searchDocumentMock = $this->getMockBuilder('Magento\Framework\Api\Search\DocumentInterface') + ->getMockForAbstractClass(); + $searchDocumentMock->expects($this->once()) + ->method('getCustomAttributes') + ->willReturn([$attributeMock]); + + $searchResultMock = $this->getMockBuilder('Magento\Framework\Api\Search\SearchResultInterface') + ->getMockForAbstractClass(); + $searchResultMock->expects($this->once()) + ->method('getTotalCount') + ->willReturn(1); + $searchResultMock->expects($this->once()) + ->method('getItems') + ->willReturn([$searchDocumentMock]); + + $this->searchCriteria->expects($this->once()) + ->method('setRequestName') + ->with(self::TEST_REQUEST_NAME) + ->willReturnSelf(); + + $this->reporting->expects($this->once()) + ->method('search') + ->with($this->searchCriteria) + ->willReturn($searchResultMock); + + $this->attributeRepository->expects($this->once()) + ->method('getList') + ->willReturn([$attributeCode => $attributeValue]); + + $result = $this->model->getData(); + + $this->assertTrue(is_array($result)); + $this->assertArrayHasKey('totalRecords', $result); + $this->assertEquals(1, $result['totalRecords']); + $this->assertArrayHasKey('items', $result); + $this->assertTrue(is_array($result['items'])); + $this->assertEquals($result['items'], $expected); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject + */ + protected function mockSearchCriteria() + { + $this->searchCriteria = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaInterface') + ->getMockForAbstractClass(); + + $searchCriteriaBuilder = $this->getMockBuilder('Magento\Framework\Api\Search\SearchCriteriaBuilder') + ->disableOriginalConstructor() + ->getMock(); + + $searchCriteriaBuilder->expects($this->any()) + ->method('create') + ->willReturn($this->searchCriteria); + + return $searchCriteriaBuilder; + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 19809e6e5ae13..92df9f65692f6 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -23,12 +23,12 @@ class ActionsTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', [], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php index 68853c63e3751..292f73888809a 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/AttributeColumnTest.php @@ -27,12 +27,12 @@ class AttributeColumnTest extends \PHPUnit_Framework_TestCase public function setup() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->uiComponentFactory = $this->getMock( 'Magento\Framework\View\Element\UiComponentFactory', [], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php index fbdfdf3ff4798..2ff207ba75f96 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/ColumnsTest.php @@ -32,12 +32,12 @@ class ColumnsTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); + $this->context = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface') + ->getMockForAbstractClass(); + $processor = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\Processor') + ->disableOriginalConstructor() + ->getMock(); + $this->context->expects($this->any())->method('getProcessor')->willReturn($processor); $this->columnFactory = $this->getMock( 'Magento\Customer\Ui\Component\ColumnFactory', ['create'], @@ -173,6 +173,7 @@ public function testPrepareWithUpdateColumn() [ 'name' => $attributeCode, 'dataType' => $backendType, + 'filter' => 'text', 'visible' => true ] ); diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php deleted file mode 100644 index 2dc73c58104a5..0000000000000 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/FiltersTest.php +++ /dev/null @@ -1,135 +0,0 @@ -context = $this->getMockForAbstractClass( - 'Magento\Framework\View\Element\UiComponent\ContextInterface', - [], - '', - false - ); - $this->filterFactory = $this->getMock( - 'Magento\Customer\Ui\Component\FilterFactory', - ['create'], - [], - '', - false - ); - $this->attributeRepository = $this->getMock( - 'Magento\Customer\Ui\Component\Listing\AttributeRepository', - [], - [], - '', - false - ); - $this->attributeMetadata = $this->getMockForAbstractClass( - 'Magento\Customer\Api\Data\AttributeMetadataInterface', - [], - '', - false - ); - $this->filter = $this->getMockForAbstractClass( - 'Magento\Ui\Component\Listing\Columns\ColumnInterface', - [], - '', - false - ); - - $this->component = new Filters( - $this->context, - $this->filterFactory, - $this->attributeRepository - ); - } - - public function testPrepare() - { - $attributeCode = 'billing_attribute_code'; - $attributeData = [ - 'attribute_code' => $attributeCode, - 'frontend_input' => 'frontend-input', - 'frontend_label' => 'frontend-label', - 'backend_type' => 'backend-type', - 'options' => [ - [ - 'label' => 'Label', - 'value' => 'Value' - ] - ], - 'is_used_in_grid' => true, - 'is_visible_in_grid' => true, - 'is_filterable_in_grid' => true, - 'is_searchable_in_grid' => true, - ]; - - $this->attributeRepository->expects($this->atLeastOnce()) - ->method('getList') - ->willReturn([$attributeCode => $attributeData]); - $this->filterFactory->expects($this->once()) - ->method('create') - ->with($attributeData, $this->context) - ->willReturn($this->filter); - $this->filter->expects($this->once()) - ->method('prepare'); - - $this->component->prepare(); - $this->assertSame($this->filter, $this->component->getComponent($attributeCode)); - } - - public function testPrepareWithAlreadyAddedComponent() - { - $attributeCode = 'billing_attribute_code'; - $attributeData = [ - 'attribute_code' => $attributeCode, - 'frontend_input' => 'frontend-input', - 'frontend_label' => 'frontend-label', - 'backend_type' => 'backend-type', - 'options' => [ - [ - 'label' => 'Label', - 'value' => 'Value' - ] - ], - 'is_used_in_grid' => true, - 'is_visible_in_grid' => true, - 'is_filterable_in_grid' => false, - 'is_searchable_in_grid' => true, - ]; - - $this->component->addComponent($attributeCode, $this->filter); - - $this->attributeRepository->expects($this->atLeastOnce()) - ->method('getList') - ->willReturn([$attributeCode => $attributeData]); - - $this->component->prepare(); - $this->assertEquals(null, $this->component->getComponent($attributeCode)); - } -} diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php index 36b2f42d3b020..bcb43fb4bfc21 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Columns.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Columns.php @@ -23,6 +23,17 @@ class Columns extends \Magento\Ui\Component\Listing\Columns /** @var InlineEditUpdater */ protected $inlineEditUpdater; + /** + * @var array + */ + protected $filterMap = [ + 'default' => 'text', + 'select' => 'select', + 'boolean' => 'select', + 'multiselect' => 'select', + 'date' => 'dateRange', + ]; + /** * @param ContextInterface $context * @param ColumnFactory $columnFactory @@ -103,6 +114,9 @@ public function prepare() public function addColumn(array $attributeData, $columnName) { $config['sortOrder'] = ++$this->columnSortOrder; + if ($attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID]) { + $config['filter'] = $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]); + } $column = $this->columnFactory->create($attributeData, $columnName, $this->getContext(), $config); $column->prepare(); $this->addComponent($attributeData[AttributeMetadata::ATTRIBUTE_CODE], $column); @@ -128,6 +142,9 @@ public function updateColumn(array $attributeData, $newAttributeCode) 'visible' => (bool)$attributeData[AttributeMetadata::IS_VISIBLE_IN_GRID] ] ); + if ($attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID]) { + $config['filter'] = $this->getFilterType($attributeData[AttributeMetadata::FRONTEND_INPUT]); + } $component->setData('config', $config); } } else { @@ -168,4 +185,15 @@ public function addOptions(UiComponentInterface $component, array $attributeData ); } } + + /** + * Retrieve filter type by $frontendInput + * + * @param string $frontendInput + * @return string + */ + protected function getFilterType($frontendInput) + { + return isset($this->filterMap[$frontendInput]) ? $this->filterMap[$frontendInput] : $this->filterMap['default']; + } } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Filters.php b/app/code/Magento/Customer/Ui/Component/Listing/Filters.php deleted file mode 100644 index 2e0816d079729..0000000000000 --- a/app/code/Magento/Customer/Ui/Component/Listing/Filters.php +++ /dev/null @@ -1,55 +0,0 @@ -filterFactory = $filterFactory; - $this->attributeRepository = $attributeRepository; - } - - /** - * {@inheritdoc} - */ - public function prepare() - { - /** @var \Magento\Customer\Model\Attribute $attribute */ - foreach ($this->attributeRepository->getList() as $attributeCode => $attributeData) { - if (!isset($this->components[$attributeCode])) { - if (!$attributeData[AttributeMetadata::BACKEND_TYPE] != 'static' - && $attributeData[AttributeMetadata::IS_USED_IN_GRID] - && $attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] - ) { - $filter = $this->filterFactory->create($attributeData, $this->getContext()); - $filter->prepare(); - $this->addComponent($attributeCode, $filter); - } - } elseif ($attributeData[AttributeMetadata::IS_USED_IN_GRID] - && !$attributeData[AttributeMetadata::IS_FILTERABLE_IN_GRID] - ) { - unset($this->components[$attributeCode]); - } - } - parent::prepare(); - } -} diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 384841938d033..0b8450f053a07 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -139,19 +139,19 @@ - + Magento\Eav\Model\Entity\VersionControl\Metadata - + Magento\Customer\Model\ResourceModel\Customer\Relation - + Magento\Customer\Model\ResourceModel\Address\Relation diff --git a/app/code/Magento/Customer/etc/module.xml b/app/code/Magento/Customer/etc/module.xml index a2b9b1eacfe84..20c352f8c538c 100644 --- a/app/code/Magento/Customer/etc/module.xml +++ b/app/code/Magento/Customer/etc/module.xml @@ -6,7 +6,7 @@ */ --> - + diff --git a/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml b/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml index d9916cb30d0d2..208394342e1f4 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml @@ -27,11 +27,13 @@ require(['prototype'], function(){ new Ajax.Request('getAjaxUrl() ?>', { parameters: params, onSuccess: function(response) { - result = ''; + var result = ''; try { - response = response.responseText; - if (response == 1) { - result = ''; + if (response.responseText.isJSON()) { + response = response.responseText.evalJSON(); + result = response.message; + } + if (response.valid == 1) { validationMessage.removeClassName('hidden').addClassName('success') } else { validationMessage.removeClassName('hidden').addClassName('error') diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml index 82cd7c7066718..f7d93b699c1af 100644 --- a/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml +++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/cart.phtml @@ -24,8 +24,10 @@ ?> diff --git a/app/code/Magento/Integration/view/adminhtml/web/js/integration.js b/app/code/Magento/Integration/view/adminhtml/web/js/integration.js index 3e299ddf77e45..93504661db614 100644 --- a/app/code/Magento/Integration/view/adminhtml/web/js/integration.js +++ b/app/code/Magento/Integration/view/adminhtml/web/js/integration.js @@ -7,9 +7,11 @@ /*global integration*/ define([ "jquery", + "Magento_Ui/js/modal/alert", "jquery/ui", - "mage/translate" -], function($){ + "mage/translate", + "Magento_Ui/js/modal/modal" +], function($, alert){ "use strict"; $.widget('mage.integration', { @@ -80,7 +82,9 @@ define([ } }, error: function (jqXHR, status, error) { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); window.console && console.log(status + ': ' + error + "\nResponse text:\n" + jqXHR.responseText); }, complete: function () { @@ -168,12 +172,12 @@ define([ $('body').trigger('processStart'); //Check for window closed window.location.reload(); - IdentityLogin.jqInfoDialog.dialog('close'); + IdentityLogin.jqInfoDialog.modal('closeModal'); } } catch (e) { //squash. In case Window closed without success callback, clear polling if (IdentityLogin.win.closed) { - IdentityLogin.jqInfoDialog.dialog('close'); + IdentityLogin.jqInfoDialog.modal('closeModal'); clearInterval(IdentityLogin.checker); } return; @@ -217,53 +221,24 @@ define([ } catch (e) { //This is expected if result is not json. Do nothing. } + if (identityLinkUrl && consumerId && popupHtml) { IdentityLogin.invokePopup(identityLinkUrl, consumerId, popup); } else { popupHtml = result; } + if (popup.length === 0){ + popup = $('
'); + } popup.html(popupHtml); var buttons = [], dialogProperties = { title: title, - modal: true, - autoOpen: true, - minHeight: 450, - minWidth: 600, - width: '75%', + type: 'slide', dialogClass: dialog == 'permissions' ? 'integration-dialog' : 'integration-dialog no-close', - closeOnEscape: false, - position: { - my: 'left top', - at: 'center top', - of: 'body' - }, - open: function () { - $(this).closest('.ui-dialog').addClass('ui-dialog-active'); - - var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30; - $(this).closest('.ui-dialog').css('margin-top', topMargin); - }, - close: function () { - $(this).closest('.ui-dialog').removeClass('ui-dialog-active'); - } }; - if (dialog == 'permissions') { - // We don't need this button in 'tokens' dialog, since if you got there - integration is - // already activated and have necessary tokens - buttons.push({ - text: $.mage.__('Cancel'), - 'class': 'action-close', - click: function () { - $(this).dialog('close'); - } - }); - } else if (dialog == 'tokensExchange') { - dialogProperties['minHeight'] = 150; - dialogProperties['minWidth'] = 500; - } // Add confirmation button to the list of dialog buttons. okButton not set for tokenExchange dialog if (okButton) { @@ -273,10 +248,13 @@ define([ if (buttons.length > 0) { dialogProperties['buttons'] = buttons } - popup.dialog(dialogProperties); + popup.modal(dialogProperties); + popup.modal('openModal'); }, error: function (jqXHR, status, error) { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); window.console && console.log(status + ': ' + error + "\nResponse text:\n" + jqXHR.responseText); }, complete: function () { @@ -322,17 +300,20 @@ define([ permissions: { text: (isReauthorize == '1') ? $.mage.__('Reauthorize') : $.mage.__('Allow'), 'class': 'action-primary', - // This data is going to be used in the next dialog - 'data-row-id': integrationId, - 'data-row-name': integrationName, - 'data-row-dialog': (isTokenExchange == '1') ? 'tokensExchange' : 'tokens', - 'data-row-is-reauthorize': isReauthorize, - 'data-row-is-token-exchange': isTokenExchange, + attr: { + 'data-row-id': integrationId, + 'data-row-name': integrationName, + 'data-row-dialog': (isTokenExchange == '1') ? 'tokensExchange' : 'tokens', + 'data-row-is-reauthorize': isReauthorize, + 'data-row-is-token-exchange': isTokenExchange + }, click: function () { // Find the 'Allow' button and clone - it has all necessary data, but is going to be // destroyed along with the current dialog - var ctx = $(this).parent().find('button.action-primary').clone(true); - $(this).dialog('destroy'); + var ctx = this.modal.find('button.action-primary').clone(true); + + this.closeModal(); + this.modal.remove(); // Make popup out of data we saved from 'Allow' button window.integration.popup.show(ctx); } diff --git a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml index 6b7142d703cdf..39cd52f20586c 100644 --- a/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml +++ b/app/code/Magento/LayeredNavigation/view/adminhtml/ui_component/product_attributes_listing.xml @@ -6,32 +6,15 @@ */ --> - - - - - Magento\LayeredNavigation\Model\Attribute\Source\FilterableOptions - - - - is_filterable - Use in Layered Navigation - Select... - - - - - + Magento\LayeredNavigation\Model\Attribute\Source\FilterableOptions - - Magento_Ui/js/grid/columns/select - + select + Magento_Ui/js/grid/columns/select select - left Use in Layered Navigation diff --git a/app/code/Magento/Marketplace/composer.json b/app/code/Magento/Marketplace/composer.json index c472be8a8fdac..de0198668102e 100644 --- a/app/code/Magento/Marketplace/composer.json +++ b/app/code/Magento/Marketplace/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-marketplace", "description": "N/A", "require": { - "php": "~5.5.0|~5.6.0", + "php": "~5.5.0|~5.6.0|~7.0.0", "magento/framework": "1.0.0-beta", "magento/module-backend": "1.0.0-beta" }, diff --git a/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php b/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php index 0b1ebbd8317f1..f5f367e40eba7 100644 --- a/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php +++ b/app/code/Magento/MediaStorage/Model/Config/Backend/Storage/Media/Database.php @@ -20,7 +20,7 @@ class Database extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\MediaStorage\Helper\File\Storage $coreFileStorage - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -30,7 +30,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\MediaStorage\Helper\File\Storage $coreFileStorage, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/MediaStorage/Model/File/Storage.php b/app/code/Magento/MediaStorage/Model/File/Storage.php index aa3e783d87a09..87b176f850b30 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage.php @@ -98,7 +98,7 @@ class Storage extends AbstractModel * @param \Magento\MediaStorage\Model\File\Storage\FileFactory $fileFactory * @param \Magento\MediaStorage\Model\File\Storage\DatabaseFactory $databaseFactory * @param Filesystem $filesystem - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -113,7 +113,7 @@ public function __construct( \Magento\MediaStorage\Model\File\Storage\FileFactory $fileFactory, \Magento\MediaStorage\Model\File\Storage\DatabaseFactory $databaseFactory, Filesystem $filesystem, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/MediaStorage/Model/File/Storage/Database/AbstractDatabase.php b/app/code/Magento/MediaStorage/Model/File/Storage/Database/AbstractDatabase.php index 5e764db6ac952..16d3439c9ace7 100644 --- a/app/code/Magento/MediaStorage/Model/File/Storage/Database/AbstractDatabase.php +++ b/app/code/Magento/MediaStorage/Model/File/Storage/Database/AbstractDatabase.php @@ -47,7 +47,7 @@ abstract class AbstractDatabase extends \Magento\Framework\Model\AbstractModel * @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\Framework\Stdlib\DateTime\DateTime $dateModel * @param \Magento\Framework\App\Config\ScopeConfigInterface $configuration - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param string $connectionName * @param array $data @@ -58,7 +58,7 @@ public function __construct( \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDb, \Magento\Framework\Stdlib\DateTime\DateTime $dateModel, \Magento\Framework\App\Config\ScopeConfigInterface $configuration, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, $connectionName = null, array $data = [] @@ -94,7 +94,7 @@ public function getConfigConnectionName() /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\AbstractResource + * @return \Magento\Framework\Model\ResourceModel\AbstractResource */ protected function _getResource() { diff --git a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/AbstractStorage.php b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/AbstractStorage.php index 93633dcf3ae26..934279fedb502 100644 --- a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/AbstractStorage.php +++ b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/AbstractStorage.php @@ -8,7 +8,7 @@ /** * Class AbstractStorage */ -abstract class AbstractStorage extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +abstract class AbstractStorage extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * File storage connection name diff --git a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/Database.php b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/Database.php index 4c2521eab93a1..429c4c3e9f1dc 100644 --- a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/Database.php +++ b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/Database.php @@ -16,12 +16,12 @@ class Database extends \Magento\MediaStorage\Model\ResourceModel\File\Storage\Ab protected $_resourceHelper; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\DB\Helper $resourceHelper * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\DB\Helper $resourceHelper, $connectionName = null ) { diff --git a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php index 1def7eab39dda..2299f66fcbdb3 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Helper/File/Storage/DatabaseTest.php @@ -107,7 +107,7 @@ public function testGetResourceStorageModel() $this->dbStorageFactoryMock->expects($this->once()) ->method('create') ->will($this->returnValue($dbModelMock)); - $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ModelResource\Db\AbstractDb') + $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMockForAbstractClass(); @@ -348,7 +348,7 @@ public function testDeleteFolder($storage, $callNum) $this->dbStorageFactoryMock->expects($this->exactly($callNum)) ->method('create') ->will($this->returnValue($dbModelMock)); - $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ModelResource\Db\AbstractDb') + $resourceModelMock = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') ->disableOriginalConstructor() ->setMethods(['deleteFolder', '__wakeup']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml b/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml index 0c9080bc8db1b..316c5fa5b3d28 100644 --- a/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml +++ b/app/code/Magento/MediaStorage/view/adminhtml/templates/system/config/system/storage/media/synchronize.phtml @@ -102,7 +102,7 @@ require([ var response; try { - response = eval('(' + transport.responseText + ')'); + response = JSON.parse(transport.responseText); if (response.state == '' && response.message ) { diff --git a/app/code/Magento/Msrp/view/base/web/js/msrp.js b/app/code/Magento/Msrp/view/base/web/js/msrp.js index 8bad507ec0714..18ea804d23818 100644 --- a/app/code/Magento/Msrp/view/base/web/js/msrp.js +++ b/app/code/Magento/Msrp/view/base/web/js/msrp.js @@ -6,11 +6,11 @@ define([ 'jquery', 'underscore', 'jquery/ui', - 'mage/dropdown' + 'mage/dropdown', + 'mage/template' ], function ($, _) { 'use strict'; - var openDropDown = null; $.widget('mage.addToCart', { options: { showAddToCart: true, @@ -21,6 +21,9 @@ define([ // Selectors cartForm: '.form.map.checkout', + msrpLabelId: '#map-popup-msrp', + priceLabelId: '#map-popup-price', + popUpAttr: '[data-role=msrp-popup-template]', cartButtonId: '', // better to be cartButton popupId: '', // better to be popup realPrice: '', @@ -31,143 +34,109 @@ define([ // Text options productName: '', addToCartUrl: '' + }, openDropDown: null, + triggerClass: 'dropdown-active', + + popUpOptions: { + appendTo: 'body', + dialogContentClass: 'active', + closeOnMouseLeave: false, + autoPosition: true, + closeOnClickOutside: false, + 'dialogClass': 'popup map-popup-wrapper', + position: { + my: 'left top', + collision: 'fit none', + at: 'left bottom', + within: 'body' + }, + shadowHinter: 'popup popup-pointer' + }, + popupOpened: false, /** * Creates widget instance * @private */ _create: function () { - $(this.options.cartButtonId).on('click', this._addToCartSubmit.bind(this)); - - $(this.options.popupId).on('click', function (event) { - var dialog; - event.preventDefault(); - - if (this.options.submitUrl) { - location.href = this.options.submitUrl; - } else { - $(this.options.popupCartButtonId) - .off('click') - .on('click', this._addToCartSubmit.bind(this)); - $('#map-popup-heading-price').text(this.options.productName); - $('#map-popup-price').html($(this.options.realPrice).html().trim()); - $('#map-popup-msrp > span.price').html(this.options.msrpPrice); - - this.element.trigger('reloadPrice'); - - dialog = $('#map-popup-click-for-price'); - this._popupDialog(dialog, this.options.popupId); - - if (this.options.addToCartUrl) { - $(this.options.cartForm).attr('action', this.options.addToCartUrl); - } - - if (!this.options.showAddToCart) { - $('#product_addtocart_form_from_popup').hide(); - } - - return false; - } - }.bind(this)); + var tierOptions; + + this.popupDOM = $(this.options.popUpAttr)[0]; + this.infoPopupDOM = $('[data-role=msrp-info-template]')[0]; + + if (this.options.popupId) { + $('body').append($(this.popupDOM).html()); + this.$popup = $($(this.popupDOM).html()); + + $(this.options.popupId).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + this.$popup.find(this.options.msrpLabelId).html(this.options.msrpPrice); + this.$popup.find(this.options.priceLabelId).html(this.options.realPrice); + this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + + this.$popup.find('button').on('click', function () { + if (this.options.addToCartButton) { + $(this.options.addToCartButton).click(); + } + }.bind(this)); + this._toggle(this.$popup); + }.bind(this)); + } - $(this.options.helpLinkId).on('click', function () { - $('#map-popup-heading-what-this').text(this.options.productName); - this._popupDialog($('#map-popup-what-this'), this.options.helpLinkId); + if (this.options.helpLinkId) { + this.$infoPopup = $(this.infoPopupDOM.innerText).appendTo('body'); + $(this.options.helpLinkId).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + this.$infoPopup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + this._toggle(this.$infoPopup); + }.bind(this)); + } - return false; - }.bind(this)); + if (this.options.attr) { + this.popupDOM = $(this.options.popUpAttr)[0]; + this.$popup = $(this.popupDOM.innerText).appendTo('body'); + this.popUpOptions.position.of = $(this.options.helpLinkId); + $(this.options.attr).on('click', function (e) { + this.popUpOptions.position.of = $(e.target); + tierOptions = JSON.parse($(e.target).attr('data-tier-price')); + this.$popup.find(this.options.msrpLabelId).html(tierOptions.msrp); + this.$popup.find(this.options.priceLabelId).html(tierOptions.price); + this.$popup.find('button').on('click', function (e) { + e.preventDefault(); + this.$popup.find('form').attr('action', tierOptions.addToCartUrl).submit(); + }.bind(this)); + this.$popup.dropdownDialog(this.popUpOptions).dropdownDialog('open'); + this._toggle(this.$popup); + }.bind(this)); + } }, /** - * Handler for dialog popup - * @param {jQuery} elementTarget - * @param {jQuery} elementTrigger + * + * @param $elem * @private */ - _popupDialog: function (elementTarget, elementTrigger) { - var target = $(elementTarget), - trigger = $(elementTrigger), - counter = 0, - triggerClass = 'dropdown-active', - options; - - options = { - appendTo: 'body', - dialogContentClass: 'active', - closeOnMouseLeave: false, - autoPosition: true, - 'dialogClass': 'popup map-popup-wrapper', - position: { - my: 'left top', - collision: 'fit none', - at: 'left bottom', - within: 'body', - of: trigger - }, - shadowHinter: 'popup popup-pointer' - }; - options = _.extend(options, this.options.dialog); - - if (openDropDown && openDropDown.is(':data(mage-dropdownDialog)')) { - openDropDown.dropdownDialog('close'); - } - - if (this.options.singleOpenDropDown) { - this.openDropDown = openDropDown; - } - openDropDown = target - .dropdownDialog(options) - .off('dropdowndialogclose') - .on('dropdowndialogclose', function () { - if (!counter) { - openDropDown = null; - $(window).off('resize'); - } - trigger.removeClass(triggerClass); - }) - .on('dropdowndialogopen', function () { - trigger.addClass(triggerClass); - }) - .dropdownDialog('open'); - - $(window) - .resize(_.debounce(function () { - if (openDropDown) { - counter--; - openDropDown.dropdownDialog('open'); - } - }, this.options.dialogDelay)) - .resize(_.debounce(function () { - if (openDropDown) { - counter++; - openDropDown.dropdownDialog('close'); - } - }, this.options.dialogDelay, true)); + _toggle: function ($elem) { + $(document).on('mouseup', function (e) { + if (!$elem.is(e.target) && $elem.has(e.target).length === 0) { + this.closePopup($elem); + } + }.bind(this)); + $(window).on('resize', function () { + this.closePopup($elem); + }.bind(this)) }, /** - * Handler for addToCart action - * @private + * + * @param $elem */ - _addToCartSubmit: function () { - this.element.trigger('addToCart', this.element); - if (this.element.data('stop-processing')) { - return false; - } - - if (this.options.addToCartButton) { - $(this.options.addToCartButton).click(); - - return; - } - - if (this.options.addToCartUrl) { - $('.mage-dropdown-dialog > .ui-dialog-content').dropdownDialog('close'); - } - $(this.options.cartForm).submit(); + closePopup: function ($elem) { + $elem.dropdownDialog('close'); + $(document).off('mouseup'); } }); diff --git a/app/code/Magento/Msrp/view/frontend/templates/popup.phtml b/app/code/Magento/Msrp/view/frontend/templates/popup.phtml index 07230989e1808..521f17e4971b6 100644 --- a/app/code/Magento/Msrp/view/frontend/templates/popup.phtml +++ b/app/code/Magento/Msrp/view/frontend/templates/popup.phtml @@ -11,6 +11,7 @@ /** @var \Magento\Msrp\Block\Popup $block */ ?> isEnabled()): ?> + + diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts.php index 8de4e7ff9221a..bbd351eee8af3 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel; -class Counts extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Counts extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize users resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php index d6cd15cda1126..da4e4bdbabee7 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Counts/Collection.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel\Counts; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize counts resource collection diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module.php index c9d73c97fb78f..43bd47407d1ff 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel; -class Module extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Module extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize module status resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php index 1b41b28aa7b81..28c4119736bd7 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Module/Collection.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel\Module; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize module status resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders.php index 8620239aef5f5..d3ba20c22ba32 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel; -class Orders extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Orders extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize orders resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php index f5a51553da223..0f49fe88bce7e 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Orders/Collection.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel\Orders; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize orders resource collection diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System.php index 6baa41ddb8d6b..b5e4edc67b9d5 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel; -class System extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class System extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize system updates resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php index c054b74d6a4f8..021b2f3d4a69e 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/System/Collection.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel\System; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize system updates resource collection diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users.php index 6240ce4015199..40b062535bf72 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel; -class Users extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Users extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize users resource model diff --git a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php index aa54af519c9d2..6f6d18c6da839 100644 --- a/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php +++ b/app/code/Magento/NewRelicReporting/Model/ResourceModel/Users/Collection.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\ResourceModel\Users; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Initialize users resource collection diff --git a/app/code/Magento/NewRelicReporting/composer.json b/app/code/Magento/NewRelicReporting/composer.json index d3336380128e1..8e8301f161e9a 100644 --- a/app/code/Magento/NewRelicReporting/composer.json +++ b/app/code/Magento/NewRelicReporting/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-new-relic-reporting", "description": "N/A", "require": { - "php": "~5.5.0|~5.6.0", + "php": "~5.5.0|~5.6.0|~7.0.0", "magento/module-store": "1.0.0-beta", "magento/module-backend": "1.0.0-beta", "magento/module-customer": "1.0.0-beta", diff --git a/app/code/Magento/Newsletter/Model/Problem.php b/app/code/Magento/Newsletter/Model/Problem.php index f881d8e9912e8..f62b509660559 100644 --- a/app/code/Magento/Newsletter/Model/Problem.php +++ b/app/code/Magento/Newsletter/Model/Problem.php @@ -43,7 +43,7 @@ class Problem extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -51,7 +51,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Newsletter\Model\SubscriberFactory $subscriberFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Newsletter/Model/Queue.php b/app/code/Magento/Newsletter/Model/Queue.php index 6b34b766a5e04..17c28f4d56fcf 100644 --- a/app/code/Magento/Newsletter/Model/Queue.php +++ b/app/code/Magento/Newsletter/Model/Queue.php @@ -117,7 +117,7 @@ class Queue extends \Magento\Framework\Model\AbstractModel implements TemplateTy * @param \Magento\Newsletter\Model\ProblemFactory $problemFactory * @param \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollectionFactory * @param \Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -131,7 +131,7 @@ public function __construct( \Magento\Newsletter\Model\ProblemFactory $problemFactory, \Magento\Newsletter\Model\ResourceModel\Subscriber\CollectionFactory $subscriberCollectionFactory, \Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Grid/Collection.php index 7c9ee8c0e289d..29ca4f54293ba 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Grid/Collection.php @@ -18,7 +18,7 @@ class Collection extends \Magento\Newsletter\Model\ResourceModel\Problem\Collect /** * Adds queue info to grid * - * @return \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection|\Magento\Newsletter\Model\ResourceModel\Grid\Collection + * @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection|\Magento\Newsletter\Model\ResourceModel\Grid\Collection */ protected function _initSelect() { diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Problem.php b/app/code/Magento/Newsletter/Model/ResourceModel/Problem.php index fb9fd78ee0b74..77d8b9baec130 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Problem.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Problem.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Problem extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Problem extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php index 4d0dfe4cb603f..110ef3c821bec 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Problem/Collection.php @@ -13,7 +13,7 @@ * * @SuppressWarnings(PHPMD.LongVariable) */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * True when subscribers info joined @@ -63,7 +63,7 @@ class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\Ab * @param CustomerRepository $customerRepository * @param \Magento\Customer\Helper\View $customerView * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactory $entityFactory, @@ -73,7 +73,7 @@ public function __construct( CustomerRepository $customerRepository, \Magento\Customer\Helper\View $customerView, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->customerRepository = $customerRepository; diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Queue.php b/app/code/Magento/Newsletter/Model/ResourceModel/Queue.php index 6bc24a47f6e99..cf8086a659828 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Queue.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Queue.php @@ -13,7 +13,7 @@ * * @author Magento Core Team */ -class Queue extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Queue extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Subscriber collection @@ -25,12 +25,12 @@ class Queue extends \Magento\Framework\Model\ModelResource\Db\AbstractDb /** * Construct * - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection $subscriberCollection * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Newsletter\Model\ResourceModel\Subscriber\Collection $subscriberCollection, $connectionName = null ) { diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php index 66eea82e01b17..138b7bd121eed 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Queue/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * True when subscribers info joined @@ -40,7 +40,7 @@ class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\Ab * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactory $entityFactory, @@ -49,7 +49,7 @@ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_date = $date; diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php index f0bac9f61c69f..ffd998a2c333f 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Subscriber extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Subscriber extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * DB connection @@ -48,13 +48,13 @@ class Subscriber extends \Magento\Framework\Model\ModelResource\Db\AbstractDb /** * Construct * - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param \Magento\Framework\Math\Random $mathRandom * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, \Magento\Framework\Math\Random $mathRandom, $connectionName = null diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php index b93f600cbdc45..92de4c8b2e6cc 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Subscriber/Collection.php @@ -12,7 +12,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Queue link table name @@ -63,7 +63,7 @@ class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\Ab * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Eav\Helper\Data $customerHelperData * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactory $entityFactory, @@ -72,7 +72,7 @@ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Eav\Helper\Data $customerHelperData, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { $this->_customerHelperData = $customerHelperData; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Template.php b/app/code/Magento/Newsletter/Model/ResourceModel/Template.php index f2a19d1c81ebe..3d9c097678af8 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Template.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Template.php @@ -13,7 +13,7 @@ * * @author Magento Core Team */ -class Template extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Template extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Date @@ -23,12 +23,12 @@ class Template extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $_date; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTime $date * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $date, $connectionName = null ) { diff --git a/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php b/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php index 17e5272f31586..925352d50497c 100644 --- a/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php +++ b/app/code/Magento/Newsletter/Model/ResourceModel/Template/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Define resource model and model diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 2a4be1caffe25..5ea6aefc0defe 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -133,7 +133,7 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel * @param CustomerRepositoryInterface $customerRepository * @param AccountManagementInterface $customerAccountManagement * @param \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -149,7 +149,7 @@ public function __construct( CustomerRepositoryInterface $customerRepository, AccountManagementInterface $customerAccountManagement, \Magento\Framework\Translate\Inline\StateInterface $inlineTranslation, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml index 84c07890a4efe..26ac1a28b3c06 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Newsletter/view/adminhtml/templates/template/edit.phtml @@ -31,9 +31,11 @@ use Magento\Framework\App\TemplateTypesInterface; require([ 'jquery', 'tinymce', + 'Magento_Ui/js/modal/prompt', + 'Magento_Ui/js/modal/confirm', 'mage/mage', 'prototype' -], function(jQuery, tinyMCE){ +], function(jQuery, tinyMCE, prompt, confirm){ //")) { - return false; - } - if(this.isEditor()) { - this.getEditor().turnOff(); - this.getEditor().getToggleButton().hide(); - } - this.unconvertedText = $(this.id).value; - $('convert_button').hide(); - $('convert_button_back').show(); - $(this.id).value = $(this.id).value.stripScripts().stripTags(); - $('field_template_styles').hide(); - this.typeChange = true; - return false; + var self = this; + + confirm({ + content: "", + actions: { + confirm: function(){ + if(self.isEditor()) { + self.getEditor().turnOff(); + self.getEditor().getToggleButton().hide(); + } + self.unconvertedText = $(self.id).value; + $('convert_button').hide(); + $('convert_button_back').show(); + $(self.id).value = $(self.id).value.stripScripts().stripTags(); + $('field_template_styles').hide(); + self.typeChange = true; + } + } + }); + }, unStripTags: function () { @@ -123,24 +131,38 @@ require([ }, saveAs: function() { + var self = this; + if (this.typeChange) { $('change_flag_element').value = '1'; } if($F('code').blank() || $F('code')==templateControl.templateName) { - value = prompt('', templateControl.templateName + ''); - if(!value) { - if(value !== null) { - $('code').value = ''; - // Temporary solution will be replaced after refactoring of newsletter functionality - jQuery('#newsletter_template_edit_form').triggerHandler('save'); - } - return false; - } else { - $('code').value = value; - } + + prompt({ + content: '', + value: templateControl.templateName + '', + actions: { + confirm: function(value) { + $('code').value = value; + self._saveAs(); + + return false; + }, + cancel: function(){ + $('code').value = ''; + // Temporary solution will be replaced after refactoring of newsletter functionality + jQuery('#newsletter_template_edit_form').triggerHandler('save'); + self._saveAs(); + + return false; + } + } + }); } + }, + _saveAs: function() { $('save_as_flag').value = '1'; if(this.isEditor()) { @@ -176,9 +198,14 @@ require([ }, deleteTemplate: function() { - if(window.confirm("")) { - window.location.href = 'getDeleteUrl() ?>'; - } + confirm({ + content: "", + actions: { + confirm: function() { + window.location.href = 'getDeleteUrl() ?>'; + } + } + }); }, isEditor: function() { diff --git a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php index 605afa7583375..08d23d9245564 100644 --- a/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/Config/Backend/Tablerate.php @@ -25,7 +25,7 @@ class Tablerate extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -35,7 +35,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\OfflineShipping\Model\ResourceModel\Carrier\TablerateFactory $tablerateFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php index 8d8c47141d93c..df0228a338358 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate.php @@ -18,7 +18,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Tablerate extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Tablerate extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Import table rates website ID @@ -122,7 +122,7 @@ class Tablerate extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $_filesystem; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -133,7 +133,7 @@ class Tablerate extends \Magento\Framework\Model\ModelResource\Db\AbstractDb * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Psr\Log\LoggerInterface $logger, \Magento\Framework\App\Config\ScopeConfigInterface $coreConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php index 441fec80fe07b..1a63a12fac974 100644 --- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php +++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Directory/country table name diff --git a/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php b/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php index fd04f1fe4ca2f..d86d8df059161 100644 --- a/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php +++ b/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php @@ -76,6 +76,11 @@ public function aroundDispatch( $this->kernel->process($result); } } else { + json_decode($result->getContent()); + if (json_last_error() == JSON_ERROR_NONE) { + // reset profiler to avoid appending profiling stat to JSON response + \Magento\Framework\Profiler::reset(); + } $this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true); } return $result; diff --git a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php index 9e4102c889052..ae38b76db495f 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/App/FrontController/BuiltinPluginTest.php @@ -200,6 +200,7 @@ public function testAroundDispatchReturnsCache($state) $this->responseMock->expects($this->never()) ->method('setHeader'); } + $this->responseMock->expects($this->once())->method('getContent'); $this->assertSame( $this->responseMock, $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock) diff --git a/app/code/Magento/Payment/Gateway/Command/CommandPool.php b/app/code/Magento/Payment/Gateway/Command/CommandPool.php index 6b1014d5aa76d..d1fc52a723782 100644 --- a/app/code/Magento/Payment/Gateway/Command/CommandPool.php +++ b/app/code/Magento/Payment/Gateway/Command/CommandPool.php @@ -18,17 +18,17 @@ class CommandPool implements CommandPoolInterface private $commands; /** - * @param array $commands * @param TMapFactory $tmapFactory + * @param array $commands */ public function __construct( - array $commands, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $commands = [] ) { $this->commands = $tmapFactory->create( [ 'array' => $commands, - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php index 0364336a2ea5e..b23964b064274 100644 --- a/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php +++ b/app/code/Magento/Payment/Gateway/Config/ValueHandlerPool.php @@ -21,12 +21,12 @@ class ValueHandlerPool implements \Magento\Payment\Gateway\Config\ValueHandlerPo private $handlers; /** - * @param array $handlers * @param TMapFactory $tmapFactory + * @param array $handlers */ public function __construct( - array $handlers, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $handlers ) { if (!isset($handlers[self::DEFAULT_HANDLER])) { throw new \LogicException('Default handler should be provided.'); @@ -35,7 +35,7 @@ public function __construct( $this->handlers = $tmapFactory->create( [ 'array' => $handlers, - 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + 'type' => ValueHandlerInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php index 66584773b638d..43f39b2932b40 100644 --- a/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php +++ b/app/code/Magento/Payment/Gateway/Request/BuilderComposite.php @@ -19,17 +19,17 @@ class BuilderComposite implements BuilderInterface private $builders; /** - * @param array $builders * @param TMapFactory $tmapFactory + * @param array $builders */ public function __construct( - array $builders, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $builders = [] ) { $this->builders = $tmapFactory->create( [ 'array' => $builders, - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php index 1425514e7e3fb..6a45311d5eb89 100644 --- a/app/code/Magento/Payment/Gateway/Response/HandlerChain.php +++ b/app/code/Magento/Payment/Gateway/Response/HandlerChain.php @@ -16,17 +16,17 @@ class HandlerChain implements HandlerInterface private $handlers; /** - * @param array $handlers * @param TMapFactory $tmapFactory + * @param array $handlers */ public function __construct( - array $handlers, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $handlers = [] ) { $this->handlers = $tmapFactory->create( [ 'array' => $handlers, - 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'type' => HandlerInterface::class ] ); } diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php index 6e7c5c8c0ab5c..b36ceed14bdfa 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorComposite.php @@ -18,18 +18,18 @@ class ValidatorComposite extends AbstractValidator /** * @param ResultInterfaceFactory $resultFactory - * @param array $validators * @param TMapFactory $tmapFactory + * @param array $validators */ public function __construct( ResultInterfaceFactory $resultFactory, - array $validators, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $validators = [] ) { $this->validators = $tmapFactory->create( [ 'array' => $validators, - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ); parent::__construct($resultFactory); diff --git a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php index e2b746ea7334f..6697dd86c3d88 100644 --- a/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php +++ b/app/code/Magento/Payment/Gateway/Validator/ValidatorPool.php @@ -17,17 +17,17 @@ class ValidatorPool implements \Magento\Payment\Gateway\Validator\ValidatorPoolI private $validators; /** - * @param array $validators * @param TMapFactory $tmapFactory + * @param array $validators */ public function __construct( - array $validators, - TMapFactory $tmapFactory + TMapFactory $tmapFactory, + array $validators = [] ) { $this->validators = $tmapFactory->create( [ 'array' => $validators, - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ); } diff --git a/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php index 8bbdbef28307a..efd63ae579a5c 100644 --- a/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php +++ b/app/code/Magento/Payment/Model/Checks/CanUseForCountry/CountryProvider.php @@ -31,8 +31,9 @@ public function __construct(DirectoryHelper $directoryHelper) */ public function getCountry(Quote $quote) { - return $quote->isVirtual() - ? $this->directoryHelper->getDefaultCountry() - : $quote->getShippingAddress()->getCountry(); + $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress(); + return $address + ? $address->getCountry() + : $this->directoryHelper->getDefaultCountry(); } } diff --git a/app/code/Magento/Payment/Model/Info.php b/app/code/Magento/Payment/Model/Info.php index f6028fc936936..4ba972b321f11 100644 --- a/app/code/Magento/Payment/Model/Info.php +++ b/app/code/Magento/Payment/Model/Info.php @@ -38,7 +38,7 @@ class Info extends AbstractExtensibleModel implements InfoInterface * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -49,7 +49,7 @@ public function __construct( \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory, \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\Encryption\EncryptorInterface $encryptor, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Payment/Model/Method/AbstractMethod.php b/app/code/Magento/Payment/Model/Method/AbstractMethod.php index cc47008313c98..8e6300b62584b 100644 --- a/app/code/Magento/Payment/Model/Method/AbstractMethod.php +++ b/app/code/Magento/Payment/Model/Method/AbstractMethod.php @@ -221,7 +221,7 @@ abstract class AbstractMethod extends \Magento\Framework\Model\AbstractExtensibl * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Logger $logger - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -234,7 +234,7 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Payment/Model/Method/Cc.php b/app/code/Magento/Payment/Model/Method/Cc.php index 23fa92da5382d..1bf0ab267e2b9 100644 --- a/app/code/Magento/Payment/Model/Method/Cc.php +++ b/app/code/Magento/Payment/Model/Method/Cc.php @@ -46,7 +46,7 @@ class Cc extends \Magento\Payment\Model\Method\AbstractMethod * @param Logger $logger * @param \Magento\Framework\Module\ModuleListInterface $moduleList * @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -61,7 +61,7 @@ public function __construct( \Magento\Payment\Model\Method\Logger $logger, \Magento\Framework\Module\ModuleListInterface $moduleList, \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Payment/Model/Method/Free.php b/app/code/Magento/Payment/Model/Method/Free.php index fd15c0a926d7d..dd534c8a58f1a 100644 --- a/app/code/Magento/Payment/Model/Method/Free.php +++ b/app/code/Magento/Payment/Model/Method/Free.php @@ -52,7 +52,7 @@ class Free extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Logger $logger * @param PriceCurrencyInterface $priceCurrency - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -66,7 +66,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, PriceCurrencyInterface $priceCurrency, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Payment/Model/Method/Logger.php b/app/code/Magento/Payment/Model/Method/Logger.php index 7e7331b77df73..47c91a25968cc 100644 --- a/app/code/Magento/Payment/Model/Method/Logger.php +++ b/app/code/Magento/Payment/Model/Method/Logger.php @@ -41,21 +41,21 @@ public function __construct( /** * Logs payment related information used for debug * - * @param array $debugData - * @param array|null $debugReplaceKeys - * @param bool|null $debugFlag + * @param array $data + * @param array|null $maskKeys + * @param bool|null $forceDebug * @return void */ - public function debug(array $debugData, array $debugReplaceKeys = null, $debugFlag = null) + public function debug(array $data, array $maskKeys = null, $forceDebug = null) { - $debugReplaceKeys = $debugReplaceKeys !== null ? $debugReplaceKeys : $this->getDebugReplaceFields(); - $debugFlag = $debugFlag !== null ? $debugFlag : $this->isDebugOn(); - if ($debugFlag === true && !empty($debugData) && !empty($debugReplaceKeys)) { - $debugData = $this->filterDebugData( - $debugData, - $debugReplaceKeys + $maskKeys = $maskKeys !== null ? $maskKeys : $this->getDebugReplaceFields(); + $debugOn = $forceDebug !== null ? $forceDebug : $this->isDebugOn(); + if ($debugOn === true) { + $data = $this->filterDebugData( + $data, + $maskKeys ); - $this->logger->debug(var_export($debugData, true)); + $this->logger->debug(var_export($data, true)); } } @@ -66,7 +66,7 @@ public function debug(array $debugData, array $debugReplaceKeys = null, $debugFl */ private function getDebugReplaceFields() { - if ($this->config->getValue('debugReplaceKeys')) { + if ($this->config and $this->config->getValue('debugReplaceKeys')) { return explode(',', $this->config->getValue('debugReplaceKeys')); } return []; @@ -79,7 +79,7 @@ private function getDebugReplaceFields() */ private function isDebugOn() { - return (bool)$this->config->getValue('debug'); + return $this->config and (bool)$this->config->getValue('debug'); } /** diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php index 92394d8bb330e..7ab96f4474e49 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Command/CommandPoolTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Command; use Magento\Payment\Gateway\Command\CommandPool; +use Magento\Payment\Gateway\CommandInterface; class CommandPoolTest extends \PHPUnit_Framework_TestCase { @@ -26,7 +27,7 @@ public function testGet() ->with( [ 'array' => ['Magento\Payment\Gateway\CommandInterface'], - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ) ->willReturn($tMap); @@ -39,7 +40,7 @@ public function testGet() ->with('command') ->willReturn($commandI); - $pool = new CommandPool(['Magento\Payment\Gateway\CommandInterface'], $tMapFactory); + $pool = new CommandPool($tMapFactory, ['Magento\Payment\Gateway\CommandInterface']); static::assertSame($commandI, $pool->get('command')); } @@ -61,7 +62,7 @@ public function testGetException() ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\CommandInterface' + 'type' => CommandInterface::class ] ) ->willReturn($tMap); @@ -70,7 +71,7 @@ public function testGetException() ->with('command') ->willReturn(false); - $pool = new CommandPool([], $tMapFactory); + $pool = new CommandPool($tMapFactory, []); $pool->get('command'); } } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php index 266128b42f6f9..cac2d6c1c9d21 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Config/ValueHandlerPoolTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Payment\Test\Unit\Gateway\Config; +use Magento\Payment\Gateway\Config\ValueHandlerInterface; use Magento\Payment\Gateway\Config\ValueHandlerPool; class ValueHandlerPoolTest extends \PHPUnit_Framework_TestCase @@ -19,7 +20,7 @@ public function testConstructorException() $tMapFactory->expects(static::never()) ->method('create'); - new ValueHandlerPool([], $tMapFactory); + new ValueHandlerPool($tMapFactory, []); } public function testGet() @@ -46,7 +47,7 @@ public function testGet() ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' ], - 'type' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' + 'type' => ValueHandlerInterface::class ] ) ->willReturn($tMap); @@ -68,11 +69,11 @@ public function testGet() ); $pool = new ValueHandlerPool( + $tMapFactory, [ ValueHandlerPool::DEFAULT_HANDLER => 'Magento\Payment\Gateway\Config\ValueHandlerInterface', 'some_value' => 'Magento\Payment\Gateway\Config\ValueHandlerInterface' - ], - $tMapFactory + ] ); static::assertSame($someValueHandler, $pool->get('some_value')); static::assertSame($defaultHandler, $pool->get(ValueHandlerPool::DEFAULT_HANDLER)); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php index e1e5ea547456a..2c31c318db678 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Request/BuilderCompositeTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Request; use Magento\Payment\Gateway\Request\BuilderComposite; +use Magento\Payment\Gateway\Request\BuilderInterface; class BuilderCompositeTest extends \PHPUnit_Framework_TestCase { @@ -24,7 +25,7 @@ public function testBuildEmpty() ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ) ->willReturn($tMap); @@ -32,7 +33,7 @@ public function testBuildEmpty() ->method('getIterator') ->willReturn(new \ArrayIterator([])); - $builder = new BuilderComposite([], $tMapFactory); + $builder = new BuilderComposite($tMapFactory, []); static::assertEquals([], $builder->build([])); } @@ -47,6 +48,7 @@ public function testBuild() 'item' => 'gas cooker', 'quantity' => 1 ]; + $tMapFactory = $this->getMockBuilder('Magento\Framework\ObjectManager\TMapFactory') ->disableOriginalConstructor() ->setMethods(['create']) @@ -96,7 +98,7 @@ public function testBuild() 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' ], - 'type' => 'Magento\Payment\Gateway\Request\BuilderInterface' + 'type' => BuilderInterface::class ] ) ->willReturn($tMap); @@ -105,12 +107,12 @@ public function testBuild() ->willReturn(new \ArrayIterator([$customerBuilder, $productBuilder, $magentoBuilder])); $builder = new BuilderComposite( + $tMapFactory, [ 'customer' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'product' => 'Magento\Payment\Gateway\Request\BuilderInterface', 'magento' => 'Magento\Payment\Gateway\Request\BuilderInterface' - ], - $tMapFactory + ] ); static::assertEquals($expectedRequest, $builder->build([])); diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php index c65a826a2624d..78891068b4cc0 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Response/HandlerChainTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Response; use Magento\Payment\Gateway\Response\HandlerChain; +use Magento\Payment\Gateway\Response\HandlerInterface; class HandlerChainTest extends \PHPUnit_Framework_TestCase { @@ -31,7 +32,7 @@ public function testHandle() 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' ], - 'type' => 'Magento\Payment\Gateway\Response\HandlerInterface' + 'type' => HandlerInterface::class ] ) ->willReturn($tMap); @@ -49,11 +50,11 @@ public function testHandle() ->with($handlingSubject, $response); $chain = new HandlerChain( + $tMapFactory, [ 'handler1' => 'Magento\Payment\Gateway\Response\HandlerInterface', 'handler2' => 'Magento\Payment\Gateway\Response\HandlerInterface' - ], - $tMapFactory + ] ); $chain->handle($handlingSubject, $response); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php index 8528b65ac6cec..27b589b02900d 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorCompositeTest.php @@ -6,6 +6,7 @@ namespace Magento\Payment\Test\Unit\Gateway\Validator; use Magento\Payment\Gateway\Validator\ValidatorComposite; +use Magento\Payment\Gateway\Validator\ValidatorInterface; class ValidatorCompositeTest extends \PHPUnit_Framework_TestCase { @@ -32,7 +33,7 @@ public function testValidate() 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' ], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -82,11 +83,11 @@ public function testValidate() $validatorComposite = new ValidatorComposite( $resultFactory, + $tMapFactory, [ 'validator1' => 'Magento\Payment\Gateway\Validator\ValidatorInterface', 'validator2' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' - ], - $tMapFactory + ] ); static::assertSame($compositeResult, $validatorComposite->validate($validationSubject)); } diff --git a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php index becc387fab2d9..dc6ed060ab7bf 100644 --- a/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php +++ b/app/code/Magento/Payment/Test/Unit/Gateway/Validator/ValidatorPoolTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Payment\Test\Unit\Gateway\Validator; +use Magento\Payment\Gateway\Validator\ValidatorInterface; use Magento\Payment\Gateway\Validator\ValidatorPool; class ValidatorPoolTest extends \PHPUnit_Framework_TestCase @@ -26,7 +27,7 @@ public function testGet() ->with( [ 'array' => ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -40,8 +41,8 @@ public function testGet() ->willReturn($commandI); $pool = new ValidatorPool( - ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'], - $tMapFactory + $tMapFactory, + ['validator' => 'Magento\Payment\Gateway\Validator\ValidatorInterface'] ); static::assertSame($commandI, $pool->get('validator')); @@ -64,7 +65,7 @@ public function testGetException() ->with( [ 'array' => [], - 'type' => 'Magento\Payment\Gateway\Validator\ValidatorInterface' + 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); @@ -73,7 +74,7 @@ public function testGetException() ->with('validator') ->willReturn(false); - $pool = new ValidatorPool([], $tMapFactory); + $pool = new ValidatorPool($tMapFactory, []); $pool->get('validator'); } } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php index 13f1ad7d41451..89fac656c32c2 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Checks/CanUseForCountry/CountryProviderTest.php @@ -33,14 +33,27 @@ public function testGetCountryForNonVirtualQuote() $this->assertEquals(1, $this->model->getCountry($quoteMock)); } - public function testGetCountryForVirtualQuote() + public function testGetCountryForVirtualQuoteWhenBillingAddressNotExist() { $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); $addressMock->expects($this->never())->method('getCountry'); $quoteMock->expects($this->never())->method('getShippingAddress'); + $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn(null); $this->directoryMock->expects($this->once())->method('getDefaultCountry')->willReturn(10); $this->assertEquals(10, $this->model->getCountry($quoteMock)); } + + public function testGetCountryForVirtualQuoteWhenBillingAddressExist() + { + $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false, false); + $quoteMock->expects($this->once())->method('isVirtual')->willReturn(true); + $addressMock = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false); + $addressMock->expects($this->once())->method('getCountry')->willReturn(10); + $quoteMock->expects($this->never())->method('getShippingAddress'); + $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($addressMock); + $this->directoryMock->expects($this->never())->method('getDefaultCountry'); + $this->assertEquals(10, $this->model->getCountry($quoteMock)); + } } diff --git a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php index b56caf5903208..36cd63d8c6db6 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/Method/LoggerTest.php @@ -45,6 +45,20 @@ public function testDebugOn() $this->logger->debug($debugData, $debugReplaceKeys, true); } + public function testDebugOnNoReplaceKeys() + { + $debugData = + [ + 'request' => ['data1' => '123', 'data2' => '123'] + ]; + + $this->loggerMock->expects(static::once()) + ->method('debug') + ->with(var_export($debugData, true)); + + $this->logger->debug($debugData, [], true); + } + public function testDebugOff() { $debugData = diff --git a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml index 9980563201013..2ce70dcad46a2 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml @@ -9,10 +9,11 @@ * @var \Magento\Payment\Block\Info $block * @see \Magento\Payment\Block\Info */ +$specificInfo = $block->getSpecificInformation(); ?> escapeHtml($block->getMethod()->getTitle()); ?> -getSpecificInformation()):?> +
escapeHtml(__('Type')); ?>escapeHtml(__('Card Number')); ?>escapeHtml(__('Is Default')); ?>escapeHtml(__('Actions')); ?>
cardType ?>maskedNumber ?>default) ? __('Yes') : __('No') ?>escapeHtml($card->cardType); ?>escapeHtml($card->maskedNumber); ?>default) ? $block->escapeHtml(__('Yes')) : $block->escapeHtml(__('No')); ?> - + + escapeHtml(__('Edit')); ?> + - + + escapeHtml(__('Delete'));?> +
$value):?> diff --git a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml index 92c44c6c5d4b9..1bb248e6fd566 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/transparent/form.phtml @@ -10,6 +10,7 @@ $code = $block->getMethodCode(); $ccType = $block->getInfoData('cc_type'); $ccExpYear = $block->getInfoData('cc_exp_year'); +$ccExpMonth = $block->getInfoData('cc_exp_month'); ?> @@ -87,11 +88,10 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); data-container="-cc-month" class="admin__control-select admin__control-select-month" data-validate='{required:true, "validate-cc-exp":"#_expiration_yr"}'> - getInfoData('cc_exp_month') ?> getCcMonths() as $k => $v): ?> diff --git a/app/code/Magento/Payment/view/adminhtml/web/transparent.js b/app/code/Magento/Payment/view/adminhtml/web/transparent.js index 7edbb30c6318f..11593e2a5b5f6 100644 --- a/app/code/Magento/Payment/view/adminhtml/web/transparent.js +++ b/app/code/Magento/Payment/view/adminhtml/web/transparent.js @@ -6,8 +6,9 @@ define([ "jquery", "mage/template", + 'Magento_Ui/js/modal/alert', "jquery/ui" -], function($, mageTemplate){ +], function($, mageTemplate, alert){ "use strict"; $.widget('mage.transparent', { @@ -157,10 +158,14 @@ define([ _processErrors: function (response) { var msg = response.error_messages; if (typeof (msg) === 'object') { - alert(msg.join("\n")); + alert({ + content: msg.join("\n") + }); } if (msg) { - alert(msg); + alert({ + content: msg + }); } } }); diff --git a/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml b/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml index eeaa13ee814cc..64ea503996cd2 100644 --- a/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml +++ b/app/code/Magento/Payment/view/frontend/templates/transparent/form.phtml @@ -10,6 +10,7 @@ $code = $block->getMethodCode(); $ccExpMonth = $block->getInfoData('cc_exp_month'); $ccExpYear = $block->getInfoData('cc_exp_year'); +$ccType = $block->getInfoData('cc_type'); $content = 'getViewFileUrl('Magento_Checkout::cvv.png') . '\" alt=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" title=\"' . $block->escapeHtml(__('Card Verification Number Visual Reference')) . '\" />'; @@ -46,10 +47,9 @@ $content = 'getViewFileUrl('Magento_Checkout::cvv.png') . "validate-cc-type-select":"#_cc_number" }'> - getInfoData('cc_type') ?> getCcAvailableTypes() as $typeCode => $typeName): ?> diff --git a/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js index 660f3e3c0471f..2812437f379e4 100644 --- a/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js +++ b/app/code/Magento/Payment/view/frontend/web/js/model/credit-card-validation/validator.js @@ -21,13 +21,34 @@ "use strict"; $.each({ + 'validate-card-type': [ + function (number, item, allowedTypes) { + var cardInfo, + i, + l; + + if (!creditCardNumberValidator(number).isValid) { + return false; + } else { + cardInfo = creditCardNumberValidator(number).card; + + for (i = 0, l = allowedTypes.length; i < l; i++) { + if (cardInfo.title == allowedTypes[i].type) { + return true; + } + } + return false; + } + }, + 'Please enter a valid credit card type number.' + ], 'validate-card-number': [ /** * Validate credit card number based on mod 10 * @param number - credit card number * @return {boolean} */ - function (number) { + function (number) { return creditCardNumberValidator(number).isValid; }, 'Please enter a valid credit card number.' diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html index 2df219f3dddf1..7db455786537c 100644 --- a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html +++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html @@ -50,7 +50,7 @@ id: getCode() + '_cc_number', title: $t('Credit Card Number'), 'data-container': getCode() + '-cc-number', - 'data-validate': JSON.stringify({'required-number':true, 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})}, + 'data-validate': JSON.stringify({'required-number':true, 'validate-card-type':getCcAvailableTypesValues(), 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})}, enable: isActive($parents), value: creditCardNumber, valueUpdate: 'keyup' "/> diff --git a/app/code/Magento/Payment/view/frontend/web/transparent.js b/app/code/Magento/Payment/view/frontend/web/transparent.js index 2060ca7c8ea5e..66b3203d7bc51 100644 --- a/app/code/Magento/Payment/view/frontend/web/transparent.js +++ b/app/code/Magento/Payment/view/frontend/web/transparent.js @@ -6,9 +6,10 @@ define([ "jquery", "mage/template", + 'Magento_Ui/js/modal/alert', "jquery/ui", "Magento_Payment/js/model/credit-card-validation/validator" -], function($, mageTemplate){ +], function($, mageTemplate, alert){ 'use strict'; $.widget('mage.transparent', { @@ -101,10 +102,14 @@ define([ } else { msg = response.error_messages; if (typeof (msg) === 'object') { - alert(msg.join("\n")); + alert({ + content: msg.join("\n") + }); } if (msg) { - alert(msg); + alert({ + content: msg + }); } } } diff --git a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php index bf45d116407a8..985f7cd8eefa6 100644 --- a/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php +++ b/app/code/Magento/Paypal/Model/Billing/AbstractAgreement.php @@ -63,7 +63,7 @@ abstract public function cancel(); * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Payment\Helper\Data $paymentData - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -71,7 +71,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Payment\Helper\Data $paymentData, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Billing/Agreement.php b/app/code/Magento/Paypal/Model/Billing/Agreement.php index f663aabaf1ad5..1e6a2cee5ae6a 100644 --- a/app/code/Magento/Paypal/Model/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/Billing/Agreement.php @@ -58,7 +58,7 @@ class Agreement extends \Magento\Paypal\Model\Billing\AbstractAgreement * @param \Magento\Payment\Helper\Data $paymentData * @param \Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementFactory * @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -68,7 +68,7 @@ public function __construct( \Magento\Payment\Helper\Data $paymentData, \Magento\Paypal\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementFactory, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Cert.php b/app/code/Magento/Paypal/Model/Cert.php index 86f4dd2b47623..a5e4cb8be07a7 100644 --- a/app/code/Magento/Paypal/Model/Cert.php +++ b/app/code/Magento/Paypal/Model/Cert.php @@ -33,7 +33,7 @@ class Cert extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -42,7 +42,7 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Encryption\EncryptorInterface $encryptor, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index 0d30a92ca3f97..9433a3b5761b1 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -149,7 +149,7 @@ class Direct extends \Magento\Payment\Model\Method\Cc * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Framework\App\RequestInterface $requestHttp * @param CartFactory $cartFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -169,7 +169,7 @@ public function __construct( \Magento\Framework\UrlInterface $urlBuilder, \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Express.php b/app/code/Magento/Paypal/Model/Express.php index 0ae6ca30f8362..52a3882a169fc 100644 --- a/app/code/Magento/Paypal/Model/Express.php +++ b/app/code/Magento/Paypal/Model/Express.php @@ -193,7 +193,7 @@ class Express extends \Magento\Payment\Model\Method\AbstractMethod * @param \Magento\Framework\Exception\LocalizedExceptionFactory $exception * @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository * @param Transaction\BuilderInterface $transactionBuilder - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -214,7 +214,7 @@ public function __construct( \Magento\Framework\Exception\LocalizedExceptionFactory $exception, \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository, \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $transactionBuilder, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index d9b9d986f1b31..d3b0cf72fc76b 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -1191,10 +1191,10 @@ public function getCustomerSession() /** * Set shipping options to api * @param \Magento\Paypal\Model\Cart $cart - * @param \Magento\Quote\Model\Quote\Address $address + * @param \Magento\Quote\Model\Quote\Address|null $address * @return void */ - private function setShippingOptions(PaypalCart $cart, Address $address) + private function setShippingOptions(PaypalCart $cart, Address $address = null) { // for included tax always disable line items (related to paypal amount rounding problem) $this->_api->setIsLineItemsEnabled($this->_config->getValue(PaypalConfig::TRANSFER_CART_LINE_ITEMS)); diff --git a/app/code/Magento/Paypal/Model/Hostedpro.php b/app/code/Magento/Paypal/Model/Hostedpro.php index 9497beb05d581..61d0c35c91695 100644 --- a/app/code/Magento/Paypal/Model/Hostedpro.php +++ b/app/code/Magento/Paypal/Model/Hostedpro.php @@ -85,7 +85,7 @@ class Hostedpro extends \Magento\Paypal\Model\Direct * @param \Magento\Framework\App\RequestInterface $requestHttp * @param CartFactory $cartFactory * @param Hostedpro\RequestFactory $hostedproRequestFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -106,7 +106,7 @@ public function __construct( \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Paypal\Model\CartFactory $cartFactory, \Magento\Paypal\Model\Hostedpro\RequestFactory $hostedproRequestFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Method/Agreement.php b/app/code/Magento/Paypal/Model/Method/Agreement.php index 0c6d70b28ef61..93321eefc89f1 100644 --- a/app/code/Magento/Paypal/Model/Method/Agreement.php +++ b/app/code/Magento/Paypal/Model/Method/Agreement.php @@ -128,7 +128,7 @@ class Agreement extends \Magento\Paypal\Model\Payment\Method\Billing\AbstractAgr * @param \Magento\Paypal\Model\ProFactory $proFactory * @param \Magento\Framework\UrlInterface $urlBuilder * @param \Magento\Paypal\Model\CartFactory $cartFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -146,7 +146,7 @@ public function __construct( \Magento\Paypal\Model\ProFactory $proFactory, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Paypal\Model\CartFactory $cartFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Payflow/Transparent.php b/app/code/Magento/Paypal/Model/Payflow/Transparent.php index 603c3cc412c71..b47e8af2012c3 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Transparent.php +++ b/app/code/Magento/Paypal/Model/Payflow/Transparent.php @@ -53,7 +53,7 @@ class Transparent extends Payflowpro implements TransparentInterface * @param Gateway $gateway * @param HandlerInterface $errorHandler * @param ResponseValidator $responseValidator - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -73,7 +73,7 @@ public function __construct( Gateway $gateway, HandlerInterface $errorHandler, ResponseValidator $responseValidator, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/PayflowExpress.php b/app/code/Magento/Paypal/Model/PayflowExpress.php index 9c719279cb2e7..a45f1153b67b5 100644 --- a/app/code/Magento/Paypal/Model/PayflowExpress.php +++ b/app/code/Magento/Paypal/Model/PayflowExpress.php @@ -66,7 +66,7 @@ class PayflowExpress extends \Magento\Paypal\Model\Express * @param \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository * @param Transaction\BuilderInterface $transactionBuilder * @param InfoFactory $paypalInfoFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -88,7 +88,7 @@ public function __construct( \Magento\Sales\Api\TransactionRepositoryInterface $transactionRepository, \Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface $transactionBuilder, InfoFactory $paypalInfoFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Payflowlink.php b/app/code/Magento/Paypal/Model/Payflowlink.php index e6808b906c871..91513032674c6 100644 --- a/app/code/Magento/Paypal/Model/Payflowlink.php +++ b/app/code/Magento/Paypal/Model/Payflowlink.php @@ -132,7 +132,7 @@ class Payflowlink extends \Magento\Paypal\Model\Payflowpro * @param \Magento\Framework\App\RequestInterface $requestHttp * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param OrderSender $orderSender - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -158,7 +158,7 @@ public function __construct( \Magento\Framework\App\RequestInterface $requestHttp, \Magento\Store\Model\WebsiteFactory $websiteFactory, OrderSender $orderSender, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Payflowpro.php b/app/code/Magento/Paypal/Model/Payflowpro.php index ba976e8eb6e9c..6efc7e7cca4ed 100644 --- a/app/code/Magento/Paypal/Model/Payflowpro.php +++ b/app/code/Magento/Paypal/Model/Payflowpro.php @@ -271,7 +271,7 @@ class Payflowpro extends \Magento\Payment\Model\Method\Cc implements GatewayInte * @param ConfigInterfaceFactory $configFactory * @param Gateway $gateway * @param HandlerInterface $errorHandler - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -290,7 +290,7 @@ public function __construct( ConfigInterfaceFactory $configFactory, Gateway $gateway, HandlerInterface $errorHandler, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php index 71b594ead9f63..521a613002676 100644 --- a/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php +++ b/app/code/Magento/Paypal/Model/Payment/Method/Billing/AbstractAgreement.php @@ -52,7 +52,7 @@ abstract class AbstractAgreement extends \Magento\Payment\Model\Method\AbstractM * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Payment\Model\Method\Logger $logger * @param \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -66,7 +66,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Payment\Model\Method\Logger $logger, \Magento\Paypal\Model\Billing\AgreementFactory $agreementFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 73698224b2b39..4fc8633bafa2f 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -168,7 +168,7 @@ class Settlement extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -178,7 +178,7 @@ public function __construct( \Magento\Framework\Filesystem $filesystem, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement.php b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement.php index f027cf7bce793..6f714ae437e60 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement.php @@ -8,7 +8,7 @@ /** * Billing agreement resource model */ -class Agreement extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Agreement extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Resource initialization diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php index 23f80dff4199b..f08876e5e61ef 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Billing/Agreement/Collection.php @@ -10,7 +10,7 @@ /** * Billing agreements resource collection */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Mapping for fields @@ -45,7 +45,7 @@ class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\Ab * @param \Magento\Customer\Model\ResourceModel\Customer $customerResource * @param \Magento\Eav\Helper\Data $eavHelper * @param mixed $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactory $entityFactory, @@ -55,7 +55,7 @@ public function __construct( \Magento\Customer\Model\ResourceModel\Customer $customerResource, \Magento\Eav\Helper\Data $eavHelper, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource); $this->_eavHelper = $eavHelper; diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Cert.php b/app/code/Magento/Paypal/Model/ResourceModel/Cert.php index 81cfd75024c05..13de6e3c1f327 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Cert.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Cert.php @@ -8,7 +8,7 @@ /** * PayPal resource model for certificate based authentication */ -class Cert extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Cert extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var \Magento\Framework\Stdlib\DateTime\DateTime @@ -21,13 +21,13 @@ class Cert extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $dateTime; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, \Magento\Framework\Stdlib\DateTime $dateTime, $connectionName = null @@ -51,7 +51,7 @@ protected function _construct() * Set date of last update * * @param \Magento\Framework\Model\AbstractModel $object - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object) { diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement.php b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement.php index 0538906b4a209..eed10fa9d69da 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement.php @@ -11,7 +11,7 @@ /** * Report settlement resource model */ -class Settlement extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Settlement extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Table name @@ -26,12 +26,12 @@ class Settlement extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $_coreDate; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, $connectionName = null ) { diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row.php b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row.php index 1501b46fa35ed..b2bc99495f7db 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Row extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Row extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Resource model initialization. diff --git a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php index e76234b84973a..6fcd59ad141e1 100644 --- a/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php +++ b/app/code/Magento/Paypal/Model/ResourceModel/Report/Settlement/Row/Collection.php @@ -11,7 +11,7 @@ */ namespace Magento\Paypal\Model\ResourceModel\Report\Settlement\Row; -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Resource initializing diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php index 48569dd3bc333..a3a1a5df48cd9 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cert.php @@ -38,7 +38,7 @@ class Cert extends \Magento\Framework\App\Config\Value * @param \Magento\Paypal\Model\CertFactory $certFactory * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor * @param \Magento\Framework\Filesystem $filesystem - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Paypal\Model\CertFactory $certFactory, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Filesystem $filesystem, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php index 0603fe3ee40ef..7f09498fe1864 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/Cron.php @@ -22,7 +22,7 @@ class Cron extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Config\ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\App\Config\ValueFactory $configValueFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -32,7 +32,7 @@ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\App\Config\ValueFactory $configValueFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php index d02e68e1bf026..de7b66382d195 100644 --- a/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/Magento/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -29,7 +29,7 @@ class MerchantCountry extends \Magento\Framework\App\Config\Value * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Helper\Data $directoryHelper - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Directory\Helper\Data $directoryHelper, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { 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 0c49932d489a2..b565aa2d66d6b 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rule.js @@ -3,7 +3,7 @@ * See COPYING.txt for license details. */ define([ - "Magento_Ui/js/lib/class", + "uiClass", "underscore" ], function (Class, _) { "use strict"; 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 index 98c79243d4832..4d94f6a2a9ff6 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/rules/conflict.js @@ -4,7 +4,9 @@ */ (function() { var executed = false; - define([], function () { + define([ + 'Magento_Ui/js/modal/alert' + ], function (alert) { "use strict"; return function ($target, $owner, data) { if ($owner.find(data.enableButton).val() == 1) { @@ -22,11 +24,11 @@ if (!isDisabled && !executed) { executed = true; - alert( - "The following error(s) occured:\n\r" - + "Some PayPal solutions conflict.\n\r" - + "Please re-enable the previously enabled payment solutions." - ); + alert({ + content: "The following error(s) occured:\n\r" + +"Some PayPal solutions conflict.\n\r" + +"Please re-enable the previously enabled payment solutions." + }); } } }; diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js b/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js index 3ff36adf61426..787d9e066cdbe 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/solution.js @@ -4,7 +4,7 @@ */ define([ "jquery", - "Magento_Ui/js/lib/class", + "uiClass", "Magento_Paypal/js/rule", "mageUtils", "underscore" diff --git a/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js b/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js index fc688c2da2a2c..b1e124aca387a 100644 --- a/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js +++ b/app/code/Magento/Paypal/view/adminhtml/web/js/solutions.js @@ -4,7 +4,7 @@ */ define([ "jquery", - "Magento_Ui/js/lib/class", + "uiClass", "Magento_Paypal/js/solution", "underscore" ], function ($, Class, Solution, _) { diff --git a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js index bd0111de817d5..bc474987c897f 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js @@ -5,9 +5,10 @@ /*jshint browser:true jquery:true*/ define([ 'jquery', + 'Magento_Ui/js/modal/confirm', 'jquery/ui', 'mage/mage' -], function ($) { +], function ($, confirm) { 'use strict'; $.widget('mage.paypalCheckout', { @@ -18,26 +19,43 @@ define([ _create: function () { this.element.on('click', '[data-action="checkout-form-submit"]', $.proxy(function (e) { var returnUrl = $(e.target).data('checkout-url'), - form; + self = this; e.preventDefault(); if (this.options.confirmUrl && this.options.confirmMessage) { - if (window.confirm(this.options.confirmMessage)) { - returnUrl = this.options.confirmUrl; - } + confirm({ + content: this.options.confirmMessage, + actions: { + confirm: function() { + returnUrl = self.options.confirmUrl; + self._redirect(returnUrl); + }, + cancel: function() { + self.redirect(returnUrl); + } + } + }); + + return false; } - if (this.options.isCatalogProduct) { - // find the form from which the button was clicked - form = $(this.options.shortcutContainerClass).closest('form'); + this._redirect(returnUrl); - $(form).find(this.options.paypalCheckoutSelector).val(returnUrl); - $(form).submit(); - } else { - $.mage.redirect(returnUrl); - } }, this)); + }, + _redirect: function(returnUrl) { + var form; + + if (this.options.isCatalogProduct) { + // find the form from which the button was clicked + form = $(this.options.shortcutContainerClass).closest('form'); + + $(form).find(this.options.paypalCheckoutSelector).val(returnUrl); + $(form).submit(); + } else { + $.mage.redirect(returnUrl); + } } }); diff --git a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js index a7a031848124e..f0095877bbc9c 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js @@ -51,9 +51,8 @@ define( placeOrder: function () { var self = this; - fullScreenLoader.startLoader(); - if (this.validateHandler() && additionalValidators.validate()) { + fullScreenLoader.startLoader(); this.isPlaceOrderActionAllowed(false); $.when(setPaymentInformationAction(this.messageContainer, { 'method': self.getCode() diff --git a/app/code/Magento/Paypal/view/frontend/web/order-review.js b/app/code/Magento/Paypal/view/frontend/web/order-review.js index 56514f9164c8f..b1a072d8e98e8 100644 --- a/app/code/Magento/Paypal/view/frontend/web/order-review.js +++ b/app/code/Magento/Paypal/view/frontend/web/order-review.js @@ -6,11 +6,12 @@ /*global alert*/ define([ "jquery", + 'Magento_Ui/js/modal/alert', "jquery/ui", "mage/translate", "mage/mage", "mage/validation" -], function($){ +], function($, alert){ "use strict"; $.widget('mage.orderReview', { @@ -129,7 +130,9 @@ define([ msg = msg.join("\n"); } } - alert($.mage.__(msg)); + alert({ + content: $.mage.__(msg) + }); return false; } if (response.redirect) { @@ -141,11 +144,15 @@ define([ return false; } this._ajaxComplete(); - alert($.mage.__('Sorry, something went wrong.')); + alert({ + content: $.mage.__('Sorry, something went wrong.') + }); } }, error: function () { - alert($.mage.__('Sorry, something went wrong. Please try again later.')); + alert({ + content: $.mage.__('Sorry, something went wrong. Please try again later.') + }); this._ajaxComplete(); } }); diff --git a/app/code/Magento/Persistent/Model/ResourceModel/Session.php b/app/code/Magento/Persistent/Model/ResourceModel/Session.php index 32f591b67798b..a858573f4f79d 100644 --- a/app/code/Magento/Persistent/Model/ResourceModel/Session.php +++ b/app/code/Magento/Persistent/Model/ResourceModel/Session.php @@ -8,7 +8,7 @@ /** * Persistent Session Resource Model */ -class Session extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Session extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Use is object new method for object saving @@ -27,12 +27,12 @@ class Session extends \Magento\Framework\Model\ModelResource\Db\AbstractDb /** * Class constructor * - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Persistent\Model\SessionFactory $sessionFactory * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Persistent\Model\SessionFactory $sessionFactory, $connectionName = null ) { diff --git a/app/code/Magento/Persistent/Model/Session.php b/app/code/Magento/Persistent/Model/Session.php index 018ab10d5c403..70c4faaa3dd31 100644 --- a/app/code/Magento/Persistent/Model/Session.php +++ b/app/code/Magento/Persistent/Model/Session.php @@ -107,7 +107,7 @@ class Session extends \Magento\Framework\Model\AbstractModel * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -123,7 +123,7 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Session\Config\ConfigInterface $sessionConfig, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php index 198bcd5909b98..c177a912bc2b7 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/SessionTest.php @@ -38,7 +38,7 @@ protected function setUp() ->getMock(); $resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [], '', false, diff --git a/app/code/Magento/ProductAlert/Model/Email.php b/app/code/Magento/ProductAlert/Model/Email.php index bb474f7080a0e..c8f8bd6c53014 100644 --- a/app/code/Magento/ProductAlert/Model/Email.php +++ b/app/code/Magento/ProductAlert/Model/Email.php @@ -117,7 +117,7 @@ class Email extends \Magento\Framework\Model\AbstractModel * @param \Magento\Customer\Helper\View $customerHelper * @param \Magento\Store\Model\App\Emulation $appEmulation * @param \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -132,7 +132,7 @@ public function __construct( \Magento\Customer\Helper\View $customerHelper, \Magento\Store\Model\App\Emulation $appEmulation, \Magento\Framework\Mail\Template\TransportBuilder $transportBuilder, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/ProductAlert/Model/Price.php b/app/code/Magento/ProductAlert/Model/Price.php index e3abeb881be4b..2d6e3535d7004 100644 --- a/app/code/Magento/ProductAlert/Model/Price.php +++ b/app/code/Magento/ProductAlert/Model/Price.php @@ -42,7 +42,7 @@ class Price extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\ProductAlert\Model\ResourceModel\Price\Customer\CollectionFactory $customerColFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -50,7 +50,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\ProductAlert\Model\ResourceModel\Price\Customer\CollectionFactory $customerColFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/ProductAlert/Model/ResourceModel/AbstractResource.php b/app/code/Magento/ProductAlert/Model/ResourceModel/AbstractResource.php index ed029f001f6e6..3d12079b84c8b 100644 --- a/app/code/Magento/ProductAlert/Model/ResourceModel/AbstractResource.php +++ b/app/code/Magento/ProductAlert/Model/ResourceModel/AbstractResource.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -abstract class AbstractResource extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +abstract class AbstractResource extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Retrieve alert row by object parameters diff --git a/app/code/Magento/ProductAlert/Model/ResourceModel/Price.php b/app/code/Magento/ProductAlert/Model/ResourceModel/Price.php index f547c2c617541..e070ec58bfad2 100644 --- a/app/code/Magento/ProductAlert/Model/ResourceModel/Price.php +++ b/app/code/Magento/ProductAlert/Model/ResourceModel/Price.php @@ -19,12 +19,12 @@ class Price extends \Magento\ProductAlert\Model\ResourceModel\AbstractResource protected $_dateFactory; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory, $connectionName = null ) { diff --git a/app/code/Magento/ProductAlert/Model/ResourceModel/Price/Collection.php b/app/code/Magento/ProductAlert/Model/ResourceModel/Price/Collection.php index 03ec7819ce791..4960fda5758c2 100644 --- a/app/code/Magento/ProductAlert/Model/ResourceModel/Price/Collection.php +++ b/app/code/Magento/ProductAlert/Model/ResourceModel/Price/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Define price collection diff --git a/app/code/Magento/ProductAlert/Model/ResourceModel/Stock.php b/app/code/Magento/ProductAlert/Model/ResourceModel/Stock.php index 944f722ea5e89..bba6ee1eed2d0 100644 --- a/app/code/Magento/ProductAlert/Model/ResourceModel/Stock.php +++ b/app/code/Magento/ProductAlert/Model/ResourceModel/Stock.php @@ -19,12 +19,12 @@ class Stock extends \Magento\ProductAlert\Model\ResourceModel\AbstractResource protected $_dateFactory; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\Stdlib\DateTime\DateTimeFactory $dateFactory, $connectionName = null ) { diff --git a/app/code/Magento/ProductAlert/Model/ResourceModel/Stock/Collection.php b/app/code/Magento/ProductAlert/Model/ResourceModel/Stock/Collection.php index 782c36ca421fc..3a31c14a640ef 100644 --- a/app/code/Magento/ProductAlert/Model/ResourceModel/Stock/Collection.php +++ b/app/code/Magento/ProductAlert/Model/ResourceModel/Stock/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Define stock collection diff --git a/app/code/Magento/ProductAlert/Model/Stock.php b/app/code/Magento/ProductAlert/Model/Stock.php index 07efb59ecfbe1..54fbedf89839e 100644 --- a/app/code/Magento/ProductAlert/Model/Stock.php +++ b/app/code/Magento/ProductAlert/Model/Stock.php @@ -40,7 +40,7 @@ class Stock extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\ProductAlert\Model\ResourceModel\Stock\Customer\CollectionFactory $customerColFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -48,7 +48,7 @@ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\ProductAlert\Model\ResourceModel\Stock\Customer\CollectionFactory $customerColFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/ProductVideo/Block/Adminhtml/Product/Edit/NewVideo.php b/app/code/Magento/ProductVideo/Block/Adminhtml/Product/Edit/NewVideo.php index 6be990b549cea..fbc2132db4999 100644 --- a/app/code/Magento/ProductVideo/Block/Adminhtml/Product/Edit/NewVideo.php +++ b/app/code/Magento/ProductVideo/Block/Adminhtml/Product/Edit/NewVideo.php @@ -12,6 +12,11 @@ */ class NewVideo extends \Magento\Backend\Block\Widget\Form\Generic { + /** + * @var \Magento\ProductVideo\Helper\Media + */ + protected $mediaHelper; + /** * @var \Magento\Framework\Json\EncoderInterface */ @@ -19,6 +24,7 @@ class NewVideo extends \Magento\Backend\Block\Widget\Form\Generic /** * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\ProductVideo\Helper\Media $mediaHelper * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Data\FormFactory $formFactory @@ -29,9 +35,11 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\Json\EncoderInterface $jsonEncoder, + \Magento\ProductVideo\Helper\Media $mediaHelper, array $data = [] ) { parent::__construct($context, $registry, $formFactory, $data); + $this->mediaHelper = $mediaHelper; $this->jsonEncoder = $jsonEncoder; $this->setUseContainer(true); } @@ -171,6 +179,11 @@ protected function _prepareForm() $this->setForm($form); } + /** + * Get html id + * + * @return mixed + */ public function getHtmlId() { if (null === $this->getData('id')) { @@ -180,6 +193,8 @@ public function getHtmlId() } /** + * Get widget options + * * @return string */ public function getWidgetOptions() @@ -189,6 +204,7 @@ public function getWidgetOptions() 'saveVideoUrl' => $this->getUrl('catalog/product_gallery/upload'), 'saveRemoteVideoUrl' => $this->getUrl('product_video/product_gallery/retrieveImage'), 'htmlId' => $this->getHtmlId(), + 'youTubeApiKey' => $this->mediaHelper->getYouTubeApiKey() ] ); } @@ -214,8 +230,9 @@ protected function getProduct() */ protected function addMediaRoleAttributes(Fieldset $fieldset) { + $fieldset->addField('roleLabel', 'note', ['text' => __('Role')]); $mediaRoles = $this->getProduct()->getMediaAttributes(); - asort($mediaRoles); + ksort($mediaRoles); foreach ($mediaRoles as $mediaRole) { $fieldset->addField( 'video_' . $mediaRole->getAttributeCode(), diff --git a/app/code/Magento/ProductVideo/Block/Product/View/Gallery.php b/app/code/Magento/ProductVideo/Block/Product/View/Gallery.php index ce93d93700a5d..8643a8bec34b2 100644 --- a/app/code/Magento/ProductVideo/Block/Product/View/Gallery.php +++ b/app/code/Magento/ProductVideo/Block/Product/View/Gallery.php @@ -18,11 +18,6 @@ class Gallery extends \Magento\Catalog\Block\Product\View\Gallery */ protected $mediaHelper; - /** - * @var \Magento\Framework\Json\EncoderInterface - */ - private $jsonEncoder; - /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils @@ -33,17 +28,17 @@ class Gallery extends \Magento\Catalog\Block\Product\View\Gallery public function __construct( \Magento\Catalog\Block\Product\Context $context, \Magento\Framework\Stdlib\ArrayUtils $arrayUtils, - \Magento\ProductVideo\Helper\Media $mediaHelper, \Magento\Framework\Json\EncoderInterface $jsonEncoder, + \Magento\ProductVideo\Helper\Media $mediaHelper, array $data = [] ) { parent::__construct( $context, $arrayUtils, + $jsonEncoder, $data ); $this->mediaHelper = $mediaHelper; - $this->jsonEncoder = $jsonEncoder; } /** diff --git a/app/code/Magento/ProductVideo/Helper/Media.php b/app/code/Magento/ProductVideo/Helper/Media.php index 5d7abc74aedc1..657c81f3aaede 100644 --- a/app/code/Magento/ProductVideo/Helper/Media.php +++ b/app/code/Magento/ProductVideo/Helper/Media.php @@ -7,6 +7,7 @@ namespace Magento\ProductVideo\Helper; use Magento\Framework\App\Area; +use Magento\Framework\App\Helper\Context; use Magento\Framework\View\ConfigInterface; use Magento\Framework\View\DesignInterface; @@ -40,6 +41,11 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper */ const MEDIA_TYPE_CONFIG_NODE = 'videos'; + /** + * Configuration path + */ + const XML_PATH_YOUTUBE_API_KEY = 'catalog/product_video/youtube_api_key'; + /** * @var ConfigInterface */ @@ -60,11 +66,14 @@ class Media extends \Magento\Framework\App\Helper\AbstractHelper /** * @param ConfigInterface $configInterface * @param DesignInterface $designInterface + * @param Context $context */ public function __construct( ConfigInterface $configInterface, - DesignInterface $designInterface + DesignInterface $designInterface, + Context $context ) { + parent::__construct($context); $this->viewConfig = $configInterface; $this->currentTheme = $designInterface->getDesignTheme(); $this->initConfig(); @@ -139,4 +148,14 @@ public function getVideoAutoRestartAttribute() return $videoAttributes[self::NODE_CONFIG_VIDEO_AUTO_RESTART]; } } + + /** + * Retrieve YouTube API key + * + * @return string + */ + public function getYouTubeApiKey() + { + return $this->scopeConfig->getValue(self::XML_PATH_YOUTUBE_API_KEY); + } } diff --git a/app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php b/app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php index 55fe3af0f92a4..e07d3144baa89 100644 --- a/app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php +++ b/app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php @@ -86,7 +86,8 @@ public function testGetWidgetOptions() $value = [ 'saveVideoUrl' => $saveVideoUrl, 'saveRemoteVideoUrl' => $saveRemoteVideoUrl, - 'htmlId' => 'id_' . $rand + 'htmlId' => 'id_' . $rand, + 'youTubeApiKey' => null ]; $this->jsonEncoderMock->expects($this->once())->method('encode')->with( $value diff --git a/app/code/Magento/ProductVideo/etc/adminhtml/system.xml b/app/code/Magento/ProductVideo/etc/adminhtml/system.xml new file mode 100644 index 0000000000000..f475ab5b70d54 --- /dev/null +++ b/app/code/Magento/ProductVideo/etc/adminhtml/system.xml @@ -0,0 +1,19 @@ + + + + +
+ + + + + + +
+
+
diff --git a/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml b/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml index eff4727524c00..000134b212f98 100755 --- a/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml +++ b/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml @@ -7,7 +7,6 @@ --> - diff --git a/app/code/Magento/ProductVideo/view/adminhtml/templates/product/edit/slideout/form.phtml b/app/code/Magento/ProductVideo/view/adminhtml/templates/product/edit/slideout/form.phtml index 6e2418f119622..50d5324fc43e6 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/templates/product/edit/slideout/form.phtml +++ b/app/code/Magento/ProductVideo/view/adminhtml/templates/product/edit/slideout/form.phtml @@ -17,7 +17,7 @@ }); }); -
+
diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/css/productvideo.css b/app/code/Magento/ProductVideo/view/adminhtml/web/css/productvideo.css deleted file mode 100755 index e2aa3047a6892..0000000000000 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/css/productvideo.css +++ /dev/null @@ -1,261 +0,0 @@ - /** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -.image.video-placeholder { - position: relative; - display: inline-block; - text-decoration: none; -} - -.image.video-placeholder:before { - background: url(../images/gallery-sprite.png) no-repeat left bottom; - content: ''; - position: absolute; - height: 49px; - width: 49px; - left: 50%; - top: 18px; - margin-left: -24px; - opacity: 0.7; - z-index: 1; -} - -.video-placeholder .image-placeholder-text { - font-weight: 400; -} - -.admin__field.field-video_image .admin__field-control, -.admin__field.field-video_small_image .admin__field-control, -.admin__field.field-video_thumbnail .admin__field-control, -.admin__field.field-video_swatch_image .admin__field-control, -.admin__field.field-new_video_disabled .admin__field-control { - width: 82px; - margin-left: calc((100%) * .33333333 - 30px); -} - -.admin__field.field-video_image .admin__field-control input, -.admin__field.field-video_small_image .admin__field-control input, -.admin__field.field-video_thumbnail .admin__field-control input, -.admin__field.field-video_swatch_image .admin__field-control input, -.admin__field.field-new_video_disabled .admin__field-control input { - float: right; -} - -.admin__field.field-video_image .admin__field-label, -.admin__field.field-video_small_image .admin__field-label, -.admin__field.field-video_thumbnail .admin__field-label, -.admin__field.field-video_swatch_image .admin__field-label, -.admin__field.field-new_video_disabled .admin__field-label { - width: 200px; - position: absolute; - margin-left: calc((100%) * .33333333 - 30px + 90px); - left: 0px; -} - -.admin__field.field-video_image .admin__field-label:before, -.admin__field.field-video_small_image .admin__field-label:before, -.admin__field.field-video_thumbnail .admin__field-label:before, -.admin__field.field-video_swatch_image .admin__field-label:before, -.admin__field.field-new_video_disabled .admin__field-label:before { - content: none; -} - -.admin__field.field-video_image .admin__field-label span, -.admin__field.field-video_small_image .admin__field-label span, -.admin__field.field-video_thumbnail .admin__field-label span, -.admin__field.field-video_swatch_image .admin__field-label span, -.admin__field.field-new_video_disabled .admin__field-label span { - float: left; -} - -.admin__field.field-video_image, -.admin__field.field-video_small_image, -.admin__field.field-video_thumbnail, -.admin__field.field-video_swatch_image { - margin-bottom: 20px !important; -} - -.admin__field.field-new_video_disabled { - margin-top: 32px !important; -} - -.admin__field.field-video_image .admin__field-control { - position: relative; -} - -.admin__field.field-video_image .admin__field-control:after { - content: 'Role'; - position: absolute; - color: #000; - width: 34px; - height: 20px; - left: 1px; - top: -2px; - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 1.4rem; - font-weight: 600; -} - -.preview_hidden_image_input_button { - display: none; -} - -.video-item { - position: relative; -} - -.video-item:after { - content: ''; - position: absolute; - bottom: 0; - right: 0; - background: url(../images/gallery-sprite.png) bottom left; - width: 49px; - height: 40px; - z-index: 3; - left: 0; - top: 10px; - margin: auto; -} - -.mage-new-video-dialog #new_video_form { - width: 65%; - float: left; -} - -.mage-new-video-dialog #video-player-preview-location { - width: 34.99999%; - float: left; -} - -.video-player-container { - width: 100%; - height: 20vw; - margin-bottom: 30px; - border: 1px solid #e3e3e3; - position: relative; -} - -.video-player-container:after { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - margin: auto; - width: 93px; - height: 60px; - background: url(../images/camera.png) no-repeat center; - z-index: 1; -} - -.video-information { - margin-bottom: 7px; - display: none; -} - -.video-information:after { - content: " "; /* Older browser do not support empty content */ - visibility: hidden; - display: block; - height: 0; - clear: both; -} - -.video-information label { - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 1.4rem; - font-weight: 600; - display: block; - width: 25%; - float: left; - text-align: right; -} - -.video-information span { - font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; - font-size: 1.4rem; - font-weight: 300; - display: block; - width: 74.9999%; - float: left; - padding-left: 20px; -} - -.product-video { - width: 100%; - z-index: 20; - height: 100%; - position: relative; -} - -.image.video-placeholder > button[data-role="add-video-button"], -.image.video-placeholder > button { - width: 100%; - height: 100%; - border: 0; - background: transparent; - z-index: 10; - position: relative; -} - -.add-video-button-container { - float: right; - margin-bottom: 10px; -} - -.admin__field.field.field-new_video_screenshot { - margin-bottom: 5px; -} - -.admin__field.field.field-new_video_screenshot_preview { - margin-bottom: 50px; -} - -.image .action-make-base:after { - -webkit-font-smoothing: antialiased; - font-size: 1.8rem; - line-height: inherit; - color: #9e9e9e; - content: '\e63b'; - font-family: 'Admin Icons'; - vertical-align: middle; - display: inline-block; - font-weight: normal; - overflow: hidden; - speak: none; - text-align: center; - position: absolute; - top: -7px; - left: -4px; -} - -.image .action-make-base:hover:after { - color: #7d7d7d; -} - -.admin__scope-old .gallery .image .action-make-base { - border: 0; - width: 0; - height: 0; - position: absolute; - margin: 0; - bottom: 9px; - right: 9px; - left: auto; - background: transparent; -} - -.image .action-make-base span { - display: none; -} - -.admin__scope-old .base-image .image-label { - display: block; -} - -.image.base-image:hover .image-label { - display: none; -} diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js b/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js index d692aaf4eccf6..52171f1537a25 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js +++ b/app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js @@ -322,7 +322,10 @@ require([ $.widget('mage.videoData', { options: { - youtubeKey: 'AIzaSyDwqDWuw1lra-LnpJL2Mr02DYuFmkuRSns' //sample data, change later! + youtubeKey: '', + noKeyErrorTxt: 'You have not entered youtube API key. ' + + 'No information about youtube video will be retrieved.', + eventSource: '' //where is data going from - focus out or click on button }, _REQUEST_VIDEO_INFORMATION_TRIGGER: 'update_video_information', @@ -337,6 +340,11 @@ require([ * @private */ _init: function () { + if (!this.options.youtubeKey && this.options.eventSource === 'click') { + alert({ + content: this.options.noKeyErrorTxt + }); + } this._onRequestHandler(); }, @@ -365,18 +373,58 @@ require([ } /** + * + * @param {Object} data * @private */ function _onYouTubeLoaded(data) { var tmp, uploadedFormatted, - respData; + respData, + createErrorMessage; + + /** + * Create errors message + * + * @returns {String} + */ + createErrorMessage = function () { + var error = data.error, + errors = error.errors, + i, + errLength = errors.length, + tmpError, + errReason, + errorsMessage = []; + + for (i = 0; i < errLength; i++) { + tmpError = errors[i]; + errReason = tmpError.reason; + + if (['keyInvalid'].indexOf(errReason) !== -1) { + errorsMessage.push('Youtube API key is an invalid'); + + break; + } - if (data.items.length < 1) { + errorsMessage.push(tmpError.message); + } + + return 'Video can\'t be shown by reason: ' + $.unique(errorsMessage).join(', '); + }; + + if (data.error && data.error.code === 400) { + this._onRequestError(createErrorMessage()); + + return; + } + + if (!data.items || data.items.length < 1) { this._onRequestError('Video not found'); return; } + tmp = data.items[0]; uploadedFormatted = tmp.snippet.publishedAt.replace('T', ' ').replace(/\..+/g, ''); respData = { @@ -429,8 +477,17 @@ require([ googleapisUrl = 'https://www.googleapis.com/youtube/v3/videos?id=' + id + '&part=snippet,contentDetails,statistics,status&key=' + - this.options.youtubeKey; - $.get(googleapisUrl, $.proxy(_onYouTubeLoaded, this)); + this.options.youtubeKey + '&alt=json&callback=?'; + $.getJSON(googleapisUrl, + { + format: 'json' + }, + $.proxy(_onYouTubeLoaded, self) + ).fail( + function () { + self._onRequestError('Video not found'); + } + ); } else if (type === 'vimeo') { $.getJSON('http://www.vimeo.com/api/v2/video/' + id + '.json?callback=?', { @@ -493,7 +550,8 @@ require([ _validateURL: function (href, forceVideo) { var id, type, - ampersandPosition; + ampersandPosition, + vimeoRegex; if (typeof href !== 'string') { return href; @@ -518,7 +576,10 @@ require([ type = 'youtube'; } else if (href.host.match(/vimeo\.com/)) { type = 'vimeo'; - id = href.pathname.replace(/^\/(video\/)?/, '').replace(/\/.*/, ''); + vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)', + '?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)' + ].join('')); + id = href.href.match(vimeoRegex)[3]; } if ((!id || !type) && forceVideo) { diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js b/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js index 980ac3a2e4ddb..e5efb668b51e9 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js +++ b/app/code/Magento/ProductVideo/view/adminhtml/web/js/new-video-dialog.js @@ -93,7 +93,7 @@ define([ $(this.options.metaData.DOM.uploader).html( '' + + '" target="_blank">' + this.options.metaData.data.uploader + '' ); @@ -102,7 +102,7 @@ define([ $(this.options.metaData.DOM.uploader).html( '' + this.options.metaData.data.uploader + + '" target="_blank">' + this.options.metaData.data.uploader + ''); } $('.' + this.options.videoClass).productVideoLoader(); @@ -243,7 +243,10 @@ define([ this._on(events); - this._videoUrlWidget = $(this._videoUrlSelector).videoData(); + this._videoUrlWidget = $(this._videoUrlSelector).videoData({ + youtubeKey: this.options.youTubeApiKey, + eventSource: 'focusout' + }); this._videoInformationGetBtn = $(this._videoInformationBtnSelector); this._videoInformationGetUrlField = $(this._videoUrlSelector); this._videoInformationGetEditBtn = $(this._editVideoBtnSelector); @@ -262,7 +265,10 @@ define([ _onGetVideoInformationClick: function () { this._onlyVideoPlayer = false; this._isEditPage = false; - this._videoInformationGetUrlField.videoData(); + this._videoInformationGetUrlField.videoData({ + youtubeKey: this.options.youTubeApiKey, + eventSource: 'click' + }); this._videoUrlWidget.trigger('update_video_information'); }, @@ -271,7 +277,10 @@ define([ * @private */ _onGetVideoInformationFocusOut: function () { - this._videoInformationGetUrlField.videoData(); + this._videoInformationGetUrlField.videoData({ + youtubeKey: this.options.youTubeApiKey, + eventSource: 'focusout' + }); this._videoUrlWidget.trigger('update_video_information'); }, @@ -282,7 +291,10 @@ define([ _onGetVideoInformationEditClick: function () { this._onlyVideoPlayer = true; this._isEditPage = true; - this._videoInformationGetUrlField.videoData(); + this._videoInformationGetUrlField.videoData({ + youtubeKey: this.options.youTubeApiKey, + eventSource: 'click' + }); this._videoUrlWidget.trigger('update_video_information'); }, diff --git a/app/code/Magento/ProductVideo/view/adminhtml/web/js/video-modal.js b/app/code/Magento/ProductVideo/view/adminhtml/web/js/video-modal.js index f7e0e72de69c1..a6e13f100fee7 100644 --- a/app/code/Magento/ProductVideo/view/adminhtml/web/js/video-modal.js +++ b/app/code/Magento/ProductVideo/view/adminhtml/web/js/video-modal.js @@ -4,56 +4,54 @@ */ define([ 'jquery', + 'productGallery', 'jquery/ui', 'Magento_Ui/js/modal/modal', 'mage/translate', 'mage/backend/tree-suggest', 'mage/backend/validation' -], function ($) { +], function ($, productGallery) { 'use strict'; - $.widget('mage.productGallery', - $.mage.productGallery, - { - - /** - * Fired when windget initialization start - * @private - */ - _create: function () { - this._bind(); - }, - - /** - * Bind events - * @private - */ - _bind: function () { - $(this.element).on('click', this.showModal.bind(this)); - $('.gallery.ui-sortable').on('openDialog', $.proxy(this._onOpenDialog, this)); - }, - - /** - * Open dialog for external video - * @private - */ - _onOpenDialog: function (e, imageData) { - - if (imageData['media_type'] !== 'external-video') { - return; - } - this.showModal(); - }, - - /** - * Fired on trigger "openModal" - */ - showModal: function () { - - $('#new-video').modal('openModal'); + $.widget('mage.productGallery', productGallery, { + + /** + * * Fired when widget initialization start + * @private + */ + _create: function () { + this._bind(); + }, + + /** + * Bind events + * @private + */ + _bind: function () { + $(this.element).on('click', this.showModal.bind(this)); + $('.gallery.ui-sortable').on('openDialog', $.proxy(this._onOpenDialog, this)); + }, + + /** + * Open dialog for external video + * @private + */ + _onOpenDialog: function (e, imageData) { + + if (imageData['media_type'] !== 'external-video') { + return; } + this.showModal(); + }, + + /** + * Fired on trigger "openModal" + */ + showModal: function () { + + $('#new-video').modal('openModal'); } - ); + }); return $.mage.productGallery; }); diff --git a/app/code/Magento/ProductVideo/view/frontend/layout/catalog_product_view.xml b/app/code/Magento/ProductVideo/view/frontend/layout/catalog_product_view.xml index 81d7989a521f2..59d2ef3e2cd95 100644 --- a/app/code/Magento/ProductVideo/view/frontend/layout/catalog_product_view.xml +++ b/app/code/Magento/ProductVideo/view/frontend/layout/catalog_product_view.xml @@ -6,14 +6,9 @@ */ --> - - - - - - + diff --git a/app/code/Magento/ProductVideo/view/frontend/requirejs-config.js b/app/code/Magento/ProductVideo/view/frontend/requirejs-config.js index 956dd40b89e31..e19b89135b441 100644 --- a/app/code/Magento/ProductVideo/view/frontend/requirejs-config.js +++ b/app/code/Magento/ProductVideo/view/frontend/requirejs-config.js @@ -6,7 +6,6 @@ var config = { map: { '*': { - fotoramaAddVideoEvents: 'Magento_ProductVideo/js/fotorama-add-video-events', loadPlayer: 'Magento_ProductVideo/js/load-player' } } diff --git a/app/code/Magento/ProductVideo/view/frontend/templates/product/view/gallery.phtml b/app/code/Magento/ProductVideo/view/frontend/templates/product/view/gallery.phtml index 192a3f18e2cc6..131b9f7e4ff33 100644 --- a/app/code/Magento/ProductVideo/view/frontend/templates/product/view/gallery.phtml +++ b/app/code/Magento/ProductVideo/view/frontend/templates/product/view/gallery.phtml @@ -10,69 +10,12 @@ * @var $block \Magento\ProductVideo\Block\Product\View\Gallery */ ?> - +getUrl( + 'adminhtml/order_shipment/printPackage', + array('shipment_id' => $block->getShipment()->getId()) +); +?> + diff --git a/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js b/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js new file mode 100644 index 0000000000000..36b934c0e9c7e --- /dev/null +++ b/app/code/Magento/Shipping/view/adminhtml/web/js/packages.js @@ -0,0 +1,39 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/modal', + 'mage/translate' +], function ($, modal, $t) { + 'use strict'; + + return function (config, element) { + config.buttons = [ + { + text: $t('Print'), + 'class': 'action action-primary', + + /** + * Click handler + */ + click: function () { + window.location.href = this.options.url; + } + }, { + text: $t('Cancel'), + 'class': 'action action-secondary', + + /** + * Click handler + */ + click: function () { + this.closeModal(); + } + } + ]; + modal(config, element); + }; +}); diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Category.php b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Category.php index 3642359663dff..75e853c13c602 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Category.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Category.php @@ -12,7 +12,7 @@ * * @author Magento Core Team */ -class Category extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Category extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Collection Zend Db select @@ -39,13 +39,13 @@ class Category extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $_categoryResource; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Catalog\Model\ResourceModel\Category $categoryResource * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Catalog\Model\ResourceModel\Category $categoryResource, $connectionName = null diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php index 9a02e012a0132..5a93ef13583fe 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php @@ -13,7 +13,7 @@ * @author Magento Core Team * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Product extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { const NOT_SELECTED_IMAGE = 'no_selection'; @@ -83,7 +83,7 @@ class Product extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $_mediaConfig; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Sitemap\Helper\Data $sitemapData * @param \Magento\Catalog\Model\ResourceModel\Product $productResource * @param \Magento\Store\Model\StoreManagerInterface $storeManager @@ -96,7 +96,7 @@ class Product extends \Magento\Framework\Model\ModelResource\Db\AbstractDb * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Sitemap\Helper\Data $sitemapData, \Magento\Catalog\Model\ResourceModel\Product $productResource, \Magento\Store\Model\StoreManagerInterface $storeManager, diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php index 34879578665f5..07640bb6a7f2e 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Cms/Page.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Page extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Page extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Init resource model (catalog/category) diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap.php b/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap.php index 63daf336eed07..b3ff7ce4838c6 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Sitemap extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Sitemap extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Init resource model diff --git a/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap/Collection.php b/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap/Collection.php index d6a575daf840b..b470759b8901a 100644 --- a/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap/Collection.php +++ b/app/code/Magento/Sitemap/Model/ResourceModel/Sitemap/Collection.php @@ -10,7 +10,7 @@ * * @author Magento Core Team */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Init collection diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index 9ec5c4b988bde..722c823d3f028 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -159,7 +159,7 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Stdlib\DateTime $dateTime - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -177,7 +177,7 @@ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Framework\Stdlib\DateTime $dateTime, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index be5d7603d9dd2..7ef0dd37d5039 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -103,7 +103,7 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements * @param \Magento\Config\Model\ResourceModel\Config\Data $configDataResource * @param \Magento\Store\Model\Store $store * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -116,7 +116,7 @@ public function __construct( \Magento\Config\Model\ResourceModel\Config\Data $configDataResource, \Magento\Store\Model\ResourceModel\Store\CollectionFactory $storeListFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Store/Model/ResourceModel/Config/Collection/Scoped.php b/app/code/Magento/Store/Model/ResourceModel/Config/Collection/Scoped.php index 21ea5ee90904f..3e37e1ad8d6a0 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Config/Collection/Scoped.php +++ b/app/code/Magento/Store/Model/ResourceModel/Config/Collection/Scoped.php @@ -7,7 +7,7 @@ */ namespace Magento\Store\Model\ResourceModel\Config\Collection; -class Scoped extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Scoped extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Scope to filter by diff --git a/app/code/Magento/Store/Model/ResourceModel/Group.php b/app/code/Magento/Store/Model/ResourceModel/Group.php index b46679e118e66..c3365055aa47d 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Group.php +++ b/app/code/Magento/Store/Model/ResourceModel/Group.php @@ -8,7 +8,7 @@ /** * Store group resource model */ -class Group extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Group extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Store/Model/ResourceModel/Group/Collection.php b/app/code/Magento/Store/Model/ResourceModel/Group/Collection.php index b452660b04b1c..805b90c291abf 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Group/Collection.php +++ b/app/code/Magento/Store/Model/ResourceModel/Group/Collection.php @@ -8,7 +8,7 @@ /** * Store group collection */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Define resource model diff --git a/app/code/Magento/Store/Model/ResourceModel/Store.php b/app/code/Magento/Store/Model/ResourceModel/Store.php index 58d74f0173e92..fec1340afe64d 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Store.php +++ b/app/code/Magento/Store/Model/ResourceModel/Store.php @@ -8,7 +8,7 @@ /** * Store Resource Model */ -class Store extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Store extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var \Magento\Framework\App\Cache\Type\Config @@ -16,11 +16,11 @@ class Store extends \Magento\Framework\Model\ModelResource\Db\AbstractDb protected $configCache; /** - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\App\Cache\Type\Config $configCacheType */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, \Magento\Framework\App\Cache\Type\Config $configCacheType ) { $this->configCache = $configCacheType; diff --git a/app/code/Magento/Store/Model/ResourceModel/Store/Collection.php b/app/code/Magento/Store/Model/ResourceModel/Store/Collection.php index 30852811667dc..ebef78956a418 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Store/Collection.php +++ b/app/code/Magento/Store/Model/ResourceModel/Store/Collection.php @@ -8,7 +8,7 @@ /** * Stores collection */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Name prefix of events that are dispatched by model diff --git a/app/code/Magento/Store/Model/ResourceModel/Website.php b/app/code/Magento/Store/Model/ResourceModel/Website.php index 884a50958e6ad..43b2612d2160c 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Website.php +++ b/app/code/Magento/Store/Model/ResourceModel/Website.php @@ -11,7 +11,7 @@ /** * Website Resource Model */ -class Website extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Website extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Define main table diff --git a/app/code/Magento/Store/Model/ResourceModel/Website/Collection.php b/app/code/Magento/Store/Model/ResourceModel/Website/Collection.php index 6eb5383fb8b85..419350a90318e 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Website/Collection.php +++ b/app/code/Magento/Store/Model/ResourceModel/Website/Collection.php @@ -8,7 +8,7 @@ /** * Websites collection */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Map field to alias diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index b04ab411d5606..375064ca57f15 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -171,7 +171,7 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement * @param \Magento\Store\Model\WebsiteFactory $websiteFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -188,7 +188,7 @@ public function __construct( \Magento\Store\Model\WebsiteFactory $websiteFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Directory\Model\CurrencyFactory $currencyFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/app/code/Magento/Swagger/composer.json b/app/code/Magento/Swagger/composer.json index 878f5c8dfefd0..0ba900539c248 100644 --- a/app/code/Magento/Swagger/composer.json +++ b/app/code/Magento/Swagger/composer.json @@ -2,7 +2,7 @@ "name": "magento/module-swagger", "description": "N/A", "require": { - "php": "~5.5.0|~5.6.0", + "php": "~5.5.0|~5.6.0|~7.0.0", "magento/framework": "1.0.0-beta" }, "type": "magento2-module", diff --git a/app/code/Magento/Swatches/Helper/Data.php b/app/code/Magento/Swatches/Helper/Data.php index c597284e6e40c..aecd9db6cfab9 100644 --- a/app/code/Magento/Swatches/Helper/Data.php +++ b/app/code/Magento/Swatches/Helper/Data.php @@ -387,9 +387,11 @@ protected function getAllSizeImages(Product $product, $imageFile) { return [ 'large' => $this->imageHelper->init($product, 'product_page_image_large') + ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false) ->setImageFile($imageFile) ->getUrl(), 'medium' => $this->imageHelper->init($product, 'product_page_image_medium') + ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false) ->setImageFile($imageFile) ->getUrl(), 'small' => $this->imageHelper->init($product, 'product_page_image_small') diff --git a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php index b361dfa68602c..fa230bf8eae2f 100644 --- a/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php +++ b/app/code/Magento/Swatches/Model/ResourceModel/Swatch.php @@ -10,7 +10,7 @@ * @codeCoverageIgnore * Swatch Resource Model */ -class Swatch extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Swatch extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize resource model diff --git a/app/code/Magento/Swatches/Model/ResourceModel/Swatch/Collection.php b/app/code/Magento/Swatches/Model/ResourceModel/Swatch/Collection.php index 28b800ecc9ca1..4099c23475385 100644 --- a/app/code/Magento/Swatches/Model/ResourceModel/Swatch/Collection.php +++ b/app/code/Magento/Swatches/Model/ResourceModel/Swatch/Collection.php @@ -9,7 +9,7 @@ * @codeCoverageIgnore * Swatch Collection */ -class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * Standard collection initialization diff --git a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php index 775e1b2196182..31e868cdf4ca9 100644 --- a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php @@ -334,6 +334,15 @@ public function testGetProductMediaGallery($mediaGallery, $image) ->method('setImageFile') ->with($image) ->willReturnSelf(); + $this->imageHelperMock->expects($this->any()) + ->method('constrainOnly') + ->willReturnSelf(); + $this->imageHelperMock->expects($this->any()) + ->method('keepAspectRatio') + ->willReturnSelf(); + $this->imageHelperMock->expects($this->any()) + ->method('keepFrame') + ->willReturnSelf(); $this->imageHelperMock->expects($this->any()) ->method('getUrl') ->willReturn('http://full_path_to_image/magento1.png'); diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml index 8b2b70a2cdbfb..0f911d563f714 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/js.phtml @@ -8,7 +8,14 @@ ?> diff --git a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js index bb697c1fa5259..a831603f9d1b4 100644 --- a/app/code/Magento/Wishlist/view/frontend/web/wishlist.js +++ b/app/code/Magento/Wishlist/view/frontend/web/wishlist.js @@ -7,10 +7,12 @@ define([ 'jquery', 'mage/template', + 'Magento_Ui/js/modal/alert', 'jquery/ui', 'mage/validation/validation', + 'mage/dataPost' -], function ($, mageTemplate) { +], function ($, mageTemplate, alert) { 'use strict'; $.widget('mage.wishlist', { @@ -152,7 +154,9 @@ define([ if ($(form).find('input:checkbox:checked').length) { form.submit(); } else { - alert(this.options.checkBoxValidationMessage); + alert({ + content: this.options.checkBoxValidationMessage + }); } }, this) }); diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less index f09454d5862d6..4cd621361e3b6 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_steps-wizard.less @@ -72,8 +72,4 @@ margin: @indent__base 0; } } - - .admin__data-grid-pager-wrap { - float: right; - } } diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/steps/_bulk-images.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/steps/_bulk-images.less index 60203c2aa3021..d1f298df84ee6 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/steps/_bulk-images.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/steps/_bulk-images.less @@ -361,16 +361,6 @@ top: 5px; } -.image-pointer { - background: url(../Magento_Backend/images/gallery-image-panel-corner.png) no-repeat; - height: 15px; - left: 50%; - margin-left: -14px; - position: absolute; - top: -11px; - width: 28px; -} - .image-panel-controls, .image-panel-preview { float: left; @@ -431,28 +421,6 @@ width: 100%; } -.image-panel { - .action-close { - padding: 0; - position: absolute; - right: 29px; - top: 17px; - .lib-icon-font( - @_icon-font-content: @icon-close-mage__content, - @_icon-font: @icons-admin__font-name, - @_icon-font-size: 2rem, - @_icon-font-color: @color-brownie-vanilla, - @_icon-font-color-hover: @color-brownie-vanilla - ); - span { - &:extend(.abs-visually-hidden all); - } - &:active { - padding: 0; - } - } -} - // // Custom Multiselect // _____________________________________________ diff --git a/app/design/adminhtml/Magento/backend/Magento_ProductVideo/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_ProductVideo/web/css/source/_module.less new file mode 100644 index 0000000000000..7f4e8a590acf9 --- /dev/null +++ b/app/design/adminhtml/Magento/backend/Magento_ProductVideo/web/css/source/_module.less @@ -0,0 +1,236 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +.image.video-placeholder { + display: inline-block; + position: relative; + text-decoration: none; + &:before { + background: url(../Magento_ProductVideo/images/gallery-sprite.png) no-repeat left bottom; + content: ''; + height: 49px; + left: 50%; + margin-left: -24px; + opacity: 0.7; + position: absolute; + top: 18px; + width: 49px; + z-index: 1; + } + .image-placeholder-text { + font-weight: 400; + } +} + +//re-arrange checkboxes fields in slideout video panel (base, small image etc) +.admin__field { + &.field-video_image, + &.field-video_small_image, + &.field-video_thumbnail, + &.field-video_swatch_image, + &.field-new_video_disabled { + .admin__field-control { + #mix-grid .column(3, @field-grid__columns); + float: left; + margin-left: 80px; + position: relative; + input { + float: right; + } + } + .admin__field-label { + left: 0; + margin-left: 35%; + padding-left: 45px; + position: absolute; + width: 250px; + &:before { + content: none; + } + span { + float: left; + } + } + } + &.field-new_video_disabled { + margin-top: 32px; + } + &.field.field-new_video_screenshot { + margin-bottom: 5px; + } + &.field.field-new_video_screenshot_preview { + margin-bottom: 50px; + } + &.field-roleLabel { + height: 0; + .admin__field-control { + #mix-grid .column(3, @field-grid__columns); + float: left; + margin-left: 80px; + position: relative; + .control-value { + color: @color-black; + font-family: 'Open Sans', @font-family__sans-serif; + font-size: @font-size__s + 0.2; + font-weight: @font-weight__semibold; + float: right; + position: relative; + right: 50px; + top: 21px; + } + } + } +} + +.admin__scope-old { + .fieldset .admin__field { + &.field-video_image, + &.field-video_small_image, + &.field-video_thumbnail, + &.field-video_swatch_image { + margin-bottom: 20px; + } + } + .gallery .image .action-make-base, + .images .image .action-make-base { + .lib-button( + @_button-background: transparent, + @_button-border: none, + @_button-background-hover: transparent, + @_button-border-hover: none, + @_button-background-active: transparent, + @_button-border-active: none, + @_button-font-content: '\e63b', + @_button-icon-use: true, + @_button-icon-font: 'Admin Icons', + @_button-icon-font-text-hide: true, + @_button-icon-font-size: @font-size__xl, + @_button-icon-font-color: @color-gray62, + @_button-icon-font-color-hover: @color-gray52, + @_button-icon-font-color-active: @color-gray52, + @_button-margin: 0 + ); + bottom: 9px; + left: auto; + position: absolute; + right: 9px; + width: 0 !important; + &:before { + left: 16px; + position: absolute; + top: -2px; + } + } + .base-image .image-label { + display: block; + } +} + +.preview_hidden_image_input_button { + display: none; +} + +.video-item { + position: relative; + &:after { + background: url(../Magento_ProductVideo/images/gallery-sprite.png) bottom left; + bottom: 0; + content: ''; + height: 40px; + left: 0; + margin: auto; + position: absolute; + right: 0; + top: 10px; + width: 49px; + z-index: 3; + } +} + +//style slideout panel add video +.mage-new-video-dialog { + form.admin__scope-old { + float: left; + width: 65%; + } + .video-player-sidebar { + width: 34.99999%; + float: left; + } + .video-player-container { + width: 100%; + height: 20vw; + margin-bottom: 30px; + border: 1px solid #e3e3e3; + position: relative; + &:after { + content: ''; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + margin: auto; + width: 93px; + height: 60px; + background: url(../Magento_ProductVideo/images/camera.png) no-repeat center; + z-index: 1; + } + } + .video-information { + margin-bottom: 7px; + display: none; + &:after { + content: ""; + visibility: hidden; + display: block; + height: 0; + clear: both; + } + label { + font-family: 'Open Sans', @font-family__sans-serif; + font-size: @font-size__s + 0.2; + font-weight: @font-weight__semibold; + display: block; + width: 25%; + float: left; + text-align: right; + } + span { + font-family: 'Open Sans', @font-family__sans-serif; + font-size: @font-size__s + 0.2; + font-weight: @font-weight__light; + display: block; + width: 74.9999%; + float: left; + padding-left: 20px; + } + } + .product-video { + width: 100%; + z-index: 20; + height: 100%; + position: relative; + } +} + +.image.video-placeholder > button[data-role="add-video-button"], +.image.video-placeholder > button { + background: transparent; + border: 0; + height: 100%; + position: relative; + width: 100%; + z-index: 10; +} + +.add-video-button-container { + float: right; + margin-bottom: 10px; +} + +.image.base-image:hover .image-label { + display: none; +} diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less index 3b4404bc0da1e..d9a3ab7292a8a 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less @@ -305,7 +305,7 @@ body._in-resize { width: 7rem; img { border: 1px solid @data-grid-td__border-color; - max-width: 5rem; + width: 5rem; } } .data-grid-multicheck-cell { diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less index a30087cb5a697..ec5761b7b2a0c 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less +++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/data-grid/data-grid-header/_data-grid-pager.less @@ -17,6 +17,7 @@ .admin__data-grid-pager-wrap { text-align: right; + float: right; } .admin__data-grid-pager { diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/_navigation-bar.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/_navigation-bar.less index e5749d613096c..b0032568136d0 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/_navigation-bar.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/_navigation-bar.less @@ -40,11 +40,12 @@ // --------------------------------------------- .nav { + .extend__clearer(); background-color: @nav__background-color; border-bottom: 1px solid @nav__border-color; border-top: 1px solid @nav__border-color; - .extend__clearer(); display: none; + margin-bottom: @nav-bar__indent-top; padding: @nav-bar-dot__size @nav__indent-right 0 0; } diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/tooltips/_tooltips.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/tooltips/_tooltips.less index 17e40244032bf..f364351ed02cc 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/tooltips/_tooltips.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/components/tooltips/_tooltips.less @@ -54,6 +54,9 @@ margin-left: -(@tooltip-arrow__size / 2); padding: 0 @tooltip-arrow__size; } + p:last-child { + margin-bottom: 0; + } } // Wrapper for the tooltip content diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_buttons.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_buttons.less index ea227158185d4..3d18910a59ed8 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_buttons.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_buttons.less @@ -113,8 +113,7 @@ ); color: @btn-prime__color; } - &:active, - &:focus { + &:active { .lib-background-gradient( @_background-gradient: true, @_background-gradient-direction: horizontal, diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_structures.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_structures.less index 5a63e7806784d..0dd2a8ed52b49 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_structures.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_structures.less @@ -3,6 +3,9 @@ // * See COPYING.txt for license details. // */ +body:not([class]) { + min-width: 0; +} .container { display: block; margin: 0 auto 4rem; diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_variables.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_variables.less index 7f63e9a9933db..7b9cc9eb8d254 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_variables.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/lib/_variables.less @@ -156,7 +156,7 @@ // --------------------------------------------- @container__width: 100rem; -@container__indent: 2rem; +@container__indent: 0; @content__indent: @indent__l; diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/pages/_readiness-check.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/pages/_readiness-check.less index 542d96aedebca..cde931e2c71e1 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/pages/_readiness-check.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/pages/_readiness-check.less @@ -10,7 +10,7 @@ // Sizes @readiness-check-side__width: 22rem; -@readiness-check-content__indent: 7.5rem; +@readiness-check-content__indent: 5.7rem; // // Common @@ -18,6 +18,12 @@ .readiness-check-item { margin-bottom: 4rem; + min-height: 2.5rem; + .spinner { + font-size: 2.5rem; + float: left; + margin: -.4rem 0 0 1.7rem; + } } .readiness-check-title { @@ -49,7 +55,7 @@ .readiness-check-icon { float: left; - margin-left: 2rem; + margin-left: 1.7rem; margin-top: .7rem; } diff --git a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/setup.less b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/setup.less index 963c6b01b9f3b..c2bbaf8f432b9 100644 --- a/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/setup.less +++ b/app/design/adminhtml/Magento/backend/web/app/setup/styles/less/setup.less @@ -98,7 +98,6 @@ // Updater pages @import '../../../updater/styles/less/pages/_common.less'; @import '../../../updater/styles/less/pages/_home.less'; -@import '../../../updater/styles/less/pages/_readiness-check.less'; @import '../../../updater/styles/less/pages/_component-manager.less'; @import '../../../updater/styles/less/pages/_login.less'; diff --git a/app/design/adminhtml/Magento/backend/web/app/updater/styles/less/pages/_readiness-check.less b/app/design/adminhtml/Magento/backend/web/app/updater/styles/less/pages/_readiness-check.less deleted file mode 100644 index 2b6356f5f41a9..0000000000000 --- a/app/design/adminhtml/Magento/backend/web/app/updater/styles/less/pages/_readiness-check.less +++ /dev/null @@ -1,23 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -// -// Upgrade -> Pages -> Readiness Check -// _____________________________________________ - -.readiness-check-item { - padding-top: .3rem; -} - -.readiness-check-icon { - margin-left: 2.4rem; - margin-top: -0.1rem; - &.icon-success { - font-size: 2rem; - } - &.icon-failed { - font-size: 1.6rem; - } -} \ No newline at end of file diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_components.less b/app/design/adminhtml/Magento/backend/web/css/source/_components.less index a9ee8f523cc02..b376a1a2bd201 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_components.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_components.less @@ -13,3 +13,4 @@ @import 'components/_popups.less'; @import 'components/_modals.less'; @import 'components/_modals_extend.less'; +@import 'components/_file-insertion.less'; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less index 2e18751ca4955..8e1e484f69ac8 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/_forms.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/_forms.less @@ -7,3 +7,4 @@ @import 'forms/_controls.less'; @import 'forms/_fields.less'; @import 'forms/_temp.less'; +@import 'forms/_form-wysiwyg.less'; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less new file mode 100644 index 0000000000000..cdc66d477555d --- /dev/null +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_file-insertion.less @@ -0,0 +1,49 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Block 'Insert File' +// _________________________________________ + +.contents-uploader { + margin: 0 0 @indent__base; + .fileinput-button { + cursor: pointer; + display: inline-block; + float: none; + vertical-align: middle; + span { + display: none; + } + input { + -moz-transforms: none; + border: none; + opacity: 1; + position: static; + } + } +} + +.file-row { + border: 1px solid @color-gray68; + margin: @indent__xs 0; + padding: 2px; +} + +.filecnt { + border: 1px solid @color-gray68; + cursor: pointer; + display: inline-block; + margin: 0 @indent__xs 15px 0; + overflow: hidden; + padding: 3px; + width: 100px; + &.selected { + border-color: @color-blue-dodger; + } + p { + text-align: center; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less index 0ea7e84b1447f..babbdf33f37c4 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_modals_extend.less @@ -21,6 +21,13 @@ @modal-action-close__font-size: 2rem; @modal-action-close__active__font-size: 1.8rem; @modal-action-close__hover__color: darken(@color-brownie-vanilla, 10%); +@modal-popup-footer-button__margin: 2rem; +@modal-popup-footer-button__padding: 1.4rem; +@modal-popup-footer-button__font-size: 1.5rem; +@modal-popup-footer-button__color: @color-brownie; +@modal-popup-colored__background: @color-lazy-sun; +@modal-popup-colorless__background: @color-white; +@modal-prompt-message__padding: 2rem; // @@ -31,6 +38,7 @@ position: absolute; right: 0; top: 0; + z-index: 1; &:active { transform: none; &:before { @@ -49,10 +57,74 @@ } .modal-popup { + &.prompt { + .prompt-message { + padding: @modal-prompt-message__padding 0; + input { + width: 100%; + } + } + } + &.confirm, + &.prompt { + .modal-inner-wrap { + .message { + background: @modal-popup-colorless__background; + } + } + } + &.modal-system-messages { + .modal-inner-wrap { + background: @modal-popup-colored__background; + } + } + &._image-box { + .modal-inner-wrap { + margin: 5rem auto; + max-width: @modal-popup-image-box__max-width; + position: static; + } + .thumbnail-preview { + padding-bottom: @indent__l; + text-align: center; + .thumbnail-preview-image-block { + border: 1px solid @modal-popup-image-box__border-color; + margin: 0 auto @indent__base; + max-width: @modal-popup-image-box-preview__max-width; + padding: @indent__base; + } + .thumbnail-preview-image { + max-height: @modal-popup-image-box-preview-image__max-height; + } + } + } + .modal-title { font-size: @modal-popup-title__font-size; margin-right: @modal-popup-title__font-size + @modal-popup__padding + 1rem; } + + .action-close { + padding: @modal-popup__padding @modal-popup__padding; + &:active{ + padding-top: @modal-popup__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 3; + padding-right: @modal-popup__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 3; + } + } + + .modal-footer { + text-align: right; + padding-top: @modal-slide__padding; + + .action-primary { + &:extend(.abs-action-secondary all); + &:extend(.abs-action-l all); + } + .action-secondary { + &:extend(.abs-action-tertiary all); + &:extend(.abs-action-l all); + } + } .action-close { padding: @modal-popup__padding; &:active, @@ -69,16 +141,63 @@ font-size: @modal-slide-title__font-size; margin-right: @modal-slide-title__font-size + @modal-slide__padding + 1rem; } + .action-close { padding: @modal-slide-header__padding-vertical @modal-slide__padding; &:active { - padding-right: @modal-slide__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; padding-top: @modal-slide-header__padding-vertical + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; + padding-right: @modal-slide__padding + (@modal-action-close__font-size - @modal-action-close__active__font-size) / 2; } } .page-main-actions { - margin-bottom: @modal-slide-header__padding-vertical - @page-main-actions__padding; margin-top: @modal-slide-header__padding-vertical; + margin-bottom: @modal-slide-header__padding-vertical - @page-main-actions__padding; + } + + .magento_message { + padding: 0 @popup__padding__horizontal @popup__padding__vertical; + position: relative; + } + + .main-col, + .magento_message { + .insert-title-inner { + &:extend(.abs-clearfix all); + border-bottom: 1px solid @color-gray68; + margin: 0 0 @indent__base; + padding-bottom: @indent__xs; + } + .insert-actions { + float: right; + } + .title { + font-size: @font-size__l; + padding-top: @indent__xs; + } + } + + .main-col, + .side-col { + float: left; + padding-bottom: 0; + &:after { + display: none; + } + } + + .side-col { + width: 20%; + } + + .main-col { + padding-right: 0; + width: 80%; + } + + .content-footer { + .form-buttons { + float: right; + } } } @@ -86,4 +205,4 @@ font-weight: @font-weight__regular; margin-bottom: 0; min-height: 1em; -} +} \ No newline at end of file diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less index 6586433b78423..520b26a148b74 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_popups.less @@ -389,15 +389,24 @@ // Attribute Popup // _____________________________________________ -.attribute-popup-actions { - background: @color-white; - border-top: 1px solid @color-gray68; - bottom: 0; - left: 0; - padding: @popup__padding; - position: fixed; - right: 0; - top: auto !important; +.catalog-product-attribute-edit { + .page-wrapper { + width: 100%; + .page-content { + padding-left: 0; + } + } +} + +.attribute-popup-actions { // ToDo UI: remove or refactor after New attribute popup refactored to sliding panel + &:extend(.abs-clearfix all); + background: @page-main-actions__background-color; + border-bottom: 1px solid @page-main-actions__border-color; + border-top: 1px solid @page-main-actions__border-color; + padding: @page-main-actions__padding; + &.page-actions { + float: none; + } &.fixed { // ToDo UI: remove or refactor after New attribute popup refactored to sliding panel background: @color-white !important; border-bottom: 0 !important; diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less index ce0fee6a77230..a8e768b98e179 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_controls.less @@ -176,6 +176,15 @@ option:empty { } } +// +// Service text or control. Can be used to add text or "Use Default Value" checkbox +// --------------------------------------------- + +.admin__control-service { + float: left; + margin: .8rem 0 0 3rem; +} + // // Textarea // --------------------------------------------- diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less new file mode 100644 index 0000000000000..8ce2fedb6619f --- /dev/null +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_form-wysiwyg.less @@ -0,0 +1,20 @@ +// /** +// * Copyright © 2015 Magento. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Wysiwyg form control styles +// --------------------------------------------- + +.admin__control-wysiwig { + .buttons-set { + margin: 0 0 15px; + button { + margin-right: 4px; + } + } + textarea{ + width: 100%; + } +} diff --git a/app/design/adminhtml/Magento/backend/web/css/styles-old.less b/app/design/adminhtml/Magento/backend/web/css/styles-old.less index 7390b3177b836..9f624fea87ed9 100644 --- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less +++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less @@ -2640,8 +2640,8 @@ } // -// Configuration -> Design -// -------------------------------------- + // Configuration -> Design + // -------------------------------------- #row_design_theme_ua_regexp .design_theme_ua_regexp { float: left; @@ -2654,6 +2654,16 @@ clear: both; } + // + // Configuration -> Advanced -> System -> Notifications section + // -------------------------------------- + + #row_system_adminnotification_last_update { + .value { + vertical-align: bottom; + } + } + // // CMS -> Banners // -------------------------------------- diff --git a/app/design/adminhtml/Magento/backend/web/js/theme.js b/app/design/adminhtml/Magento/backend/web/js/theme.js index 9d1524c4e2352..5fdaa4c582430 100644 --- a/app/design/adminhtml/Magento/backend/web/js/theme.js +++ b/app/design/adminhtml/Magento/backend/web/js/theme.js @@ -126,12 +126,13 @@ define('globalNavigationScroll', [ menuItems.on('click', function (e) { var submenu = $(this).children(subMenuClass), - delta; + delta, + logo = $('.logo')[0].offsetHeight; submenuHeight = submenu.height(); - if (submenuHeight > menuHeight && menuHeight > winHeight) { - menu.height(submenuHeight - $('.logo')[0].offsetHeight); + if (submenuHeight > menuHeight && menuHeight + logo > winHeight) { + menu.height(submenuHeight - logo); delta = -menu.position().top; window.scrollTo(0, 0); positionMenu(); diff --git a/app/design/frontend/Magento/blank/Magento_ProductVideo/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_ProductVideo/web/css/source/_module.less new file mode 100644 index 0000000000000..d51b978a97e0f --- /dev/null +++ b/app/design/frontend/Magento/blank/Magento_ProductVideo/web/css/source/_module.less @@ -0,0 +1,70 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +.fotorama-video-container { + &:after { + background: url(../Magento_ProductVideo/img/gallery-sprite.png) bottom right; + bottom: 0; + content: ''; + height: 100px; + left: 0; + margin: auto; + position: absolute; + right: 0; + top: 12px; + width: 100px; + } + .magnify-lens { + display: none !important; + } + &.video-unplayed { + &:hover { + img { + opacity: 0.6; + } + &:after { + transform: scale(1.25); + } + } + } +} + +.video-thumb-icon:after { + background: url(../Magento_ProductVideo/img/gallery-sprite.png) bottom left; + bottom: 0; + content: ''; + height: 40px; + left: 0; + margin: auto; + position: absolute; + right: 0; + top: 10px; + width: 49px; +} + +.product-video { + height: 85%; + margin-top: 15%; + position: absolute; + top: 0; + width: 100%; + iframe { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + z-index: 9999; + } +} + +.fotorama__arr.hidden-video { + z-index: -1; +} + +.fotorama__video-close { + bottom: 89%; + top: auto; +} diff --git a/app/design/frontend/Magento/blank/etc/view.xml b/app/design/frontend/Magento/blank/etc/view.xml index 6020a6ad025f5..bdb3014469903 100644 --- a/app/design/frontend/Magento/blank/etc/view.xml +++ b/app/design/frontend/Magento/blank/etc/view.xml @@ -181,20 +181,65 @@ - - thumbs - true - true - true - false + + + thumbs + true + true + true + false + true + horizontal + true + slides + + slide + 500 + + + thumbs + true + true + false + false + horizontal + 150 + 150 + true + + dissolve + 500 + true + + + - - - - - hover - true - + + 5 + + + + + hover + true + + + + + + 767px + + + + dots + + + false + + + + + 100 275 diff --git a/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less index 7149c5d38d888..2dea6077b721a 100644 --- a/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Review/web/css/source/_module.less @@ -38,40 +38,6 @@ } } -// -// Reviews list and form -//-------------------------------------- - -.catalog-product-view.ajax-loading { - height: 100%; - overflow: hidden; - &:after { - content: ""; - position:fixed; - height: 100%; - display: block; - width: 100%; - z-index: 998; - background: rgba(255,255,255,.4); - } - &:before { - content: ""; - position:fixed; - top: 0; - left: 0; - bottom: 0; - right: 0; - margin:auto; - display: block; - @loading__size: 74px; - width: @loading__size; - height: @loading__size; - border-radius: @loading__size/2; - z-index: 999; - background: rgba(255, 255, 255, .7) url('../images/loader-1.gif') no-repeat 50% 50%; - } -} - // // Review product page //-------------------------------------- diff --git a/app/design/frontend/Magento/luma/etc/view.xml b/app/design/frontend/Magento/luma/etc/view.xml index 60da26b477424..974c4c9fe5a80 100644 --- a/app/design/frontend/Magento/luma/etc/view.xml +++ b/app/design/frontend/Magento/luma/etc/view.xml @@ -78,20 +78,20 @@ - 560 - 700 + 700 + 560 88 110 - 560 - 700 + 700 + 560 - 560 - 700 + 700 + 560 88 @@ -185,20 +185,65 @@ - - dots - false - true - true - true + + + thumbs + true + true + true + false + true + horizontal + true + slides + + slide + 500 + + + thumbs + true + true + false + false + horizontal + 150 + 150 + true + + dissolve + 500 + true + + + - - - - - click - true - + + 5 + + + + + hover + true + + + + + + 767px + + + + dots + + + false + + + + + 100 275 diff --git a/app/etc/di.xml b/app/etc/di.xml index e1aaf36869b13..598bc2c341ed3 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -94,7 +94,7 @@ - + @@ -133,13 +133,13 @@ - + - + Magento\Framework\Filesystem\Driver\File diff --git a/composer.json b/composer.json index 0fa24640ae43b..a9e71e4b11044 100644 --- a/composer.json +++ b/composer.json @@ -69,6 +69,7 @@ "ext-intl": "*", "ext-xsl": "*", "ext-mbstring": "*", + "ext-openssl": "*", "sjparkinson/static-review": "~4.1", "fabpot/php-cs-fixer": "~1.2", "lusitanian/oauth": "~0.3 <=0.7.0" diff --git a/composer.lock b/composer.lock index 30da261194897..9da039729694a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "c4198e8a51c13b0d2c96bb54023cf2c6", - "content-hash": "444606690390cbbc73e906d61746c25d", + "hash": "80867d6202a3ae5d2f4c079e2cfd702f", + "content-hash": "41493176956dcfd2401ac1181d4d4782", "packages": [ { "name": "braintree/braintree_php", @@ -2571,16 +2571,16 @@ }, { "name": "fabpot/php-cs-fixer", - "version": "v1.10", + "version": "v1.10.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "8e21b4fb32c4618a425817d9f0daf3d57a9808d1" + "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/8e21b4fb32c4618a425817d9f0daf3d57a9808d1", - "reference": "8e21b4fb32c4618a425817d9f0daf3d57a9808d1", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", + "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", "shasum": "" }, "require": { @@ -2621,7 +2621,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2015-07-27 20:56:10" + "time": "2015-10-12 20:13:46" }, { "name": "league/climate", @@ -3941,6 +3941,7 @@ "ext-iconv": "*", "ext-intl": "*", "ext-xsl": "*", - "ext-mbstring": "*" + "ext-mbstring": "*", + "ext-openssl": "*" } } diff --git a/dev/tests/api-functional/_files/Magento/TestModule4/Model/ResourceModel/Item.php b/dev/tests/api-functional/_files/Magento/TestModule4/Model/ResourceModel/Item.php index 39e1bf089cd38..b8cab8ad42eec 100644 --- a/dev/tests/api-functional/_files/Magento/TestModule4/Model/ResourceModel/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModule4/Model/ResourceModel/Item.php @@ -9,7 +9,7 @@ /** * Sample resource model */ -class Item extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Item extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/ResourceModel/Item.php b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/ResourceModel/Item.php index 4052cef7763ca..fcdce38ba6742 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/ResourceModel/Item.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleMSC/Model/ResourceModel/Item.php @@ -9,7 +9,7 @@ /** * Sample resource model */ -class Item extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class Item extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Initialize connection and define main table diff --git a/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php new file mode 100644 index 0000000000000..72005876cc595 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Bundle/Api/OrderItemRepositoryTest.php @@ -0,0 +1,128 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Bundle/_files/order_item_with_bundle_and_options.php + */ + public function testGet() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $orderItem = current($order->getItems()); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $orderItem->getId(), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['id' => $orderItem->getId()]); + + $this->assertTrue(is_array($response)); + $this->assertOrderItem($orderItem, $response); + } + + /** + * @magentoApiDataFixture Magento/Bundle/_files/order_item_with_bundle_and_options.php + */ + public function testGetList() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + + /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ + $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + + $searchCriteriaBuilder->addFilters( + [ + $filterBuilder->setField('order_id') + ->setValue($order->getId()) + ->create(), + ] + ); + + $requestData = ['criteria' => $searchCriteriaBuilder->create()->__toArray()]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertTrue(is_array($response)); + $this->assertArrayHasKey('items', $response); + $this->assertCount(1, $response['items']); + $this->assertTrue(is_array($response['items'][0])); + $this->assertOrderItem(current($order->getItems()), $response['items'][0]); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $bundleOption = $orderItem->getBuyRequest()->getBundleOption(); + $bundleOptionQty = $orderItem->getBuyRequest()->getBundleOptionQty(); + + $this->assertArrayHasKey('product_option', $response); + $this->assertArrayHasKey('extension_attributes', $response['product_option']); + $this->assertArrayHasKey('bundle_options', $response['product_option']['extension_attributes']); + + $actualOptions = $response['product_option']['extension_attributes']['bundle_options']; + + $this->assertEquals(array_keys($bundleOption), array_column($actualOptions, 'option_id')); + $this->assertEquals($bundleOptionQty, array_column($actualOptions, 'option_qty', 'option_id')); + + foreach ($actualOptions as $option) { + $expectedSelections = is_array($bundleOption[$option['option_id']]) + ? $bundleOption[$option['option_id']] + : [$bundleOption[$option['option_id']]]; + $this->assertEquals($expectedSelections, $option['option_selections']); + } + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php new file mode 100644 index 0000000000000..db63fbb608460 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/OrderItemRepositoryTest.php @@ -0,0 +1,129 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/order_item_with_product_and_custom_options.php + */ + public function testGet() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $orderItem = current($order->getItems()); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $orderItem->getId(), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['id' => $orderItem->getId()]); + + $this->assertTrue(is_array($response)); + $this->assertOrderItem($orderItem, $response); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/order_item_with_product_and_custom_options.php + */ + public function testGetList() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + + /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ + $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + + $searchCriteriaBuilder->addFilters( + [ + $filterBuilder->setField('order_id') + ->setValue($order->getId()) + ->create(), + ] + ); + + $requestData = ['criteria' => $searchCriteriaBuilder->create()->__toArray()]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertTrue(is_array($response)); + $this->assertArrayHasKey('items', $response); + $this->assertCount(1, $response['items']); + $this->assertTrue(is_array($response['items'][0])); + $this->assertOrderItem(current($order->getItems()), $response['items'][0]); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $expected = $orderItem->getBuyRequest()->getOptions(); + + $this->assertArrayHasKey('product_option', $response); + $this->assertArrayHasKey('extension_attributes', $response['product_option']); + $this->assertArrayHasKey('custom_options', $response['product_option']['extension_attributes']); + + $actualOptions = $response['product_option']['extension_attributes']['custom_options']; + + $expectedOptions = []; + foreach ($expected as $optionId => $optionValue) { + if (is_array($optionValue)) { + $optionValue = implode(',', $optionValue); + } + $expectedOptions[] = [ + 'option_id' => $optionId, + 'option_value' => $optionValue, + ]; + } + $this->assertEquals($expectedOptions, $actualOptions); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php new file mode 100644 index 0000000000000..25cb0e8652bf2 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OrderItemRepositoryTest.php @@ -0,0 +1,125 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php + */ + public function testGet() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $orderItem = current($order->getItems()); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $orderItem->getId(), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['id' => $orderItem->getId()]); + + $this->assertTrue(is_array($response)); + $this->assertOrderItem($orderItem, $response); + } + + /** + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php + */ + public function testGetList() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + + /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ + $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + + $searchCriteriaBuilder->addFilters( + [ + $filterBuilder->setField('order_id') + ->setValue($order->getId()) + ->create(), + ] + ); + + $requestData = ['criteria' => $searchCriteriaBuilder->create()->__toArray()]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertTrue(is_array($response)); + $this->assertArrayHasKey('items', $response); + $this->assertCount(1, $response['items']); + $this->assertTrue(is_array($response['items'][0])); + $this->assertOrderItem(current($order->getItems()), $response['items'][0]); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $expected = $orderItem->getBuyRequest()->getSuperAttribute(); + + $this->assertArrayHasKey('product_option', $response); + $this->assertArrayHasKey('extension_attributes', $response['product_option']); + $this->assertArrayHasKey('configurable_item_options', $response['product_option']['extension_attributes']); + + $actualOptions = $response['product_option']['extension_attributes']['configurable_item_options']; + + $this->assertTrue(is_array($actualOptions)); + $this->assertTrue(is_array($actualOptions[0])); + $this->assertArrayHasKey('option_id', $actualOptions[0]); + $this->assertArrayHasKey('option_value', $actualOptions[0]); + + $this->assertEquals(key($expected), $actualOptions[0]['option_id']); + $this->assertEquals(current($expected), $actualOptions[0]['option_value']); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php new file mode 100644 index 0000000000000..41a5c6a506962 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/OrderItemRepositoryTest.php @@ -0,0 +1,120 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Downloadable/_files/order_item_with_downloadable_and_options.php + */ + public function testGet() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + $orderItem = current($order->getItems()); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $orderItem->getId(), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['id' => $orderItem->getId()]); + + $this->assertTrue(is_array($response)); + $this->assertOrderItem($orderItem, $response); + } + + /** + * @magentoApiDataFixture Magento/Downloadable/_files/order_item_with_downloadable_and_options.php + */ + public function testGetList() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + + /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ + $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + + $searchCriteriaBuilder->addFilters( + [ + $filterBuilder->setField('order_id') + ->setValue($order->getId()) + ->create(), + ] + ); + + $requestData = ['criteria' => $searchCriteriaBuilder->create()->__toArray()]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertTrue(is_array($response)); + $this->assertArrayHasKey('items', $response); + $this->assertCount(1, $response['items']); + $this->assertTrue(is_array($response['items'][0])); + $this->assertOrderItem(current($order->getItems()), $response['items'][0]); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $expected = $orderItem->getBuyRequest()->getLinks(); + + $this->assertArrayHasKey('product_option', $response); + $this->assertArrayHasKey('extension_attributes', $response['product_option']); + $this->assertArrayHasKey('downloadable_option', $response['product_option']['extension_attributes']); + + $actualOptions = $response['product_option']['extension_attributes']['downloadable_option']; + + $this->assertArrayHasKey('downloadable_links', $actualOptions); + $this->assertEquals($expected, $actualOptions['downloadable_links']); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php new file mode 100644 index 0000000000000..1cd2b7a30656e --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php @@ -0,0 +1,88 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Sales/_files/order.php + */ + public function testGetList() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + + /** @var $searchCriteriaBuilder \Magento\Framework\Api\SearchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder'); + /** @var $filterBuilder \Magento\Framework\Api\FilterBuilder */ + $filterBuilder = $this->objectManager->create('Magento\Framework\Api\FilterBuilder'); + + $searchCriteriaBuilder->addFilters( + [ + $filterBuilder->setField('order_id') + ->setValue($order->getId()) + ->create(), + ] + ); + + $requestData = ['criteria' => $searchCriteriaBuilder->create()->__toArray()]; + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '?' . http_build_query($requestData), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'getList', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, $requestData); + + $this->assertTrue(is_array($response)); + $this->assertArrayHasKey('items', $response); + $this->assertCount(1, $response['items']); + $this->assertTrue(is_array($response['items'][0])); + $this->assertOrderItem(current($order->getItems()), $response['items'][0]); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $this->assertEquals($orderItem->getId(), $response['item_id']); + $this->assertEquals($orderItem->getOrderId(), $response['order_id']); + $this->assertEquals($orderItem->getProductId(), $response['product_id']); + $this->assertEquals($orderItem->getProductType(), $response['product_type']); + $this->assertEquals($orderItem->getBasePrice(), $response['base_price']); + $this->assertEquals($orderItem->getRowTotal(), $response['row_total']); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php new file mode 100644 index 0000000000000..ca2803a520d4a --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetTest.php @@ -0,0 +1,72 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + } + + /** + * @magentoApiDataFixture Magento/Sales/_files/order.php + */ + public function testGet() + { + /** @var \Magento\Sales\Model\Order $order */ + $order = $this->objectManager->create('Magento\Sales\Model\Order'); + $order->loadByIncrementId(self::ORDER_INCREMENT_ID); + /** @var \Magento\Sales\Model\Order\Item $orderItem */ + $orderItem = current($order->getItems()); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => self::RESOURCE_PATH . '/' . $orderItem->getId(), + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'get', + ], + ]; + + $response = $this->_webApiCall($serviceInfo, ['id' => $orderItem->getId()]); + + $this->assertTrue(is_array($response)); + $this->assertOrderItem($orderItem, $response); + } + + /** + * @param \Magento\Sales\Model\Order\Item $orderItem + * @param array $response + * @return void + */ + protected function assertOrderItem(\Magento\Sales\Model\Order\Item $orderItem, array $response) + { + $this->assertEquals($orderItem->getId(), $response['item_id']); + $this->assertEquals($orderItem->getOrderId(), $response['order_id']); + $this->assertEquals($orderItem->getProductId(), $response['product_id']); + $this->assertEquals($orderItem->getProductType(), $response['product_type']); + $this->assertEquals($orderItem->getBasePrice(), $response['base_price']); + $this->assertEquals($orderItem->getRowTotal(), $response['row_total']); + } +} diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 5f941b700f540..4e4d5972cd500 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc35", + "magento/mtf": "1.0.0-rc36", "php": "~5.5.0|~5.6.0|~7.0.0", "phpunit/phpunit": "4.1.0", "phpunit/phpunit-selenium": ">=1.2" diff --git a/dev/tests/functional/etc/events.xml b/dev/tests/functional/etc/events.xml index e838968e1c2a2..b724c773b6c23 100644 --- a/dev/tests/functional/etc/events.xml +++ b/dev/tests/functional/etc/events.xml @@ -8,7 +8,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/tests/functional/lib/Magento/Mtf/Handler/Webapi.php b/dev/tests/functional/lib/Magento/Mtf/Handler/Webapi.php index 443eafd1c256c..f69225110c81f 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Handler/Webapi.php +++ b/dev/tests/functional/lib/Magento/Mtf/Handler/Webapi.php @@ -13,7 +13,7 @@ /** * Abstract class for webapi handlers. */ -abstract class Webapi implements HandlerInterface +abstract class Webapi extends Curl implements HandlerInterface { /** * Configuration parameters array. diff --git a/dev/tests/functional/lib/Magento/Mtf/Page/BackendPage.php b/dev/tests/functional/lib/Magento/Mtf/Page/BackendPage.php index e5b6c09f90538..26231f9fbef70 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Page/BackendPage.php +++ b/dev/tests/functional/lib/Magento/Mtf/Page/BackendPage.php @@ -8,7 +8,7 @@ use Magento\Mtf\Factory\Factory; /** - * Class BackendPage + * Admin backend page. * * @SuppressWarnings(PHPMD.NumberOfChildren) */ @@ -19,13 +19,13 @@ class BackendPage extends Page * * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_backend_url'] . static::MCA; + $this->url = $_ENV['app_backend_url'] . static::MCA; } /** - * Open backend page and log in if needed + * Open backend page and log in if needed. * * @param array $params * @return $this diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/RepositoryResource.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/RepositoryResource.php index ee45b740731ce..db91d8a9984fc 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/RepositoryResource.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/RepositoryResource.php @@ -10,7 +10,7 @@ * Class Resource * */ -class RepositoryResource extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class RepositoryResource extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Set fixture entity_type @@ -28,7 +28,7 @@ public function setFixture(array $fixture) * @param \Magento\Framework\Model\AbstractModel $object * @param mixed $value * @param null $field - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb|void + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb|void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function load(\Magento\Framework\Model\AbstractModel $object, $value, $field = null) diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php index e22e7837b72fd..bdfbd8544da31 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Generate/Repository/TableCollection.php @@ -6,7 +6,7 @@ namespace Magento\Mtf\Util\Generate\Repository; -use Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; /** * Class CollectionProvider @@ -26,7 +26,7 @@ class TableCollection extends AbstractCollection * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param null $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource * @param array $fixture */ public function __construct( @@ -35,7 +35,7 @@ public function __construct( \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null, + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null, array $fixture = [] ) { $this->setModel('Magento\Framework\DataObject'); diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml index 74541d4f5662e..b41addebd2c62 100644 --- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml @@ -6,12 +6,12 @@ */ --> - + catalogProductSimple::product_10_dollar, configurableProduct::with_one_option, bundleProduct::bundle_fixed_100_dollar_product us_ca_ny_rule default - US_address_1 + US_address_1 guest Flat Rate Fixed diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php index 988614620e01b..be0e3f829e2eb 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache.php @@ -59,7 +59,6 @@ public function flushMagentoCache() public function flushCacheStorage() { $this->_rootElement->find($this->flushCacheStorageButton)->click(); - $this->browser->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache/Grid.php new file mode 100644 index 0000000000000..686e688a9acf3 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Cache/Grid.php @@ -0,0 +1,32 @@ +getRow($filter, false)->find($this->selectItem); + if ($selectItem->isVisible()) { + $selectItem->click(); + } else { + throw new \Exception('Searched item was not found.'); + } + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php index 246c3113a8d17..1b8a503460cb6 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/FormPageActions.php @@ -49,7 +49,7 @@ class FormPageActions extends PageActions * * @var string */ - protected $deleteButton = '#delete'; + protected $deleteButton = '.delete'; /** * Magento loader @@ -110,7 +110,6 @@ public function save() public function delete() { $this->_rootElement->find($this->deleteButton)->click(); - $this->browser->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php index 2dbbdd6fe04c8..281c4fbd7a081 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/System/Config/PageActions.php @@ -35,7 +35,6 @@ public function selectStore($websiteScope) { $this->_rootElement->find($this->scopeSelector, Locator::SELECTOR_CSS, 'liselectstore') ->setValue($websiteScope); - $this->browser->acceptAlert(); return $this; } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php index b104c3230510c..c847513f244f2 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/FormTabs.php @@ -17,7 +17,7 @@ use Magento\Mtf\Client\Element\SimpleElement; /** - * Is used to represent any form with tabs on the page + * Is used to represent any form with tabs on the page. * * @SuppressWarnings(PHPMD.NumberOfChildren) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -25,17 +25,26 @@ class FormTabs extends Form { /** + * Tabs list. + * * @var array */ protected $tabs = []; /** - * Fields which aren't assigned to any tab + * Fields which aren't assigned to any tab. * * @var array */ protected $unassignedFields = []; + /** + * Page header selector. + * + * @var string + */ + protected $header = 'header'; + /** * @constructor * @param SimpleElement $element @@ -55,7 +64,7 @@ public function __construct( } /** - * Initialize block + * Initialize block. */ protected function init() { @@ -63,7 +72,7 @@ protected function init() } /** - * Fill form with tabs + * Fill form with tabs. * * @param FixtureInterface $fixture * @param SimpleElement|null $element @@ -76,7 +85,7 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null) } /** - * Fill specified form with tabs + * Fill specified form with tabs. * * @param array $tabs * @param SimpleElement|null $element @@ -91,14 +100,14 @@ protected function fillTabs(array $tabs, SimpleElement $element = null) $tab->fillFormTab($tabFields, $context); } if (!empty($this->unassignedFields)) { - $this->fillMissedFields($tabs); + $this->fillMissedFields(); } return $this; } /** - * Fill fields which weren't found on filled tabs + * Fill fields which weren't found on filled tabs. * * @throws \Exception * @SuppressWarnings(PHPMD.UnusedLocalVariable) @@ -130,7 +139,7 @@ protected function fillMissedFields() } /** - * Get data of the tabs + * Get data of the tabs. * * @param FixtureInterface|null $fixture * @param SimpleElement|null $element @@ -163,7 +172,7 @@ public function getData(FixtureInterface $fixture = null, SimpleElement $element } /** - * Update form with tabs + * Update form with tabs. * * @param FixtureInterface $fixture * @return FormTabs @@ -178,7 +187,7 @@ public function update(FixtureInterface $fixture) } /** - * Create data array for filling tabs + * Create data array for filling tabs. * * @param FixtureInterface $fixture * @return array @@ -194,7 +203,7 @@ protected function getFieldsByTabs(FixtureInterface $fixture) } /** - * Create data array for filling tabs (new fixture specification) + * Create data array for filling tabs (new fixture specification). * * @param InjectableFixture $fixture * @return array @@ -217,7 +226,7 @@ private function getFixtureFieldsByTabs(InjectableFixture $fixture) } /** - * Create data array for filling tabs (deprecated fixture specification) + * Create data array for filling tabs (deprecated fixture specification). * * @param FixtureInterface $fixture * @return array @@ -284,6 +293,7 @@ protected function getTabElement($tabName) */ public function openTab($tabName) { + $this->browser->find($this->header)->hover(); $this->getTabElement($tabName)->click(); return $this; } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 8e1e7be037137..65017b9c85d99 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -188,6 +188,13 @@ abstract class Grid extends Block */ protected $rowPattern = '//tbody/tr[%s]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Get backend abstract block * @@ -340,7 +347,10 @@ protected function massActionSubmit($acceptAlert) { $this->_rootElement->find($this->massactionSubmit, Locator::SELECTOR_CSS)->click(); if ($acceptAlert) { - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Tab.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Tab.php index a4f434313fc12..02afe0f286897 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Tab.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Tab.php @@ -11,8 +11,7 @@ use Magento\Mtf\Client\Locator; /** - * Class Tab - * Is used to represent any tab on the page + * Is used to represent any tab on the page. * * @SuppressWarnings(PHPMD.NumberOfChildren) */ @@ -23,24 +22,24 @@ class Tab extends AbstractForm * * @var string */ - protected $mageErrorField = '//*[contains(@class,"field ")][.//*[@class="mage-error"]]'; + protected $mageErrorField = '//fieldset/*[contains(@class,"field ")][.//*[contains(@class,"error")]]'; /** * Fields label with mage error. * * @var string */ - protected $mageErrorLabel = './label'; + protected $mageErrorLabel = './/*[contains(@class,"label")]'; /** * Mage error text. * * @var string */ - protected $mageErrorText = './/*[@class="mage-error"]'; + protected $mageErrorText = './/label[contains(@class,"error")]'; /** - * Fill data to fields on tab + * Fill data to fields on tab. * * @param array $fields * @param SimpleElement|null $element @@ -55,7 +54,7 @@ public function fillFormTab(array $fields, SimpleElement $element = null) } /** - * Get data of tab + * Get data of tab. * * @param array|null $fields * @param SimpleElement|null $element @@ -68,10 +67,11 @@ public function getDataFormTab($fields = null, SimpleElement $element = null) } /** - * Update data to fields on tab + * Update data to fields on tab. * * @param array $fields * @param SimpleElement|null $element + * @return void */ public function updateFormTab(array $fields, SimpleElement $element = null) { diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertCacheIsRefreshableAndInvalidated.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertCacheIsRefreshableAndInvalidated.php new file mode 100644 index 0000000000000..5492c69ef0b27 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertCacheIsRefreshableAndInvalidated.php @@ -0,0 +1,58 @@ + $cacheTag, + 'status' => 'Invalidated' + ]; + } + + $adminCache->open(); + $adminCache->getGridBlock()->massaction($items, 'Refresh'); + + \PHPUnit_Framework_Assert::assertEquals( + sprintf(self::SUCCESS_MESSAGE, count($items)), + $adminCache->getMessagesBlock()->getSuccessMessages(), + 'Cache is Invalid and refreshable.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Cache is not Invalid or not refreshable.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php index ffd5e52d7eaa2..fd241121f62fc 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Constraint/AssertStoreCanBeLocalized.php @@ -38,6 +38,7 @@ public function processAssert( // Set locale options $systemConfig->open(); $systemConfig->getPageActions()->selectStore($store->getGroupId() . "/" . $store->getName()); + $systemConfig->getModalBlock()->acceptAlert(); $configGroup = $systemConfig->getForm()->getGroup('Locale Options'); $configGroup->open(); $configGroup->setValue('select-groups-locale-fields-code-value', $locale); diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/AdminAuthLogin.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/AdminAuthLogin.php index b262b81e09c0e..74290a5b8bb71 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/AdminAuthLogin.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/AdminAuthLogin.php @@ -43,9 +43,9 @@ class AdminAuthLogin extends Page /** * Constructor. */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_backend_url'] . self::MCA; + $this->url = $_ENV['app_backend_url'] . self::MCA; } /** @@ -56,7 +56,7 @@ protected function _init() public function getLoginBlock() { return Factory::getBlockFactory()->getMagentoBackendAdminLogin( - $this->_browser->find($this->loginBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->loginBlock, Locator::SELECTOR_CSS) ); } @@ -68,7 +68,7 @@ public function getLoginBlock() public function getHeaderBlock() { return Factory::getBlockFactory()->getMagentoBackendPageHeader( - $this->_browser->find($this->headerBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->headerBlock, Locator::SELECTOR_CSS) ); } @@ -79,7 +79,7 @@ public function getHeaderBlock() */ public function getMessagesBlock() { - return Factory::getBlockFactory()->getMagentoBackendMessages($this->_browser->find($this->messagesBlock)); + return Factory::getBlockFactory()->getMagentoBackendMessages($this->browser->find($this->messagesBlock)); } /** @@ -89,7 +89,7 @@ public function getMessagesBlock() */ public function waitForHeaderBlock() { - $browser = $this->_browser; + $browser = $this->browser; $selector = $this->headerBlock; $browser->waitUntil( function () use ($browser, $selector) { diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml index bb9fc78299f5d..3cdc372ff2c64 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/AdminCache.xml @@ -10,5 +10,7 @@ + + diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml index 9b9a0f3a3093c..4dbb6babb500e 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Page/Adminhtml/SystemConfig.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php index 20688802c899c..7f973d398b8d5 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php @@ -22,7 +22,7 @@ class Option extends Form * * @var string */ - protected $searchGridBlock = "ancestor::body//div[contains(@style,'display: block') and @role='dialog']"; + protected $searchGridBlock = "ancestor::body//aside[contains(@class,'_show') and @data-role='modal']"; /** * Added product row diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php index 4a1ba08b8565e..6af0253e217e3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/CategoryForm.php @@ -7,37 +7,56 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Category\Edit; use Magento\Backend\Test\Block\Widget\FormTabs; -use Magento\Mtf\Factory\Factory; +use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Mtf\Client\Locator; +use Magento\Mtf\Fixture\FixtureInterface; /** - * Class CategoryForm - * Category container block + * Category container block. */ class CategoryForm extends FormTabs { /** - * Save button + * Default sore switcher block locator. * * @var string */ - protected $saveButton = '[data-ui-id=category-edit-form-save-button]'; + protected $storeSwitcherBlock = '.store-switcher'; /** - * Category Products grid + * Dropdown block locator. * * @var string */ - protected $productsGridBlock = '#catalog_category_products'; + protected $dropdownBlock = '.dropdown'; /** - * Get Category edit form + * Selector for confirm. * - * @return \Magento\Catalog\Test\Block\Adminhtml\Category\Tab\ProductGrid + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + + /** + * Fill form with tabs. + * + * @param FixtureInterface $fixture + * @param SimpleElement|null $element + * @return FormTabs */ - public function getCategoryProductsGrid() + public function fill(FixtureInterface $fixture, SimpleElement $element = null) { - return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlCategoryTabProductGrid( - $this->_rootElement->find($this->productsGridBlock) - ); + $tabs = $this->getFieldsByTabs($fixture); + if ($fixture->hasData('store_id')) { + $store = $fixture->getStoreId(); + $storeSwitcherBlock = $this->browser->find($this->storeSwitcherBlock); + $storeSwitcherBlock->find($this->dropdownBlock, Locator::SELECTOR_CSS, 'liselectstore')->setValue($store); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); + } + + return $this->fillTabs($tabs, $element); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/PageActions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/PageActions.php index 4c34c902a1689..4389411c00650 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Category/Edit/PageActions.php @@ -9,8 +9,7 @@ use Magento\Backend\Test\Block\FormPageActions; /** - * Class PageActions - * Category page actions + * Category page actions. */ class PageActions extends FormPageActions { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php index 47a2e261ba15f..58128695cc34a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Attribute/Set/Main.php @@ -50,6 +50,13 @@ class Main extends Block */ protected $noteBlock = '.attribute-set .title'; + /** + * Selector for prompt. + * + * @var string + */ + protected $promptModal = '.prompt._show[data-role=modal]'; + /** * Move Attribute to Attribute Group * @@ -123,7 +130,10 @@ public function checkUnassignedProductAttribute($attributeLabel) public function addAttributeSetGroup($groupName) { $this->_rootElement->find($this->addGroupButton)->click(); - $this->browser->setAlertText($groupName); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->promptModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->setAlertText($groupName); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php index 6416c7c9c7a06..9af022411c24b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Composite/Configure.php @@ -44,7 +44,7 @@ class Configure extends AbstractConfigureBlock * * @var string */ - protected $okButton = '.ui-button.action-primary'; + protected $okButton = '.action-primary[data-role="action"]'; /** * Backend abstract block. diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php index 8b7671c7d7194..b86fc8430b45e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab.php @@ -6,16 +6,23 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit; +use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab\OptionTier; use Magento\Mtf\Client\Element\SimpleElement; /** - * Class AdvancedPricingTab - * Product advanced pricing tab + * Product advanced pricing tab. */ class AdvancedPricingTab extends ProductTab { /** - * Class name 'Subform' of the main tab form + * Locator for Tier Price block. + * + * @var string + */ + protected $tierPrice = '#attribute-tier_price-container'; + + /** + * Class name 'Subform' of the main tab form. * * @var array */ @@ -24,7 +31,7 @@ class AdvancedPricingTab extends ProductTab ]; /** - * Fill 'Advanced price' product form on tab + * Fill 'Advanced price' product form on tab. * * @param array $fields * @param SimpleElement|null $element @@ -61,7 +68,7 @@ public function fillFormTab(array $fields, SimpleElement $element = null) } /** - * Get data of tab + * Get data of tab. * * @param array|null $fields * @param SimpleElement|null $element @@ -96,4 +103,17 @@ public function getDataFormTab($fields = null, SimpleElement $element = null) return $formData; } + + /** + * Get Tier Price block. + * + * @return OptionTier + */ + public function getTierPriceForm() + { + return $this->blockFactory->create( + 'Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab\OptionTier', + ['element' => $this->_rootElement->find($this->tierPrice)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab/OptionTier.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab/OptionTier.php index 7dc90c88899bb..53417ecace24b 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab/OptionTier.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/AdvancedPricingTab/OptionTier.php @@ -7,23 +7,31 @@ namespace Magento\Catalog\Test\Block\Adminhtml\Product\Edit\AdvancedPricingTab; use Magento\Catalog\Test\Block\Adminhtml\Product\Edit\Tab\Options\AbstractOptions; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Mtf\Client\Element\SimpleElement; +use Magento\Mtf\Client\Locator; /** - * Class OptionTier - * Form 'Tier prices' on the 'Advanced Pricing' tab + * Form 'Tier prices' on the 'Advanced Pricing' tab. */ class OptionTier extends AbstractOptions { /** - * 'Add Tier' button selector + * 'Add Tier' button selector. * * @var string */ protected $buttonFormLocator = "#tiers_table tfoot button"; /** - * Fill product form 'Tier price' + * Locator for Customer Group element. + * + * @var string + */ + protected $customerGroup = '//*[contains(@name, "[cust_group]")]'; + + /** + * Fill product form 'Tier price'. * * @param array $fields * @param SimpleElement $element @@ -34,4 +42,18 @@ public function fillOptions(array $fields, SimpleElement $element = null) $this->_rootElement->find($this->buttonFormLocator)->click(); return parent::fillOptions($fields, $element); } + + /** + * Check whether Customer Group is visible. + * + * @param CustomerGroup $customerGroup + * @return bool + */ + public function isVisibleCustomerGroup(CustomerGroup $customerGroup) + { + $this->_rootElement->find($this->buttonFormLocator)->click(); + + $options = $this->_rootElement->find($this->customerGroup, Locator::SELECTOR_XPATH)->getText(); + return false !== strpos($options, $customerGroup->getCustomerGroupCode()); + } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php index e1524101cee79..0cd4538436086 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Edit/Tab/Options.php @@ -51,7 +51,7 @@ class Options extends Tab * * @var string */ - protected $importGrid = "//ancestor::body/div[*[@id='import-container'] and contains(@style,'display: block')]"; + protected $importGrid = "//ancestor::body//aside[*//div[@id='import-container']]"; /** * Fill custom options form on tab diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php index c23f96bef04d1..c13742e661e3f 100755 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/Grid.php @@ -27,37 +27,37 @@ class Grid extends DataGrid */ protected $filters = [ 'name' => [ - 'selector' => '[name="filters[name]"]', + 'selector' => '[name="name"]', ], 'sku' => [ - 'selector' => '[name="filters[sku]"]', + 'selector' => '[name="sku"]', ], 'type' => [ - 'selector' => '[name="filters[type_id]"]', + 'selector' => '[name="type_id"]', 'input' => 'select', ], 'price_from' => [ - 'selector' => '[name="filters[price][from]"]', + 'selector' => '[name="price[from]"]', ], 'price_to' => [ - 'selector' => '[name="filters[price][to]"]', + 'selector' => '[name="price[to]"]', ], 'qty_from' => [ - 'selector' => '[name="filters[qty][from]"]', + 'selector' => '[name="qty[from]"]', ], 'qty_to' => [ - 'selector' => '[name="filters[qty][to]"]', + 'selector' => '[name="qty[to]"]', ], 'visibility' => [ - 'selector' => '[name="filters[visibility]"]', + 'selector' => '[name="visibility"]', 'input' => 'select', ], 'status' => [ - 'selector' => '[name="filters[status]"]', + 'selector' => '[name="status"]', 'input' => 'select', ], 'set_name' => [ - 'selector' => '[name="filters[attribute_set_id]"]', + 'selector' => '[name="attribute_set_id"]', 'input' => 'select', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Grouped/AssociatedProducts/Search/Grid.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Grouped/AssociatedProducts/Search/Grid.php index e8dc06003db01..fb9acfa2da5da 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Grouped/AssociatedProducts/Search/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/Grouped/AssociatedProducts/Search/Grid.php @@ -9,19 +9,26 @@ use Magento\Backend\Test\Block\Widget\Grid as GridInterface; /** - * Class Grid + * Associated products grid. */ class Grid extends GridInterface { /** - * 'Add Selected Products' button + * 'Add Selected Products' button. * * @var string */ protected $addProducts = 'button.add'; /** - * Filters array mapping + * An element locator which allows to select entities in grid. + * + * @var string + */ + protected $selectItem = '[data-column=entity_id] input'; + + /** + * Filters array mapping. * * @var array */ @@ -35,18 +42,7 @@ class Grid extends GridInterface ]; /** - * Initialize block elements - * - * @return void - */ - protected function _init() - { - parent::_init(); - $this->selectItem = "[data-column=entity_id] input"; - } - - /** - * Press 'Add Selected Products' button + * Press 'Add Selected Products' button. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php new file mode 100644 index 0000000000000..f85d76989b0c5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryBreadcrumbs.php @@ -0,0 +1,115 @@ +browser = $browser; + $this->openCategory($category); + + $breadcrumbs = $this->getBreadcrumbs($category); + $pageBreadcrumbs = $catalogCategoryView->getBreadcrumbs()->getText(); + \PHPUnit_Framework_Assert::assertEquals( + $breadcrumbs, + $pageBreadcrumbs, + 'Wrong breadcrumbs of category page.' + . "\nExpected: " . $breadcrumbs + . "\nActual: " . $pageBreadcrumbs + ); + } + + /** + * Open category. + * + * @param Category $category + * @return void + */ + protected function openCategory(Category $category) + { + $categoryUrlKey = []; + + while ($category) { + $categoryUrlKey[] = $category->hasData('url_key') + ? strtolower($category->getUrlKey()) + : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); + + $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + if ($category !== null && 1 == $category->getParentId()) { + $category = null; + } + } + $categoryUrlKey = $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html'; + + $this->browser->open($categoryUrlKey); + } + + /** + * Prepare and return category breadcrumbs. + * + * @param Category $category + * @return string + */ + protected function getBreadcrumbs(Category $category) + { + $breadcrumbs = []; + + while ($category) { + $breadcrumbs[] = $category->getName(); + + $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + if ($category !== null && 1 == $category->getParentId()) { + $category = null; + } + } + $breadcrumbs[] = self::HOME_PAGE; + + return implode(' ', array_reverse($breadcrumbs)); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Breadcrumbs on category page equals to passed from fixture.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index def6490e3bf27..992fdc6c76702 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -19,7 +19,7 @@ class AssertCategoryPage extends AbstractConstraint { /** - * CMS Block display mode + * CMS Block display mode. * * @var array */ @@ -29,14 +29,14 @@ class AssertCategoryPage extends AbstractConstraint ]; /** - * Category view page + * Category view page. * * @var CatalogCategoryView */ protected $categoryViewPage; /** - * Browser instance + * Browser instance. * * @var BrowserInterface */ @@ -68,6 +68,8 @@ public function processAssert( } /** + * Prepare comparison data. + * * @param FixtureFactory $fixtureFactory * @param Category $category * @param Category $initialCategory @@ -92,21 +94,30 @@ protected function prepareData(FixtureFactory $fixtureFactory, Category $categor } /** - * Get category url to open + * Get category url to open. * * @param Category $category * @return string */ protected function getCategoryUrl(Category $category) { - $categoryUrlKey = $category->hasData('url_key') - ? strtolower($category->getUrlKey()) - : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); - return $_ENV['app_frontend_url'] . $categoryUrlKey . '.html'; + $categoryUrlKey = []; + while ($category) { + $categoryUrlKey[] = $category->hasData('url_key') + ? strtolower($category->getUrlKey()) + : trim(strtolower(preg_replace('#[^0-9a-z%]+#i', '-', $category->getName())), '-'); + + $category = $category->getDataFieldConfig('parent_id')['source']->getParentCategory(); + if (1 == $category->getParentId()) { + $category = null; + } + } + + return $_ENV['app_frontend_url'] . implode('/', array_reverse($categoryUrlKey)) . '.html'; } /** - * Assert category general information + * Assert category general information. * * @param Category $category * @param array $categoryData @@ -147,7 +158,7 @@ protected function assertGeneralInformation(Category $category, array $categoryD } /** - * Assert category display settings + * Assert category display settings. * * @param Category $category * @param array $categoryData diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryWithCustomStoreOnFrontend.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryWithCustomStoreOnFrontend.php new file mode 100644 index 0000000000000..a448fcaa3f18d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryWithCustomStoreOnFrontend.php @@ -0,0 +1,66 @@ +open(); + $cmsIndex->getLinksBlock()->waitWelcomeMessage(); + $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html'); + \PHPUnit_Framework_Assert::assertEquals( + $initialCategory->getName(), + $categoryView->getTitleBlock()->getTitle(), + 'Wrong category name is displayed for default store.' + ); + + $store = $category->getDataFieldConfig('store_id')['source']->store->getName(); + $cmsIndex->getStoreSwitcherBlock()->selectStoreView($store); + $cmsIndex->getLinksBlock()->waitWelcomeMessage(); + $browser->open($_ENV['app_frontend_url'] . $initialCategory->getUrlKey() . '.html'); + \PHPUnit_Framework_Assert::assertEquals( + $category->getName(), + $categoryView->getTitleBlock()->getTitle(), + 'Wrong category name is displayed for ' . $store + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Category name is different on different store view.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml index 2c5e23a9099b7..975ae3ed0e70d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml @@ -41,5 +41,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/StoreId.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/StoreId.php new file mode 100644 index 0000000000000..981a7499f5835 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category/StoreId.php @@ -0,0 +1,58 @@ +params = $params; + + if (isset($data['dataset'])) { + $store = $fixtureFactory->createByCode('store', $data); + /** @var Store $store */ + if (!$store->getStoreId()) { + $store->persist(); + } + $this->store = $store; + $this->data = $store->getGroupId() . '/' . $store->getName(); + } else { + $this->data = $data; + } + } + + /** + * Return Store fixture. + * + * @return Store + */ + public function getStore() + { + return $this->store; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php index 169eb6805b3d3..3a2520083bc20 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/CatalogProductAttribute/Curl.php @@ -58,6 +58,9 @@ class Curl extends AbstractCurl implements CatalogProductAttributeInterface */ public function persist(FixtureInterface $fixture = null) { + if ($fixture->hasData('attribute_id')) { + return ['attribute_id' => $fixture->getData('attribute_id')]; + } $data = $this->replaceMappingData($fixture->getData()); $data['frontend_label'] = [0 => $data['frontend_label']]; diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml index 6c94684f9931a..a9efc7486ed7a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogCategoryEdit.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml index 7340141c593ee..b53ec68704e70 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductAttributeNew.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml index be45d688fbc5a..318016cdd3035 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Adminhtml/CatalogProductSetEdit.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategory.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategory.php index d79e8a0823236..ec71bb91ffa15 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategory.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategory.php @@ -50,10 +50,12 @@ class CatalogCategory extends Page /** * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_backend_url'] . self::MCA; + $this->url = $_ENV['app_backend_url'] . self::MCA; } /** @@ -78,7 +80,7 @@ public function open(array $params = []) public function getFormBlock() { return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlCategoryEditCategoryForm( - $this->_browser->find($this->formBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->formBlock, Locator::SELECTOR_CSS) ); } @@ -90,7 +92,7 @@ public function getFormBlock() public function getTreeBlock() { return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlCategoryTree( - $this->_browser->find($this->treeBlock, Locator::SELECTOR_CSS, 'tree'), + $this->browser->find($this->treeBlock, Locator::SELECTOR_CSS, 'tree'), $this->getTemplateBlock() ); } @@ -103,7 +105,7 @@ public function getTreeBlock() public function getMessagesBlock() { return Factory::getBlockFactory()->getMagentoBackendMessages( - $this->_browser->find($this->messagesBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->messagesBlock, Locator::SELECTOR_CSS) ); } @@ -115,7 +117,7 @@ public function getMessagesBlock() public function getTemplateBlock() { return Factory::getBlockFactory()->getMagentoBackendTemplate( - $this->_browser->find($this->templateBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->templateBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryEdit.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryEdit.php index 110b175a7d09e..6a2938edc0b96 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryEdit.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryEdit.php @@ -61,9 +61,9 @@ class CatalogCategoryEdit extends Page * * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_backend_url'] . self::MCA; + $this->url = $_ENV['app_backend_url'] . self::MCA; } /** @@ -88,7 +88,7 @@ public function open(array $params = []) public function getFormBlock() { return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlCategoryEditCategoryForm( - $this->_browser->find($this->formBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->formBlock, Locator::SELECTOR_CSS) ); } @@ -100,7 +100,7 @@ public function getFormBlock() public function getTreeBlock() { return Factory::getBlockFactory()->getMagentoCatalogAdminhtmlCategoryTree( - $this->_browser->find($this->treeBlock, Locator::SELECTOR_CSS), + $this->browser->find($this->treeBlock, Locator::SELECTOR_CSS), $this->getTemplateBlock() ); } @@ -113,7 +113,7 @@ public function getTreeBlock() public function getMessagesBlock() { return Factory::getBlockFactory()->getMagentoBackendMessages( - $this->_browser->find($this->messagesBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->messagesBlock, Locator::SELECTOR_CSS) ); } @@ -125,7 +125,7 @@ public function getMessagesBlock() public function getTemplateBlock() { return Factory::getBlockFactory()->getMagentoBackendTemplate( - $this->_browser->find($this->templateBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->templateBlock, Locator::SELECTOR_CSS) ); } @@ -137,7 +137,7 @@ public function getTemplateBlock() public function getPageActionsBlock() { return Factory::getBlockFactory()->getMagentoBackendFormPageActions( - $this->_browser->find($this->pageActionsBlock) + $this->browser->find($this->pageActionsBlock) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml index 45839712e35c6..730724269f29e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Page/Category/CatalogCategoryView.xml @@ -8,6 +8,7 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml index 9ef0bcfd31196..83a4e691faf57 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductAttribute.xml @@ -13,6 +13,46 @@ No + + 113 + Quantity + quantity_and_stock_status + Dropdown + No + + + Yes + In Stock + In Stock + + + No + Out of Stock + Out of Stock + + + + + + 172 + Tax Class + tax_class_id + Dropdown + No + + + No + None + None + + + Yes + Taxable Goods + Taxable Goods + + + + attribute_text%isolation% attribute_text%isolation% diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml index 6be4a2275e353..8a2df347d213a 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml @@ -42,6 +42,7 @@ Product \'!@#$%^&*()+:;\\|}{][?=-~` %isolation% sku_simple_product_%isolation% No + Yes 1 25 @@ -73,6 +74,7 @@ 25 In Stock + Yes 1 560 diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml index f621b1c38c169..9cdfded386641 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/Category.xml @@ -61,5 +61,15 @@ Yes Yes + + + Category%isolation% + category-%isolation% + + default_subcategory + + Yes + Yes + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml index 555443367b77b..0c2a2bf3e4be4 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml @@ -149,5 +149,17 @@ + + Create category with three nesting + addSubcategory + two_nested_category + Category%isolation% + Category%isolation% + Yes + Category Required + Yes + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php index e6bafe0e25615..ec77f237b21cf 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/DeleteCategoryEntityTest.php @@ -74,5 +74,6 @@ public function test(Category $category) $this->catalogCategoryIndex->open(); $this->catalogCategoryIndex->getTreeCategories()->selectCategory($category); $this->catalogCategoryEdit->getFormPageActions()->delete(); + $this->catalogCategoryEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml index 2c108c67f3975..a28b5e16ab25d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/UpdateCategoryEntityTest.xml @@ -46,5 +46,11 @@ + + custom + Category %isolation% + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml index f46eff7dac4b8..97aee8c72ce21 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateSimpleProductEntityTest.xml @@ -271,7 +271,6 @@ - Create product with tax class and check absent special price diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml index 395b421268e0b..dc3aadb36e7f5 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/CreateVirtualProductEntityTest.xml @@ -76,7 +76,6 @@ - diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml index 3c3dda5716404..b967e6f87b9f6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/UpdateVirtualProductEntityTest.xml @@ -118,7 +118,6 @@ - @@ -210,7 +209,6 @@ - diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml index 03cf25cfa8abe..b945d770fe82d 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/CreateProductAttributeEntityTest.xml @@ -58,6 +58,7 @@ Yes + @@ -69,8 +70,11 @@ Yes attr_yesno_%isolation% Global + Yes + Yes No Yes/No_Global + @@ -100,6 +104,7 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php index b1994e6b362d3..a3c0028f6e70c 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAssignedToTemplateProductAttributeTest.php @@ -78,6 +78,7 @@ public function test(CatalogAttributeSet $productTemplate) $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen($filter); $this->attributeNew->getPageActions()->delete(); + $this->attributeNew->getModalBlock()->acceptAlert(); return ['productTemplate' => $productTemplate, 'attribute' => $attribute]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php index 4eb5df71d91d4..d996e70adb410 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteAttributeSetTest.php @@ -93,6 +93,7 @@ public function test(FixtureFactory $fixtureFactory, CatalogAttributeSet $produc $this->productSetIndex->open(); $this->productSetIndex->getGrid()->searchAndOpen($filter); $this->productSetEdit->getPageActions()->delete(); + $this->productSetEdit->getModalBlock()->acceptAlert(); return ['product' => $product]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php index b2803209bad71..0574f736acace 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteProductAttributeEntityTest.php @@ -53,5 +53,6 @@ public function testDeleteProductAttribute( $attributeIndex->open(); $attributeIndex->getGrid()->searchAndOpen(['frontend_label' => $attribute->getFrontendLabel()]); $attributeNew->getPageActions()->delete(); + $attributeNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php index 4b5c4403e8c87..934b2e185add6 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/DeleteUsedInConfigurableProductAttributeTest.php @@ -82,6 +82,7 @@ public function test(ConfigurableProduct $product) $this->attributeIndex->open(); $this->attributeIndex->getGrid()->searchAndOpen(['attribute_code' => $attribute->getAttributeCode()]); $this->attributeNew->getPageActions()->delete(); + $this->attributeNew->getModalBlock()->acceptAlert(); return ['attribute' => $attribute]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php index 8429c349f0cfe..755ff5eb886e3 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.php @@ -8,8 +8,10 @@ use Magento\Catalog\Test\Fixture\CatalogAttributeSet; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; +use Magento\Catalog\Test\Fixture\CatalogProductSimple; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductAttributeNew; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; /** @@ -36,6 +38,24 @@ class UpdateProductAttributeEntityTest extends Injectable const DOMAIN = 'MX'; /* end tags */ + /** + * Factory for fixtures. + * + * @var FixtureFactory + */ + protected $fixtureFactory; + + /** + * Prepare data. + * + * @param FixtureFactory $fixtureFactory + * @return void + */ + public function __prepare(FixtureFactory $fixtureFactory) + { + $this->fixtureFactory = $fixtureFactory; + } + /** * Run UpdateProductAttributeEntity test * @@ -44,14 +64,16 @@ class UpdateProductAttributeEntityTest extends Injectable * @param CatalogAttributeSet $productTemplate * @param CatalogProductAttributeIndex $attributeIndex * @param CatalogProductAttributeNew $attributeNew - * @return void + * @param CatalogProductSimple $productSimple + * @return array */ public function testUpdateProductAttribute( CatalogProductAttribute $productAttributeOriginal, CatalogProductAttribute $attribute, CatalogAttributeSet $productTemplate, CatalogProductAttributeIndex $attributeIndex, - CatalogProductAttributeNew $attributeNew + CatalogProductAttributeNew $attributeNew, + CatalogProductSimple $productSimple ) { //Precondition $productTemplate->persist(); @@ -66,5 +88,42 @@ public function testUpdateProductAttribute( $attributeIndex->getGrid()->searchAndOpen($filter); $attributeNew->getAttributeForm()->fill($attribute); $attributeNew->getPageActions()->save(); + $attribute = $this->prepareAttribute($attribute, $productAttributeOriginal); + $productSimple->persist(); + + return ['product' => $this->prepareProduct($productSimple, $attribute, $productTemplate)]; + } + + /** + * Prepare product data. + * + * @param CatalogProductSimple $product + * @param CatalogProductAttribute $attribute + * @param CatalogAttributeSet $productTemplate + * @return CatalogProductSimple + */ + protected function prepareProduct($product, $attribute, $productTemplate) + { + $data = [ + 'attribute_set_id' => ['attribute_set' => $productTemplate], + 'custom_attribute' => $attribute + ]; + $data = array_merge($data, $product->getData()); + + return $this->fixtureFactory->createByCode('catalogProductSimple', ['data' => $data]); + } + + /** + * Prepare attribute data. + * + * @param CatalogProductAttribute $attribute + * @param CatalogProductAttribute $productAttributeOriginal + * @return CatalogProductAttribute + */ + protected function prepareAttribute($attribute, $productAttributeOriginal) + { + $attributeData = array_merge($attribute->getData(), $productAttributeOriginal->getData()); + + return $this->fixtureFactory->createByCode('catalogProductAttribute', ['data' => $attributeData]); } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml index 11b2cbcd6b5c0..63dabf015796e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/ProductAttribute/UpdateProductAttributeEntityTest.xml @@ -34,6 +34,7 @@ default Yes Global + attribute_edited%isolation% Yes Yes Yes @@ -49,5 +50,16 @@ + + custom_attribute_set + tax_class_id + Yes + Yes + + FPC + + + + diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/AddAttributeToProductTemplateStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/AddAttributeToProductTemplateStep.php index e022906b29b18..3d5aa19186cec 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/AddAttributeToProductTemplateStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/AddAttributeToProductTemplateStep.php @@ -8,6 +8,8 @@ use Magento\Catalog\Test\Fixture\CatalogAttributeSet; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; +use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductSetEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductSetIndex; use Magento\Mtf\Fixture\FixtureFactory; @@ -46,6 +48,20 @@ class AddAttributeToProductTemplateStep implements TestStepInterface */ protected $productTemplate; + /** + * Catalog Product Index page. + * + * @var CatalogProductIndex + */ + protected $catalogProductIndex; + + /** + * Catalog Product Edit page. + * + * @var CatalogProductEdit + */ + protected $catalogProductEdit; + /** * @constructor * @param CatalogProductSetIndex $catalogProductSetIndex @@ -53,19 +69,25 @@ class AddAttributeToProductTemplateStep implements TestStepInterface * @param CatalogProductAttribute $attribute * @param CatalogAttributeSet $productTemplate * @param FixtureFactory $fixtureFactory + * @param CatalogProductIndex $catalogProductIndex + * @param CatalogProductEdit $catalogProductEdit */ public function __construct( CatalogProductSetIndex $catalogProductSetIndex, CatalogProductSetEdit $catalogProductSetEdit, CatalogProductAttribute $attribute, CatalogAttributeSet $productTemplate, - FixtureFactory $fixtureFactory + FixtureFactory $fixtureFactory, + CatalogProductIndex $catalogProductIndex, + CatalogProductEdit $catalogProductEdit ) { $this->catalogProductSetIndex = $catalogProductSetIndex; $this->catalogProductSetEdit = $catalogProductSetEdit; $this->attribute = $attribute; $this->productTemplate = $productTemplate; $this->fixtureFactory = $fixtureFactory; + $this->catalogProductIndex = $catalogProductIndex; + $this->catalogProductEdit = $catalogProductEdit; } /** @@ -87,10 +109,14 @@ public function run() 'dataset' => 'product_with_category_with_anchor', 'data' => [ 'attribute_set_id' => ['attribute_set' => $this->productTemplate], + 'custom_attribute' => $this->attribute ], ] ); - $product->persist(); + $this->catalogProductIndex->open()->getGridPageActionBlock()->addProduct('simple'); + $productForm = $this->catalogProductEdit->getProductForm(); + $productForm->fill($product); + $this->catalogProductEdit->getFormPageActions()->save(); return ['product' => $product]; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php index 8665338166eb9..26db72b37ef72 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestStep/DeleteAttributeStep.php @@ -67,6 +67,7 @@ public function run() if ($this->catalogProductAttributeIndex->getGrid()->isRowVisible($filter)) { $this->catalogProductAttributeIndex->getGrid()->searchAndOpen($filter); $this->catalogProductAttributeNew->getPageActions()->delete(); + $this->catalogProductAttributeNew->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml index c02f461a87578..92c41c11a06ef 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/etc/di.xml @@ -151,4 +151,9 @@ high + + + low + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.php index 62b27d30a0738..2a3f2883b1921 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.php @@ -8,8 +8,6 @@ use Magento\Backend\Test\Block\Widget\FormTabs; use Magento\Mtf\Client\Element\SimpleElement; -use Magento\Mtf\Client\Element; -use Magento\Mtf\Client\Locator; use Magento\Mtf\Fixture\FixtureInterface; /** @@ -17,20 +15,6 @@ */ class PromoForm extends FormTabs { - /** - * Add button. - * - * @var string - */ - protected $addButton = '.rule-param-new-child a'; - - /** - * Locator for Customer Segment Conditions. - * - * @var string - */ - protected $conditionFormat = '//*[@id="conditions__1__new_child"]//option[contains(.,"%s")]'; - /** * Fill form with tabs. * @@ -71,19 +55,4 @@ protected function prepareData(array $tabs, array $replace) return $tabs; } - - /** - * Check if attribute is available in conditions. - * - * @param string $name - * @return bool - */ - public function isAttributeInConditions($name) - { - $this->_rootElement->find($this->addButton)->click(); - return $this->_rootElement->find( - sprintf($this->conditionFormat, $name), - Locator::SELECTOR_XPATH - )->isVisible(); - } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.xml b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.xml index bf5b8646097f9..1b940ba5bab4e 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/PromoForm.xml @@ -7,7 +7,7 @@ --> - \Magento\Backend\Test\Block\Widget\Tab + \Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\Tab\RuleInformation #promo_catalog_edit_tabs_main_section css selector @@ -25,7 +25,7 @@ - \Magento\Backend\Test\Block\Widget\Tab + Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\Tab\Conditions #promo_catalog_edit_tabs_conditions_section css selector diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php index 2ad3ea93baad5..049cde37bf289 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/Conditions.php @@ -6,42 +6,41 @@ namespace Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\Tab; -use Magento\Mtf\Factory\Factory; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; +use Magento\Mtf\Client\Locator; use Magento\Backend\Test\Block\Widget\Tab; -use Magento\Mtf\Client\Element\SimpleElement; /** - * Class Conditions - * Form Tab for specifying catalog price rule conditions - * + * Form Tab for specifying catalog price rule conditions. */ class Conditions extends Tab { /** - * Rule conditions block selector + * Add button. * * @var string */ - protected $ruleConditions = '#rule_conditions_fieldset'; + protected $addButton = '.rule-param-new-child a'; /** - * Fill condition options + * Locator for specific conditions. * - * @param array $fields - * @param SimpleElement|null $element - * @return void + * @var string */ - public function fillFormTab(array $fields, SimpleElement $element = null) - { - $data = $this->dataMapping($fields); + protected $conditionFormat = '//*[@id="conditions__1__new_child"]//option[contains(.,"%s")]'; - $conditionsBlock = Factory::getBlockFactory()->getMagentoCatalogRuleConditions( - $element->find($this->ruleConditions) - ); - $conditionsBlock->clickAddNew(); - - $conditionsBlock->selectCondition($data['condition_type']['value']); - $conditionsBlock->clickEllipsis(); - $conditionsBlock->selectConditionValue($data['condition_value']['value']); + /** + * Check if attribute is available in conditions. + * + * @param CatalogProductAttribute $attribute + * @return bool + */ + public function isAttributeInConditions(CatalogProductAttribute $attribute) + { + $this->_rootElement->find($this->addButton)->click(); + return $this->_rootElement->find( + sprintf($this->conditionFormat, $attribute->getFrontendLabel()), + Locator::SELECTOR_XPATH + )->isVisible(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/RuleInformation.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/RuleInformation.php new file mode 100644 index 0000000000000..e4beb9105661c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Block/Adminhtml/Promo/Catalog/Edit/Tab/RuleInformation.php @@ -0,0 +1,35 @@ +_rootElement->find($this->customerGroup)->getText(); + return false !== strpos($options, $customerGroup->getCustomerGroupCode()); + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertProductAttributeIsUsedPromoRules.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertProductAttributeIsUsedPromoRules.php index c0d88eac2804e..89b72240318f5 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertProductAttributeIsUsedPromoRules.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertProductAttributeIsUsedPromoRules.php @@ -8,6 +8,7 @@ use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Catalog\Test\Fixture\CatalogProductAttribute; +use Magento\CatalogRule\Test\Block\Adminhtml\Promo\Catalog\Edit\Tab\Conditions; use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleNew; use Magento\CatalogRule\Test\Page\Adminhtml\CatalogRuleIndex; @@ -33,8 +34,10 @@ public function processAssert( $catalogRuleIndex->getGridPageActions()->addNew(); $catalogRuleNew->getEditForm()->openTab('conditions'); + /** @var Conditions $conditionsTab */ + $conditionsTab = $catalogRuleNew->getEditForm()->getTab('conditions'); \PHPUnit_Framework_Assert::assertTrue( - $catalogRuleNew->getEditForm()->isAttributeInConditions($attribute->getFrontendLabel()), + $conditionsTab->isAttributeInConditions($attribute), 'Product attribute can\'t be used on promo rules conditions.' ); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml index 5dd34d3be1a90..af8118dc6be7f 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Page/Adminhtml/CatalogRuleNew.xml @@ -6,8 +6,9 @@ */ --> - - - - + + + + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php index 959edfcf46434..aaea841d414f4 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/DeleteCatalogPriceRuleEntityTest.php @@ -82,5 +82,6 @@ public function testDeleteCatalogPriceRule(CatalogRule $catalogPriceRule) $this->catalogRuleIndex->open(); $this->catalogRuleIndex->getCatalogRuleGrid()->searchAndOpen($filter); $this->catalogRuleNew->getFormPageActions()->delete(); + $this->catalogRuleNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php index 12412122501f2..8cf299da48d7d 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/CreateCatalogRuleStep.php @@ -10,19 +10,19 @@ use Magento\Mtf\TestStep\TestStepInterface; /** - * Creating catalog rule + * Creating catalog rule. */ class CreateCatalogRuleStep implements TestStepInterface { /** - * Catalog Rule dataset name + * Catalog Rule dataset name. * * @var string */ protected $catalogRule; /** - * Factory for Fixture + * Factory for Fixture. * * @var FixtureFactory */ @@ -36,7 +36,7 @@ class CreateCatalogRuleStep implements TestStepInterface protected $deleteAllCatalogRule; /** - * Preparing step properties + * Preparing step properties. * * @constructor * @param FixtureFactory $fixtureFactory @@ -51,7 +51,7 @@ public function __construct(FixtureFactory $fixtureFactory, DeleteAllCatalogRule } /** - * Create catalog rule + * Create catalog rule. * * @return array */ @@ -76,6 +76,8 @@ public function run() */ public function cleanup() { - $this->deleteAllCatalogRule->run(); + if ($this->catalogRule != '-') { + $this->deleteAllCatalogRule->run(); + } } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php index dcc06c224c0ba..5a733e8224def 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestStep/DeleteAllCatalogRulesStep.php @@ -55,6 +55,7 @@ public function run() while ($this->catalogRuleIndex->getCatalogRuleGrid()->isFirstRowVisible()) { $this->catalogRuleIndex->getCatalogRuleGrid()->openFirstRow(); $this->catalogRuleNew->getFormPageActions()->delete(); + $this->catalogRuleNew->getModalBlock()->acceptAlert(); $this->catalogRuleIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Date.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Date.php new file mode 100644 index 0000000000000..c4ef4cb26ddea --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Date.php @@ -0,0 +1,57 @@ +getData(); + + // Mapping + $mapping = $this->dataMapping($data, $mapping); + $attribute = $fixture->getDataFieldConfig('custom_attribute')['source']->getAttribute(); + $mappingDate['custom_attribute']['from'] = $mapping['custom_attribute']; + $mappingDate['custom_attribute']['to'] = $mapping['custom_attribute']; + $attributeCode = $attribute->getAttributeCode(); + $mappingDate['custom_attribute']['from']['selector'] = sprintf($this->dateFromSelector, $attributeCode); + $mappingDate['custom_attribute']['to']['selector'] = sprintf($this->dateToSelector, $attributeCode); + + $this->_fill($mappingDate, $element); + + return $this; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Select.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Select.php new file mode 100644 index 0000000000000..a7aee1dadc90b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Select.php @@ -0,0 +1,42 @@ +getDataFieldConfig('custom_attribute')['source']->getAttribute(); + $mapping['custom_attribute']['selector'] = sprintf($this->selectSelector, $attribute->getAttributeCode()); + $mapping['custom_attribute']['input'] = 'select'; + $this->_fill($mapping, $element); + + return $this; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Text.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Text.php new file mode 100644 index 0000000000000..5beb76c1d06ba --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/CustomAttribute/Text.php @@ -0,0 +1,41 @@ +getDataFieldConfig('custom_attribute')['source']->getAttribute(); + $mapping['custom_attribute']['selector'] = sprintf($this->inputSelector, $attribute->getAttributeCode()); + $this->_fill($mapping, $element); + + return $this; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.php index 0f2a69ae8e95e..f70152800ba75 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.php @@ -6,6 +6,7 @@ namespace Magento\CatalogSearch\Test\Block\Advanced; +use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Mtf\Block\Form as ParentForm; use Magento\Mtf\Client\Element; use Magento\Mtf\Client\Locator; @@ -45,6 +46,13 @@ class Form extends ParentForm */ protected $labelSelector = 'label'; + /** + * Selector for custom attribute. + * + * @var string + */ + protected $customAttributeSelector = 'div[class*="%s"]'; + /** * Submit search form. * @@ -73,27 +81,24 @@ public function fill(FixtureInterface $fixture, SimpleElement $element = null) // Mapping $mapping = $this->dataMapping($data); - $this->_fill($mapping, $element); + $attributeType = $attributeCode = ''; + if ($fixture->hasData('custom_attribute')) { + /** @var CatalogProductAttribute $attribute */ + $attribute = $fixture->getDataFieldConfig('custom_attribute')['source']->getAttribute(); + $attributeType = $attribute->getFrontendInput(); + $attributeCode = $attribute->getAttributeCode(); + } + if ($this->hasRender($attributeType)) { + $element = $this->_rootElement->find(sprintf($this->customAttributeSelector, $attributeCode)); + $arguments = ['fixture' => $fixture, 'element' => $element, 'mapping' => $mapping]; + $this->callRender($attributeType, 'fill', $arguments); + } else { + $this->_fill($mapping, $element); + } return $this; } - /** - * Fill form with custom fields. - * (for End To End Tests) - * - * @param FixtureInterface $fixture - * @param array $fields - * @param SimpleElement $element - */ - public function fillCustom(FixtureInterface $fixture, array $fields, SimpleElement $element = null) - { - $data = $fixture->getData('fields'); - $dataForMapping = array_intersect_key($data, array_flip($fields)); - $mapping = $this->dataMapping($dataForMapping); - $this->_fill($mapping, $element); - } - /** * Get form fields. * diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.xml index ee3886f04ef7e..01642bfd697ae 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Block/Advanced/Form.xml @@ -25,9 +25,5 @@ #price_to - - #tax_class_id - select - - \ No newline at end of file + diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchNoResult.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchNoResult.php new file mode 100644 index 0000000000000..caf6de9b9e87d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchNoResult.php @@ -0,0 +1,45 @@ +getSearchResultBlock()->isVisibleMessages(self::ERROR_MESSAGE), + "The error message '" . self::ERROR_MESSAGE . "' is not visible." + ); + } + + /** + * Returns a string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return 'Error message is visible.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductByAttribute.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductByAttribute.php new file mode 100644 index 0000000000000..17686b94f919d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Constraint/AssertAdvancedSearchProductByAttribute.php @@ -0,0 +1,86 @@ +fixtureFactory = $fixtureFactory; + $cmsIndex->open(); + $cmsIndex->getFooterBlock()->openAdvancedSearch(); + $searchForm = $searchPage->getForm(); + $productSearch = $this->prepareFixture($product); + + $searchForm->fill($productSearch); + $searchForm->submit(); + $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); + while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) { + $isVisible = $catalogSearchResult->getListProductBlock()->getProductItem($product)->isVisible(); + } + + \PHPUnit_Framework_Assert::assertTrue($isVisible, 'Product attribute is not searchable on Frontend.'); + } + + /** + * Preparation of fixture data before comparing. + * + * @param InjectableFixture $productSearch + * @return CatalogProductSimple + */ + protected function prepareFixture(InjectableFixture $productSearch) + { + $customAttribute = $productSearch->getDataFieldConfig('custom_attribute')['source']->getAttribute(); + return $this->fixtureFactory->createByCode( + 'catalogProductSimple', + ['data' => ['custom_attribute' => $customAttribute]] + ); + } + + /** + * Returns string representation of object. + * + * @return string + */ + public function toString() + { + return 'Product attribute is searchable on Frontend.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml index 87d6b0b791a79..0d20a2f4ac16b 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/Adminhtml/CatalogSearchEdit.xml @@ -6,8 +6,9 @@ */ --> - - - - + + + + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml index f4e3ce23e3e95..0ad76850c0615 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/Page/AdvancedSearch.xml @@ -6,8 +6,14 @@ */ --> - - - - + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.xml index 06d89946b5e1f..d36c3f5eb51fe 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/AdvancedSearchEntityTest.xml @@ -111,5 +111,10 @@ 50 + + Negative product search + Negative_product_search + + diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php index b8400504d031a..4c9cdecc2c323 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.php @@ -78,5 +78,6 @@ public function test(CatalogSearchQuery $searchTerm) $this->indexPage->open(); $this->indexPage->getGrid()->searchAndOpen(['search_query' => $searchText]); $this->editPage->getFormPageActions()->delete(); + $this->editPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml index b2b6b2290fb9a..6056844a06473 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Shipping.xml @@ -6,7 +6,6 @@ */ --> - shippingAddress select diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php index 7d0966f153598..43dbd23499a0d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar/Item.php @@ -28,6 +28,13 @@ class Item extends Sidebar */ protected $editItem = '.action.edit'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Remove product item from mini cart * @@ -36,7 +43,10 @@ class Item extends Sidebar public function removeItemFromMiniCart() { $this->_rootElement->find($this->removeItem)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php index 663a88d34b66c..8b2bfcbd56d4f 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Totals.php @@ -10,83 +10,82 @@ use Magento\Mtf\Client\Locator; /** - * Class Totals - * Cart totals block + * Cart totals block. */ class Totals extends Block { /** - * Grand total search mask + * Grand total search mask. * * @var string */ protected $grandTotal = '.grand.totals .price'; /** - * Grand total search mask + * Grand total search mask. * * @var string */ protected $grandTotalExclTax = '.totals.grand.excl span'; /** - * Grand total search mask + * Grand total search mask. * * @var string */ protected $grandTotalInclTax = '.totals.grand.incl span'; /** - * Subtotal search mask + * Subtotal search mask. * * @var string */ protected $subtotal = '.totals.sub .price'; /** - * Subtotal search mask + * Subtotal search mask. * * @var string */ protected $subtotalExclTax = '.totals.sub.excl .price'; /** - * Subtotal search mask + * Subtotal search mask. * * @var string */ protected $subtotalInclTax = '.totals.sub.incl .price'; /** - * Tax search mask + * Tax search mask. * * @var string */ protected $tax = '.totals-tax span'; /** - * Get shipping price selector + * Get shipping price selector. * * @var string */ protected $shippingPriceSelector = '.shipping.excl .price'; /** - * Get discount + * Get discount. * * @var string */ protected $discount = '[class=totals] .amount .price'; /** - * Get shipping price including tax selector + * Get shipping price including tax selector. * * @var string */ protected $shippingPriceInclTaxSelector = '.shipping.incl .price'; /** - * Get shipping price block selector + * Get shipping price block selector. * * @var string */ @@ -97,10 +96,10 @@ class Totals extends Block * * @var string */ - protected $blockWaitElement = '._block-content-loading'; + protected $blockWaitElement = '.loading-mask'; /** - * Get Grand Total Text + * Get Grand Total Text. * * @return string */ @@ -111,7 +110,7 @@ public function getGrandTotal() } /** - * Get Grand Total Text + * Get Grand Total Text. * * @return string|null */ @@ -122,7 +121,7 @@ public function getGrandTotalIncludingTax() } /** - * Get Grand Total Text + * Get Grand Total Text. * * @return string|null */ @@ -133,7 +132,7 @@ public function getGrandTotalExcludingTax() } /** - * Get Tax text from Order Totals + * Get Tax text from Order Totals. * * @return string|null */ @@ -144,7 +143,7 @@ public function getTax() } /** - * Check that Tax is visible + * Check that Tax is visible. * * @return bool */ @@ -154,7 +153,7 @@ public function isTaxVisible() } /** - * Get Subtotal text + * Get Subtotal text. * * @return string */ @@ -165,7 +164,7 @@ public function getSubtotal() } /** - * Get Subtotal text + * Get Subtotal text. * * @return string|null */ @@ -176,7 +175,7 @@ public function getSubtotalIncludingTax() } /** - * Get Subtotal text + * Get Subtotal text. * * @return string|null */ @@ -187,7 +186,7 @@ public function getSubtotalExcludingTax() } /** - * Method that escapes currency symbols + * Method that escapes currency symbols. * * @param string $price * @return string|null @@ -199,7 +198,7 @@ protected function escapeCurrency($price) } /** - * Get discount + * Get discount. * * @return string|null */ @@ -210,7 +209,7 @@ public function getDiscount() } /** - * Get shipping price + * Get shipping price. * * @return string|null */ @@ -221,7 +220,7 @@ public function getShippingPrice() } /** - * Get shipping price + * Get shipping price. * * @return string|null */ @@ -232,7 +231,7 @@ public function getShippingPriceInclTax() } /** - * Is visible shipping price block + * Is visible shipping price block. * * @return bool */ diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.php index ffa5b1d91cb77..a90e1f3e4ce99 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.php @@ -20,7 +20,7 @@ class Billing extends Form * * @var string */ - protected $updateButtonSelector = '.action-toolbar .action-update'; + protected $updateButtonSelector = '.action.action-update'; /** * Wait element. diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.xml index a00c55ccbc2e9..b86b6378e26f8 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.xml @@ -9,22 +9,40 @@ billingAddress - [name='customerDetails[email]'] + ./ancestor::*[contains(@class, 'checkout-payment-method')]//input[contains(@name, 'username')] + xpath - - - + + input[name*=firstname] + + + input[name*=lastname] + + + input[name*=company] + - [name='billingAddress[street][0]'] + input[name*='street[0]'] - + + input[name*=city] + + select[name*=region_id] select - + + input[name*=region] + + + input[name*=postcode] + + select[name*=country_id] select - + + input[name*=telephone] + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml index 1b99093b23eec..a61ff0273b51d 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.xml @@ -6,7 +6,6 @@ */ --> - shippingAddress #customer-email @@ -15,7 +14,7 @@ - [name='shippingAddress[street][0]'] + input[name="street[0]"] @@ -25,8 +24,6 @@ select - - [name='shippingAddress[postcode]'] - + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertEstimateShippingAndTax.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertEstimateShippingAndTax.php index 66a4f25834be0..b55f6fb7edcd9 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertEstimateShippingAndTax.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertEstimateShippingAndTax.php @@ -10,6 +10,7 @@ use Magento\Checkout\Test\Page\CheckoutCart; use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\ObjectManager; +use Magento\Mtf\System\Event\EventManagerInterface; /** * Assert that grand total is equal to expected. @@ -54,6 +55,7 @@ class AssertEstimateShippingAndTax extends AbstractConstraint /** * @constructor * @param ObjectManager $objectManager + * @param EventManagerInterface $eventManager * @param AssertSubtotalInShoppingCart $assertSubtotalInShoppingCart * @param AssertGrandTotalInShoppingCart $assertGrandTotalInShoppingCart * @param AssertTaxInShoppingCart $assertTaxInShoppingCart @@ -61,12 +63,13 @@ class AssertEstimateShippingAndTax extends AbstractConstraint */ public function __construct( ObjectManager $objectManager, + EventManagerInterface $eventManager, AssertSubtotalInShoppingCart $assertSubtotalInShoppingCart, AssertGrandTotalInShoppingCart $assertGrandTotalInShoppingCart, AssertTaxInShoppingCart $assertTaxInShoppingCart, AssertShippingInShoppingCart $assertShippingInShoppingCart ) { - parent::__construct($objectManager); + parent::__construct($objectManager, $eventManager); $this->assertSubtotalInShoppingCart = $assertSubtotalInShoppingCart; $this->assertGrandTotalInShoppingCart = $assertGrandTotalInShoppingCart; $this->assertTaxInShoppingCart = $assertTaxInShoppingCart; diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml index 397bd616ea313..fadf354d75dfb 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Page/CheckoutOnepage.xml @@ -6,11 +6,12 @@ */ --> - - - - - - - + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php index 6d95166845123..7fdc478b1da5e 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.php @@ -42,7 +42,6 @@ class OnePageCheckoutTest extends Scenario const MVP = 'yes'; const DOMAIN = 'CS'; const TEST_TYPE = 'acceptance_test, 3rd_party_test'; - const TO_MAINTAIN = 'yes'; /* end tags */ /** diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml index 696bf1324beea..0b86f927eef12 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutTest.xml @@ -9,16 +9,15 @@ catalogProductVirtual::default - active_sales_rule_with_percent_price_discount_coupon - default - UK_address - guest + active_sales_rule_for_all_groups + customer_UK_1_default_billing_address + login 5.00 checkmo Pending - Back, Cancel, Send Notification, Hold, Invoice, Edit + Back, Send Email, Cancel, Hold, Invoice, Edit checkmo_specificcountry_gb @@ -29,8 +28,8 @@ catalogProductSimple::default active_sales_rule_for_all_groups default - US_address_1 guest + US_address_1 Flat Rate Fixed @@ -38,24 +37,26 @@ banktransfer Pending - Back, Cancel, Send Notification, Hold, Reorder, Invoice, Edit + Back, Send Email, Cancel, Hold, Ship, Invoice, Edit banktransfer - - catalogProductVirtual::default + + catalogProductSimple::default default - UK_address guest + UK_address + Flat Rate + Fixed - 10.00 + 565.00 banktransfer Pending - Back, Cancel, Send Notification, Hold, Invoice, Edit + Back, Send Email, Cancel, Hold, Ship, Invoice, Edit banktransfer_specificcountry_gb @@ -65,8 +66,8 @@ catalogProductSimple::product_with_special_price, configurableProduct::product_with_special_price default - US_address_1_without_email login + US_address_1_without_email Flat Rate Fixed @@ -85,8 +86,8 @@ catalogProductSimple::product_10_dollar, configurableProduct::with_one_option, bundleProduct::bundle_fixed_100_dollar_product us_ca_ny_rule - US_address_1 guest + US_address_1 Free Shipping Free diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml index 401dac62e9c0a..05356444ea635 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/Page/Adminhtml/CheckoutAgreementNew.xml @@ -9,5 +9,6 @@ + \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php index 3599882b174c1..b40f50f32d2ba 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteAllTermsEntityStep.php @@ -56,6 +56,7 @@ public function run() while ($this->agreementIndex->getAgreementGridBlock()->isFirstRowVisible()) { $this->agreementIndex->getAgreementGridBlock()->openFirstRow(); $this->agreementNew->getPageActionsBlock()->delete(); + $this->agreementNew->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php index d5b572db6ea2f..34c352f39ea40 100644 --- a/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php +++ b/dev/tests/functional/tests/app/Magento/CheckoutAgreements/Test/TestStep/DeleteTermEntityStep.php @@ -63,5 +63,6 @@ public function run() { $this->agreementIndex->open()->getAgreementGridBlock()->searchAndOpen(['name' => $this->agreement->getName()]); $this->agreementNew->getPageActionsBlock()->delete(); + $this->agreementNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php index 4ca3fe0ead7b6..1f4c5cfbd659b 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Block/CmsGrid.php @@ -28,36 +28,36 @@ class CmsGrid extends DataGrid */ protected $filters = [ 'block_id_from' => [ - 'selector' => '[name="filters[block_id][from]"]', + 'selector' => '[name="block_id[from]"]', ], 'block_id_to' => [ - 'selector' => '[name="filters[block_id][to]"]', + 'selector' => '[name="block_id[to]"]', ], 'title' => [ - 'selector' => '[name="filters[title]"]', + 'selector' => '[name="title"]', ], 'identifier' => [ - 'selector' => '[name="filters[identifier]"]', + 'selector' => '[name="identifier"]', ], 'store_id' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'simplifiedselect' ], 'is_active' => [ - 'selector' => '[name="filters[is_active]"]', + 'selector' => '[name="is_active"]', 'input' => 'select', ], 'creation_time_from' => [ - 'selector' => '[name="filters[creation_time][from]"]', + 'selector' => '[name="creation_time[from]"]', ], 'creation_time_to' => [ - 'selector' => '[name="filters[creation_time][to]"]', + 'selector' => '[name="creation_time[to]"]', ], 'update_time_from' => [ - 'selector' => '[name="filters[update_time][from]"]', + 'selector' => '[name="update_time[from]"]', ], 'update_time_to' => [ - 'selector' => '[name="filters[update_time][to]"]', + 'selector' => '[name="update_time[to]"]', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php index a07445f3eee83..24b1999344084 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Edit/Tab/Content.php @@ -62,11 +62,13 @@ class Content extends Tab /** * Clicking in content tab 'Insert Variable' button. * + * @param SimpleElement $element [optional] * @return void */ - public function clickInsertVariable() + public function clickInsertVariable(SimpleElement $element = null) { - $addVariableButton = $this->_rootElement->find($this->addVariableButton); + $context = $element === null ? $this->_rootElement : $element; + $addVariableButton = $context->find($this->addVariableButton); if ($addVariableButton->isVisible()) { $addVariableButton->click(); } @@ -75,11 +77,13 @@ public function clickInsertVariable() /** * Clicking in content tab 'Insert Widget' button. * + * @param SimpleElement $element [optional] * @return void */ - public function clickInsertWidget() + public function clickInsertWidget(SimpleElement $element = null) { - $addWidgetButton = $this->_rootElement->find($this->addWidgetButton); + $context = $element === null ? $this->_rootElement : $element; + $addWidgetButton = $context->find($this->addWidgetButton); if ($addWidgetButton->isVisible()) { $addWidgetButton->click(); } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php index 76415b59ed47a..8562232305382 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php @@ -29,43 +29,43 @@ class Grid extends DataGrid */ protected $filters = [ 'page_id_from' => [ - 'selector' => '[name="filters[page_id][from]"]', + 'selector' => '[name="page_id[from]"]', ], 'page_id_to' => [ - 'selector' => '[name="filters[page_id][to]"]', + 'selector' => '[name="page_id[to]"]', ], 'title' => [ - 'selector' => '[name="filters[title]"]', + 'selector' => '[name="title"]', ], 'identifier' => [ - 'selector' => '[name="filters[identifier]"]', + 'selector' => '[name="identifier"]', ], 'page_layout' => [ - 'selector' => '[name="filters[page_layout]"]', + 'selector' => '[name="page_layout"]', 'input' => 'select', ], 'store_id' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'selectstore' ], 'is_active' => [ - 'selector' => '[name="filters[is_active]"]', + 'selector' => '[name="is_active"]', 'input' => 'select', ], 'creation_time_from' => [ - 'selector' => '[name="filters[creation_time][from]"]', + 'selector' => '[name="creation_time[from]"]', ], 'creation_time_to' => [ - 'selector' => '[name="filters[creation_time][to]"]', + 'selector' => '[name="creation_time[to]"]', ], 'update_time_from' => [ - 'selector' => '[name="filters[update_time][from]"]', + 'selector' => '[name="update_time[from]"]', ], 'update_time_to' => [ - 'selector' => '[name="filters[update_time][to]"]', + 'selector' => '[name="update_time[to]"]', ], 'under_version_control' => [ - 'selector' => '[name="filters[under_version_control]"]', + 'selector' => '[name="under_version_control"]', ], ]; diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Fixture/CmsPage/Content.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Fixture/CmsPage/Content.php index 0ce3f511d5732..31a9d22a15303 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Fixture/CmsPage/Content.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Fixture/CmsPage/Content.php @@ -25,14 +25,19 @@ class Content extends DataSource */ protected $fixtureFactory; + /** + * Repository factory. + * + * @var RepositoryFactory + */ + protected $repositoryFactory; + /** * @constructor * @param RepositoryFactory $repositoryFactory * @param FixtureFactory $fixtureFactory * @param array $params * @param array $data - * - * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function __construct( RepositoryFactory $repositoryFactory, @@ -41,37 +46,62 @@ public function __construct( array $data = [] ) { $this->fixtureFactory = $fixtureFactory; + $this->repositoryFactory = $repositoryFactory; $this->params = $params; $this->data = $data; - if (isset($data['widget']['dataset']) && isset($this->params['repository'])) { - $this->data['widget']['dataset'] = $repositoryFactory->get($this->params['repository'])->get( - $data['widget']['dataset'] + $this->prepareSourceData(); + } + + /** + * Prepare source data. + * + * @return void + */ + protected function prepareSourceData() + { + if (isset($this->data['widget']['dataset']) && isset($this->params['repository'])) { + $this->data['widget']['dataset'] = $this->repositoryFactory->get($this->params['repository'])->get( + $this->data['widget']['dataset'] ); - foreach ($this->data['widget']['dataset'] as $key => $widget) { - if (isset($widget['chosen_option']['category_path']) - && !isset($widget['chosen_option']['filter_sku']) - ) { - $category = $this->createCategory($widget); - $categoryName = $category->getData('name'); - $this->data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName; - } - if (isset($widget['chosen_option']['category_path']) && isset($widget['chosen_option']['filter_sku'])) { - $product = $this->createProduct($widget); - $categoryName = $product->getCategoryIds()[0]['name']; - $productSku = $product->getData('sku'); - $this->data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName; - $this->data['widget']['dataset'][$key]['chosen_option']['filter_sku'] = $productSku; - } - if ($widget['widget_type'] == 'Catalog New Products List') { - $this->createProduct(); - } - if ($widget['widget_type'] == 'CMS Static Block') { - $block = $this->createBlock($widget); - $blockIdentifier = $block->getIdentifier(); - $this->data['widget']['dataset'][$key]['chosen_option']['filter_identifier'] = $blockIdentifier; - } + $this->data = array_merge($this->data, $this->prepareWidgetData($this->data['widget'])); + } + } + + /** + * Prepare widget data for the source. + * + * @param array $widgets + * @return array + */ + protected function prepareWidgetData(array $widgets) + { + $data = []; + foreach ($widgets['dataset'] as $key => $widget) { + if (isset($widget['chosen_option']['category_path']) + && !isset($widget['chosen_option']['filter_sku']) + ) { + $category = $this->createCategory($widget); + $categoryName = $category->getData('name'); + $data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName; + } + if (isset($widget['chosen_option']['category_path']) && isset($widget['chosen_option']['filter_sku'])) { + $product = $this->createProduct($widget); + $categoryName = $product->getCategoryIds()[0]['name']; + $productSku = $product->getData('sku'); + $data['widget']['dataset'][$key]['chosen_option']['category_path'] = $categoryName; + $data['widget']['dataset'][$key]['chosen_option']['filter_sku'] = $productSku; + } + if ($widget['widget_type'] == 'Catalog New Products List') { + $this->createProduct(); + } + if ($widget['widget_type'] == 'CMS Static Block') { + $block = $this->createBlock($widget); + $blockIdentifier = $block->getIdentifier(); + $data['widget']['dataset'][$key]['chosen_option']['filter_identifier'] = $blockIdentifier; } } + + return $data; } /** diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml index d37d3e1420419..a9089eeddc760 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsBlockNew.xml @@ -10,5 +10,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml index 252dc039121b9..fc93801cdc7ef 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Page/Adminhtml/CmsPageNew.xml @@ -9,5 +9,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php index 07f8d2dea4488..31f36c5eb25d6 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsBlockEntityTest.php @@ -77,5 +77,6 @@ public function test(CmsBlock $cmsBlock) $this->cmsBlockIndex->open(); $this->cmsBlockIndex->getCmsBlockGrid()->searchAndOpen($filter, true, false); $this->cmsBlockNew->getFormPageActions()->delete(); + $this->cmsBlockNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php index 5801ba85ea504..17d47b6681c4c 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageEntityTest.php @@ -74,5 +74,6 @@ public function test(CmsPage $cmsPage) $this->cmsPageIndex->open(); $this->cmsPageIndex->getCmsPageGridBlock()->searchAndOpen(['title' => $cmsPage->getTitle()]); $this->cmsPageNew->getPageMainActions()->delete(); + $this->cmsPageNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php index 7d5364c7c6fe4..7ef7db00e0aa7 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.php @@ -77,5 +77,6 @@ public function test(UrlRewrite $urlRewrite) $this->urlRewriteIndex->open(); $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen(['request_path' => $urlRewrite->getRequestPath()]); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php index 523ff4c9c377d..78e58b4926c51 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Block/Adminhtml/Product/AttributesGrid.php @@ -20,7 +20,7 @@ class AttributesGrid extends DataGrid */ protected $filters = [ 'frontend_label' => [ - 'selector' => '[name="filters[frontend_label]"]', + 'selector' => '[name="frontend_label"]', ], ]; } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml index 2fd3b20f3769c..25540646b7181 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct.xml @@ -38,6 +38,37 @@ + + Test configurable product %isolation% + sku_test_configurable_product_%isolation% + + 40 + + 30 + Yes + Product online + Catalog, Search + + taxable_goods + + configurable-product-%isolation% + + default + + + In Stock + + + Main Website + + + default + + + configurable_options_with_qty_1 + + + Test configurable product %isolation% sku_test_configurable_product_%isolation% diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml index 4f058ad0611c0..5b7d919c0f356 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/CheckoutData.xml @@ -28,6 +28,27 @@ + + + + + attribute_key_0 + option_key_0 + + + attribute_key_1 + option_key_1 + + + + 1 + + 40 + 1 + 40 + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php index 8929219497886..9e316ceabeab7 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Account/AddressesAdditional.php @@ -36,6 +36,13 @@ class AddressesAdditional extends Block */ protected $additionalAddressContent = '.block-content'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Delete Additional Address * @@ -46,7 +53,10 @@ public function deleteAdditionalAddress(Address $address) { $this->_rootElement->find(sprintf($this->addressSelector, $address->getStreet()), Locator::SELECTOR_XPATH) ->find($this->deleteAddressLink)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php index 2a33378d7c701..30f762335acba 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.php @@ -141,4 +141,21 @@ public function openTab($tabName) return $this; } + + /** + * Get array of label => js error text. + * + * @return array + */ + public function getJsErrors() + { + $tabs = ['account_information', 'addresses']; + $jsErrors = []; + foreach ($tabs as $tabName) { + $tab = $this->getTab($tabName); + $this->openTab($tabName); + $jsErrors = array_merge($jsErrors, $tab->getJsErrors()); + } + return $jsErrors; + } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml index bc70891ffa44c..c4778125723fb 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Block/Adminhtml/Edit/CustomerForm.xml @@ -10,7 +10,7 @@ \Magento\Backend\Test\Block\Widget\Tab #tab_customer css selector - data[customer] + customer select diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendBackButton.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendBackButton.php new file mode 100644 index 0000000000000..6d37238734116 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendBackButton.php @@ -0,0 +1,43 @@ +getPageActionsBlock()->back(); + \PHPUnit_Framework_Assert::assertTrue( + $customerGridPage->getCustomerGridBlock()->isVisible(), + 'Clicking on "Back" button does not redirect to customers grid.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return '"Back" button on customer edit page redirects to customers grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendDuplicateErrorMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendDuplicateErrorMessage.php new file mode 100644 index 0000000000000..27394f8e074ec --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendDuplicateErrorMessage.php @@ -0,0 +1,49 @@ +getMessagesBlock()->getErrorMessages(); + \PHPUnit_Framework_Assert::assertEquals( + self::ERROR_SAVE_MESSAGE, + $actualMessage, + 'Wrong error message is displayed.' + . "\nExpected: " . self::ERROR_SAVE_MESSAGE + . "\nActual: " . $actualMessage + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Assert that error duplicated message is displayed.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendRequiredFields.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendRequiredFields.php new file mode 100644 index 0000000000000..802b24652594a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerBackendRequiredFields.php @@ -0,0 +1,54 @@ +getCustomerForm()->getJsErrors(); + foreach ($expectedRequiredFields as $field) { + \PHPUnit_Framework_Assert::assertTrue( + isset($actualRequiredFields[$field]), + "Field '$field' is not highlighted with an JS error." + ); + \PHPUnit_Framework_Assert::assertEquals( + self::REQUIRE_MESSAGE, + $actualRequiredFields[$field], + "Field '$field' is not highlighted as required." + ); + } + } + + /** + * Return string representation of object. + * + * @return string + */ + public function toString() + { + return 'All required fields on customer form are highlighted.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php new file mode 100644 index 0000000000000..5f49cbee1e5a4 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCartPriceRuleForm.php @@ -0,0 +1,54 @@ +open(); + $promoQuoteIndex->getGridPageActions()->addNew(); + $promoQuoteNew->getSalesRuleForm()->openTab('rule_information'); + + /** @var RuleInformation $ruleInformationTab */ + $ruleInformationTab = $promoQuoteNew->getSalesRuleForm()->getTab('rule_information'); + \PHPUnit_Framework_Assert::assertTrue( + $ruleInformationTab->isVisibleCustomerGroup($customerGroup), + "Customer group {$customerGroup->getCustomerGroupCode()} not in cart price rule page." + ); + } + + /** + * Success assert of customer group find on cart price rule page. + * + * @return string + */ + public function toString() + { + return 'Customer group find on cart price rule page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php new file mode 100644 index 0000000000000..15fac430dc685 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCatalogPriceRuleForm.php @@ -0,0 +1,54 @@ +open(); + $catalogRuleIndex->getGridPageActions()->addNew(); + $catalogRuleNew->getEditForm()->openTab('rule_information'); + + /** @var RuleInformation $ruleInformationTab */ + $ruleInformationTab = $catalogRuleNew->getEditForm()->getTab('rule_information'); + \PHPUnit_Framework_Assert::assertTrue( + $ruleInformationTab->isVisibleCustomerGroup($customerGroup), + "Customer group {$customerGroup->getCustomerGroupCode()} not in catalog price rule page." + ); + } + + /** + * Success assert of customer group find on catalog price rule page. + * + * @return string + */ + public function toString() + { + return 'Customer group find on catalog price rule page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php index d0f38165dea70..0ab32aa443c90 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnCustomerForm.php @@ -14,12 +14,12 @@ use Magento\Mtf\Fixture\FixtureFactory; /** - * Class AssertCustomerGroupOnCustomerForm + * Assert that customer group find on account information page. */ class AssertCustomerGroupOnCustomerForm extends AbstractConstraint { /** - * Assert that customer group find on account information page + * Assert that customer group find on account information page. * * @param FixtureFactory $fixtureFactory * @param CustomerGroup $customerGroup @@ -53,12 +53,12 @@ public function processAssert( \PHPUnit_Framework_Assert::assertTrue( empty($diff), - "Customer group {$customerGroup->getCustomerGroupCode()} not in customer form." + "Customer group {$customerGroup->getCustomerGroupCode()} not in account information page." ); } /** - * Success assert of customer group find on account information page + * Success assert of customer group find on account information page. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnProductForm.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnProductForm.php new file mode 100644 index 0000000000000..f783c4b4ea625 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerGroupOnProductForm.php @@ -0,0 +1,54 @@ +open(); + $catalogProductIndex->getGridPageActionBlock()->addProduct(); + $catalogProductNew->getProductForm()->openTab('advanced-pricing'); + + /** @var AdvancedPricingTab $advancedPricingTab */ + $advancedPricingTab = $catalogProductNew->getProductForm()->getTab('advanced-pricing'); + \PHPUnit_Framework_Assert::assertTrue( + $advancedPricingTab->getTierPriceForm()->isVisibleCustomerGroup($customerGroup), + "Customer group {$customerGroup->getCustomerGroupCode()} not in tier price form on product page." + ); + } + + /** + * Success assert of customer group find on product page. + * + * @return string + */ + public function toString() + { + return 'Customer group find on product page.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerLogout.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerLogout.php new file mode 100644 index 0000000000000..0db06b1df1ab5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerLogout.php @@ -0,0 +1,59 @@ +open(); + $cmsIndex->getCmsPageBlock()->waitPageInit(); + + $cmsIndex->getLinksBlock()->openLink('Sign Out'); + $cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible(self::LOGOUT_PAGE_TITLE); + $cmsIndex->getCmsPageBlock()->waitUntilTextIsVisible(self::HOME_PAGE_TITLE); + $cmsIndex->getCmsPageBlock()->waitPageInit(); + \PHPUnit_Framework_Assert::assertTrue( + $cmsIndex->getLinksBlock()->isLinkVisible('Sign In'), + "Customer wasn't logged out." + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return "Customer is successfully log out."; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerSuccessRegisterMessage.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerSuccessRegisterMessage.php index 13d0cdae0112f..bf70b9806347f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerSuccessRegisterMessage.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerSuccessRegisterMessage.php @@ -10,15 +10,14 @@ use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertCustomerSuccessRegisterMessage - * + * Assert that success message is displayed after customer registered on frontend. */ class AssertCustomerSuccessRegisterMessage extends AbstractConstraint { const SUCCESS_MESSAGE = 'Thank you for registering with Main Website Store.'; /** - * Assert that success message is displayed after customer registered on frontend + * Assert that success message is displayed after customer registered on frontend. * * @param CustomerAccountCreate $registerPage * @return void @@ -36,7 +35,7 @@ public function processAssert(CustomerAccountCreate $registerPage) } /** - * Text of success register message is displayed + * Text of success register message is displayed. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Webapi.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Webapi.php index 1934bc456d920..44485d16264c6 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Webapi.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Webapi.php @@ -26,6 +26,11 @@ class Webapi extends AbstractWebapi implements CustomerInterface * @var array */ protected $mappingData = [ + 'gender' => [ + 'Male' => 1, + 'Female' => 2, + 'Not Specified' => 3 + ], 'country_id' => [ 'United States' => 'US', 'United Kingdom' => 'GB' @@ -70,7 +75,7 @@ public function persist(FixtureInterface $customer = null) */ protected function prepareData(Customer $customer) { - $data['customer'] = $customer->getData(); + $data['customer'] = $this->replaceMappingData($customer->getData()); $data['customer']['group_id'] = $this->getCustomerGroup($customer); $data['password'] = $data['customer']['password']; unset($data['customer']['password']); @@ -105,7 +110,6 @@ protected function prepareAddressData(array $data) return $data; } foreach ($data['customer']['address'] as $key => $addressData) { - $addressData['country_id'] = $this->mappingData['country_id'][$addressData['country_id']]; $addressData = $this->prepareRegionData($addressData); $addressData = $this->prepareStreetData($addressData); $addressData = $this->prepareDefaultAddressData($addressData); @@ -132,7 +136,7 @@ protected function prepareRegionData(array $addressData) } if (isset($addressData['region_id'])) { $addressData['region'] = [ - 'region_id' => $this->mappingData['region_id'][$addressData['region_id']] + 'region_id' => $addressData['region_id'] ]; unset($addressData['region_id']); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Address/DefaultAddress.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Address/DefaultAddress.php index 90b432c8d47ac..249e0e30184e9 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Address/DefaultAddress.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Address/DefaultAddress.php @@ -11,32 +11,31 @@ use Magento\Mtf\Page\Page; /** - * Class DefaultAddress - * Default address page + * Default address page. */ class DefaultAddress extends Page { /** - * URL for customer Dashboard + * URL for customer Dashboard. */ const MCA = 'customer/address/index'; /** - * Selector for default address block + * Selector for default address block. * * @var string */ protected $defaultAddressesSelector = '.block-addresses-default'; /** - * Get default addresses block + * Get default addresses block. * * @return \Magento\Customer\Test\Block\Account\AddressesDefault */ public function getDefaultAddresses() { return Factory::getBlockFactory()->getMagentoCustomerAccountAddressesDefault( - $this->_browser->find($this->defaultAddressesSelector, Locator::SELECTOR_CSS) + $this->browser->find($this->defaultAddressesSelector, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml index 69db394b4cd95..72d8c4bf82311 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerGroupNew.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml index 80bd928de60ac..7dfacbc495c12 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/Adminhtml/CustomerIndexEdit.xml @@ -6,11 +6,12 @@ */ --> - - - - - - - + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountForgotPassword.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountForgotPassword.php index ff129b94eb172..0d0364d823819 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountForgotPassword.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountForgotPassword.php @@ -11,36 +11,41 @@ use Magento\Mtf\Page\Page; /** + * Customer forgot password page. */ class CustomerAccountForgotPassword extends Page { /** - * URL for reset customer password + * URL for reset customer password. */ const MCA = 'customer/account/forgotpassword'; /** + * Forgot password form. + * * @var string */ protected $forgotPasswordForm = '#form-validate'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } /** - * Get Customer Forgot Password form + * Get Customer Forgot Password form. * * @return \Magento\Customer\Test\Block\Form\ForgotPassword */ public function getForgotPasswordForm() { return Factory::getBlockFactory()->getMagentoCustomerFormForgotPassword( - $this->_browser->find( + $this->browser->find( $this->forgotPasswordForm, Locator::SELECTOR_CSS ) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogout.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogout.php index 2f73386919242..e9584762883d0 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogout.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAccountLogout.php @@ -9,22 +9,22 @@ use Magento\Mtf\Page\Page; /** - * Class CustomerAccountLogout * Customer frontend logout page. - * */ class CustomerAccountLogout extends Page { /** - * URL for customer logout + * URL for customer logout. */ const MCA = 'customer/account/logout'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAddressEdit.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAddressEdit.php index f217c900d0b65..53a2867b16ac7 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAddressEdit.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Page/CustomerAddressEdit.php @@ -12,39 +12,40 @@ /** * Customer Address Edit page. - * */ class CustomerAddressEdit extends Page { /** - * URL for Customer Address Edit page + * URL for Customer Address Edit page. */ const MCA = 'customer/address/edit'; /** - * Customer Address Edit form + * Customer Address Edit form. * * @var string */ protected $editForm = '#form-validate'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } /** - * Get Customer Address Edit form + * Get Customer Address Edit form. * * @return \Magento\Customer\Test\Block\Address\Edit */ public function getEditForm() { return Factory::getBlockFactory()->getMagentoCustomerAddressEdit( - $this->_browser->find($this->editForm, Locator::SELECTOR_CSS) + $this->browser->find($this->editForm, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml index bca31130341c1..1acc441405884 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml @@ -159,7 +159,6 @@ United Kingdom London 444-44-444-44 - 444-44-444-44 Yes Yes @@ -175,7 +174,6 @@ United Kingdom London 444-44-444-44 - 444-44-444-44 @@ -188,7 +186,6 @@ United Kingdom London 444-44-444-44 - 444-44-444-44 diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml index 4ee4ba83044c3..1b89235517ffe 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerBackendEntityTest.xml @@ -96,5 +96,44 @@ + + saveAndContinue + Main Website + customer_group_retail_customer + John%isolation% + Doe%isolation% + JohnDoe%isolation%@example.com + + + + + + save + Main Website + General + + First Name + Last Name + Email + + + + + save + Main Website + General + John%isolation% + Doe%isolation% + JohnDoe%isolation%@example.com + Magento + + Street Address + City + Country + Zip/Postal Code + Phone Number + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.xml index b50e80215cceb..1294aafbdc281 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateCustomerGroupEntityTest.xml @@ -13,6 +13,9 @@ + + + retail_customer diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.php new file mode 100644 index 0000000000000..f3721ef7b3659 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.php @@ -0,0 +1,81 @@ + All Customers. + * 3. Press "Add New Customer" button. + * 4. Fill form with data from previously created customer. + * 5. Click "Save Customer" button. + * 6. Perform all assertions. + * + * @ZephyrId MAGETWO-43685 + */ +class CreateExistingCustomerBackendEntity extends Injectable +{ + /* tags */ + const MVP = 'yes'; + const DOMAIN = 'CS'; + /* end tags */ + + /** + * Customer index page. + * + * @var CustomerIndex + */ + protected $pageCustomerIndex; + + /** + * New customer page. + * + * @var CustomerIndexNew + */ + protected $pageCustomerIndexNew; + + /** + * Inject customer pages. + * + * @param CustomerIndex $pageCustomerIndex + * @param CustomerIndexNew $pageCustomerIndexNew + * @return void + */ + public function __inject( + CustomerIndex $pageCustomerIndex, + CustomerIndexNew $pageCustomerIndexNew + ) { + $this->pageCustomerIndex = $pageCustomerIndex; + $this->pageCustomerIndexNew = $pageCustomerIndexNew; + } + + /** + * Create customer on backend. + * + * @param Customer $customer + * @return void + */ + public function test(Customer $customer) + { + // Precondition + $customer->persist(); + + // Steps + $this->pageCustomerIndex->open(); + $this->pageCustomerIndex->getPageActionsBlock()->addNew(); + $this->pageCustomerIndexNew->getCustomerForm()->fillCustomer($customer); + $this->pageCustomerIndexNew->getPageActionsBlock()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.xml new file mode 100644 index 0000000000000..2c711d79991b7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerBackendEntity.xml @@ -0,0 +1,15 @@ + + + + + + default + + + + diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php index adb0c3fc6db5b..55193f4834afa 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerBackendEntityTest.php @@ -74,5 +74,6 @@ public function testDeleteCustomerBackendEntity(Customer $customer) $this->customerIndexPage->open(); $this->customerIndexPage->getCustomerGridBlock()->searchAndOpen($filter); $this->customerIndexEditPage->getPageActionsBlock()->delete(); + $this->customerIndexEditPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php index 7b3cfefbf139c..067e17a8d0e59 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/DeleteCustomerGroupEntityTest.php @@ -80,5 +80,6 @@ public function test(CustomerGroup $customerGroup) $this->customerGroupIndex->open(); $this->customerGroupIndex->getCustomerGroupGrid()->searchAndOpen($filter); $this->customerGroupNew->getPageMainActions()->delete(); + $this->customerGroupNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php index 8d89091816aa5..a5ac5b7688319 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.php @@ -9,7 +9,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\CustomerAccountCreate; use Magento\Cms\Test\Page\CmsIndex; -use Magento\Customer\Test\Page\CustomerAccountLogout; +use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep; use Magento\Mtf\TestCase\Injectable; /** @@ -32,40 +32,49 @@ class RegisterCustomerFrontendEntityTest extends Injectable /* end tags */ /** + * Customer registry page. + * * @var CustomerAccountCreate */ protected $customerAccountCreate; /** - * @var CustomerAccountLogout + * Cms page. + * + * @var CmsIndex $cmsIndex */ - protected $customerAccountLogout; + protected $cmsIndex; /** - * @var CmsIndex $cmsIndex + * Customer log out step. + * + * @var LogoutCustomerOnFrontendStep */ - protected $cmsIndex; + protected $logoutCustomerOnFrontendStep; /** + * Inject data. + * * @param CustomerAccountCreate $customerAccountCreate - * @param CustomerAccountLogout $customerAccountLogout * @param CmsIndex $cmsIndex + * @param LogoutCustomerOnFrontendStep $logoutCustomerOnFrontendStep + * @return void */ public function __inject( CustomerAccountCreate $customerAccountCreate, - CustomerAccountLogout $customerAccountLogout, - CmsIndex $cmsIndex + CmsIndex $cmsIndex, + LogoutCustomerOnFrontendStep $logoutCustomerOnFrontendStep ) { - $this->customerAccountLogout = $customerAccountLogout; $this->customerAccountCreate = $customerAccountCreate; $this->cmsIndex = $cmsIndex; - $this->customerAccountLogout->open(); + $this->logoutCustomerOnFrontendStep = $logoutCustomerOnFrontendStep; } /** * Create Customer account on Storefront. * * @param Customer $customer + * @return void */ public function test(Customer $customer) { @@ -76,12 +85,12 @@ public function test(Customer $customer) } /** - * Logout customer from frontend account + * Logout customer from frontend account. * - * return void + * @return void */ public function tearDown() { - $this->customerAccountLogout->open(); + $this->logoutCustomerOnFrontendStep->run(); } } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.xml index ba55d1feb8d4f..f9db269ee2b0f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/RegisterCustomerFrontendEntityTest.xml @@ -7,8 +7,7 @@ --> - - Register new customer + john doe johndoe%isolation%@example.com @@ -17,9 +16,9 @@ 123123q + - - Register new customer with subscribing + john doe johndoe%isolation%@example.com diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LogoutCustomerOnFrontendStep.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LogoutCustomerOnFrontendStep.php index 63399666bbc44..4c536396af65a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LogoutCustomerOnFrontendStep.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestStep/LogoutCustomerOnFrontendStep.php @@ -15,11 +15,6 @@ */ class LogoutCustomerOnFrontendStep implements TestStepInterface { - /** - * Logout page title. - */ - const LOGOUT_PAGE_TITLE = 'You are signed out.'; - /** * Cms index page. * diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml index f314e6315e00d..dcee2b9bd421f 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml @@ -41,4 +41,19 @@ high + + + middle + + + + + middle + + + + + middle + + diff --git a/dev/tests/functional/tests/app/Magento/Dhl/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Dhl/Test/TestCase/OnePageCheckoutTest.xml index a9e54ed517058..5b8bedaf9b977 100644 --- a/dev/tests/functional/tests/app/Magento/Dhl/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Dhl/Test/TestCase/OnePageCheckoutTest.xml @@ -6,22 +6,22 @@ */ --> - + catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product login customer_DE DE_address - customer_DE + customer_DE DHL Express worldwide Express worldwide checkmo checkmo, dhl_eu, shipping_origin_CH, config_base_currency_ch test_type:3rd_party_test - - - + + + diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml index 5c8e12cbb0e1a..89234e4b9a12c 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.xml @@ -276,7 +276,6 @@ - Create product with tier price diff --git a/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml index d53852fef4800..580de1cac6f91 100644 --- a/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Fedex/Test/TestCase/OnePageCheckoutTest.xml @@ -6,37 +6,38 @@ */ --> - + catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product guest default UK_address - UK_address + UK_address Federal Express International Economy International Economy checkmo checkmo, fedex, shipping_origin_US_CA - - - + test_type:3rd_party_test + + + catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product login customer_DE DE_address - customer_DE + customer_DE Federal Express Ground Ground checkmo checkmo, fedex, shipping_origin_US_CA test_type:3rd_party_test - - - + + + diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php deleted file mode 100644 index e3c8e2bd1dbd4..0000000000000 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Constraint/AssertGroupedPriceOnGroupedProductPage.php +++ /dev/null @@ -1,51 +0,0 @@ -processAssertPrice($product, $catalogProductView, $groupedPrice, $browser); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php index fa5f9a0e4a2f8..73c66f0af0aa7 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/Block/Adminhtml/Integration/IntegrationGrid.php @@ -74,6 +74,13 @@ class IntegrationGrid extends Grid */ protected $tokensPopupSelector = './/ancestor::body/div[descendant::fieldset[contains(@id,"integration_token")]]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Search and delete current item * @@ -84,13 +91,10 @@ public function searchAndDelete(array $item) { $this->search($item); $this->_rootElement->find($this->deleteLink)->click(); - - /** @var \Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\DeleteDialog $deleteDialog */ - $deleteDialog = $this->blockFactory->create( - 'Magento\Integration\Test\Block\Adminhtml\Integration\IntegrationGrid\DeleteDialog', - ['element' => $this->_rootElement->find($this->deleteBlockSelector, Locator::SELECTOR_XPATH)] - ); - $deleteDialog->acceptDeletion(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutAddressNewShipping.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutAddressNewShipping.php index 37d0cda809996..746296b32c108 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutAddressNewShipping.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutAddressNewShipping.php @@ -11,41 +11,41 @@ use Magento\Mtf\Page\Page; /** - * class MultishippingCheckoutAddressNewShipping - * Create Shipping Address page - * + * Create Shipping Address page. */ class MultishippingCheckoutAddressNewShipping extends Page { /** - * URL for new shipping address page + * URL for new shipping address page. */ const MCA = 'multishipping/checkout_address/newShipping'; /** - * Form for edit customer address + * Form for edit customer address. * * @var string */ protected $editBlock = '#form-validate'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } /** - * Get form for edit customer address + * Get form for edit customer address. * * @return \Magento\Customer\Test\Block\Address\Edit */ public function getEditBlock() { return Factory::getBlockFactory()->getMagentoCustomerAddressEdit( - $this->_browser->find($this->editBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->editBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutCart.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutCart.php index acbd1375dbbbb..3a3e1981636a3 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutCart.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutCart.php @@ -11,32 +11,31 @@ use Magento\Mtf\Page\Page; /** - * class MultishippingCheckoutCart - * + * Multishipping checkout cart page. */ class MultishippingCheckoutCart extends Page { /** - * URL for multishipping checkout cart page + * URL for multishipping checkout cart page. */ const MCA = 'multishipping/checkout/cart'; /** - * Multishipping cart link block + * Multishipping cart link block. * * @var string */ protected $multishippingLinkBlock = '.action.multicheckout'; /** - * Get multishipping cart link block + * Get multishipping cart link block. * * @return \Magento\Multishipping\Test\Block\Checkout\Link */ public function getMultishippingLinkBlock() { return Factory::getBlockFactory()->getMagentoMultishippingCheckoutLink( - $this->_browser->find($this->multishippingLinkBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->multishippingLinkBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutLogin.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutLogin.php index cb233ab410587..8c0a07f7dfb71 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutLogin.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutLogin.php @@ -11,39 +11,41 @@ use Magento\Mtf\Page\Page; /** - * Multishipping login page + * Multishipping login page. */ class MultishippingCheckoutLogin extends Page { /** - * URL for multishipping login page + * URL for multishipping login page. */ const MCA = 'multishipping/checkout/login'; /** - * Form for customer login + * Form for customer login. * * @var string */ protected $loginBlock = '.login-container'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } /** - * Get form for customer login + * Get form for customer login. * * @return \Magento\Customer\Test\Block\Form\Login */ public function getLoginBlock() { return Factory::getBlockFactory()->getMagentoCustomerFormLogin( - $this->_browser->find($this->loginBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->loginBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutRegister.php b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutRegister.php index 4b858c8514a5f..757848308d76e 100644 --- a/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutRegister.php +++ b/dev/tests/functional/tests/app/Magento/Multishipping/Test/Page/MultishippingCheckoutRegister.php @@ -11,41 +11,41 @@ use Magento\Mtf\Page\Page; /** - * class MultishippingCheckoutRegister - * Register new customer while performing multishipping addresses checkout - * + * Register new customer while performing multishipping addresses checkout. */ class MultishippingCheckoutRegister extends Page { /** - * URL for register customer page + * URL for register customer page. */ const MCA = 'multishipping/checkout/register'; /** - * Customer register block form + * Customer register block form. * * @var string */ protected $registerBlock = '#form-validate'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $_ENV['app_frontend_url'] . self::MCA; + $this->url = $_ENV['app_frontend_url'] . self::MCA; } /** - * Get customer register block form + * Get customer register block form. * * @return \Magento\Customer\Test\Block\Form\Register */ public function getRegisterBlock() { return Factory::getBlockFactory()->getMagentoCustomerFormRegister( - $this->_browser->find($this->registerBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->registerBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Subscriber/Grid.php b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Subscriber/Grid.php index 0937402339864..9c2f66542e902 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Subscriber/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/Block/Adminhtml/Subscriber/Grid.php @@ -7,13 +7,12 @@ namespace Magento\Newsletter\Test\Block\Adminhtml\Subscriber; /** - * Newsletter subscribers grid - * + * Newsletter subscribers grid. */ -class Grid extends \Magento\Ui\Test\Block\Adminhtml\DataGrid +class Grid extends \Magento\Backend\Test\Block\Widget\Grid { /** - * Filters array mapping + * Filters array mapping. * * @var array */ diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php index efbf9ac19ef2c..c490b2dbaf13b 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/Edit/Tab/ImagesAndVideos.php @@ -20,7 +20,7 @@ class ImagesAndVideos extends Tab * * @var string */ - protected $addVideoButton = '#product_info_tabs_images-and-videos_content #add_video_button'; + protected $addVideoButton = '#product_info_tabs_image-management_content #add_video_button'; /** * Video dialog CSS locator. diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml index 94e28feef713c..5a3c8fbe3fd8a 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Block/Adminhtml/Product/ProductForm.xml @@ -8,7 +8,7 @@ \Magento\ProductVideo\Test\Block\Adminhtml\Product\Edit\Tab\ImagesAndVideos - #product_info_tabs_images-and-videos + #product_info_tabs_image-management css selector diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Repository/ConfigData.xml new file mode 100755 index 0000000000000..5227236ce505b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/Repository/ConfigData.xml @@ -0,0 +1,27 @@ + + + + + + + default + 0 + + AIzaSyDwqDWuw1lra-LnpJL2Mr02DYuFmkuRSns + + + + + default + 0 + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateSimpleProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateSimpleProductEntityTest.xml index 6a151535f05f0..74f73a10f81e3 100755 --- a/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateSimpleProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateSimpleProductEntityTest.xml @@ -34,6 +34,7 @@ https://youtu.be/WMp2PvU2qi8 Foo Test 1 This is a test "Foo Test 1" + youtube_api_key @@ -50,18 +51,19 @@ - product_with_category - simple_product_with_category_%isolation% + product_with_category + simple_product_with_category_%isolation% sku_simple_product_with_video_%isolation% https://youtu.be/WMp2PvU2qi8 Foo Test 1 + youtube_api_key - product_with_category - simple_product_with_category_%isolation% + product_with_category + simple_product_with_category_%isolation% https://vimeo.com/21776334 Foo Test 2 @@ -73,6 +75,7 @@ product_with_video_youtube sku_simple_product_with_video_%isolation% https://youtu.be/bpOSxM0rNPM + youtube_api_key @@ -97,6 +100,7 @@ https://youtu.be/bpOSxM0rNPM Edit Test This is an edit test + youtube_api_key @@ -105,6 +109,7 @@ simple_product_with_category_%isolation% https://youtu.be/WMp2PvU2qi8 Foo Fighters - Congregation + youtube_api_key diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AbstractAssertInvoiceReportResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AbstractAssertInvoiceReportResult.php index df6e3fb9662d4..0bf83c62bc8a2 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AbstractAssertInvoiceReportResult.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AbstractAssertInvoiceReportResult.php @@ -10,22 +10,22 @@ use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\ObjectManager; +use Magento\Mtf\System\Event\EventManagerInterface; /** - * Class AbstractAssertInvoiceReportResult - * Abstract assert for search in invoice report grid + * Abstract assert for search in invoice report grid. */ abstract class AbstractAssertInvoiceReportResult extends AbstractConstraint { /** - * Invoice report page + * Invoice report page. * * @var SalesInvoiceReport */ protected $salesInvoiceReport; /** - * Order + * Order. * * @var OrderInjectable */ @@ -34,16 +34,20 @@ abstract class AbstractAssertInvoiceReportResult extends AbstractConstraint /** * @constructor * @param ObjectManager $objectManager + * @param EventManagerInterface $eventManager * @param SalesInvoiceReport $salesInvoiceReport */ - public function __construct(ObjectManager $objectManager, SalesInvoiceReport $salesInvoiceReport) - { - parent::__construct($objectManager); + public function __construct( + ObjectManager $objectManager, + EventManagerInterface $eventManager, + SalesInvoiceReport $salesInvoiceReport + ) { + parent::__construct($objectManager, $eventManager); $this->salesInvoiceReport = $salesInvoiceReport; } /** - * Search in invoice report grid + * Search in invoice report grid. * * @param array $invoiceReport * @return void @@ -57,7 +61,7 @@ protected function searchInInvoiceReportGrid(array $invoiceReport) } /** - * Prepare expected result + * Prepare expected result. * * @param array $expectedInvoiceData * @return array diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php index 1e627941bd767..ea33820808df7 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Constraint/AssertSetApprovedProductReview.php @@ -69,6 +69,7 @@ protected function flushCacheStorageWithAssert() { $this->cachePage->open(); $this->cachePage->getActionsBlock()->flushCacheStorage(); + $this->cachePage->getModalBlock()->acceptAlert(); \PHPUnit_Framework_Assert::assertTrue( $this->cachePage->getActionsBlock()->isStorageCacheFlushed(), 'Cache is not flushed.' diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml index 2f6ca2960091c..f5f44551d0222 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Review/Test/Page/Adminhtml/RatingEdit.xml @@ -9,5 +9,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php index 9f826b41451c3..bbfabc028edbf 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductRatingEntityTest.php @@ -127,5 +127,6 @@ public function tearDown() $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen($filter); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php index 937cca411d93b..961ab02b043db 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewBackendEntityTest.php @@ -135,6 +135,7 @@ public function tearDown() foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php index d0635638f9ff2..406f4deef9c96 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/CreateProductReviewFrontendEntityTest.php @@ -128,6 +128,7 @@ public function tearDown() foreach ($ratings as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php index 193c7307ab800..8b7d3bf5749d9 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/DeleteProductRatingEntityTest.php @@ -90,5 +90,6 @@ public function testDeleteProductRatingEntity(Rating $productRating) $this->ratingIndex->open(); $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $productRating->getRatingCode()]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php index f0a34008cf012..b7d7b5b53f55c 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/ManageProductReviewFromCustomerPageTest.php @@ -208,6 +208,7 @@ public function tearDown() foreach ($this->reviewInitial->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php index f351eb72b7d93..188ec0fa1e69d 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/MassActionsProductReviewEntityTest.php @@ -119,6 +119,7 @@ public function tearDown() foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php index 7b6908ce0a0ae..0a373da1808d8 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityOnProductPageTest.php @@ -178,6 +178,7 @@ public function tearDown() foreach ($this->reviewInitial->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php index f2ab71072a284..f3005a32db022 100644 --- a/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Review/Test/TestCase/UpdateProductReviewEntityTest.php @@ -132,6 +132,7 @@ public function tearDown() foreach ($this->review->getRatings() as $rating) { $this->ratingIndex->getRatingGrid()->searchAndOpen(['rating_code' => $rating['title']]); $this->ratingEdit->getPageActions()->delete(); + $this->ratingEdit->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php index 4d5bf937f8f11..f034bbb2c52b7 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Actions.php @@ -10,111 +10,117 @@ use Magento\Mtf\Client\Locator; /** - * Class Actions - * Order actions block + * Order actions block. */ class Actions extends Block { /** - * 'Back' button + * 'Back' button. * * @var string */ protected $back = '#back'; /** - * 'Edit' button + * 'Edit' button. * * @var string */ protected $edit = '#order_edit'; /** - * 'Cancel' button + * 'Cancel' button. * * @var string */ - protected $cancel = '#order_cancel'; + protected $cancel = '[id$=cancel-button]'; /** - * 'Send Email' button + * 'Send Email' button. * * @var string */ protected $sendEmail = '#send_notification'; /** - * 'Void' button + * 'Void' button. * * @var string */ protected $void = '#void_payment'; /** - * 'Hold' button + * 'Hold' button. * * @var string */ - protected $hold = '#order_hold'; + protected $hold = '[id$=hold-button]'; /** - * 'Invoice' button + * 'Invoice' button. * * @var string */ protected $invoice = '#order_invoice'; /** - * 'Reorder' button + * 'Reorder' button. * * @var string */ protected $reorder = '#order_reorder'; /** - * 'Ship' button + * 'Ship' button. * * @var string */ protected $ship = '#order_ship'; /** - * 'Credit Memo' button on the order page + * 'Credit Memo' button on the order page. * * @var string */ protected $orderCreditMemo = '#order_creditmemo'; /** - * 'Credit Memo' button on the order invoice page + * 'Credit Memo' button on the order invoice page. * * @var string */ protected $orderInvoiceCreditMemo = '#capture'; /** - * 'Refund' button + * 'Refund' button. * * @var string */ protected $refund = '.submit-button.refund'; /** - * 'Refund Offline' button + * 'Refund Offline' button. * * @var string */ protected $refundOffline = '.submit-button'; /** - * General button selector + * General button selector. * * @var string */ - protected $button = 'button[data-ui-id$="%s-button"]'; + protected $button = '//button[@title="%s"]'; /** - * Ship order + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + + /** + * Ship order. * * @return void */ @@ -124,7 +130,7 @@ public function ship() } /** - * Invoice order + * Invoice order. * * @return void */ @@ -134,7 +140,7 @@ public function invoice() } /** - * Reorder order + * Reorder order. * * @return void */ @@ -144,7 +150,7 @@ public function reorder() } /** - * Go back + * Go back. * * @return void */ @@ -154,7 +160,7 @@ public function back() } /** - * Edit order + * Edit order. * * @return void */ @@ -164,18 +170,21 @@ public function edit() } /** - * Cancel order + * Cancel order. * * @return void */ public function cancel() { $this->_rootElement->find($this->cancel)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** - * Send email + * Send email. * * @return void */ @@ -185,7 +194,7 @@ public function sendEmail() } /** - * Void order + * Void order. * * @return void */ @@ -195,7 +204,7 @@ public function void() } /** - * Hold order + * Hold order. * * @return void */ @@ -205,7 +214,7 @@ public function hold() } /** - * Order credit memo + * Order credit memo. * * @return void */ @@ -215,7 +224,7 @@ public function orderCreditMemo() } /** - * Order invoice credit memo + * Order invoice credit memo. * * @return void */ @@ -225,7 +234,7 @@ public function orderInvoiceCreditMemo() } /** - * Refund order + * Refund order. * * @return void */ @@ -235,7 +244,7 @@ public function refund() } /** - * Refund offline order + * Refund offline order. * * @return void */ @@ -245,14 +254,13 @@ public function refundOffline() } /** - * Check if action button is visible + * Check if action button is visible. * * @param string $buttonName * @return bool */ public function isActionButtonVisible($buttonName) { - $buttonName = str_replace(' ', '-', strtolower($buttonName)); - return $this->_rootElement->find(sprintf($this->button, $buttonName))->isVisible(); + return $this->_rootElement->find(sprintf($this->button, $buttonName), Locator::SELECTOR_XPATH)->isVisible(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php index 8ea2b8ea680f0..eafb045e43909 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Grid.php @@ -21,39 +21,39 @@ class Grid extends DataGrid */ protected $filters = [ 'id' => [ - 'selector' => '[name="filters[increment_id]"]', + 'selector' => '[name="increment_id"]', ], 'status' => [ - 'selector' => '[name="filters[status]"]', + 'selector' => '[name="status"]', 'input' => 'select', ], 'purchase_date_from' => [ - 'selector' => '[name="filters[created_at][from]"]', + 'selector' => '[name="created_at[from]"]', ], 'purchase_date_to' => [ - 'selector' => '[name="filters[created_at][to]"]', + 'selector' => '[name="created_at[to]"]', ], 'base_grand_total_from' => [ - 'selector' => '[name="filters[base_grand_total][from]"]', + 'selector' => '[name="base_grand_total[from]"]', ], 'base_grand_total_to' => [ - 'selector' => '[name="filters[base_grand_total][to]"]', + 'selector' => '[name="base_grand_total[to]"]', ], 'purchased_gran_total_from' => [ - 'selector' => '[name="filters[grand_total][from]"]', + 'selector' => '[name="grand_total[from]"]', ], 'purchased_gran_total_to' => [ - 'selector' => '[name="filters[grand_total][to]"]', + 'selector' => '[name="grand_total[to]"]', ], 'purchase_point' => [ - 'selector' => '[name="filters[store_id]"]', + 'selector' => '[name="store_id"]', 'input' => 'selectstore' ], 'bill_to_name' => [ - 'selector' => '[name="filters[billing_name]"]' + 'selector' => '[name="billing_name"]' ], 'ship_to_name' => [ - 'selector' => '[name="filters[shipping_name]"]', + 'selector' => '[name="shipping_name"]', ] ]; diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php index 9ba84f6a064de..0c8fecdff10e4 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AbstractAssertOrderOnFrontend.php @@ -11,22 +11,22 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\ObjectManager; +use Magento\Mtf\System\Event\EventManagerInterface; /** - * Abstract Class AbstractAssertOrderOnFrontend - * Abstract class for frontend asserts + * Abstract class for frontend asserts. */ abstract class AbstractAssertOrderOnFrontend extends AbstractConstraint { /** - * Cms index page + * Cms index page. * * @var CmsIndex */ protected $cmsIndex; /** - * Customer account index page + * Customer account index page. * * @var CustomerAccountIndex */ @@ -35,21 +35,23 @@ abstract class AbstractAssertOrderOnFrontend extends AbstractConstraint /** * @constructor * @param ObjectManager $objectManager + * @param EventManagerInterface $eventManager * @param CmsIndex $cmsIndex * @param CustomerAccountIndex $customerAccountIndex */ public function __construct( ObjectManager $objectManager, + EventManagerInterface $eventManager, CmsIndex $cmsIndex, CustomerAccountIndex $customerAccountIndex ) { - parent::__construct($objectManager); + parent::__construct($objectManager, $eventManager); $this->cmsIndex = $cmsIndex; $this->customerAccountIndex = $customerAccountIndex; } /** - * Login customer and open Order page + * Login customer and open Order page. * * @param Customer $customer * @return void diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCreditMemoButton.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCreditMemoButton.php index 6baff36cc94eb..4ce59a74583bf 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCreditMemoButton.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCreditMemoButton.php @@ -29,7 +29,7 @@ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderI $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); \PHPUnit_Framework_Assert::assertTrue( - $salesOrderView->getPageActions()->isActionButtonVisible('CreditMemo'), + $salesOrderView->getPageActions()->isActionButtonVisible('Credit Memo'), 'Credit memo button is absent on order view page.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertNoCreditMemoButton.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertNoCreditMemoButton.php index ed8806f44c616..d9e935600ba18 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertNoCreditMemoButton.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertNoCreditMemoButton.php @@ -29,7 +29,7 @@ public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderI $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $order->getId()]); \PHPUnit_Framework_Assert::assertFalse( - $salesOrderView->getPageActions()->isActionButtonVisible('CreditMemo'), + $salesOrderView->getPageActions()->isActionButtonVisible('Credit Memo'), 'Credit memo button is present on order view page.' ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml index 9ca28ac5ddd33..cdfafdfa83244 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/OrderCreateIndex.xml @@ -13,6 +13,6 @@ - + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/SalesOrderShipmentNew.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/SalesOrderShipmentNew.php index 352f752784045..28f2387011d62 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/SalesOrderShipmentNew.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/SalesOrderShipmentNew.php @@ -11,41 +11,41 @@ use Magento\Mtf\Page\Page; /** - * Class SalesOrder - * Manage orders page - * + * Manage orders page. */ class SalesOrderShipmentNew extends Page { /** - * URL for manage orders page + * URL for manage orders page. */ const MCA = 'sales/order/shipment/new'; /** - * Shipment totals block + * Shipment totals block. * * @var string */ protected $totalsBlock = '.order-totals'; /** - * Custom constructor + * Init page. Set page url. + * + * @return void */ - protected function _init() + protected function initUrl() { - $this->_url = $this->_url = $_ENV['app_backend_url'] . self::MCA; + $this->url = $_ENV['app_backend_url'] . self::MCA; } /** - * Get shipment totals + * Get shipment totals. * * @return \Magento\Sales\Test\Block\Adminhtml\Order\Shipment\Totals */ public function getTotalsBlock() { return Factory::getBlockFactory()->getMagentoSalesAdminhtmlOrderShipmentTotals( - $this->_browser->find($this->totalsBlock, Locator::SELECTOR_CSS) + $this->browser->find($this->totalsBlock, Locator::SELECTOR_CSS) ); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml index c6a9fa03bb5c0..a073396e9136d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml @@ -20,7 +20,7 @@ cashondelivery Pending - Back, Reorder, Cancel, Send Notification, Hold, Invoice, Ship, Edit + Back, Reorder, Cancel, Send Email, Hold, Invoice, Ship, Edit cashondelivery @@ -39,7 +39,7 @@ checkmo Pending - Back, Cancel, Send Notification, Hold, Invoice, Edit + Back, Cancel, Send Email, Hold, Invoice, Edit checkmo_specificcountry_gb @@ -60,7 +60,7 @@ banktransfer Pending - Back, Cancel, Send Notification, Hold, Reorder, Invoice, Edit + Back, Cancel, Send Email, Hold, Reorder, Invoice, Edit banktransfer @@ -80,7 +80,7 @@ banktransfer Pending - Back, Cancel, Send Notification, Hold, Invoice, Edit + Back, Cancel, Send Email, Hold, Invoice, Edit freeshipping_specificcountry_gb, banktransfer @@ -102,7 +102,7 @@ purchaseorder 123456 Pending - Back, Cancel, Send Notification, Hold, Invoice, Reorder, Edit + Back, Cancel, Send Email, Hold, Invoice, Reorder, Edit purchaseorder diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml index facb72b9d3086..1ad7453a1253f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveLastOrderedProductsOnOrderPageTest.xml @@ -14,7 +14,7 @@ default - configurableProduct::default + configurableProduct::configurable_with_qty_1 diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml index fd66961ecdb57..ef57ce932a9ca 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveProductsInComparedOnOrderPageTest.xml @@ -12,7 +12,7 @@ - configurableProduct::default,configurableProduct::default + configurableProduct::configurable_with_qty_1,configurableProduct::configurable_with_qty_1 diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml index b37eb5a0a491d..1ffaa89fc6046 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveRecentlyComparedProductsOnOrderPageTest.xml @@ -11,8 +11,8 @@ catalogProductSimple::default,catalogProductSimple::default - - configurableProduct::default,configurableProduct::default + + configurableProduct::configurable_with_qty_1,configurableProduct::configurable_with_qty_1 diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml index c82da591595d3..d03339663c03c 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/MoveShoppingCartProductsOnOrderPageTest.xml @@ -12,7 +12,7 @@ - configurableProduct::default + configurableProduct::configurable_with_qty_1 diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml index fb43e4a85b4c9..6d9ff785a5df9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/ReorderOrderEntityTest.xml @@ -21,7 +21,7 @@ checkmo Pending Pending - Back, Reorder, Cancel, Send Notification, Hold, Invoice, Ship, Edit + Back, Reorder, Cancel, Send Email, Hold, Invoice, Ship, Edit diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/RuleInformation.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/RuleInformation.php index 4c4b9a024af41..22168f005697e 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/RuleInformation.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Block/Adminhtml/Promo/Quote/Edit/Tab/RuleInformation.php @@ -7,6 +7,7 @@ namespace Magento\SalesRule\Test\Block\Adminhtml\Promo\Quote\Edit\Tab; use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Customer\Test\Fixture\CustomerGroup; use Magento\Mtf\Client\Element\SimpleElement; /** @@ -14,6 +15,13 @@ */ class RuleInformation extends Tab { + /** + * Locator for Customer Group element. + * + * @var string + */ + protected $customerGroup = '#rule_customer_group_ids'; + /** * Get data of tab. * @@ -31,4 +39,16 @@ public function getDataFormTab($fields = null, SimpleElement $element = null) } return $this->_getData($data, $element); } + + /** + * Check whether Customer Group is visible. + * + * @param CustomerGroup $customerGroup + * @return bool + */ + public function isVisibleCustomerGroup(CustomerGroup $customerGroup) + { + $options = $this->_rootElement->find($this->customerGroup)->getText(); + return false !== strpos($options, $customerGroup->getCustomerGroupCode()); + } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml index 23b3fe8d67b3a..432d754fddf7e 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Page/Adminhtml/PromoQuoteEdit.xml @@ -9,5 +9,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php index 906a7b51a359b..833752c00f609 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.php @@ -142,5 +142,6 @@ public function tearDown() $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php index 39acead1497ca..354d27064be2e 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/DeleteSalesRuleEntityTest.php @@ -75,5 +75,6 @@ public function testDeleteSalesRule(SalesRule $salesRule) $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen(['name' => $salesRule->getName()]); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php index a1ef4b347fef4..5ae2160bc42b3 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/UpdateSalesRuleEntityTest.php @@ -127,5 +127,6 @@ public function tearDown() $this->promoQuoteIndex->open(); $this->promoQuoteIndex->getPromoQuoteGrid()->searchAndOpen($filter); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php index 49fedf0d5d16d..3e21afe5ef91b 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/ApplySalesRuleOnFrontendStep.php @@ -49,6 +49,7 @@ public function run() { if ($this->salesRule !== null) { $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($this->salesRule->getCouponCode()); + $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals(); } } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php index 56db436ccb68d..ad0d2fbe86454 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/CreateSalesRuleStep.php @@ -77,6 +77,8 @@ public function run() */ public function cleanup() { - $this->deleteAllSalesRule->run(); + if ($this->salesRule !== null) { + $this->deleteAllSalesRule->run(); + } } } diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php index 98bf51e84f7c3..db64010c1af08 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestStep/DeleteAllSalesRuleStep.php @@ -54,6 +54,7 @@ public function run() while ($this->promoQuoteIndex->getPromoQuoteGrid()->isFirstRowVisible()) { $this->promoQuoteIndex->getPromoQuoteGrid()->openFirstRow(); $this->promoQuoteEdit->getFormPageActions()->delete(); + $this->promoQuoteEdit->getModalBlock()->acceptAlert(); $this->promoQuoteIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Constraint/AssertShipmentItems.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Constraint/AssertShipmentItems.php index e85ce0c7b0e2e..1b915560f211f 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Constraint/AssertShipmentItems.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Constraint/AssertShipmentItems.php @@ -11,15 +11,15 @@ use Magento\Shipping\Test\Page\Adminhtml\SalesShipmentView; use Magento\Shipping\Test\Page\Adminhtml\ShipmentIndex; use Magento\Mtf\ObjectManager; +use Magento\Mtf\System\Event\EventManagerInterface; /** - * Class AssertShipmentItems - * Assert shipment items on shipment view page + * Assert shipment items on shipment view page. */ class AssertShipmentItems extends AbstractAssertItems { /** - * Shipment index page + * Shipment index page. * * @var ShipmentIndex */ @@ -28,16 +28,20 @@ class AssertShipmentItems extends AbstractAssertItems /** * @constructor * @param ObjectManager $objectManager + * @param EventManagerInterface $eventManager * @param ShipmentIndex $shipmentIndex */ - public function __construct(ObjectManager $objectManager, ShipmentIndex $shipmentIndex) - { - parent::__construct($objectManager); + public function __construct( + ObjectManager $objectManager, + EventManagerInterface $eventManager, + ShipmentIndex $shipmentIndex + ) { + parent::__construct($objectManager, $eventManager); $this->shipmentPage = $shipmentIndex; } /** - * Assert shipped products are represented on shipment view page + * Assert shipped products are represented on shipment view page. * * @param SalesShipmentView $orderShipmentView * @param OrderInjectable $order @@ -56,7 +60,7 @@ public function processAssert( } /** - * Process assert + * Process assert. * * @param OrderInjectable $order * @param array $ids @@ -85,7 +89,7 @@ protected function assert( } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml index 78ebe3f0f12dd..9f2d045ae61a8 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/Page/Adminhtml/SitemapEdit.xml @@ -6,7 +6,8 @@ */ --> - - - + + + + diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php index 56371fb69ad3d..9e62c9111a036 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.php @@ -72,5 +72,6 @@ public function testDeleteSitemap(Sitemap $sitemap) $this->sitemapIndex->open(); $this->sitemapIndex->getSitemapGrid()->searchAndOpen($filter); $this->sitemapEdit->getFormPageActions()->delete(); + $this->sitemapEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/TaxRate.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/TaxRate.php index 30ee53017146c..4c06dede0433d 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/TaxRate.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Block/Adminhtml/Rule/Edit/TaxRate.php @@ -9,20 +9,19 @@ use Magento\Mtf\Block\Form as FormInterface; /** - * Class TaxRate - * Tax rate block + * Tax rate block. */ class TaxRate extends FormInterface { /** - * 'Save' button on dialog window for creating new tax rate + * 'Save' button on dialog window for creating new tax rate. * * @var string */ - protected $saveTaxRate = '#tax-rule-edit-apply-button'; + protected $saveTaxRate = '.action-save'; /** - * Clicking 'Save' button on dialog window for creating new tax rate + * Clicking 'Save' button on dialog window for creating new tax rate. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php index 51caa4822fa60..e66cdb00918e8 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Constraint/AssertTaxRuleApplying.php @@ -17,65 +17,65 @@ use Magento\Mtf\Fixture\FixtureFactory; /** - * Abstract class for implementing assert applying + * Abstract class for implementing assert applying. */ abstract class AssertTaxRuleApplying extends AbstractConstraint { /** - * Initial tax rule + * Initial tax rule. * * @var TaxRule */ protected $initialTaxRule; /** - * Tax rule + * Tax rule. * * @var TaxRule */ protected $taxRule; /** - * Product simple + * Product simple. * * @var CatalogProductSimple */ protected $productSimple; /** - * Checkout cart page + * Checkout cart page. * * @var CheckoutCart */ protected $checkoutCart; /** - * Shipping carrier and method + * Shipping carrier and method. * * @var array */ protected $shipping; /** - * Tax Rule name + * Tax Rule name. * * @var string */ protected $taxRuleCode; /** - * Implementation assert + * Implementation assert. * * @return void */ abstract protected function assert(); /** - * 1. Creating product simple with custom tax product class - * 2. Log In as customer - * 3. Add product to shopping cart - * 4. Estimate Shipping and Tax - * 5. Implementation assert + * 1. Creating product simple with custom tax product class. + * 2. Log In as customer. + * 3. Add product to shopping cart. + * 4. Estimate Shipping and Tax. + * 5. Implementation assert. * * @param FixtureFactory $fixtureFactory * @param TaxRule $taxRule @@ -136,9 +136,7 @@ public function processAssert( $catalogProductView->getMessagesBlock()->waitSuccessMessage(); // Estimate Shipping and Tax $checkoutCart->open(); - $checkoutCart->getShippingBlock()->openEstimateShippingAndTax(); - $checkoutCart->getShippingBlock()->fill($address); - $checkoutCart->getShippingBlock()->clickGetQuote(); + $checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($address); $checkoutCart->getShippingBlock()->selectShippingMethod($shipping); $this->assert(); } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml index 0237379975c22..9940b8cca862f 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRateNew.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml index 3396503e1d46f..3806a2e36a130 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Page/Adminhtml/TaxRuleNew.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php index 4bbdfbe520493..a83bfa60070df 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRateEntityTest.php @@ -81,5 +81,6 @@ public function testDeleteTaxRate(TaxRate $taxRate) $this->taxRateIndex->open(); $this->taxRateIndex->getTaxRateGrid()->searchAndOpen($filter); $this->taxRateNew->getFormPageActions()->delete(); + $this->taxRateNew->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php index bef4c799b43f3..de83384d07acc 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestCase/DeleteTaxRuleEntityTest.php @@ -89,5 +89,6 @@ public function testDeleteTaxRule(TaxRule $taxRule) $this->taxRuleIndexPage->open(); $this->taxRuleIndexPage->getTaxRuleGrid()->searchAndOpen(['code' => $taxRule->getCode()]); $this->taxRuleNewPage->getFormPageActions()->delete(); + $this->taxRuleNewPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php index a587216002ed8..f2e786edf2358 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/CreateTaxRuleStep.php @@ -80,6 +80,8 @@ public function run() */ public function cleanup() { - $this->deleteAllTaxRule->run(); + if ($this->taxRule !== null) { + $this->deleteAllTaxRule->run(); + } } } diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php index d24b2ca4c4de8..212d8beabc956 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/TestStep/DeleteAllTaxRulesStep.php @@ -55,6 +55,7 @@ public function run() while ($this->taxRuleIndexPage->getTaxRuleGrid()->isFirstRowVisible()) { $this->taxRuleIndexPage->getTaxRuleGrid()->openFirstRow(); $this->taxRuleNewPage->getFormPageActions()->delete(); + $this->taxRuleNewPage->getModalBlock()->acceptAlert(); } } } diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Breadcrumbs.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Breadcrumbs.php new file mode 100644 index 0000000000000..a5ef31b358494 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Html/Breadcrumbs.php @@ -0,0 +1,25 @@ +_rootElement->getText(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php index 3375541068cb1..31f1a6fd97bac 100644 --- a/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php +++ b/dev/tests/functional/tests/app/Magento/Theme/Test/Block/Links.php @@ -75,8 +75,11 @@ public function openLink($linkTitle) */ public function isLinkVisible($linkTitle) { - $this->expandCustomerMenu(); - return $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH)->isVisible(); + $link = $this->_rootElement->find(sprintf($this->link, $linkTitle), Locator::SELECTOR_XPATH); + if (!$link->isVisible()) { + $this->expandCustomerMenu(); + } + return $link->isVisible(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index f8091af4cc497..5757bf446e6ee 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -121,6 +121,13 @@ class DataGrid extends Grid */ protected $noRecords = '[class$=no-data]'; + /** + * Selector for alert. + * + * @var string + */ + protected $alertModal = '._show[data-role=modal]'; + /** * Clear all applied Filters. * @@ -250,7 +257,10 @@ public function massaction(array $items, $action, $acceptAlert = false, $massAct ->find(sprintf($this->massActionToggleList, $actionType), Locator::SELECTOR_XPATH) ->click(); if ($acceptAlert) { - $this->browser->find($this->actionButton)->click(); + $element = $this->browser->find($this->alertModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php new file mode 100644 index 0000000000000..96ed46ae296cd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/Modal.php @@ -0,0 +1,94 @@ +_rootElement->find($this->acceptButtonSelector)->click(); + } + + /** + * Press Cancel on an alert, confirm, prompt a dialog. + * + * @return void + */ + public function dismissAlert() + { + $this->_rootElement->find($this->dismissButtonSelector)->click(); + } + + /** + * Press Close on an alert, confirm, prompt a dialog. + * + * @return void + */ + public function closeAlert() + { + $this->_rootElement->find($this->closeButtonSelector)->click(); + } + + /** + * Get the alert dialog text. + * + * @return string + */ + public function getAlertText() + { + return $this->_rootElement->find($this->inputFieldSelector)->getValue(); + } + + /** + * Set the text to a prompt popup. + * + * @param string $text + * @return void + */ + public function setAlertText($text) + { + $this->_rootElement->find($this->inputFieldSelector)->setValue($text); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml index 6c3a76c5c9986..d739d5bae2626 100644 --- a/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Ups/Test/TestCase/OnePageCheckoutTest.xml @@ -6,12 +6,12 @@ */ --> - + catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product login default - US_address_1 + US_address_1_without_email United Parcel Service UPS Ground UPS Ground @@ -27,12 +27,13 @@ guest default UK_address - UK_address + UK_address United Parcel Service UPS Worldwide Expedited UPS Worldwide Expedited checkmo checkmo, ups, shipping_origin_US_CA + test_type:3rd_party_test diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml index 77022c54f4f73..96a0d514a3073 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/Page/Adminhtml/UrlRewriteEdit.xml @@ -6,13 +6,14 @@ */ --> - - - - - - - - - + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php index 75365689598a4..a7eebdeae3e29 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.php @@ -82,5 +82,6 @@ public function test(UrlRewrite $urlRewrite) } $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php index f5592e87abef0..d34485b7819e7 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCustomUrlRewriteEntityTest.php @@ -78,5 +78,6 @@ public function test(UrlRewrite $urlRewrite) $filter = ['request_path' => $urlRewrite->getRequestPath()]; $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php index c668f0512eabd..5673b0ae5e35c 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteProductUrlRewriteEntityTest.php @@ -80,5 +80,6 @@ public function test(UrlRewrite $productRedirect) $filter = ['request_path' => $productRedirect->getRequestPath()]; $this->urlRewriteIndex->getUrlRedirectGrid()->searchAndOpen($filter); $this->urlRewriteEdit->getPageMainActions()->delete(); + $this->urlRewriteEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php index c2cf7eaf64395..4c75ccbc6e183 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/Block/Adminhtml/User/Edit/PageActions.php @@ -21,6 +21,13 @@ class PageActions extends FormPageActions */ protected $forceSignIn = '#invalidate'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Click on 'Force Sign-In' button. * @@ -29,6 +36,9 @@ class PageActions extends FormPageActions public function forceSignIn() { $this->_rootElement->find($this->forceSignIn)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml index 63f872991799b..67a3334680817 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserEdit.xml @@ -6,10 +6,11 @@ */ --> - - - - - - + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml index 739a150f8a484..4f30dddd026cc 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Page/Adminhtml/UserRoleEditRole.xml @@ -6,9 +6,10 @@ */ --> - - - - - + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php index 662992062276a..0e0c500fc5f12 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php @@ -120,6 +120,7 @@ public function testDeleteAdminUserEntity( $this->userIndex->open(); $this->userIndex->getUserGrid()->searchAndOpen($filter); $this->userEdit->getPageActions()->delete(); + $this->userEdit->getModalBlock()->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php index 22421a9557c82..8f66d93cc0831 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteUserRoleEntityTest.php @@ -122,6 +122,7 @@ public function testDeleteAdminUserRole( $this->userRoleIndex->open(); $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter); $this->userRoleEditRole->getPageActions()->delete(); + $this->userRoleEditRole->getModalBlock()->acceptAlert(); } /** diff --git a/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml index 7f049503781c6..cf2ad50688a9e 100644 --- a/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Usps/Test/TestCase/OnePageCheckoutTest.xml @@ -6,12 +6,12 @@ */ --> - + catalogProductSimple::default, configurableProduct::default, bundleProduct::bundle_fixed_product login default - US_address_1 + US_address_1_without_email United States Postal Service Priority Mail 1-Day Priority Mail 1-Day @@ -27,12 +27,13 @@ guest default UK_address - UK_address + UK_address United States Postal Service Priority Mail International Priority Mail International checkmo checkmo, usps, shipping_origin_US_CA + test_type:3rd_party_test diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php index 8fa7f1fc390d3..fab74ada1dcf7 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/Block/Adminhtml/System/Variable/FormPageActions.php @@ -35,6 +35,13 @@ class FormPageActions extends AbstractFormPageActions */ protected $storeView = './/*/a[contains(text(),"%s")]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Select Store View. * @@ -56,7 +63,10 @@ public function selectStoreView($storeName) } else { throw new \Exception('Store View with name \'' . $storeName . '\' is not visible!'); } - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); return null; } diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml b/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml index 1ef12a76ebccb..294fbe0a1e976 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/Page/Adminhtml/SystemVariableNew.xml @@ -6,8 +6,9 @@ */ --> - - - - + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php index 48ae7608c5683..a52fdc02ca3c2 100644 --- a/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Variable/Test/TestCase/DeleteCustomVariableEntityTest.php @@ -80,5 +80,6 @@ public function test(SystemVariable $systemVariable) $this->systemVariableIndexPage->open(); $this->systemVariableIndexPage->getSystemVariableGrid()->searchAndOpen($filter); $this->systemVariableNewPage->getFormPageActions()->delete(); + $this->systemVariableNewPage->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml b/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml index ce17b52e6d47f..a91e0a5d3c3e4 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Page/Adminhtml/WidgetInstanceEdit.xml @@ -10,5 +10,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php index b89af1b2bc4e7..076cc16f6fef7 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/DeleteWidgetEntityTest.php @@ -77,5 +77,6 @@ public function test(Widget $widget) $this->widgetInstanceIndex->open(); $this->widgetInstanceIndex->getWidgetGrid()->searchAndOpen($filter); $this->widgetInstanceEdit->getPageActionsBlock()->delete(); + $this->widgetInstanceEdit->getModalBlock()->acceptAlert(); } } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php index fd5825cb022ec..f3d8184eea17d 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestStep/DeleteAllWidgetsStep.php @@ -55,6 +55,7 @@ public function run() $this->widgetInstanceIndex->getWidgetGrid()->openFirstRow(); $this->widgetInstanceEdit->getTemplateBlock()->waitLoader(); $this->widgetInstanceEdit->getPageActionsBlock()->delete(); + $this->widgetInstanceEdit->getModalBlock()->acceptAlert(); $this->widgetInstanceIndex->getSystemMessageDialog()->closePopup(); } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php index e7147535ce163..a13e0feda8523 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Block/Adminhtml/Customer/Edit/Tab/Wishlist/Grid.php @@ -57,6 +57,13 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid */ protected $rowTemplateStrict = 'td[contains(.,normalize-space("%s"))]'; + /** + * Selector for confirm. + * + * @var string + */ + protected $confirmModal = '.confirm._show[data-role=modal]'; + /** * Delete product * @@ -65,7 +72,10 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid protected function delete() { $this->_rootElement->find($this->rowItem . ' ' . $this->deleteLink)->click(); - $this->browser->acceptAlert(); + $element = $this->browser->find($this->confirmModal); + /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ + $modal = $this->blockFactory->create('Magento\Ui\Test\Block\Adminhtml\Modal', ['element' => $element]); + $modal->acceptAlert(); } /** diff --git a/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php b/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php index 4e59fa47d7da9..7f624342718b7 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Db/ConnectionAdapter.php @@ -7,7 +7,7 @@ */ namespace Magento\TestFramework\Db; -class ConnectionAdapter extends \Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql +class ConnectionAdapter extends \Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql { /** * Retrieve DB connection class name diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options.php new file mode 100644 index 0000000000000..b4e01574fae77 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options.php @@ -0,0 +1,79 @@ +create('Magento\Sales\Model\Order\Address', ['data' => $addressData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +$payment = $objectManager->create('Magento\Sales\Model\Order\Payment'); +$payment->setMethod('checkmo'); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create('Magento\Catalog\Model\Product'); +$product->load(3); + +/** @var $typeInstance \Magento\Bundle\Model\Product\Type */ +$typeInstance = $product->getTypeInstance(); +$typeInstance->setStoreFilter($product->getStoreId(), $product); +$optionCollection = $typeInstance->getOptionsCollection($product); + +$bundleOptions = []; +$bundleOptionsQty = []; +foreach ($optionCollection as $option) { + /** @var $option \Magento\Bundle\Model\Option */ + $selectionsCollection = $typeInstance->getSelectionsCollection([$option->getId()], $product); + if ($option->isMultiSelection()) { + $bundleOptions[$option->getId()] = array_column($selectionsCollection->toArray(), 'selection_id'); + } else { + $bundleOptions[$option->getId()] = $selectionsCollection->getFirstItem()->getSelectionId(); + } + $bundleOptionsQty[$option->getId()] = 1; +} + +$requestInfo = [ + 'product' => $product->getId(), + 'bundle_option' => $bundleOptions, + 'bundle_option_qty' => $bundleOptionsQty, + 'qty' => 1, +]; + +/** @var \Magento\Sales\Model\Order\Item $orderItem */ +$orderItem = $objectManager->create('Magento\Sales\Model\Order\Item'); +$orderItem->setProductId($product->getId()); +$orderItem->setQtyOrdered(1); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType($product->getTypeId()); +$orderItem->setProductOptions(['info_buyRequest' => $requestInfo]); + +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->setIncrementId('100000001'); +$order->setState(\Magento\Sales\Model\Order::STATE_NEW); +$order->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_NEW)); +$order->setCustomerIsGuest(true); +$order->setCustomerEmail('customer@null.com'); +$order->setCustomerFirstname('firstname'); +$order->setCustomerLastname('lastname'); +$order->setBillingAddress($billingAddress); +$order->setShippingAddress($shippingAddress); +$order->setAddresses([$billingAddress, $shippingAddress]); +$order->setPayment($payment); +$order->addItem($orderItem); +$order->setStoreId($objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId()); +$order->setSubtotal(100); +$order->setBaseSubtotal(100); +$order->setBaseGrandTotal(100); +$order->save(); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options_rollback.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options_rollback.php new file mode 100644 index 0000000000000..e528be5818b7b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/order_item_with_bundle_and_options_rollback.php @@ -0,0 +1,8 @@ +create('Magento\Sales\Model\Order\Address', ['data' => $addressData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +$payment = $objectManager->create('Magento\Sales\Model\Order\Payment'); +$payment->setMethod('checkmo'); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create('Magento\Catalog\Model\Product'); +$product->load(1); + +$optionValuesByType = [ + 'field' => 'Test value', + 'date_time' => [ + 'year' => '2015', + 'month' => '9', + 'day' => '9', + 'hour' => '2', + 'minute' => '2', + 'day_part' => 'am', + 'date_internal' => '', + ], + 'drop_down' => '3-1-select', + 'radio' => '4-1-radio', +]; + +$requestInfo = ['options' => []]; +$productOptions = $product->getOptions(); +foreach ($productOptions as $option) { + $requestInfo['options'][$option->getOptionId()] = $optionValuesByType[$option->getType()]; +} + +/** @var \Magento\Sales\Model\Order\Item $orderItem */ +$orderItem = $objectManager->create('Magento\Sales\Model\Order\Item'); +$orderItem->setProductId($product->getId()); +$orderItem->setQtyOrdered(1); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType($product->getTypeId()); +$orderItem->setProductOptions(['info_buyRequest' => $requestInfo]); + +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->setIncrementId('100000001'); +$order->setState(\Magento\Sales\Model\Order::STATE_NEW); +$order->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_NEW)); +$order->setCustomerIsGuest(true); +$order->setCustomerEmail('customer@null.com'); +$order->setCustomerFirstname('firstname'); +$order->setCustomerLastname('lastname'); +$order->setBillingAddress($billingAddress); +$order->setShippingAddress($shippingAddress); +$order->setAddresses([$billingAddress, $shippingAddress]); +$order->setPayment($payment); +$order->addItem($orderItem); +$order->setStoreId($objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId()); +$order->setSubtotal(100); +$order->setBaseSubtotal(100); +$order->setBaseGrandTotal(100); +$order->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/order_item_with_product_and_custom_options_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/order_item_with_product_and_custom_options_rollback.php new file mode 100644 index 0000000000000..dc1ef8a350e6b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/order_item_with_product_and_custom_options_rollback.php @@ -0,0 +1,8 @@ +_model = Bootstrap::getObjectManager()->create('Magento\Checkout\Model\Type\Onepage'); - /** @var \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection */ - $quoteCollection = Bootstrap::getObjectManager()->create('Magento\Quote\Model\ResourceModel\Quote\Collection'); - /** @var \Magento\Quote\Model\Quote $quote */ - $this->_currentQuote = $quoteCollection->getLastItem(); - $this->_model->setQuote($this->_currentQuote); - } - - /** - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testSaveShippingWithCustomerId() - { - $this->_currentQuote->setCustomerId(1)->save(); - $data = [ - 'address_id' => '', - 'firstname' => 'Joe', - 'lastname' => 'Black', - 'company' => 'Lunatis', - 'street' => ['1100 Parmer', 'ln.'], - 'city' => 'Austin', - 'region_id' => '57', - 'region' => '', - 'postcode' => '78757', - 'country_id' => 'US', - 'telephone' => '(512) 999-9999', - 'fax' => '', - 'save_in_address_book' => 1, - ]; - $this->_model->saveShipping($data, 1); - - $address = $this->_currentQuote->getShippingAddress(); - - /* Verify that data from Customer Address identified by id=1 is set */ - $this->assertEquals('John', $address->getFirstname()); - $this->assertEquals('Smith', $address->getLastname()); - $this->assertEquals(['Green str, 67'], $address->getStreet()); - $this->assertEquals('CityM', $address->getCity()); - $this->assertEquals('Alabama', $address->getRegion()); - $this->assertEquals(1, $address->getRegionId()); - $this->assertEquals('75477', $address->getPostcode()); - $this->assertEquals('US', $address->getCountryId()); - $this->assertEquals('3468676', $address->getTelephone()); - $this->assertEquals('customer@example.com', $address->getEmail()); - $this->assertTrue($address->getCollectShippingRates()); - $this->assertEquals(1, $address->getCustomerAddressId()); - } - - /** - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testSaveShippingWithData() - { - $data = [ - 'address_id' => '', - 'firstname' => 'Joe', - 'lastname' => 'Black', - 'company' => 'Lunatis', - 'street' => ['1100 Parmer', 'ln.'], - 'city' => 'Austin', - 'region_id' => '57', - 'region' => '', - 'postcode' => '78757', - 'country_id' => 'US', - 'telephone' => '(512) 999-9999', - 'save_in_address_book' => 1, - ]; - $this->_model->saveShipping($data, null); - - $address = $this->_currentQuote->getShippingAddress(); - - /* Verify that data from the form is set */ - $this->assertEquals('Joe', $address->getFirstname()); - $this->assertEquals('Black', $address->getLastname()); - $this->assertEquals('Lunatis', $address->getCompany()); - $this->assertEquals("1100 Parmer\nln.", $address->getData('street')); - $this->assertEquals('Austin', $address->getCity()); - $this->assertEquals('US', $address->getCountryId()); - $this->assertEquals('Texas', $address->getRegion()); - $this->assertEquals('57', $address->getRegionId()); - $this->assertEquals('78757', $address->getPostcode()); - $this->assertEquals('(512) 999-9999', $address->getTelephone()); - $this->assertNull($address->getCustomerAddressId()); - } - - /** - * @magentoAppIsolation enabled - */ - public function testSaveOrder() - { - $this->markTestIncomplete('MAGETWO-31257'); - $this->_model->saveBilling($this->_getCustomerData(), null); - $this->_prepareQuote($this->_getQuote()); - - $this->_model->saveOrder(); - - /** @var $order \Magento\Sales\Model\Order */ - $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order'); - $order->loadByIncrementId($this->_model->getLastOrderId()); - - $this->assertNotEmpty( - $this->_model->getQuote()->getShippingAddress()->getCustomerAddressId(), - 'Quote shipping CustomerAddressId should not be empty' - ); - $this->assertNotEmpty( - $this->_model->getQuote()->getBillingAddress()->getCustomerAddressId(), - 'Quote billing CustomerAddressId should not be empty' - ); - - $this->assertNotEmpty( - $order->getShippingAddress()->getCustomerAddressId(), - 'Order shipping CustomerAddressId should not be empty' - ); - $this->assertNotEmpty( - $order->getBillingAddress()->getCustomerAddressId(), - 'Order billing CustomerAddressId should not be empty' - ); - } - - /** - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testInitCheckoutNotLoggedIn() - { - /* The customer session must be cleared before the real test begins. Need to - have a customer via the data fixture to actually log out. */ - /** @var $customerSession \Magento\Customer\Model\Session*/ - $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session'); - $customerSession->setCustomerId(1); - $customerSession->logout(); - - $this->_model->saveBilling($this->_getCustomerData(), null); - $this->_prepareQuote($this->_getQuote()); - $this->assertTrue($this->_model->getCheckout()->getSteps()['shipping']['allow']); - $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']); - $this->_model->initCheckout(); - $this->assertFalse($this->_model->getCheckout()->getSteps()['shipping']['allow']); - $this->assertFalse($this->_model->getCheckout()->getSteps()['billing']['allow']); - $this->assertNull($this->_model->getQuote()->getCustomer()->getEmail()); - } - - /** - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testInitCheckoutLoggedIn() - { - $this->_model->saveBilling($this->_getCustomerData(), null); - $this->_prepareQuote($this->_getQuote()); - $customerIdFromFixture = 1; - $emailFromFixture = 'customer@example.com'; - /** @var $customerSession \Magento\Customer\Model\Session*/ - $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session'); - /** @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface */ - $customerRepository = Bootstrap::getObjectManager()->create( - 'Magento\Customer\Api\CustomerRepositoryInterface' - ); - $customerData = $customerRepository->getById($customerIdFromFixture); - $customerSession->setCustomerDataObject($customerData); - $this->_model = Bootstrap::getObjectManager()->create( - 'Magento\Checkout\Model\Type\Onepage', - ['customerSession' => $customerSession] - ); - $this->assertTrue($this->_model->getCheckout()->getSteps()['shipping']['allow']); - $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']); - $this->_model->initCheckout(); - $this->assertFalse($this->_model->getCheckout()->getSteps()['shipping']['allow']); - //When the user is logged in and for Step billing - allow is not reset to true - $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']); - $this->assertEquals($emailFromFixture, $this->_model->getQuote()->getCustomer()->getEmail()); - } - - /** - * New customer, the same address should be used for shipping and billing, it should be persisted to DB. - * - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - */ - public function testSaveBillingSameAsShipping() - { - $quote = $this->_model->getQuote(); - - /** Preconditions */ - $customerData = $this->_getCustomerData(); - $customerAddressId = false; - $this->assertEquals(1, $customerData['use_for_shipping'], "Precondition failed: use_for_shipping is invalid"); - $this->assertEquals( - 1, - $customerData['save_in_address_book'], - "Precondition failed: save_in_address_book is invalid" - ); - $this->assertEmpty( - $quote->getBillingAddress()->getId(), - "Precondition failed: billing address must not be initialized." - ); - $this->assertEmpty( - $quote->getShippingAddress()->getId(), - "Precondition failed: billing address must not be initialized." - ); - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $this->assertEquals([], $result, 'Return value is invalid'); - - /** Ensure that quote addresses were persisted correctly */ - $billingAddress = $quote->getBillingAddress(); - $shippingAddress = $quote->getShippingAddress(); - - $quoteAddressFieldsToCheck = [ - 'quote_id' => $quote->getId(), - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => 'John.Smith@example.com', - 'street' => '6131 Monterey Rd, Apt 1', - 'city' => 'Los Angeles', - 'postcode' => '90042', - 'country_id' => 'US', - 'region_id' => '1', - 'region' => 'Alabama', - 'telephone' => '(323) 255-5861', - 'customer_id' => null, - 'customer_address_id' => null, - ]; - - foreach ($quoteAddressFieldsToCheck as $field => $value) { - $this->assertEquals($value, $billingAddress->getData($field), "{$field} value is invalid"); - $this->assertEquals($value, $shippingAddress->getData($field), "{$field} value is invalid"); - } - $this->assertEquals('1', $shippingAddress->getData('same_as_billing'), "same_as_billing value is invalid"); - $this->assertGreaterThan(0, $shippingAddress->getData('address_id'), "address_id value is invalid"); - $this->assertGreaterThan(0, $billingAddress->getData('address_id'), "address_id value is invalid"); - $this->assertEquals( - 1, - $billingAddress->getData('save_in_address_book'), - "save_in_address_book value is invalid" - ); - $this->assertEquals( - 0, - $shippingAddress->getData('save_in_address_book'), - "As soon as 'same_as_billing' is set to 1, 'save_in_address_book' of shipping should be 0" - ); - - /** Ensure that customer-related data was ported to quote correctly */ - $quoteFieldsToCheck = [ - 'customer_firstname' => 'John', - 'customer_lastname' => 'Smith', - 'customer_email' => 'John.Smith@example.com', - ]; - foreach ($quoteFieldsToCheck as $field => $value) { - $this->assertEquals($value, $quote->getData($field), "{$field} value is set to quote incorrectly."); - } - - /** Perform if checkout steps status was correctly updated in session */ - /** @var \Magento\Checkout\Model\Session $checkoutSession */ - $checkoutSession = Bootstrap::getObjectManager()->get('Magento\Checkout\Model\Session'); - $this->assertTrue($checkoutSession->getStepData('billing', 'allow'), 'Billing step should be allowed.'); - $this->assertTrue($checkoutSession->getStepData('billing', 'complete'), 'Billing step should be completed.'); - $this->assertTrue($checkoutSession->getStepData('shipping', 'allow'), 'Shipping step should be allowed.'); - } - - /** - * New customer, billing address should not be used as shipping address, it should be persisted to DB. - * - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - */ - public function testSaveBilling() - { - $quote = $this->_model->getQuote(); - - /** Preconditions */ - $customerData = $this->_getCustomerData(); - $customerData['use_for_shipping'] = 0; - $customerAddressId = false; - $this->assertEquals( - 1, - $customerData['save_in_address_book'], - "Precondition failed: save_in_address_book is invalid" - ); - $this->assertEmpty( - $quote->getBillingAddress()->getId(), - "Precondition failed: billing address must not be initialized." - ); - $this->assertEmpty( - $quote->getShippingAddress()->getId(), - "Precondition failed: billing address must not be initialized." - ); - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $this->assertEquals([], $result, 'Return value is invalid'); - - /** Ensure that quote addresses were persisted correctly */ - $billingAddress = $quote->getBillingAddress(); - $shippingAddress = $quote->getShippingAddress(); - - $quoteAddressFieldsToCheck = [ - 'quote_id' => $quote->getId(), - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => 'John.Smith@example.com', - 'street' => '6131 Monterey Rd, Apt 1', - 'city' => 'Los Angeles', - 'postcode' => '90042', - 'country_id' => 'US', - 'region_id' => '1', - 'region' => 'Alabama', - 'telephone' => '(323) 255-5861', - 'customer_id' => null, - 'customer_address_id' => null, - ]; - - foreach ($quoteAddressFieldsToCheck as $field => $value) { - $this->assertEquals($value, $billingAddress->getData($field), "{$field} value is invalid"); - } - $this->assertGreaterThan(0, $billingAddress->getData('address_id'), "address_id value is invalid"); - $this->assertEmpty( - $shippingAddress->getData('firstname'), - "Shipping address should not be populated with billing address data when 'same_as_billing' is set to 0." - ); - $this->assertEquals( - 1, - $billingAddress->getData('save_in_address_book'), - "save_in_address_book value is invalid" - ); - - /** Ensure that customer-related data was ported to quote correctly */ - $quoteFieldsToCheck = [ - 'customer_firstname' => 'John', - 'customer_lastname' => 'Smith', - 'customer_email' => 'John.Smith@example.com', - ]; - foreach ($quoteFieldsToCheck as $field => $value) { - $this->assertEquals($value, $quote->getData($field), "{$field} value is set to quote incorrectly."); - } - - /** Perform if checkout steps status was correctly updated in session */ - /** @var \Magento\Checkout\Model\Session $checkoutSession */ - $checkoutSession = Bootstrap::getObjectManager()->get('Magento\Checkout\Model\Session'); - $this->assertTrue($checkoutSession->getStepData('billing', 'allow'), 'Billing step should be allowed.'); - $this->assertTrue($checkoutSession->getStepData('billing', 'complete'), 'Billing step should be completed.'); - $this->assertTrue($checkoutSession->getStepData('shipping', 'allow'), 'Shipping step should be allowed.'); - } - - /** - * New address, address data is invalid. - */ - public function testSaveBillingValidationErrorNewAddress() - { - /** Preconditions */ - $customerData = $this->_getCustomerData(); - unset($customerData['firstname']); - $customerAddressId = false; - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $validationErrors = [ - '"First Name" is a required value.', - '"First Name" length must be equal or greater than 1 characters.', - ]; - $this->assertEquals( - ['error' => 1, 'message' => $validationErrors], - $result, - 'Validation error is invalid.' - ); - } - - /** - * Existing address, address data is invalid. - * - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testSaveBillingExistingAddressInvalidData() - { - /** Preconditions */ - $addressIdFromFixture = 1; - $customerIdFromFixture = 1; - $customerData = $this->_getCustomerData(); - unset($customerData['firstname']); - $this->_getQuote()->setCustomerId($customerIdFromFixture); - - /** Execute SUT */ - /** - * If customer address is available, provided customer data is not validated, - * that's why no error occurs when invalid data is provided - */ - $result = $this->_model->saveBilling($customerData, $addressIdFromFixture); - $this->assertEquals([], $result, 'No errors expected.'); - } - - /** - * Address exists, but it does not belong to the current customer which is set to quote. - * - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - */ - public function testSaveBillingInvalidAddressId() - { - /** Preconditions */ - $addressIdFromFixture = 1; - $customerData = $this->_getCustomerData(); - unset($customerData['firstname']); - /** Any ID can be used, which is not equal to ID of customer to which current address belongs. */ - $secondCustomerId = 2; - $this->_getQuote()->setCustomerId($secondCustomerId); - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $addressIdFromFixture); - $validationErrors = 'The customer address is not valid.'; - $this->assertEquals( - ['error' => 1, 'message' => $validationErrors], - $result, - 'Validation error is invalid.' - ); - } - - /** - * Empty data. - */ - public function testSaveBillingEmptyData() - { - /** Execute SUT */ - $customerData = []; - $customerAddressId = false; - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $this->assertEquals( - ['error' => -1, 'message' => 'Invalid data'], - $result, - 'Validation error is invalid.' - ); - } - - /** - * Address does not exist, but existing email is specified in address data. - * - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testSaveBillingNewAddressErrorExistingEmail() - { - /** Preconditions */ - $customerData = $this->_getCustomerData(); - $fixtureCustomerEmail = 'customer@example.com'; - $customerData['email'] = $fixtureCustomerEmail; - $customerAddressId = false; - $this->_getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $this->assertArrayHasKey('message', $result, 'Error message was expected to be set'); - $this->assertStringStartsWith( - 'This email address already belongs to a registered customer.', - (string)$result['message'], - 'Validation error is invalid.' - ); - } - - /** - * New address, customer address is invalid (customer validation should fail, not address validation). - */ - public function testSaveBillingInvalidCustomerData() - { - /** Preconditions */ - $customerData = $this->_getCustomerData(); - $customerData['email'] = 'invalidemail'; - $this->_getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); - $customerAddressId = false; - - /** Execute SUT */ - $result = $this->_model->saveBilling($customerData, $customerAddressId); - $validationErrors = '"Email" is not a valid email address.'; - $this->assertEquals( - ['error' => -1, 'message' => $validationErrors], - $result, - 'Validation error is invalid.' - ); - } - - /** - * @return \Magento\Quote\Model\Quote - */ - protected function _getQuote() - { - return $this->_currentQuote; - } - - /** - * Prepare Quote - * - * @param \Magento\Quote\Model\Quote $quote - */ - protected function _prepareQuote($quote) - { - /** @var $rate \Magento\Quote\Model\Quote\Address\Rate */ - $rate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Quote\Model\Quote\Address\Rate' - ); - $rate->setCode('freeshipping_freeshipping'); - $rate->getPrice(1); - - $quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping'); - $quote->getShippingAddress()->addShippingRate($rate); - $quote->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER); - } - - /** - * Customer data for quote - * - * @return array - */ - protected function _getCustomerData() - { - return [ - 'firstname' => 'John', - 'lastname' => 'Smith', - 'email' => 'John.Smith@example.com', - 'street' => ['6131 Monterey Rd, Apt 1', ''], - 'city' => 'Los Angeles', - 'postcode' => '90042', - 'country_id' => 'US', - 'region_id' => '1', - 'telephone' => '(323) 255-5861', - 'customer_password' => 'password', - 'confirm_password' => 'password', - 'save_in_address_book' => '1', - 'use_for_shipping' => '1' - ]; - } -} diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php new file mode 100644 index 0000000000000..3a63d6c93e73e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options.php @@ -0,0 +1,70 @@ +create('Magento\Sales\Model\Order\Address', ['data' => $addressData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +$payment = $objectManager->create('Magento\Sales\Model\Order\Payment'); +$payment->setMethod('checkmo'); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create('Magento\Catalog\Model\Product'); +$product->load(1); + +/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ +$eavConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Eav\Model\Config'); +$attribute = $eavConfig->getAttribute('catalog_product', 'test_configurable'); + +/** @var $options \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection */ +$options = $objectManager->create('Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection'); +$option = $options->setAttributeFilter($attribute->getId()) + ->getFirstItem(); + +$requestInfo = [ + 'qty' => 1, + 'super_attribute' => [ + $attribute->getId() => $option->getId(), + ], +]; + +/** @var \Magento\Sales\Model\Order\Item $orderItem */ +$orderItem = $objectManager->create('Magento\Sales\Model\Order\Item'); +$orderItem->setProductId($product->getId()); +$orderItem->setQtyOrdered(1); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType($product->getTypeId()); +$orderItem->setProductOptions(['info_buyRequest' => $requestInfo]); + +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->setIncrementId('100000001'); +$order->setState(\Magento\Sales\Model\Order::STATE_NEW); +$order->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_NEW)); +$order->setCustomerIsGuest(true); +$order->setCustomerEmail('customer@null.com'); +$order->setCustomerFirstname('firstname'); +$order->setCustomerLastname('lastname'); +$order->setBillingAddress($billingAddress); +$order->setShippingAddress($shippingAddress); +$order->setAddresses([$billingAddress, $shippingAddress]); +$order->setPayment($payment); +$order->addItem($orderItem); +$order->setStoreId($objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId()); +$order->setSubtotal(100); +$order->setBaseSubtotal(100); +$order->setBaseGrandTotal(100); +$order->save(); diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options_rollback.php new file mode 100644 index 0000000000000..bb2003ecfc1e4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/order_item_with_configurable_and_options_rollback.php @@ -0,0 +1,8 @@ +create('Magento\Sales\Model\Order\Address', ['data' => $addressData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +$payment = $objectManager->create('Magento\Sales\Model\Order\Payment'); +$payment->setMethod('checkmo'); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create('Magento\Catalog\Model\Product'); +$product->load(1); + +$requestInfo = [ + 'links' => array_keys($product->getDownloadableLinks()), +]; + +/** @var \Magento\Sales\Model\Order\Item $orderItem */ +$orderItem = $objectManager->create('Magento\Sales\Model\Order\Item'); +$orderItem->setProductId($product->getId()); +$orderItem->setQtyOrdered(1); +$orderItem->setBasePrice($product->getPrice()); +$orderItem->setPrice($product->getPrice()); +$orderItem->setRowTotal($product->getPrice()); +$orderItem->setProductType($product->getTypeId()); +$orderItem->setProductOptions(['info_buyRequest' => $requestInfo]); + +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create('Magento\Sales\Model\Order'); +$order->setIncrementId('100000001'); +$order->setState(\Magento\Sales\Model\Order::STATE_NEW); +$order->setStatus($order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_NEW)); +$order->setCustomerIsGuest(true); +$order->setCustomerEmail('customer@null.com'); +$order->setCustomerFirstname('firstname'); +$order->setCustomerLastname('lastname'); +$order->setBillingAddress($billingAddress); +$order->setShippingAddress($shippingAddress); +$order->setAddresses([$billingAddress, $shippingAddress]); +$order->setPayment($payment); +$order->addItem($orderItem); +$order->setStoreId($objectManager->get('Magento\Store\Model\StoreManagerInterface')->getStore()->getId()); +$order->setSubtotal(100); +$order->setBaseSubtotal(100); +$order->setBaseGrandTotal(100); +$order->save(); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_item_with_downloadable_and_options_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_item_with_downloadable_and_options_rollback.php new file mode 100644 index 0000000000000..3d18328b96d75 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_item_with_downloadable_and_options_rollback.php @@ -0,0 +1,8 @@ + [ TemplateTypesInterface::TYPE_HTML, 'file="css/file-with-error.css"', - \Magento\Framework\Css\PreProcessor\AdapterInterface::ERROR_MESSAGE_PREFIX, + \Magento\Framework\View\Asset\ContentProcessorInterface::ERROR_MESSAGE_PREFIX, ], ]; } @@ -356,7 +356,7 @@ public function inlinecssDirectiveDataProvider() ], 'Developer mode - File with compilation error results in error message' => [ '

{{inlinecss file="css/file-with-error.css"}}', - \Magento\Framework\Css\PreProcessor\AdapterInterface::ERROR_MESSAGE_PREFIX, + \Magento\Framework\View\Asset\ContentProcessorInterface::ERROR_MESSAGE_PREFIX, false, ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/OyejorgeTest.php b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/OyejorgeTest.php deleted file mode 100644 index 399f0b7a44bfd..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/OyejorgeTest.php +++ /dev/null @@ -1,62 +0,0 @@ -model = $objectManager->create('Magento\Framework\Css\PreProcessor\Adapter\Less\Oyejorge'); - $this->state = $objectManager->get('Magento\Framework\App\State'); - } - - public function testProcess() - { - $sourceFilePath = realpath(__DIR__ . '/_files/oyejorge.less'); - $expectedCss = ($this->state->getMode() === State::MODE_DEVELOPER) - ? file_get_contents(__DIR__ . '/_files/oyejorge_dev.css') - : file_get_contents(__DIR__ . '/_files/oyejorge.css'); - $actualCss = ($this->model->process($sourceFilePath)); - - $this->assertEquals($this->cutCopyrights($expectedCss), $actualCss); - } - - /** - * Cuts copyrights from css source - * - * @param string $cssSource - * @return string - */ - private function cutCopyrights($cssSource) - { - $copyright = <<<'TAG' -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - - -TAG; - return (string)str_replace($copyright, '', $cssSource); - - } -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/nested/import.less b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/nested/import.less deleted file mode 100644 index 0b6a8af1a5130..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/nested/import.less +++ /dev/null @@ -1,6 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -h1 { background-color: red; } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/oyejorge.less b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/oyejorge.less deleted file mode 100644 index c71bb050df796..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/cache/lib/oyejorge.less +++ /dev/null @@ -1,6 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -@import "nested/import.less"; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/nested/import.less b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/nested/import.less deleted file mode 100644 index 2e284b2e8eb87..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/nested/import.less +++ /dev/null @@ -1,6 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -@body-bg-img: url(Magento_Theme::validation_advice_bg.gif); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.css b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.css deleted file mode 100644 index bcf1aa406b5ed..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.css +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -#header{color: #4d926f}h2{color: #4d926f}#header{-webkit-border-radius: 5px;-moz-border-radius: 5px;-ms-border-radius: 5px;-o-border-radius: 5px;border-radius: 5px}#footer{-webkit-border-radius: 10px;-moz-border-radius: 10px;-ms-border-radius: 10px;-o-border-radius: 10px;border-radius: 10px}#header h1{font-size: 26px;font-weight: bold}#header p{font-size: 12px}#header p a{text-decoration: none}#header p a:hover{border-width: 1px}#header{color: #333;border-left: 1px;border-right: 2px}#footer{color: #141;border-color: #7d2717}body{background-image: url(Magento_Theme::validation_advice_bg.gif)} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.less b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.less deleted file mode 100644 index 58914770c2f5d..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge.less +++ /dev/null @@ -1,74 +0,0 @@ -// /** -// * Copyright © 2015 Magento. All rights reserved. -// * See COPYING.txt for license details. -// */ - -// Variables - -@color: #4D926F; - -#header { - color: @color; -} - -h2 { - color: @color; -} - -// Mixins - -.rounded-corners (@radius: 5px) { - -webkit-border-radius: @radius; - -moz-border-radius: @radius; - -ms-border-radius: @radius; - -o-border-radius: @radius; - border-radius: @radius; -} - -#header { - .rounded-corners; -} - -#footer { - .rounded-corners(10px); -} - -// Nested Rules - -#header { - h1 { - font-size: 26px; - font-weight: bold; - } - p { font-size: 12px; - a { - text-decoration: none; - &:hover { - border-width: 1px; - } - } - } -} - -// Functions & Operations - -@the-border: 1px; -@base-color: #111; -@red: #842210; - -#header { - color: (@base-color * 3); - border-left: @the-border; - border-right: (@the-border * 2); -} - -#footer { - color: (@base-color + #003300); - border-color: desaturate(@red, 10%); -} - -@import "nested/import.less"; - -body { - background-image: @body-bg-img; -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge_dev.css b/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge_dev.css deleted file mode 100644 index 0e70c6da760db..0000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Css/PreProcessor/Adapter/Less/_files/oyejorge_dev.css +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -#header { - color: #4d926f; -} -h2 { - color: #4d926f; -} -#header { - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - -ms-border-radius: 5px; - -o-border-radius: 5px; - border-radius: 5px; -} -#footer { - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - -ms-border-radius: 10px; - -o-border-radius: 10px; - border-radius: 10px; -} -#header h1 { - font-size: 26px; - font-weight: bold; -} -#header p { - font-size: 12px; -} -#header p a { - text-decoration: none; -} -#header p a:hover { - border-width: 1px; -} -#header { - color: #333333; - border-left: 1px; - border-right: 2px; -} -#footer { - color: #114411; - border-color: #7d2717; -} -body { - background-image: url(Magento_Theme::validation_advice_bg.gif); -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/AbstractTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/AbstractTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/AbstractTest.php index c772877befa9e..ca8c899be7be3 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/AbstractTest.php @@ -6,12 +6,12 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; class AbstractTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $_model; @@ -19,10 +19,10 @@ protected function setUp() { $resource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\App\ResourceConnection'); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - '\Magento\Framework\Model\ModelResource\Db\Context', + '\Magento\Framework\Model\ResourceModel\Db\Context', ['resource' => $resource] ); - $this->_model = $this->getMockForAbstractClass('Magento\Framework\Model\ModelResource\Db\AbstractDb', + $this->_model = $this->getMockForAbstractClass('Magento\Framework\Model\ResourceModel\Db\AbstractDb', ['context' => $context] ); } @@ -59,11 +59,11 @@ public function testGetTableName() ['tablePrefix' => 'prefix_'] ); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - '\Magento\Framework\Model\ModelResource\Db\Context', + '\Magento\Framework\Model\ResourceModel\Db\Context', ['resource' => $resource] ); - $model = $this->getMockForAbstractClass('Magento\Framework\Model\ModelResource\Db\AbstractDb', + $model = $this->getMockForAbstractClass('Magento\Framework\Model\ResourceModel\Db\AbstractDb', ['context' => $context] ); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/Collection/AbstractTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/Collection/AbstractTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractTest.php index 49449b23aa54b..0bdb5fa5e4bd6 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/Collection/AbstractTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\Collection; +namespace Magento\Framework\Model\ResourceModel\Db\Collection; class AbstractTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection + * @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection */ protected $_model = null; @@ -17,12 +17,12 @@ protected function setUp() $resourceModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get('Magento\Framework\App\ResourceConnection'); $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - '\Magento\Framework\Model\ModelResource\Db\Context', + '\Magento\Framework\Model\ResourceModel\Db\Context', ['resource' => $resourceModel] ); $resource = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [$context], '', true, @@ -52,7 +52,7 @@ protected function setUp() $logger = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Psr\Log\LoggerInterface'); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection', + 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', [$entityFactory, $logger, $fetchStrategy, $eventManager, null, $resource] ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php similarity index 90% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/ProfilerTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php index 98031031fe140..34b1d0a51b312 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Db/ProfilerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php @@ -1,11 +1,11 @@ getConfigData(ConfigOptionsListConstants::KEY_DB); $connectionConfig = $dbConfig['connection']['default']; $connectionConfig['profiler'] = [ - 'class' => 'Magento\Framework\Model\ModelResource\Db\Profiler', + 'class' => 'Magento\Framework\Model\ResourceModel\Db\Profiler', 'enabled' => 'true', ]; @@ -78,9 +78,9 @@ public function testProfilerInit($selectQuery, $queryType) $result->fetchAll(); } - /** @var \Magento\Framework\Model\ModelResource\Db\Profiler $profiler */ + /** @var \Magento\Framework\Model\ResourceModel\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Framework\Model\ModelResource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Framework\Model\ResourceModel\Db\Profiler', $profiler); $queryProfiles = $profiler->getQueryProfiles($queryType); $this->assertCount(1, $queryProfiles); @@ -140,9 +140,9 @@ public function testProfilerDuringSqlException() $testTableName = $resource->getTableName('setup_module'); $connection->query('SELECT * FROM ' . $testTableName); - /** @var \Magento\Framework\Model\ModelResource\Db\Profiler $profiler */ + /** @var \Magento\Framework\Model\ResourceModel\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Framework\Model\ModelResource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Framework\Model\ResourceModel\Db\Profiler', $profiler); $queryProfiles = $profiler->getQueryProfiles(\Magento\Framework\DB\Profiler::SELECT); $this->assertCount(2, $queryProfiles); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Entity/TableTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Entity/TableTest.php similarity index 84% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Entity/TableTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Entity/TableTest.php index 432aa215b12fe..80209e56a038f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Entity/TableTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Entity/TableTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Entity; +namespace Magento\Framework\Model\ResourceModel\Entity; class TableTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Entity\Table + * @var \Magento\Framework\Model\ResourceModel\Entity\Table */ protected $_model; @@ -21,7 +21,7 @@ protected function setUp() // @codingStandardsIgnoreEnd $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create('Magento\Framework\Model\ModelResource\Entity\Table', ['config' => $config]); + ->create('Magento\Framework\Model\ResourceModel\Entity\Table', ['config' => $config]); } public function testGetTable() diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/IteratorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/IteratorTest.php similarity index 88% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/IteratorTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/IteratorTest.php index 930397c73d24f..808ce9113056b 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/IteratorTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/IteratorTest.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource; +namespace Magento\Framework\Model\ResourceModel; class IteratorTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Iterator + * @var \Magento\Framework\Model\ResourceModel\Iterator */ protected $_model; @@ -22,7 +22,7 @@ class IteratorTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Model\ModelResource\Iterator' + 'Magento\Framework\Model\ResourceModel\Iterator' ); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryTest.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryTest.php index a23a42f42d4a6..84ff6306201d6 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type\Db; +namespace Magento\Framework\Model\ResourceModel\Type\Db; class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase { diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/Pdo/MysqlTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/MysqlTest.php similarity index 87% rename from dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/Pdo/MysqlTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/MysqlTest.php index 871c85d9faf5c..f57497cd8e906 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ModelResource/Type/Db/Pdo/MysqlTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/MysqlTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type\Db\Pdo; +namespace Magento\Framework\Model\ResourceModel\Type\Db\Pdo; class MysqlTest extends \PHPUnit_Framework_TestCase { @@ -23,9 +23,9 @@ public function testGetConnection() 'dbname' => $db->getSchema(), 'active' => true, ]; - /** @var \Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql $object */ + /** @var \Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql $object */ $object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - 'Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql', + 'Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql', ['config' => $config] ); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceTest.php index 666627931acc8..961fc60985a5d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceTest.php @@ -1,6 +1,6 @@ [ 'profiler' => [ - 'class' => 'Magento\Framework\Model\ModelResource\Db\Profiler', + 'class' => 'Magento\Framework\Model\ResourceModel\Db\Profiler', 'enabled' => 'true', ], 'username' => 'username', @@ -63,10 +63,10 @@ public function testProfilerInit() ] ); - /** @var \Magento\Framework\Model\ModelResource\Db\Profiler $profiler */ + /** @var \Magento\Framework\Model\ResourceModel\Db\Profiler $profiler */ $profiler = $connection->getProfiler(); - $this->assertInstanceOf('Magento\Framework\Model\ModelResource\Db\Profiler', $profiler); + $this->assertInstanceOf('Magento\Framework\Model\ResourceModel\Db\Profiler', $profiler); $this->assertTrue($profiler->getEnabled()); } } diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json index 436ee0afe3eb6..d8c398fe8f3b0 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/Dependency/_files/composer3.json @@ -2,7 +2,7 @@ "name": "magento/module-module1", "description": "N/A", "require": { - "php": "~5.5.0|~5.6.0" + "php": "~5.5.0|~5.6.0|~7.0.0" }, "type": "magento2-module", "version": "0.1.0-alpha103" diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/ResourceModel/Store/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/ResourceModel/Store/CollectionTest.php index daf46fa185e6e..a7ccac4bbaf0e 100644 --- a/dev/tests/integration/testsuite/Magento/Store/Model/ResourceModel/Store/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/Model/ResourceModel/Store/CollectionTest.php @@ -88,8 +88,8 @@ public function testToOptionArrayHash() } /** - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::addFieldToSelect - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::removeFieldFromSelect + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::addFieldToSelect + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::removeFieldFromSelect */ public function testAddRemoveFieldToSelect() { @@ -108,7 +108,7 @@ public function testAddRemoveFieldToSelect() } /** - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::addExpressionFieldToSelect + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::addExpressionFieldToSelect */ public function testAddExpressionFieldToSelect() { @@ -118,7 +118,7 @@ public function testAddExpressionFieldToSelect() } /** - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::getAllIds + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::getAllIds */ public function testGetAllIds() { @@ -126,7 +126,7 @@ public function testGetAllIds() } /** - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::getData + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::getData */ public function testGetData() { @@ -134,7 +134,7 @@ public function testGetData() } /** - * @covers \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection::join + * @covers \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection::join */ public function testJoin() { diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index a4ce584c44b37..854a38cd66016 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -166,7 +166,7 @@ public function testRoleUserExists() public function testGetCollection() { - $this->assertInstanceOf('Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection', + $this->assertInstanceOf('Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', $this->_model->getCollection()); } diff --git a/dev/tests/js/JsTestDriver/jsTestDriverOrder.php b/dev/tests/js/JsTestDriver/jsTestDriverOrder.php index b12aef10f57a3..6314b1dbd16f5 100644 --- a/dev/tests/js/JsTestDriver/jsTestDriverOrder.php +++ b/dev/tests/js/JsTestDriver/jsTestDriverOrder.php @@ -21,6 +21,5 @@ '/lib/web/mage/decorate.js', '/lib/web/jquery/jquery.validate.js', '/lib/web/jquery/jquery.metadata.js', - '/lib/web/mage/translate.js', - '/lib/web/mage/requirejs/plugin/id-normalizer.js', + '/lib/web/mage/translate.js' ]; diff --git a/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js b/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js deleted file mode 100644 index a52466bda124d..0000000000000 --- a/dev/tests/js/JsTestDriver/testsuite/mage/requirejs/plugin/id-normalizer-test.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -/*jshint globalstrict: true*/ - -"use strict"; - -/*jshint undef: false, newcap: false*/ -var IdNormalizerTest = TestCase('IdNormalizerTest'); - -IdNormalizerTest.prototype.setUp = function() { - var defineArgs = jsunit.requirejsUtil.getDefineArgsInScript('lib/web/mage/requirejs/plugin/id-normalizer.js'); - assertNotUndefined('There expected to be a define() call', defineArgs); - assertEquals('Wrong number of arguments in the define() call', 1, defineArgs.length); - - this.normalizer = defineArgs[0]; - assertObject(this.normalizer); - assertFunction(this.normalizer.normalize); - assertFunction(this.normalizer.load); -}; - -IdNormalizerTest.prototype.testNormalize = function () { - var actual = this.normalizer.normalize('Magento_Catalog::foo/bar.js'); - assertEquals('Magento_Catalog/foo/bar.js', actual); -}; - -IdNormalizerTest.prototype.testLoad = function () { - // Check that load() is just a proxy - var modulePassed, onloadPassed; - var parentRequire = function (moduleIn, onloadIn) { - modulePassed = moduleIn; - onloadPassed = onloadIn; - }; - var onload = function (){}; - - this.normalizer.load('module', parentRequire, onload); - - assertEquals('module', modulePassed); - assertSame(onload, onloadPassed); -}; - diff --git a/dev/tests/js/jasmine/assets/gallery/config.json b/dev/tests/js/jasmine/assets/gallery/config.json index b3c8b8bc0b38d..d1d8e94d7f220 100644 --- a/dev/tests/js/jasmine/assets/gallery/config.json +++ b/dev/tests/js/jasmine/assets/gallery/config.json @@ -59,12 +59,17 @@ "arrows": "false", "thumbwidth": "90", "thumbheight": "90", - "ratio": "1" + "ratio": "1", + "allowfullscreen": true + }, + "fullscreen": { + "nav": false }, "breakpoints": { "alias": { "conditions": { - "min-width": "0px" + "min-width": "0px", + "max-width": "1px" }, "options": { "options": { diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js index a39203675c280..f2edf7f7065c3 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/core/layout.test.js @@ -4,7 +4,7 @@ */ define([ 'underscore', - 'Magento_Ui/js/core/renderer/layout' + 'uiLayout' ], function (_, layout) { 'use strict'; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js index ce954310178c0..3d1e7dcfe0dbe 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/columns/column.test.js @@ -24,17 +24,17 @@ define([ describe('sort method', function () { it('apply sorting first time', function () { column.sort(true); - expect(column.sorting()).toBe('asc'); + expect(column.sorting).toBe('asc'); }); it('apply sorting in other direction', function () { column.sort(true).sort(true); - expect(column.sorting()).toBe('desc'); + expect(column.sorting).toBe('desc'); }); it('remove sorting', function () { column.sort(false); - expect(column.sorting()).toBeFalsy(); + expect(column.sorting).toBeFalsy(); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js similarity index 95% rename from dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js rename to dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js index 59e46e213d7c7..29267c110c52e 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js @@ -5,11 +5,11 @@ define([ 'underscore', - 'Magento_Ui/js/grid/filters/group' + 'Magento_Ui/js/grid/filters/range' ], function (_, Group) { 'use strict'; - describe('ui/js/grid/filters/filters', function () { + describe('ui/js/grid/filters/range', function () { var group; beforeEach(function () { diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js index 43df680002775..ef72deab470d0 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js @@ -17,7 +17,7 @@ define([ paging = new Paging({ pageSize: 2 }); - paging.totalRecords(7); + paging.totalRecords = 7; }); describe('Normalize method', function () { @@ -42,73 +42,73 @@ define([ describe('countPages method', function () { it('correct number of pages', function () { paging.countPages(); - expect(paging.pages()).toBe(4); + expect(paging.pages).toBe(4); }); it('if no records', function () { - paging.totalRecords(0); + paging.totalRecords = 0; paging.countPages(); - expect(paging.pages()).toBe(1); + expect(paging.pages).toBe(1); }); }); describe('page manipualations', function () { it('setPage method', function () { paging.setPage(2); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); it('next', function () { - paging.current(1); + paging.current = 1; paging.next(); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); it('next out of boundary', function () { - paging.current(4); + paging.current = 4; paging.next(); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); }); it('prev', function () { - paging.current(4); + paging.current = 4; paging.prev(); - expect(paging.current()).toBe(3); + expect(paging.current).toBe(3); }); it('prev out of boundary', function () { - paging.current(1); + paging.current = 1; paging.prev(); - expect(paging.current()).toBe(1); + expect(paging.current).toBe(1); }); it('goFirst', function () { paging.goFirst(); - expect(paging.current()).toBe(1); + expect(paging.current).toBe(1); }); it('goLast', function () { paging.goLast(); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); }); it('isFirst for 1st page', function () { - paging.current(1); + paging.current = 1; expect(paging.isFirst()).toBeTruthy(); }); it('isFirst for 2nd page', function () { - paging.current(2); + paging.current = 2; expect(paging.isFirst()).toBeFalsy(); }); it('isLast for last page', function () { - paging.current(4); + paging.current = 4; expect(paging.isLast()).toBeTruthy(); }); it('isLast for first page', function () { - paging.current(1); + paging.current = 1; expect(paging.isLast()).toBeFalsy(); }); }); @@ -116,22 +116,22 @@ define([ describe('countPages method', function () { it('correct number of pages', function () { paging.countPages(); - expect(paging.pages()).toBe(4); + expect(paging.pages).toBe(4); }); it('if no records', function () { - paging.totalRecords(0); + paging.totalRecords = 0; paging.countPages(); - expect(paging.pages()).toBe(1); + expect(paging.pages).toBe(1); }); }); describe('onPagesChange method', function () { it('pages amount became less than current', function () { - paging.current(4); - expect(paging.current()).toBe(4); + paging.current = 4; + expect(paging.current).toBe(4); paging.onPagesChange(2); - expect(paging.current()).toBe(2); + expect(paging.current).toBe(2); }); }); @@ -141,7 +141,7 @@ define([ }); it('read from _current', function () { - paging.current(2); + paging.current = 2; expect(paging._current()).toBe(2); }); @@ -149,7 +149,7 @@ define([ spyOn(paging, 'normalize').and.callThrough(); spyOn(paging._current, 'notifySubscribers'); paging._current(4); - expect(paging.current()).toBe(4); + expect(paging.current).toBe(4); expect(paging._current.notifySubscribers).toHaveBeenCalledWith(4); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js index 04b7f0ebe5a7e..90e17a46a65e1 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/component/links.test.js @@ -3,11 +3,11 @@ * See COPYING.txt for license details. */ define([ - 'Magento_Ui/js/lib/component/links' + 'Magento_Ui/js/lib/core/element/links' ], function (links) { 'use strict'; - describe('Magento_Ui/js/lib/component/links', function () { + describe('Magento_Ui/js/lib/core/element/links', function () { var linksObj, returnedValue; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js index bc2f08748f45e..4ae9b2121426e 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/events.test.js @@ -4,13 +4,13 @@ */ define([ - 'Magento_Ui/js/lib/events' + 'Magento_Ui/js/lib/core/events' ], function (EventBus) { 'use strict'; var EVENT = 'testEvent'; - describe('Magento_Ui/js/lib/events', function () { + describe('Magento_Ui/js/lib/core/events', function () { describe('"on" method', function () { afterEach(function () { EventBus.off(EVENT); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js index 196bdd121dcf3..ac02100dffa90 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/registry/registry.test.js @@ -6,7 +6,7 @@ /*eslint max-nested-callbacks: 0*/ define([ - 'Magento_Ui/js/lib/registry/registry' + 'uiRegistry' ], function (registry) { 'use strict'; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js new file mode 100644 index 0000000000000..548d093942f58 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/alert.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/alert' +], function ($) { + 'use strict'; + + describe('ui/js/modal/alert', function () { + var element = $('
some element
'), + alert = element.alert({}); + + it('Check for modal definition', function () { + expect(alert).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(alert.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js new file mode 100644 index 0000000000000..922a14f54f924 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/confirm.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/confirm' +], function ($) { + 'use strict'; + + describe('ui/js/modal/confirm', function () { + var element = $('
some element
'), + confirm = element.confirm({}); + + it('Check for modal definition', function () { + expect(confirm).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(confirm.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js index 2b1496d56e270..a8f4a13979d06 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/modal.test.js @@ -17,8 +17,11 @@ define([ expect(modal).toBeDefined(); }); it('Show/hide function check', function () { - expect(element.trigger('openDialog')).toBe(element); - expect(element.trigger('closeDialog')).toBe(element); + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect($(modal).length).toEqual(1); }); }); }); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js new file mode 100644 index 0000000000000..1d61f4c735404 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/modal/prompt.test.js @@ -0,0 +1,27 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Ui/js/modal/prompt' +], function ($) { + 'use strict'; + + describe('ui/js/modal/prompt', function () { + var element = $('
some element
'), + prompt = element.prompt({}); + + it('Check for modal definition', function () { + expect(prompt).toBeDefined(); + }); + it('Show/hide function check', function () { + expect(element.trigger('openModal')).toBe(element); + expect(element.trigger('closeModal')).toBe(element); + }); + it('Integration: modal created on page', function () { + expect(prompt.length).toEqual(1); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/lib/mage/gallery.test.js b/dev/tests/js/jasmine/tests/lib/mage/gallery.test.js index f198fee51b045..ffcd3abf327c8 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/gallery.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/gallery.test.js @@ -19,6 +19,7 @@ define([ stageSelector = '[data-gallery-role="stage-shaft"]', navSelector = '[data-gallery-role="nav-frame"]', dotSelector = '[data-nav-type="dot"]', + navWrap = '[data-gallery-role="nav-wrap"]', dataToUpdate = [ { img: 'data:image/png;base64,' + @@ -33,7 +34,16 @@ define([ img: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAw' + 'CAAAAC0lEQVR42mP4Xw8AAoABf5/NhYYAAAAASUVORK5CYII=' } - ]; + ], + waitsFor = function (test, fn) { + if (test()) { + fn(); + } else { + setTimeout(function () { + waitsFor(test, fn); + }, 10); + } + }; gallery(magnifier(conf, body), body); @@ -115,5 +125,30 @@ define([ it('breakpoints override configs', function () { expect($('.fotorama__arr').css('display')).toBe('block'); }); + + it('fullscreen enter', function (done) { + expect($(navWrap).css('display') === 'block').toBeTruthy(); + galleryAPI.fotorama.requestFullScreen(); + + waitsFor(function () { + return $(navWrap).css('display') !== 'block'; + }, function () { + expect($(navWrap).css('display') === 'none').toBeTruthy(); + done(); + }); + }); + + it('fullscreen exit', function (done) { + expect($(navWrap).css('display') === 'none').toBeTruthy(); + galleryAPI.fotorama.cancelFullScreen(); + + waitsFor(function () { + return $(navWrap).css('display') !== 'none'; + }, function () { + expect($(navWrap).css('display') === 'block').toBeTruthy(); + done(); + }); + }); + }); }); diff --git a/dev/tests/static/framework/Magento/Sniffs/NamingConventions/ReservedWordsSniff.php b/dev/tests/static/framework/Magento/Sniffs/NamingConventions/ReservedWordsSniff.php index 734170053c932..e33309f46d88f 100644 --- a/dev/tests/static/framework/Magento/Sniffs/NamingConventions/ReservedWordsSniff.php +++ b/dev/tests/static/framework/Magento/Sniffs/NamingConventions/ReservedWordsSniff.php @@ -12,7 +12,6 @@ class ReservedWordsSniff implements PHP_CodeSniffer_Sniff { /** * source: http://php.net/manual/en/reserved.other-reserved-words.php - * disabled(commented) items are not restricted int PHP 7 beta 3, just declared as prohibited * * @var array PHP 7 reserved words for name spaces */ diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php index 530d99c68dcdf..215df89727a1d 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ComposerTest.php @@ -154,6 +154,7 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json) $xml = simplexml_load_file("$dir/etc/module.xml"); $this->assertConsistentModuleName($xml, $json->name); $this->assertDependsOnPhp($json->require); + $this->assertPhpVersionInSync($json->name, $json->require->php); $this->assertDependsOnFramework($json->require); $this->assertRequireInSync($json); $this->assertAutoload($json); @@ -166,12 +167,14 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json) case 'magento2-theme': $this->assertRegExp('/^magento\/theme-(?:adminhtml|frontend)(\-[a-z0-9_]+)+$/', $json->name); $this->assertDependsOnPhp($json->require); + $this->assertPhpVersionInSync($json->name, $json->require->php); $this->assertDependsOnFramework($json->require); $this->assertRequireInSync($json); break; case 'magento2-library': $this->assertDependsOnPhp($json->require); $this->assertRegExp('/^magento\/framework*/', $json->name); + $this->assertPhpVersionInSync($json->name, $json->require->php); $this->assertRequireInSync($json); $this->assertAutoload($json); break; @@ -277,6 +280,22 @@ private function assertVersionInSync($name, $version) ); } + /** + * Assert that PHP versions in root composer.json and Magento component's composer.json are not out of sync + * + * @param string $name + * @param string $phpVersion + */ + private function assertPhpVersionInSync($name, $phpVersion) + { + $this->assertEquals( + self::$rootJson['require']['php'], + $phpVersion, + "PHP version {$phpVersion} in component {$name} is inconsistent with version " + . self::$rootJson['require']['php'] . ' in root composer.json' + ); + } + /** * Make sure requirements of components are reflected in root composer.json * diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt index 30b6cb91bf29a..70168b63a4efb 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/blacklist/magento.txt @@ -173,10 +173,10 @@ app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/summ app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js app/code/Magento/ConfigurableProduct/view/frontend/requirejs-config.js app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js -app/code/Magento/Cookie/View/adminhtml/requirejs-config.js -app/code/Magento/Cookie/View/frontend/requirejs-config.js -app/code/Magento/Cookie/View/frontend/web/js/notices.js -app/code/Magento/Cookie/View/frontend/web/js/require-cookie.js +app/code/Magento/Cookie/view/adminhtml/requirejs-config.js +app/code/Magento/Cookie/view/frontend/requirejs-config.js +app/code/Magento/Cookie/view/frontend/web/js/notices.js +app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js app/code/Magento/Customer/view/adminhtml/requirejs-config.js app/code/Magento/Customer/view/adminhtml/web/edit/tab/js/addresses.js app/code/Magento/Customer/view/frontend/requirejs-config.js @@ -384,99 +384,37 @@ app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js app/code/Magento/Ui/view/base/web/js/core/renderer/types.js app/code/Magento/Ui/view/base/web/js/form/adapter.js app/code/Magento/Ui/view/base/web/js/form/client.js -app/code/Magento/Ui/view/base/web/js/form/components/area.js app/code/Magento/Ui/view/base/web/js/form/components/collection.js -app/code/Magento/Ui/view/base/web/js/form/components/collection/item.js -app/code/Magento/Ui/view/base/web/js/form/components/fieldset.js -app/code/Magento/Ui/view/base/web/js/form/components/group.js app/code/Magento/Ui/view/base/web/js/form/components/html.js -app/code/Magento/Ui/view/base/web/js/form/components/tab_group.js app/code/Magento/Ui/view/base/web/js/form/components/tab.js app/code/Magento/Ui/view/base/web/js/form/element/abstract.js -app/code/Magento/Ui/view/base/web/js/form/element/boolean.js -app/code/Magento/Ui/view/base/web/js/form/element/date.js app/code/Magento/Ui/view/base/web/js/form/element/helpers/options.js -app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js app/code/Magento/Ui/view/base/web/js/form/element/post-code.js app/code/Magento/Ui/view/base/web/js/form/element/region.js app/code/Magento/Ui/view/base/web/js/form/element/select.js -app/code/Magento/Ui/view/base/web/js/form/element/textarea.js app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js app/code/Magento/Ui/view/base/web/js/form/form.js app/code/Magento/Ui/view/base/web/js/form/provider.js -app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js -app/code/Magento/Ui/view/base/web/js/grid/columns/column.js -app/code/Magento/Ui/view/base/web/js/grid/columns/date.js -app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js -app/code/Magento/Ui/view/base/web/js/grid/columns/select.js app/code/Magento/Ui/view/base/web/js/grid/columns/thumbnail.js -app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/bookmarks.js app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/storage.js -app/code/Magento/Ui/view/base/web/js/grid/controls/bookmarks/view.js -app/code/Magento/Ui/view/base/web/js/grid/controls/columns.js -app/code/Magento/Ui/view/base/web/js/grid/dnd.js -app/code/Magento/Ui/view/base/web/js/grid/editing/bulk.js -app/code/Magento/Ui/view/base/web/js/grid/editing/client.js -app/code/Magento/Ui/view/base/web/js/grid/editing/editor-view.js -app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js -app/code/Magento/Ui/view/base/web/js/grid/editing/record.js app/code/Magento/Ui/view/base/web/js/grid/export.js -app/code/Magento/Ui/view/base/web/js/grid/filters/chips.js -app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js -app/code/Magento/Ui/view/base/web/js/grid/filters/group.js -app/code/Magento/Ui/view/base/web/js/grid/massactions.js -app/code/Magento/Ui/view/base/web/js/grid/paging/paging.js -app/code/Magento/Ui/view/base/web/js/grid/paging/sizes.js -app/code/Magento/Ui/view/base/web/js/grid/provider.js app/code/Magento/Ui/view/base/web/js/grid/resize.js -app/code/Magento/Ui/view/base/web/js/grid/search/search.js app/code/Magento/Ui/view/base/web/js/grid/sticky/sticky.js -app/code/Magento/Ui/view/base/web/js/grid/tree-massactions.js -app/code/Magento/Ui/view/base/web/js/lib/class.js -app/code/Magento/Ui/view/base/web/js/lib/collapsible.js -app/code/Magento/Ui/view/base/web/js/lib/component/core.js -app/code/Magento/Ui/view/base/web/js/lib/component/links.js -app/code/Magento/Ui/view/base/web/js/lib/component/main.js -app/code/Magento/Ui/view/base/web/js/lib/component/manip.js -app/code/Magento/Ui/view/base/web/js/lib/component/provider.js -app/code/Magento/Ui/view/base/web/js/lib/component/traversal.js -app/code/Magento/Ui/view/base/web/js/lib/events.js +app/code/Magento/Ui/view/base/web/js/lib/core/element/links.js app/code/Magento/Ui/view/base/web/js/lib/key-codes.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/after-render.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/class.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/collapsible.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/datepicker.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/fadeVisible.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/i18n.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/keyboard.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/mage-init.js app/code/Magento/Ui/view/base/web/js/lib/ko/bind/optgroup.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/outer_click.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/scope.js -app/code/Magento/Ui/view/base/web/js/lib/ko/bind/stop_propagation.js -app/code/Magento/Ui/view/base/web/js/lib/ko/extender/bound-nodes.js app/code/Magento/Ui/view/base/web/js/lib/ko/extender/observable_array.js -app/code/Magento/Ui/view/base/web/js/lib/ko/initialize.js -app/code/Magento/Ui/view/base/web/js/lib/ko/template/engine.js -app/code/Magento/Ui/view/base/web/js/lib/ko/template/observable_source.js -app/code/Magento/Ui/view/base/web/js/lib/loader.js -app/code/Magento/Ui/view/base/web/js/lib/registry/events.js -app/code/Magento/Ui/view/base/web/js/lib/registry/registry.js -app/code/Magento/Ui/view/base/web/js/lib/registry/storage.js -app/code/Magento/Ui/view/base/web/js/lib/renderer/renderer.js app/code/Magento/Ui/view/base/web/js/lib/spinner.js app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js -app/code/Magento/Ui/view/base/web/js/lib/storage.js app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js app/code/Magento/Ui/view/base/web/js/lib/validation/utils.js app/code/Magento/Ui/view/base/web/js/lib/validation/validator.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/async.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/bindings.js -app/code/Magento/Ui/view/base/web/js/lib/view/utils/dom-observer.js app/code/Magento/Ui/view/base/web/js/lib/view/utils/raf.js -app/code/Magento/Ui/view/base/web/js/modal/alert.js -app/code/Magento/Ui/view/base/web/js/modal/confirm.js -app/code/Magento/Ui/view/base/web/js/modal/modal.js app/code/Magento/Ui/view/base/web/js/modal/modalToggle.js app/code/Magento/Ui/view/frontend/web/js/model/messageList.js app/code/Magento/Ui/view/frontend/web/js/model/messages.js @@ -543,7 +481,7 @@ dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/bookmarks/v dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/controls/columns.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/editing/bulk.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/filters.test.js -dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/group.test.js +dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/filters/range.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/paging/paging.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/resize.test.js dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/grid/search/search.test.js @@ -623,10 +561,7 @@ lib/web/mage/mage.js lib/web/mage/menu.js lib/web/mage/popup-window.js lib/web/mage/redirect-url.js -lib/web/mage/requirejs/mixins.js -lib/web/mage/requirejs/plugin/id-normalizer.js lib/web/mage/requirejs/resolver.js -lib/web/mage/requirejs/static.js lib/web/mage/smart-keyboard-handler.js lib/web/mage/sticky.js lib/web/mage/storage.js @@ -640,13 +575,7 @@ lib/web/mage/translate-inline.js lib/web/mage/translate.js lib/web/mage/url.js lib/web/mage/utils/arrays.js -lib/web/mage/utils/compare.js -lib/web/mage/utils/main.js lib/web/mage/utils/misc.js -lib/web/mage/utils/objects.js -lib/web/mage/utils/strings.js -lib/web/mage/utils/template.js -lib/web/mage/utils/wrapper.js lib/web/mage/validation.js lib/web/mage/validation/validation.js lib/web/mage/view/composite.js @@ -1153,4 +1082,4 @@ vendor/magento/module-wishlist/view/frontend/web/wishlist.js vendor/magento/theme-adminhtml-backend/web/js/theme.js vendor/magento/theme-frontend-blank/web/js/navigation-menu.js vendor/magento/theme-frontend-blank/web/js/responsive.js -vendor/magento/theme-frontend-blank/web/js/theme.js \ No newline at end of file +vendor/magento/theme-frontend-blank/web/js/theme.js diff --git a/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc b/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc index b8071503882e2..0a4404817de47 100644 --- a/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc +++ b/dev/tests/static/testsuite/Magento/Test/Js/_files/jscs/.jscsrc @@ -75,6 +75,7 @@ "disallowTrailingComma": true, "disallowTrailingWhitespace": true, "disallowYodaConditions": true, + "maxErrors": null, "requireBlocksOnNewline": true, "requireDotNotation": "except_snake_case", "requireCamelCaseOrUpperCaseIdentifiers": true, diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php index de26ad3053019..813aababf3b6b 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/ObsoleteCodeTest.php @@ -14,6 +14,9 @@ use Magento\Framework\App\Utility\AggregateInvoker; use Magento\TestFramework\Utility\ChangedFiles; +/** + * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + */ class ObsoleteCodeTest extends \PHPUnit_Framework_TestCase { /**@#+ @@ -871,7 +874,7 @@ protected function _assertNotRegexp($regex, $content, $message) public function testMageMethodsObsolete() { - $ignored = $this->getBlacklistFiles(); + $ignored = $this->getBlacklistFiles(true); $files = Files::init()->getPhpFiles( Files::INCLUDE_APP_CODE | Files::INCLUDE_TESTS @@ -900,18 +903,43 @@ function ($file) { ); } + /** + * @param string $appPath + * @param string $pattern + * @return array + * @throws \Exception + */ + private function processPattern($appPath, $pattern) + { + $files = []; + $relativePathStart = strlen($appPath); + + $fileSet = glob($appPath . DIRECTORY_SEPARATOR . $pattern, GLOB_NOSORT); + foreach ($fileSet as $file) { + $files[] = substr($file, $relativePathStart); + } + + return $files; + } + /** * Reads list of blacklisted files * + * @param bool $absolutePath * @return array + * @throws \Exception */ - private function getBlacklistFiles() + private function getBlacklistFiles($absolutePath = false) { $blackList = include __DIR__ . '/_files/blacklist/obsolete_mage.php'; $ignored = []; $appPath = Files::init()->getPathToSource(); foreach ($blackList as $file) { - $ignored = array_merge($ignored, glob($appPath . '/' . $file, GLOB_NOSORT)); + if ($absolutePath) { + $ignored = array_merge($ignored, glob($appPath . DIRECTORY_SEPARATOR . $file, GLOB_NOSORT)); + } else { + $ignored = array_merge($ignored, $this->processPattern($appPath, $file)); + } } return $ignored; } diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php index 1e240b0bebc67..cf42cd0950a7a 100755 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php @@ -803,23 +803,47 @@ ['Magento\Core\Model\Email\Info', 'Magento\Framework\Mail\MessageInterface'], ['Magento\Core\Model\Email\Sender', 'Magento\Framework\Mail\Template\TransportBuilder'], ['Magento\Core\Model\Email\Template\Mailer', 'Magento\Framework\Mail\Template\TransportBuilder'], - ['Magento\Core\Model\Resource\AbstractResource', 'Magento\Framework\Model\ModelResource\AbstractResource'], - ['Magento\Core\Model\Resource\Db\AbstractDb', 'Magento\Framework\Model\ModelResource\Db\AbstractDb'], - ['Magento\Core\Model\Resource\Db\Profiler', 'Magento\Framework\Model\ModelResource\Db\Profiler'], + ['Magento\Core\Model\Resource\AbstractResource', 'Magento\Framework\Model\ResourceModel\AbstractResource'], + [ + 'Magento\Framework\Model\ModelResource\AbstractResource', + 'Magento\Framework\Model\ResourceModel\AbstractResource' + ], + ['Magento\Core\Model\Resource\Db\AbstractDb', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb'], + ['Magento\Core\Model\Resource\Db\Profiler', 'Magento\Framework\Model\ResourceModel\Db\Profiler'], + ['Magento\Framework\Model\ModelResource\Db\Profiler', 'Magento\Framework\Model\ResourceModel\Db\Profiler'], [ 'Magento\Core\Model\Resource\Entity\AbstractEntity', + 'Magento\Framework\Model\ResourceModel\Entity\AbstractEntity', + ], + [ 'Magento\Framework\Model\ModelResource\Entity\AbstractEntity', + 'Magento\Framework\Model\ResourceModel\Entity\AbstractEntity', ], - ['Magento\Core\Model\Resource\Entity\Table', 'Magento\Framework\Model\ModelResource\Entity\Table'], + ['Magento\Core\Model\Resource\Entity\Table', 'Magento\Framework\Model\ResourceModel\Entity\Table'], + ['Magento\Framework\Model\ModelResource\Entity\Table', 'Magento\Framework\Model\ResourceModel\Entity\Table'], ['Magento\Core\Model\Resource\Flag', 'Magento\Framework\Flag\FlagResource'], - ['Magento\Core\Model\Resource\Iterator', 'Magento\Framework\Model\ModelResource\Iterator'], + ['Magento\Core\Model\Resource\Iterator', 'Magento\Framework\Model\ResourceModel\Iterator'], + ['Magento\Framework\Model\ModelResource\Iterator', 'Magento\Framework\Model\ResourceModel\Iterator'], ['Magento\Core\Model\Resource\Resource', 'Magento\Framework\Module\ModuleResource'], - ['Magento\Core\Model\Resource\Type\AbstractType', 'Magento\Framework\Model\ModelResource\Type\AbstractType'], - ['Magento\Core\Model\Resource\Type\Db', 'Magento\Framework\Model\ModelResource\Type\Db'], - ['Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', 'Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql'], + ['Magento\Core\Model\Resource\Type\AbstractType', 'Magento\Framework\Model\ResourceModel\Type\AbstractType'], + [ + 'Magento\Framework\Model\ModelResource\Type\AbstractType', + 'Magento\Framework\Model\ResourceModel\Type\AbstractType' + ], + ['Magento\Core\Model\Resource\Type\Db', 'Magento\Framework\Model\ResourceModel\Type\Db'], + ['Magento\Framework\Model\ModelResource\Type\Db', 'Magento\Framework\Model\ResourceModel\Type\Db'], + ['Magento\Core\Model\Resource\Type\Db\Pdo\Mysql', 'Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql'], + [ + 'Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql', + 'Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql' + ], [ 'Magento\Core\Model\Resource\Db\Collection\AbstractCollection', + 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', + ], + [ 'Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection', + 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', ], ['Magento\Email\Model\Info', 'Magento\Framework\Mail\MessageInterface'], ['Magento\Email\Model\Sender', 'Magento\Framework\Mail\Template\TransportBuilder'], @@ -2925,7 +2949,8 @@ 'Magento\Bundle\Api\ProductOptionTypeListInterface', ], ['Magento\Sales\Controller\Adminhtml\Order\InvoiceLoader'], - ['Magento\Sales\Model\ResourceModel\AbstractResource', 'Magento\Framework\Model\ModelResource\Db\AbstractDb'], + ['Magento\Sales\Model\ResourceModel\AbstractResource', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb'], + ['Magento\Framework\Model\ModelResource\Db\AbstractDb', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb'], ['Magento\Backend\Block\System\Config\Switcher'], ['Magento\VersionsCms\Block\Adminhtml\Scope\Switcher'], ['Magento\Backend\Block\Widget\View\Container'], @@ -3921,6 +3946,8 @@ ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Inventory'], ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Renderer\Checkbox'], ['Magento\ConfigurableProduct\Block\Adminhtml\Product\Edit\Tab\Super\Config\Grid\Filter\Inventory'], + ['Magento\Catalog\Ui\Component\Listing\Filters'], + ['Magento\Customer\Ui\Component\Listing\Filters'], ['Magento\Catalog\Block\Product\TemplateSelector'], ['Magento\Downloadable\Controller\Adminhtml\Downloadable\Product\Edit\SuggestProductTemplates'], ['Magento\Bundle\Controller\Adminhtml\Bundle\Product\Edit\SuggestProductTemplates'], @@ -3975,7 +4002,6 @@ ['Magento\Framework\Module\Resource', 'Magento\Framework\Module\ModuleResource'], ['Magento\OfflineShipping\Model\Observer\SalesRule\ActionsTab', 'Magento\OfflineShipping\Observer\*'], ['Magento\Theme\Model\Observer', 'Magento\Theme\Observer\*'], - ['Magento\Catalog\Model\Product\Compare\Item', 'Magento\Catalog\Observer\*'], ['Magento\Catalog\Observer\AddCatalogToTopmenuItems', 'Magento\Catalog\Observer\*'], ['Magento\Catalog\Observer\CatalogCheckIsUsingStaticUrlsAllowed', 'Magento\Catalog\Observer\*'], [ @@ -3991,9 +4017,6 @@ ['Magento\Msrp\Model\Observer\Frontend\Quote\SetCanApplyMsrp', 'Magento\Msrp\Observer\*'], ['Magento\Customer\Model\Observer\Log', 'Magento\Customer\Observer\*'], ['Magento\Customer\Model\Observer', 'Magento\Customer\Observer\*'], - ['Magento\Paypal\Observer\SaveOrderAfterSubmitObserver', 'Magento\Paypal\Observer\*'], - ['Magento\Paypal\Observer\SetResponseAfterSaveOrderObserver', 'Magento\Paypal\Observer\*'], - ['Magento\Paypal\Observer\AddPaypalShortcutsObserver', 'Magento\Paypal\Observer\*'], ['Magento\Paypal\Model\Observer\RestrictAdminBillingAgreementUsage', 'Magento\Paypal\Observer\*'], ['Magento\GiftMessage\Model\Observer', 'Magento\GiftMessage\Observer\*'], ['Magento\Quote\Model\Observer\Webapi\Submit', 'Magento\Quote\Observer\*'], @@ -4021,7 +4044,6 @@ ['Magento\CatalogUrlRewrite\Model\Product\Observer', 'Magento\CatalogUrlRewrite\Observer\*'], ['Magento\CatalogUrlRewrite\Model\Category\Observer', 'Magento\CatalogUrlRewrite\Observer\*'], ['Magento\CatalogUrlRewrite\Observer\ProductUrlKeyAutogenerator', 'Magento\CatalogUrlRewrite\Observer\*'], - ['Magento\CatalogSearch\Model\Indexer\Fulltext\Store', 'Magento\CatalogSearch\Observer\*'], ['Magento\Weee\Model\Total\Observer\Webapi\Item', 'Magento\Weee\Observer\*'], ['Magento\Captcha\Model\Observer', 'Magento\Captcha\Observer\*'], ['Magento\GoogleAdwords\Model\Observer', 'Magento\GoogleAdwords\Observer\*'], @@ -4071,7 +4093,6 @@ ['Magento\PageCache\Model\Observer\InvalidateCache', 'Magento\PageCache\Observer\*'], ['Magento\PageCache\Model\Observer\RegisterFormKeyFromCookie', 'Magento\PageCache\Observer\*'], ['Magento\PageCache\Model\Observer\FlushFormKeyOnLogout', 'Magento\PageCache\Observer\*'], - ['Magento\CatalogInventory\Model\Quote\Item\QuantityValidator', 'Magento\CatalogInventory\Observer\*'], ['Magento\GoogleOptimizer\Model\Observer\Product\Save', 'Magento\GoogleOptimizer\Observer\*'], ['Magento\GoogleOptimizer\Model\Observer\Product\Delete', 'Magento\GoogleOptimizer\Observer\*'], ['Magento\GoogleOptimizer\Model\Observer\Category\Save', 'Magento\GoogleOptimizer\Observer\*'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 174f0004e29bd..1a0a6503809d5 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -19,7 +19,7 @@ ['CACHE_TAG', 'Magento\Framework\AppInterface'], [ 'CACHE_TAG', - 'Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection', + 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection', 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG', ], ['CACHE_TAG', 'Magento\Framework\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'], @@ -148,11 +148,6 @@ ['XML_CHARSET_NODE', 'Magento\SalesRule\Helper\Coupon'], ['XML_CHARSET_SEPARATOR', 'Magento\SalesRule\Helper\Coupon'], ['XML_NODE_RELATED_CACHE', 'Magento\CatalogRule\Model\Rule'], - [ - 'XML_NODE_ATTRIBUTE_NODES', - 'Magento\Catalog\Model\ResourceModel\Product\Flat\Indexer', - 'XML_NODE_ATTRIBUTE_GROUPS', - ], [ 'XML_PATH_ALLOW_DUPLICATION', 'Magento\Core\Model\Design\PackageInterface', @@ -310,8 +305,6 @@ ['XML_NODE_ADD_FILTERABLE_ATTRIBUTES', 'Magento\Catalog\Helper\Product\Flat'], ['XML_NODE_ADD_CHILD_DATA', 'Magento\Catalog\Helper\Product\Flat'], ['XML_PATH_CONTENT_TEMPLATE_FILTER', 'Magento\Catalog\Helper\Data'], - ['XML_NODE_MAX_INDEX_COUNT', 'Magento\Catalog\Model\ResourceModel\Product\Flat\Indexer'], - ['XML_NODE_ATTRIBUTE_GROUPS', 'Magento\Catalog\Model\ResourceModel\Product\Flat\Indexer'], ['XML_PATH_UNASSIGNABLE_ATTRIBUTES', 'Magento\Catalog\Helper\Product'], ['XML_PATH_ATTRIBUTES_USED_IN_AUTOGENERATION', 'Magento\Catalog\Helper\Product'], ['XML_PATH_PRODUCT_TYPE_SWITCHER_LABEL', 'Magento\Catalog\Helper\Product'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index fa5c796ff6a46..ca7f4471723dc 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -866,7 +866,7 @@ ['validateDataArray', 'Magento\Framework\Convert\Container\AbstractContainer'], ['validateFile', 'Magento\Core\Model\Design\Package'], ['validateOrder', 'Magento\Checkout\Model\Type\Onepage'], - ['viewTrackAction', 'Magento\Sales\Controller\Adminhtml\Order\Shipment'], + ['viewTrackAction', 'Magento\Shipping\Controller\Adminhtml\Order\Shipment'], ['_prepareOptionValues', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], ['_getOptionValuesCollection', 'Magento\Eav\Block\Adminhtml\Attribute\Edit\Options\AbstractOptions'], [ @@ -951,7 +951,7 @@ ['_getUsers', 'Magento\User\Block\Role\Grid\User', 'getUsers'], ['_getGridHtml', 'Magento\User\Block\Role\Tab\Users', 'getGridHtml'], ['_getSelectedRoles', 'Magento\User\Block\User\Edit\Tab\Roles', 'getSelectedRoles'], - ['_prepareSelect', 'Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection'], + ['_prepareSelect', 'Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection'], ['_prepareSelect', 'Magento\Framework\Data\Collection\AbstractDb'], ['_createOrderFromAddress', 'Magento\Checkout\Model\Type\AbstractType'], ['_addLoadAttributesSelectFields', 'Magento\Catalog\Model\ResourceModel\AbstractResource'], @@ -1116,12 +1116,12 @@ ], [ 'formatDate', - 'Magento\Framework\Model\ModelResource\AbstractResource', + 'Magento\Framework\Model\ResourceModel\AbstractResource', '\Magento\Framework\Stdlib\DateTime::formatDate', ], [ 'mktime', - 'Magento\Framework\Model\ModelResource\AbstractResource', + 'Magento\Framework\Model\ResourceModel\AbstractResource', '\Magento\Framework\Stdlib\DateTime::toTimestamp', ], ['getPlainTemplateMode', '\Magento\Email\Model\Template\Filter'], @@ -2342,11 +2342,11 @@ ['_getReadAdapter', 'Magento\Framework\DB\Helper\AbstractHelper', 'getConnection'], ['_getWriteAdapter', 'Magento\Framework\DB\Helper\AbstractHelper', 'getConnection'], ['_getConnection', 'Magento\Framework\DB\Helper\AbstractHelper', 'getConnection'], - ['_getReadAdapter', 'Magento\Framework\Model\ModelResource\AbstractResource', 'getConnection'], - ['_getWriteAdapter', 'Magento\Framework\Model\ModelResource\AbstractResource', 'getConnection'], - ['_getReadAdapter', 'Magento\Framework\Model\ModelResource\Db\AbstractDb', 'getConnection'], - ['_getWriteAdapter', 'Magento\Framework\Model\ModelResource\Db\AbstractDb', 'getConnection'], - ['getReadConnection', 'Magento\Framework\Model\ModelResource\Db\AbstractDb', 'getConnection'], + ['_getReadAdapter', 'Magento\Framework\Model\ResourceModel\AbstractResource', 'getConnection'], + ['_getWriteAdapter', 'Magento\Framework\Model\ResourceModel\AbstractResource', 'getConnection'], + ['_getReadAdapter', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', 'getConnection'], + ['_getWriteAdapter', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', 'getConnection'], + ['getReadConnection', 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', 'getConnection'], ['getReadAdapter', 'Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction'], ['getWriteAdapter', 'Magento\Catalog\Model\Indexer\Category\Flat\AbstractAction'], ['getReadAdapter', 'Magento\Catalog\Model\Indexer\Category\Product\AbstractAction'], diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php index 03be375c65521..2419014c40dc8 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_namespaces.php @@ -190,6 +190,8 @@ ['Magento\Catalog\Test\Unit\Plugin\Model\Resource', 'Magento\Catalog\Test\Unit\Plugin\Model\ResourceModel'], ['Magento\Framework\Acl\Resource', 'Magento\Framework\Acl\AclResource'], ['Magento\Framework\App\Resource', 'Magento\Framework\App\ResourceConnection'], - ['Magento\Framework\Model\Resource', 'Magento\Framework\Model\ModelResource'], - ['Magento\Framework\Model\Test\Unit\Resource', 'Magento\Framework\Model\Test\Unit\ModelResource'], + ['Magento\Framework\Model\Resource', 'Magento\Framework\Model\ResourceModel'], + ['Magento\Framework\Model\ModelResource', 'Magento\Framework\Model\ResourceModel'], + ['Magento\Framework\Model\Test\Unit\Resource', 'Magento\Framework\Model\Test\Unit\ResourceModel'], + ['Magento\Framework\Model\Test\Unit\ModelResource', 'Magento\Framework\Model\Test\Unit\ResourceModel'], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php index becf2127e4881..43ec07e30fda4 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_properties.php @@ -173,13 +173,13 @@ ['_dirModel', 'Magento\Downloadable\Controller\Adminhtml\Downloadable\File'], ['_dirModel', 'Magento\Downloadable\Model\Link'], ['_dirModel', 'Magento\Downloadable\Model\Sample'], - ['_dir', 'Magento\Framework\App\Dir'], + ['_dir', 'Magento\Framework\Filesystem'], ['_baseDir', 'Magento\Backup\Model\Fs\Collection'], ['_filesystem', 'Magento\Backup\Model\Fs\Collection'], ['_dir', 'Magento\Backup\Model\Fs\Collection'], ['_dir', 'Magento\Cms\Model\Wysiwyg\Images\Storage'], ['_dirs', 'Magento\Core\Helper\Theme'], - ['_dirs', 'Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql'], + ['_dirs', 'Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql'], ['_filesystem', 'Magento\GiftWrapping\Model\Wrapping'], ['_customer', 'Magento\Backend\Model\Session\Quote'], ['_customerFactory', 'Magento\Backend\Model\Session\Quote'], diff --git a/lib/internal/Magento/Framework/App/Config/Value.php b/lib/internal/Magento/Framework/App/Config/Value.php index 32bb526b01516..5be19ff291332 100644 --- a/lib/internal/Magento/Framework/App/Config/Value.php +++ b/lib/internal/Magento/Framework/App/Config/Value.php @@ -8,7 +8,7 @@ /** * Config data model * - * @method \Magento\Framework\Model\ModelResource\Db\AbstractDb getResource() + * @method \Magento\Framework\Model\ResourceModel\Db\AbstractDb getResource() * @method string getScope() * @method \Magento\Framework\App\Config\ValueInterface setScope(string $value) * @method int getScopeId() @@ -50,10 +50,10 @@ class Value extends \Magento\Framework\Model\AbstractModel implements \Magento\F /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\App\Config\ScopeConfigInterface $config + * @param ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data */ public function __construct( @@ -61,7 +61,7 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/lib/internal/Magento/Framework/App/ErrorHandler.php b/lib/internal/Magento/Framework/App/ErrorHandler.php index 59119102e6955..99eaab78f51b8 100644 --- a/lib/internal/Magento/Framework/App/ErrorHandler.php +++ b/lib/internal/Magento/Framework/App/ErrorHandler.php @@ -51,17 +51,11 @@ public function handler($errorNo, $errorStr, $errorFile, $errorLine) return false; } - if (strpos($errorStr, 'Automatically populating $HTTP_RAW_POST_DATA is deprecated') !== false) { - // this warning should be suppressed as it is a known bug in php 5.6.0 https://bugs.php.net/bug.php?id=66763 - // and workaround suggested here (http://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data) - // is not compatible with HHVM - return false; - } - $errorNo = $errorNo & error_reporting(); if ($errorNo == 0) { return false; } + $msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})"; $msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}"; throw new \Exception($msg); diff --git a/lib/internal/Magento/Framework/App/Http.php b/lib/internal/Magento/Framework/App/Http.php index 897985cc0982b..f87e64ea88937 100644 --- a/lib/internal/Magento/Framework/App/Http.php +++ b/lib/internal/Magento/Framework/App/Http.php @@ -184,9 +184,12 @@ private function redirectToSetup(Bootstrap $bootstrap, \Exception $exception) $this->_response->setRedirect($setupInfo->getUrl()); $this->_response->sendHeaders(); } else { - $newMessage = $exception->getMessage() . "\nNOTE: web setup wizard is not accessible.\n" - . 'In order to install, use Magento Setup CLI or configure web access to the following directory: ' - . $setupInfo->getDir($projectRoot); + $newMessage = $exception->getMessage() . "\nNOTE: You cannot install Magento using the Setup Wizard " + . "because the Magento setup directory cannot be accessed. \n" + . 'You can install Magento using either the command line or you must restore access ' + . 'to the following directory: ' . $setupInfo->getDir($projectRoot) . "\n"; + $newMessage .= 'If you are using the sample nginx configuration, please go to ' + . $this->_request->getScheme(). '://' . $this->_request->getHttpHost() . $setupInfo->getUrl(); throw new \Exception($newMessage, 0, $exception); } } diff --git a/lib/internal/Magento/Framework/App/ResourceConnection.php b/lib/internal/Magento/Framework/App/ResourceConnection.php index 13e106244841a..56d220ebb57f4 100644 --- a/lib/internal/Magento/Framework/App/ResourceConnection.php +++ b/lib/internal/Magento/Framework/App/ResourceConnection.php @@ -9,7 +9,7 @@ use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\ResourceConnection\ConfigInterface as ResourceConfigInterface; -use Magento\Framework\Model\ModelResource\Type\Db\ConnectionFactoryInterface; +use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactoryInterface; use Magento\Framework\Config\ConfigOptionsListConstants; class ResourceConnection diff --git a/lib/internal/Magento/Framework/App/ResourceConnection/ConnectionFactory.php b/lib/internal/Magento/Framework/App/ResourceConnection/ConnectionFactory.php index 6a9922c138c84..7924f4babdac9 100644 --- a/lib/internal/Magento/Framework/App/ResourceConnection/ConnectionFactory.php +++ b/lib/internal/Magento/Framework/App/ResourceConnection/ConnectionFactory.php @@ -7,7 +7,7 @@ */ namespace Magento\Framework\App\ResourceConnection; -use Magento\Framework\Model\ModelResource\Type\Db\ConnectionFactory as ModelConnectionFactory; +use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactory as ModelConnectionFactory; use Magento\Framework\DB\Adapter\DdlCache; class ConnectionFactory extends ModelConnectionFactory diff --git a/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php b/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php index c32a284af11d7..265ca6f2964e4 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/AclResourceTest.php @@ -8,7 +8,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Config\ConfigOptionsListConstants; -use Magento\Framework\Model\ModelResource\Type\Db\ConnectionFactoryInterface; +use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactoryInterface; class AclResourceTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php index c2c928b2376ef..44258c7f135ce 100644 --- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php +++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php @@ -48,7 +48,7 @@ public static function register($type, $componentName, $path) if (isset(self::$paths[$type][$componentName])) { throw new \LogicException('\'' . $componentName . '\' component already exists'); } else { - self::$paths[$type][$componentName] = $path; + self::$paths[$type][$componentName] = str_replace('\\', '/', $path); } } diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php index 5bb8e80888b6b..4fbeaecc85d18 100644 --- a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php +++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php @@ -97,4 +97,9 @@ class ConfigOptionsListConstants * Key for modules */ const KEY_MODULES = 'modules'; + + /** + * Size of random string generated for store's encryption key + */ + const STORE_KEY_RANDOM_STRING_SIZE = 32; } diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php index 00aab9b33e2e3..98a9614018816 100644 --- a/lib/internal/Magento/Framework/Config/View.php +++ b/lib/internal/Magento/Framework/Config/View.php @@ -80,12 +80,7 @@ protected function _extractData(\DOMDocument $dom) switch ($childNode->tagName) { case 'vars': $moduleName = $childNode->getAttribute('module'); - /** @var $varNode \DOMElement */ - foreach ($childNode->getElementsByTagName('var') as $varNode) { - $varName = $varNode->getAttribute('name'); - $varValue = $varNode->nodeValue; - $result[$childNode->tagName][$moduleName][$varName] = $varValue; - } + $result[$childNode->tagName][$moduleName] = $this->parseVarElement($childNode); break; case 'exclude': /** @var $itemNode \DOMElement */ @@ -111,6 +106,27 @@ protected function _extractData(\DOMDocument $dom) return $result; } + /** + * Recursive parser for nodes + * + * @param \DOMElement $node + * @return string|boolean|number|null|[] + */ + protected function parseVarElement(\DOMElement $node) + { + $result = []; + for ($varNode = $node->firstChild; $varNode !== null; $varNode = $varNode->nextSibling) { + if ($varNode instanceof \DOMElement && $varNode->tagName == "var") { + $varName = $varNode->getAttribute('name'); + $result[$varName] = $this->parseVarElement($varNode); + } + } + if (!count($result)) { + $result = $node->nodeValue; + } + return $result; + } + /** * Get a list of variables in scope of specified module * @@ -129,11 +145,24 @@ public function getVars($module) * * @param string $module * @param string $var - * @return string|false + * @return string|false|array */ public function getVarValue($module, $var) { - return isset($this->_data['vars'][$module][$var]) ? $this->_data['vars'][$module][$var] : false; + if (!isset($this->_data['vars'][$module])) { + return false; + } + + $value = $this->_data['vars'][$module]; + foreach (explode('/', $var) as $node) { + if (is_array($value) && isset($value[$node])) { + $value = $value[$node]; + } else { + return false; + } + } + + return $value; } /** diff --git a/lib/internal/Magento/Framework/Config/etc/view.xsd b/lib/internal/Magento/Framework/Config/etc/view.xsd index 21a371d863342..1ded09402a6b0 100644 --- a/lib/internal/Magento/Framework/Config/etc/view.xsd +++ b/lib/internal/Magento/Framework/Config/etc/view.xsd @@ -12,15 +12,7 @@ - - - - - - - - - + @@ -38,6 +30,13 @@ + + + + + + + diff --git a/lib/internal/Magento/Framework/Controller/Result/Json.php b/lib/internal/Magento/Framework/Controller/Result/Json.php index f1d480efec72e..bc3855448ccc2 100644 --- a/lib/internal/Magento/Framework/Controller/Result/Json.php +++ b/lib/internal/Magento/Framework/Controller/Result/Json.php @@ -63,6 +63,8 @@ public function setJsonData($jsonData) */ protected function render(ResponseInterface $response) { + // reset profiler to avoid appending profiling stat to JSON response + \Magento\Framework\Profiler::reset(); $this->translateInline->processResponseBody($this->json, true); $response->representJson($this->json); return $this; diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Oyejorge.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Oyejorge.php deleted file mode 100644 index eed8d0555341b..0000000000000 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Oyejorge.php +++ /dev/null @@ -1,54 +0,0 @@ -logger = $logger; - $this->appState = $appState; - } - - /** - * @param string $sourceFilePath - * @return string - */ - public function process($sourceFilePath) - { - $options = ['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]; - try { - $parser = new \Less_Parser($options); - $parser->parseFile($sourceFilePath, ''); - return $parser->getCss(); - } catch (\Exception $e) { - $errorMessage = self::ERROR_MESSAGE_PREFIX . $e->getMessage(); - $this->logger->critical($errorMessage); - return $errorMessage; - } - } -} diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php new file mode 100644 index 0000000000000..26cb1ce21d66a --- /dev/null +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Adapter/Less/Processor.php @@ -0,0 +1,92 @@ +logger = $logger; + $this->appState = $appState; + $this->assetSource = $assetSource; + $this->temporaryFile = $temporaryFile; + } + + /** + * @inheritdoc + */ + public function processContent(File $asset) + { + try { + $parser = new \Less_Parser( + [ + 'relativeUrls' => false, + 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER + ] + ); + + $content = $this->assetSource->getContent($asset); + + if (trim($content) === '') { + return ''; + } + + $tmpFilePath = $this->temporaryFile->createFile($asset->getPath(), $content); + $parser->parseFile($tmpFilePath, ''); + + $content = $parser->getCss(); + + return $content; + } catch (\Exception $e) { + $errorMessage = self::ERROR_MESSAGE_PREFIX . $e->getMessage(); + $this->logger->critical($errorMessage); + + return $errorMessage; + } + } +} diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/AdapterInterface.php b/lib/internal/Magento/Framework/Css/PreProcessor/AdapterInterface.php deleted file mode 100644 index b2b230bc30233..0000000000000 --- a/lib/internal/Magento/Framework/Css/PreProcessor/AdapterInterface.php +++ /dev/null @@ -1,20 +0,0 @@ -tmpDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); - $this->assetRepo = $assetRepo; - $this->assetSource = $assetSource; - - $this->magentoImportProcessor = $magentoImportProcessor; - $this->importProcessor = $importProcessor; - $this->relatedGenerator = $relatedGenerator; - $this->config = $config; - $this->temporaryFile = $temporaryFile; - } - - /** - * Create a tree of self-sustainable files and return the topmost source file, - * ready for passing to 3rd party library - * - * @param Chain $chain - * @return string Absolute path of generated topmost source file - */ - public function generateFileTree(Chain $chain) - { - /** - * wait if generation process has already started - */ - while ($this->isProcessLocked()) { - sleep(1); - } - $lockFilePath = $this->config->getMaterializationRelativePath() . '/' . self::LOCK_FILE; - $this->tmpDirectory->writeFile($lockFilePath, time()); - - $this->magentoImportProcessor->process($chain); - $this->importProcessor->process($chain); - $this->relatedGenerator->generate($this->importProcessor); - - $contentType = $chain->getContentType(); - $relativePath = preg_replace('#\.css$#', '.' . $contentType, $chain->getAsset()->getPath()); - $tmpFilePath = $this->temporaryFile->createFile($relativePath, $chain->getContent()); - - $this->tmpDirectory->delete($lockFilePath); - return $tmpFilePath; - } - - /** - * Check whether generation process has already locked - * - * @return bool - */ - protected function isProcessLocked() - { - $lockFilePath = $this->config->getMaterializationRelativePath() . '/' . self::LOCK_FILE; - if ($this->tmpDirectory->isExist($lockFilePath)) { - $lockTime = time() - (int)$this->tmpDirectory->readFile($lockFilePath); - if ($lockTime >= self::MAX_LOCK_TIME) { - $this->tmpDirectory->delete($lockFilePath); - return false; - } - return true; - } - return false; - } -} diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Instruction/Import.php b/lib/internal/Magento/Framework/Css/PreProcessor/Instruction/Import.php index 158d022f78a0e..2559c32270373 100644 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Instruction/Import.php +++ b/lib/internal/Magento/Framework/Css/PreProcessor/Instruction/Import.php @@ -11,6 +11,7 @@ use Magento\Framework\View\Asset\LocalInterface; use Magento\Framework\View\Asset\NotationResolver; use Magento\Framework\View\Asset\PreProcessorInterface; +use Magento\Framework\Css\PreProcessor\FileGenerator\RelatedGenerator; /** * @import instruction preprocessor @@ -34,11 +35,22 @@ class Import implements PreProcessorInterface protected $relatedFiles = []; /** + * @var RelatedGenerator + */ + private $relatedFileGenerator; + + /** + * Constructor + * * @param NotationResolver\Module $notationResolver + * @param RelatedGenerator $relatedFileGenerator */ - public function __construct(NotationResolver\Module $notationResolver) - { + public function __construct( + NotationResolver\Module $notationResolver, + RelatedGenerator $relatedFileGenerator + ) { $this->notationResolver = $notationResolver; + $this->relatedFileGenerator = $relatedFileGenerator; } /** @@ -54,6 +66,7 @@ public function process(\Magento\Framework\View\Asset\PreProcessor\Chain $chain) $content = $this->removeComments($chain->getContent()); $processedContent = preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $content); + $this->relatedFileGenerator->generate($this); if ($processedContent !== $content) { $chain->setContent($processedContent); diff --git a/lib/internal/Magento/Framework/Css/PreProcessor/Less.php b/lib/internal/Magento/Framework/Css/PreProcessor/Less.php deleted file mode 100644 index 4bdbbcf31a58e..0000000000000 --- a/lib/internal/Magento/Framework/Css/PreProcessor/Less.php +++ /dev/null @@ -1,49 +0,0 @@ -fileGenerator = $fileGenerator; - $this->adapter = $adapter; - } - - /** - * {@inheritdoc} - */ - public function process(\Magento\Framework\View\Asset\PreProcessor\Chain $chain) - { - $chain->setContentType('less'); - $tmpFile = $this->fileGenerator->generateFileTree($chain); - $cssContent = $this->adapter->process($tmpFile); - $cssTrimmedContent = trim($cssContent); - if (!empty($cssTrimmedContent)) { - $chain->setContent($cssContent); - } - $chain->setContentType('css'); - } -} diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/FileGeneratorTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/FileGeneratorTest.php deleted file mode 100644 index 4f034c1636077..0000000000000 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/FileGeneratorTest.php +++ /dev/null @@ -1,177 +0,0 @@ -tmpDirectory = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface'); - $this->rootDirectory = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\ReadInterface'); - $this->rootDirectory->expects($this->any()) - ->method('getRelativePath') - ->will($this->returnArgument(0)); - $this->rootDirectory->expects($this->any()) - ->method('readFile') - ->will( - $this->returnCallback( - function ($file) { - return "content of '$file'"; - } - ) - ); - $filesystem = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false); - $filesystem->expects($this->once()) - ->method('getDirectoryWrite') - ->will($this->returnValue($this->tmpDirectory)); - $this->assetRepo = $this->getMock('\Magento\Framework\View\Asset\Repository', [], [], '', false); - $this->magentoImport = $this->getMock( - 'Magento\Framework\Css\PreProcessor\Instruction\MagentoImport', - [], - [], - '', - false - ); - $this->import = $this->getMock( - 'Magento\Framework\Css\PreProcessor\Instruction\Import', - [], - [], - '', - false - ); - - $assetSource = $this->getMock( - 'Magento\Framework\View\Asset\Source', - [], - [], - '', - false - ); - - $this->relatedGenerator = $this->getMockBuilder( - 'Magento\Framework\Css\PreProcessor\FileGenerator\RelatedGenerator' - ) - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $this->config = $this->getMockBuilder('Magento\Framework\Css\PreProcessor\Config') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $this->temporaryFile = $this->getMockBuilder('Magento\Framework\Css\PreProcessor\File\Temporary') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $this->object = new \Magento\Framework\Css\PreProcessor\FileGenerator( - $filesystem, - $this->assetRepo, - $this->magentoImport, - $this->import, - $assetSource, - $this->relatedGenerator, - $this->config, - $this->temporaryFile - ); - } - - public function testGenerateFileTree() - { - $lessDirectory = 'path/to/less'; - $expectedContent = 'updated content'; - $expectedRelativePath = 'some/file.less'; - $expectedPath = $lessDirectory . '/some/file.less'; - - - $asset = $this->getMock('Magento\Framework\View\Asset\File', [], [], '', false); - $chain = $this->getMock('Magento\Framework\View\Asset\PreProcessor\Chain', [], [], '', false); - - $this->config->expects($this->any()) - ->method('getLessDirectory') - ->willReturn($lessDirectory); - $this->tmpDirectory->expects($this->once()) - ->method('isExist') - ->willReturn(true); - - $this->magentoImport->expects($this->once()) - ->method('process') - ->with($chain); - $this->import->expects($this->once()) - ->method('process') - ->with($chain); - $this->relatedGenerator->expects($this->once()) - ->method('generate') - ->with($this->import); - - $asset->expects($this->once()) - ->method('getPath') - ->will($this->returnValue('some/file.css')); - $chain->expects($this->once()) - ->method('getContent') - ->willReturn($expectedContent); - $chain->expects($this->once()) - ->method('getAsset') - ->willReturn($asset); - $chain->expects($this->once()) - ->method('getContentType') - ->willReturn('less'); - - $this->temporaryFile->expects($this->once()) - ->method('createFile') - ->with( - $expectedRelativePath, - $expectedContent - ) - ->willReturn($expectedPath); - - $this->assertSame($expectedPath, $this->object->generateFileTree($chain)); - } -} diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php index 6be802eaf35dc..b5959faaf5d9e 100644 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php +++ b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/Instruction/ImportTest.php @@ -8,6 +8,12 @@ namespace Magento\Framework\Css\Test\Unit\PreProcessor\Instruction; +use Magento\Framework\Css\PreProcessor\FileGenerator\RelatedGenerator; +use Magento\Framework\Css\PreProcessor\Instruction\Import; + +/** + * Class ImportTest + */ class ImportTest extends \PHPUnit_Framework_TestCase { /** @@ -21,18 +27,29 @@ class ImportTest extends \PHPUnit_Framework_TestCase private $asset; /** - * @var \Magento\Framework\Css\PreProcessor\Instruction\Import + * @var Import */ private $object; + /** + * @var RelatedGenerator + */ + private $relatedFileGeneratorMock; + protected function setUp() { + $this->notationResolver = $this->getMock( '\Magento\Framework\View\Asset\NotationResolver\Module', [], [], '', false ); $this->asset = $this->getMock('\Magento\Framework\View\Asset\File', [], [], '', false); $this->asset->expects($this->any())->method('getContentType')->will($this->returnValue('css')); - $this->object = new \Magento\Framework\Css\PreProcessor\Instruction\Import($this->notationResolver); + + $this->relatedFileGeneratorMock = $this->getMockBuilder(RelatedGenerator::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->object = new Import($this->notationResolver, $this->relatedFileGeneratorMock); } /** diff --git a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/LessTest.php b/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/LessTest.php deleted file mode 100644 index 4b13f6d09411d..0000000000000 --- a/lib/internal/Magento/Framework/Css/Test/Unit/PreProcessor/LessTest.php +++ /dev/null @@ -1,58 +0,0 @@ -fileGenerator = $this->getMock('\Magento\Framework\Css\PreProcessor\FileGenerator', [], [], '', false); - $this->adapter = $this->getMockForAbstractClass('\Magento\Framework\Css\PreProcessor\AdapterInterface'); - $asset = $this->getMockForAbstractClass('\Magento\Framework\View\Asset\LocalInterface'); - $asset->expects($this->once())->method('getContentType')->will($this->returnValue('origType')); - $this->chain = new Chain($asset, 'original content', 'origType', 'origPath'); - $this->object = new \Magento\Framework\Css\PreProcessor\Less($this->fileGenerator, $this->adapter); - } - - public function testProcess() - { - $expectedContent = 'updated content'; - $tmpFile = 'tmp/file.ext'; - $this->fileGenerator->expects($this->once()) - ->method('generateFileTree') - ->with($this->chain) - ->will($this->returnValue($tmpFile)); - $this->adapter->expects($this->once()) - ->method('process') - ->with($tmpFile) - ->will($this->returnValue($expectedContent)); - $this->object->process($this->chain); - $this->assertEquals($expectedContent, $this->chain->getContent()); - $this->assertEquals('css', $this->chain->getContentType()); - } -} diff --git a/lib/internal/Magento/Framework/DB/AbstractMapper.php b/lib/internal/Magento/Framework/DB/AbstractMapper.php index eb34aa778a066..630e3ceb0ae3b 100644 --- a/lib/internal/Magento/Framework/DB/AbstractMapper.php +++ b/lib/internal/Magento/Framework/DB/AbstractMapper.php @@ -29,7 +29,7 @@ abstract class AbstractMapper implements MapperInterface /** * Resource instance * - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $resource; @@ -206,7 +206,7 @@ protected function getResourceModelName() /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource() { diff --git a/lib/internal/Magento/Framework/DB/Ddl/Table.php b/lib/internal/Magento/Framework/DB/Ddl/Table.php index a623ba4c0fb33..0b168e4c94a50 100644 --- a/lib/internal/Magento/Framework/DB/Ddl/Table.php +++ b/lib/internal/Magento/Framework/DB/Ddl/Table.php @@ -310,8 +310,8 @@ public function addColumn($name, $type, $size = null, $options = [], $comment = case self::TYPE_DECIMAL: case self::TYPE_NUMERIC: $match = []; - $scale = 10; - $precision = 0; + $scale = 0; + $precision = 10; // parse size value if (is_array($size)) { if (count($size) == 2) { diff --git a/lib/internal/Magento/Framework/DB/MapperInterface.php b/lib/internal/Magento/Framework/DB/MapperInterface.php index a8d6a54b918f2..4bf1e3be23c26 100644 --- a/lib/internal/Magento/Framework/DB/MapperInterface.php +++ b/lib/internal/Magento/Framework/DB/MapperInterface.php @@ -25,7 +25,7 @@ public function map(\Magento\Framework\Api\CriteriaInterface $criteria); /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource(); diff --git a/lib/internal/Magento/Framework/DB/Query.php b/lib/internal/Magento/Framework/DB/Query.php index 22368c1227bfd..203a5158f644f 100644 --- a/lib/internal/Magento/Framework/DB/Query.php +++ b/lib/internal/Magento/Framework/DB/Query.php @@ -27,7 +27,7 @@ class Query implements QueryInterface /** * Resource instance * - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $resource; @@ -78,13 +78,13 @@ class Query implements QueryInterface /** * @param \Magento\Framework\DB\Select $select * @param \Magento\Framework\Api\CriteriaInterface $criteria - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy */ public function __construct( \Magento\Framework\DB\Select $select, \Magento\Framework\Api\CriteriaInterface $criteria, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource, + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy ) { $this->select = $select; @@ -224,7 +224,7 @@ public function getConnection() /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource() { diff --git a/lib/internal/Magento/Framework/DB/QueryBuilder.php b/lib/internal/Magento/Framework/DB/QueryBuilder.php index 02eccb25e111c..c1e25ed0981eb 100644 --- a/lib/internal/Magento/Framework/DB/QueryBuilder.php +++ b/lib/internal/Magento/Framework/DB/QueryBuilder.php @@ -25,7 +25,7 @@ class QueryBuilder /** * Resource instance * - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $resource; @@ -65,10 +65,10 @@ public function setCriteria(\Magento\Framework\Api\CriteriaInterface $criteria) /** * Set Resource * - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource * @return void */ - public function setResource(\Magento\Framework\Model\ModelResource\Db\AbstractDb $resource) + public function setResource(\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource) { $this->resource = $resource; } diff --git a/lib/internal/Magento/Framework/DB/QueryInterface.php b/lib/internal/Magento/Framework/DB/QueryInterface.php index d1806a63466a5..e24290315926b 100644 --- a/lib/internal/Magento/Framework/DB/QueryInterface.php +++ b/lib/internal/Magento/Framework/DB/QueryInterface.php @@ -86,7 +86,7 @@ public function getConnection(); /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource(); diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php index 102cf2c9e1b8f..deec1825b9ef6 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/AbstractMapperTest.php @@ -16,7 +16,7 @@ class AbstractMapperTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -63,7 +63,7 @@ class AbstractMapperTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [], '', false, diff --git a/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php b/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php index 13626313c9809..d466786094ba8 100644 --- a/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php +++ b/lib/internal/Magento/Framework/DB/Test/Unit/QueryTest.php @@ -21,7 +21,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase protected $criteriaMock; /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -71,7 +71,7 @@ protected function setUp() [] ); $this->resourceMock = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [], '', false, diff --git a/lib/internal/Magento/Framework/Data/Collection/AbstractDb.php b/lib/internal/Magento/Framework/Data/Collection/AbstractDb.php index 0c602a4a09152..339c76f06c25b 100644 --- a/lib/internal/Magento/Framework/Data/Collection/AbstractDb.php +++ b/lib/internal/Magento/Framework/Data/Collection/AbstractDb.php @@ -117,7 +117,7 @@ public function __construct( /** * Get resource instance. * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ abstract public function getResource(); diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php b/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php index 1eb259438a5b2..c4f88313fc339 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php @@ -194,10 +194,10 @@ protected function _optionToHtml($option) { $id = $this->getHtmlId() . '_' . $this->_escape($option['value']); - $html = '
getHtmlAttributes() as $attribute) { if ($value = $this->getDataUsingMethod($attribute, $option['value'])) { - $html .= ' ' . $attribute . '="' . $value . '"'; + $html .= ' ' . $attribute . '="' . $value . '" class="admin__control-checkbox"'; } } $html .= ' value="' . @@ -205,9 +205,9 @@ protected function _optionToHtml($option) '" />' . '
' . + '
' . "\n"; return $html; } diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php index a5b5c41168bf0..9b33d71b7ca3b 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php @@ -385,14 +385,14 @@ protected function _getButtonHtml($data) protected function _wrapIntoContainer($html) { if (!$this->getConfig('use_container')) { - return $html; + return '
' .$html . '
'; } $html = '
getConfig( 'no_display' ) ? ' style="display:none;"' : '') . ($this->getConfig( 'container_class' - ) ? ' class="' . $this->getConfig( + ) ? ' class="admin__control-wysiwig ' . $this->getConfig( 'container_class' ) . '"' : '') . '>' . $html . '
'; diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Note.php b/lib/internal/Magento/Framework/Data/Form/Element/Note.php index be04c5e2bea43..06cad0f195e18 100644 --- a/lib/internal/Magento/Framework/Data/Form/Element/Note.php +++ b/lib/internal/Magento/Framework/Data/Form/Element/Note.php @@ -39,7 +39,7 @@ public function getElementHtml() $html = $this->getBeforeElementHtml() . '
' + . '" class="control-value admin__field-value">' . $this->getText() . '
' . $this->getAfterElementHtml(); diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbCollection.php b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbCollection.php index c334bf20d4ddb..144ef6fe20dfc 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbCollection.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbCollection.php @@ -11,17 +11,17 @@ class DbCollection extends \Magento\Framework\Data\Collection\AbstractDb { /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ private $resource; /** * Set DB resource for testing purposes. * - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource * @return $this */ - public function setResource(\Magento\Framework\Model\ModelResource\Db\AbstractDb $resource) + public function setResource(\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource) { $this->resource = $resource; return $this; @@ -30,7 +30,7 @@ public function setResource(\Magento\Framework\Model\ModelResource\Db\AbstractDb /** * Get resource instance. * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource() { diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php index 23e07bf7fb26c..a76a244f1cebc 100644 --- a/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php +++ b/lib/internal/Magento/Framework/Data/Test/Unit/Form/Element/NoteTest.php @@ -63,7 +63,7 @@ public function testGetElementHtml() $this->_model->setValue('Note Text'); $html = $this->_model->getElementHtml(); $this->assertEquals( - "note_before
note_after", + "note_before
note_after", $html ); } diff --git a/lib/internal/Magento/Framework/Flag/FlagResource.php b/lib/internal/Magento/Framework/Flag/FlagResource.php index 1ec3b61e0c1e7..730fee2e5d286 100644 --- a/lib/internal/Magento/Framework/Flag/FlagResource.php +++ b/lib/internal/Magento/Framework/Flag/FlagResource.php @@ -8,7 +8,7 @@ /** * Flag Resource model */ -class FlagResource extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +class FlagResource extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * Define main table diff --git a/lib/internal/Magento/Framework/Math/Random.php b/lib/internal/Magento/Framework/Math/Random.php index 03c0727efd26e..8ed28cb6021a9 100644 --- a/lib/internal/Magento/Framework/Math/Random.php +++ b/lib/internal/Magento/Framework/Math/Random.php @@ -24,9 +24,10 @@ class Random /** * Get random string * - * @param int $length + * @param int $length * @param null|string $chars * @return string + * @throws \Magento\Framework\Exception\LocalizedException */ public function getRandomString($length, $chars = null) { @@ -53,12 +54,9 @@ public function getRandomString($length, $chars = null) } fclose($fp); } else { - // fallback to mt_rand() if all else fails - mt_srand(10000000 * (double)microtime()); - for ($i = 0, $lc = strlen($chars) - 1; $i < $length; $i++) { - $rand = mt_rand(0, $lc); // random integer from 0 to $lc - $str .= $chars[$rand]; // random character in $chars - } + throw new \Magento\Framework\Exception\LocalizedException( + new \Magento\Framework\Phrase("Please make sure you have 'openssl' extension installed") + ); } return $str; @@ -70,6 +68,7 @@ public function getRandomString($length, $chars = null) * @param $min [optional] * @param $max [optional] * @return int A random integer value between min (or 0) and max + * @throws \Magento\Framework\Exception\LocalizedException */ public static function getRandomNumber($min = 0, $max = null) { @@ -91,9 +90,9 @@ public static function getRandomNumber($min = 0, $max = null) $offset = abs(hexdec($hex) % $range); // random integer from 0 to $range fclose($fp); } else { - // fallback to mt_rand() if all else fails - mt_srand(mt_rand() + (100000000 * microtime()) % PHP_INT_MAX); - return mt_rand($min, $max); // random integer from $min to $max + throw new \Magento\Framework\Exception\LocalizedException( + new \Magento\Framework\Phrase("Please make sure you have 'openssl' extension installed") + ); } return $min + $offset; // random integer from $min to $max diff --git a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php index 8ae263b14678a..24802ef1ac110 100644 --- a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php @@ -48,7 +48,7 @@ abstract class AbstractExtensibleModel extends AbstractModel implements * @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param AttributeValueFactory $customAttributeFactory - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ @@ -57,7 +57,7 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, AttributeValueFactory $customAttributeFactory, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php index 23280395c5f62..f72c455daf860 100644 --- a/lib/internal/Magento/Framework/Model/AbstractModel.php +++ b/lib/internal/Magento/Framework/Model/AbstractModel.php @@ -62,14 +62,14 @@ abstract class AbstractModel extends \Magento\Framework\DataObject /** * Resource model instance * - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $_resource; /** * Resource collection * - * @var \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection + * @var \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection */ protected $_resourceCollection; @@ -163,14 +163,14 @@ abstract class AbstractModel extends \Magento\Framework\DataObject /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry - * @param \Magento\Framework\Model\ModelResource\AbstractResource $resource + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, - \Magento\Framework\Model\ModelResource\AbstractResource $resource = null, + \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { @@ -448,7 +448,7 @@ protected function _setResourceModel($resourceName, $collectionName = null) * Get resource instance * * @throws \Magento\Framework\Exception\LocalizedException - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected function _getResource() { @@ -476,7 +476,7 @@ public function getResourceName() * * @TODO MAGETWO-23541: Incorrect dependencies between Model\AbstractModel and Data\Collection\Db from Framework * @throws \Magento\Framework\Exception\LocalizedException - * @return \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection + * @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection */ public function getResourceCollection() { @@ -496,7 +496,7 @@ public function getResourceCollection() * Retrieve collection instance * * @TODO MAGETWO-23541: Incorrect dependencies between Model\AbstractModel and Data\Collection\Db from Framework - * @return \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection + * @return \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection */ public function getCollection() { @@ -849,7 +849,7 @@ public function afterDeleteCommit() /** * Retrieve model resource * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource() { diff --git a/lib/internal/Magento/Framework/Model/ModelResource/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php similarity index 99% rename from lib/internal/Magento/Framework/Model/ModelResource/AbstractResource.php rename to lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 17cd5e51c23e6..ccd2131de93d8 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -6,7 +6,7 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\ModelResource; +namespace Magento\Framework\Model\ResourceModel; /** * Abstract resource model diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php similarity index 98% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/AbstractDb.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php index 814135e008aa0..6f25689747e99 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php @@ -4,12 +4,12 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\AlreadyExistsException; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Model\ModelResource\AbstractResource; +use Magento\Framework\Model\ResourceModel\AbstractResource; /** * Abstract resource model class @@ -133,10 +133,10 @@ abstract class AbstractDb extends AbstractResource /** * Class constructor * - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param string $connectionName */ - public function __construct(\Magento\Framework\Model\ModelResource\Db\Context $context, $connectionName = null) + public function __construct(\Magento\Framework\Model\ResourceModel\Db\Context $context, $connectionName = null) { $this->transactionManager = $context->getTransactionManager(); $this->_resources = $context->getResources(); diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/Collection/AbstractCollection.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php similarity index 97% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/Collection/AbstractCollection.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php index 352861097da76..582d6c79f64e0 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/Collection/AbstractCollection.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php @@ -6,7 +6,7 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\ModelResource\Db\Collection; +namespace Magento\Framework\Model\ResourceModel\Db\Collection; use Magento\Framework\App\ResourceConnection\SourceProviderInterface; /** @@ -33,7 +33,7 @@ abstract class AbstractCollection extends \Magento\Framework\Data\Collection\Abs /** * Resource instance * - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $_resource; @@ -106,7 +106,7 @@ abstract class AbstractCollection extends \Magento\Framework\Data\Collection\Abs * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, @@ -114,7 +114,7 @@ public function __construct( \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { $this->_eventManager = $eventManager; parent::__construct($entityFactory, $logger, $fetchStrategy, $connection); @@ -455,7 +455,7 @@ public function getResourceModelName() /** * Get resource instance * - * @return \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ public function getResource() { diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/Context.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Context.php similarity index 96% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/Context.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/Context.php index 59fefb8016be7..13877e882e989 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/Context.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Context.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; /** * @codeCoverageIgnore diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/ObjectRelationProcessor.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/ObjectRelationProcessor.php similarity index 95% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/ObjectRelationProcessor.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/ObjectRelationProcessor.php index 194d00d242906..89ec37c6bf0f9 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/ObjectRelationProcessor.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/ObjectRelationProcessor.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; use Magento\Framework\DB\Adapter\AdapterInterface as Connection; diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/Profiler.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Profiler.php similarity index 94% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/Profiler.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/Profiler.php index 05655c886f660..0ae0f5ea4c373 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/Profiler.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/Profiler.php @@ -5,7 +5,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; class Profiler extends \Magento\Framework\DB\Profiler { @@ -33,7 +33,7 @@ class Profiler extends \Magento\Framework\DB\Profiler protected function _getTimerName($operation) { // default name of connection type - $timerName = \Magento\Framework\Model\ModelResource\Db\Profiler::DEFAULT_CONNECTION_TYPE; + $timerName = \Magento\Framework\Model\ResourceModel\Db\Profiler::DEFAULT_CONNECTION_TYPE; // connection type to database if (!empty($this->_type)) { @@ -48,7 +48,7 @@ protected function _getTimerName($operation) $timerName .= '_' . $this->_host; } - return \Magento\Framework\Model\ModelResource\Db\Profiler::TIMER_PREFIX . ':' . $timerName; + return \Magento\Framework\Model\ResourceModel\Db\Profiler::TIMER_PREFIX . ':' . $timerName; } /** diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManager.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManager.php similarity index 96% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManager.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManager.php index 57a636a577b97..920eca7e94155 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManager.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManager.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; use Magento\Framework\DB\Adapter\AdapterInterface as Connection; diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManagerInterface.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManagerInterface.php similarity index 91% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManagerInterface.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManagerInterface.php index 981edbb64c1bc..e4e72c8999a47 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/TransactionManagerInterface.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/TransactionManagerInterface.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db; +namespace Magento\Framework\Model\ResourceModel\Db; use Magento\Framework\DB\Adapter\AdapterInterface as Connection; diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/AbstractDb.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/AbstractDb.php similarity index 86% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/AbstractDb.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/AbstractDb.php index 8b8e3e8c3558c..b6da084e2b771 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/AbstractDb.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/AbstractDb.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; /** * Class AbstractDb with snapshot saving and relation save processing */ -abstract class AbstractDb extends \Magento\Framework\Model\ModelResource\Db\AbstractDb +abstract class AbstractDb extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb { /** * @var Snapshot @@ -23,11 +23,11 @@ abstract class AbstractDb extends \Magento\Framework\Model\ModelResource\Db\Abst /** * @param Snapshot $entitySnapshot * @param RelationComposite $entityRelationComposite - * @param \Magento\Framework\Model\ModelResource\Db\Context $context + * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param string $connectionName */ public function __construct( - \Magento\Framework\Model\ModelResource\Db\Context $context, + \Magento\Framework\Model\ResourceModel\Db\Context $context, Snapshot $entitySnapshot, RelationComposite $entityRelationComposite, $connectionName = null diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Collection.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Collection.php similarity index 85% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Collection.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Collection.php index 75804638605b6..3591c1a2c07b8 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Collection.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Collection.php @@ -3,12 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; /** * Class Collection */ -abstract class Collection extends \Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection +abstract class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection { /** * @var Snapshot @@ -22,7 +22,7 @@ abstract class Collection extends \Magento\Framework\Model\ModelResource\Db\Coll * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param Snapshot $entitySnapshot * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection - * @param \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource + * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct( \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, @@ -31,7 +31,7 @@ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, Snapshot $entitySnapshot, \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ModelResource\Db\AbstractDb $resource = null + \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null ) { $this->entitySnapshot = $entitySnapshot; parent::__construct( diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Metadata.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Metadata.php similarity index 94% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Metadata.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Metadata.php index 7dfef23ac5ba2..bfab1304282e7 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Metadata.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Metadata.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; /** * Class Metadata represents a list of entity fields that are applicable for persistence operations diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationComposite.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php similarity index 95% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationComposite.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php index 49d9ff8db1a91..23626faa7bf66 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationComposite.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationComposite.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; use Magento\Framework\Model\AbstractModel; use Magento\Framework\Event\ManagerInterface as EventManager; diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationInterface.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationInterface.php similarity index 86% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationInterface.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationInterface.php index 636597621ff74..257b9652b316c 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/RelationInterface.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/RelationInterface.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; /** * Interface RelationInterface diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Snapshot.php b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php similarity index 96% rename from lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Snapshot.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php index 854c1423dc081..c2de9047c4ed4 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Db/VersionControl/Snapshot.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Db/VersionControl/Snapshot.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\ResourceModel\Db\VersionControl; /** * Class Snapshot register snapshot of entity data, for tracking changes diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Entity/AbstractEntity.php b/lib/internal/Magento/Framework/Model/ResourceModel/Entity/AbstractEntity.php similarity index 94% rename from lib/internal/Magento/Framework/Model/ModelResource/Entity/AbstractEntity.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Entity/AbstractEntity.php index d725a10274482..6b323bf323c28 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Entity/AbstractEntity.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Entity/AbstractEntity.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Entity; +namespace Magento\Framework\Model\ResourceModel\Entity; abstract class AbstractEntity { diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Entity/Table.php b/lib/internal/Magento/Framework/Model/ResourceModel/Entity/Table.php similarity index 73% rename from lib/internal/Magento/Framework/Model/ModelResource/Entity/Table.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Entity/Table.php index 75fe3c8189ad4..f6eac910f3ea4 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Entity/Table.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Entity/Table.php @@ -3,13 +3,13 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Entity; +namespace Magento\Framework\Model\ResourceModel\Entity; /** * Class describing db table resource entity * */ -class Table extends \Magento\Framework\Model\ModelResource\Entity\AbstractEntity +class Table extends \Magento\Framework\Model\ResourceModel\Entity\AbstractEntity { /** * Get table diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Iterator.php b/lib/internal/Magento/Framework/Model/ResourceModel/Iterator.php similarity index 94% rename from lib/internal/Magento/Framework/Model/ModelResource/Iterator.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Iterator.php index 63de2861a2bed..c165dec4e7a5f 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Iterator.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Iterator.php @@ -7,7 +7,7 @@ /** * Active record implementation */ -namespace Magento\Framework\Model\ModelResource; +namespace Magento\Framework\Model\ResourceModel; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\LocalizedException; @@ -22,7 +22,7 @@ class Iterator extends \Magento\Framework\DataObject * @param array|string $callbacks * @param array $args * @param AdapterInterface $connection - * @return \Magento\Framework\Model\ModelResource\Iterator + * @return \Magento\Framework\Model\ResourceModel\Iterator */ public function walk($query, array $callbacks, array $args = [], $connection = null) { diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Type/AbstractType.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php similarity index 83% rename from lib/internal/Magento/Framework/Model/ModelResource/Type/AbstractType.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php index 6a219bf660890..172434f5d56b2 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Type/AbstractType.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/AbstractType.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type; +namespace Magento\Framework\Model\ResourceModel\Type; abstract class AbstractType { @@ -19,7 +19,7 @@ abstract class AbstractType * * @var String */ - protected $_entityClass = 'Magento\Framework\Model\ModelResource\Entity\AbstractEntity'; + protected $_entityClass = 'Magento\Framework\Model\ResourceModel\Entity\AbstractEntity'; /** * Retrieve entity type diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php similarity index 50% rename from lib/internal/Magento/Framework/Model/ModelResource/Type/Db.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php index 9c07c36575d65..db4737b9923c3 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db.php @@ -3,15 +3,15 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type; +namespace Magento\Framework\Model\ResourceModel\Type; -abstract class Db extends \Magento\Framework\Model\ModelResource\Type\AbstractType +abstract class Db extends \Magento\Framework\Model\ResourceModel\Type\AbstractType { /** * Constructor */ public function __construct() { - $this->_entityClass = 'Magento\Framework\Model\ModelResource\Entity\Table'; + $this->_entityClass = 'Magento\Framework\Model\ResourceModel\Entity\Table'; } } diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactory.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactory.php similarity index 95% rename from lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactory.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactory.php index 886d1fdbdaaa3..ed253a64539aa 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactory.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactory.php @@ -5,7 +5,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type\Db; +namespace Magento\Framework\Model\ResourceModel\Type\Db; use Magento\Framework\ObjectManagerInterface; diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryInterface.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryInterface.php similarity index 88% rename from lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryInterface.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryInterface.php index ce5cbb166d27c..02a9dd0bce60d 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/ConnectionFactoryInterface.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/ConnectionFactoryInterface.php @@ -5,7 +5,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\ModelResource\Type\Db; +namespace Magento\Framework\Model\ResourceModel\Type\Db; interface ConnectionFactoryInterface { diff --git a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/Pdo/Mysql.php b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/Mysql.php similarity index 95% rename from lib/internal/Magento/Framework/Model/ModelResource/Type/Db/Pdo/Mysql.php rename to lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/Mysql.php index 5ed1847c4df13..e28f3109687db 100644 --- a/lib/internal/Magento/Framework/Model/ModelResource/Type/Db/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/Type/Db/Pdo/Mysql.php @@ -6,13 +6,13 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\ModelResource\Type\Db\Pdo; +namespace Magento\Framework\Model\ResourceModel\Type\Db\Pdo; use Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface; use Magento\Framework\DB; use Magento\Framework\Stdlib; -class Mysql extends \Magento\Framework\Model\ModelResource\Type\Db implements ConnectionAdapterInterface +class Mysql extends \Magento\Framework\Model\ResourceModel\Type\Db implements ConnectionAdapterInterface { /** * @var Stdlib\StringUtils diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php index 753c995c8c2cc..84959d0952390 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractExtensibleModelTest.php @@ -29,7 +29,7 @@ class AbstractExtensibleModelTest extends \PHPUnit_Framework_TestCase protected $registryMock; /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -72,7 +72,7 @@ protected function setUp() ); $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [ '_construct', 'getConnection', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php index 0ca67c81c32fb..e0674f8a882a8 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/AbstractModelTest.php @@ -25,7 +25,7 @@ class AbstractModelTest extends \PHPUnit_Framework_TestCase protected $registryMock; /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; @@ -62,7 +62,7 @@ protected function setUp() ); $this->registryMock = $this->getMock('Magento\Framework\Registry', [], [], '', false); $this->resourceMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [ '_construct', 'getConnection', diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/AbstractDbTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php similarity index 93% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/AbstractDbTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php index 71d0c2be8b028..b6ec3d9a68f27 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/AbstractDbTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/AbstractDbTest.php @@ -6,12 +6,12 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\Test\Unit\ModelResource\Db; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db; class AbstractDbTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $_model; @@ -41,16 +41,16 @@ protected function setUp() ); $this->relationProcessorMock = $this->getMock( - '\Magento\Framework\Model\ModelResource\Db\ObjectRelationProcessor', + '\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor', [], [], '', false ); $this->transactionManagerMock = $this->getMock( - '\Magento\Framework\Model\ModelResource\Db\TransactionManagerInterface' + '\Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface' ); - $contextMock = $this->getMock('\Magento\Framework\Model\ModelResource\Db\Context', [], [], '', false); + $contextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); $contextMock->expects($this->once())->method('getResources')->willReturn($this->_resourcesMock); $contextMock->expects($this->once()) ->method('getObjectRelationProcessor') @@ -60,7 +60,7 @@ protected function setUp() ->willReturn($this->transactionManagerMock); $this->_model = $this->getMockForAbstractClass( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [$contextMock], '', true, @@ -113,7 +113,7 @@ public function addUniqueFieldDataProvider() public function testAddUniqueFieldArray() { $this->assertInstanceOf( - '\Magento\Framework\Model\ModelResource\Db\AbstractDb', + '\Magento\Framework\Model\ResourceModel\Db\AbstractDb', $this->_model->addUniqueField(['someField']) ); } @@ -131,7 +131,7 @@ public function testGetIdFieldname() { $data = 'MainTableName'; $idFieldNameProperty = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', '_idFieldName' + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName' ); $idFieldNameProperty->setAccessible(true); $idFieldNameProperty->setValue($this->_model, $data); @@ -154,7 +154,7 @@ public function testGetMainTableException() */ public function testGetMainTable($tableName, $expectedResult) { - $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ModelResource\Db\AbstractDb', '_mainTable'); + $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable'); $mainTableProperty->setAccessible(true); $mainTableProperty->setValue($this->_model, $tableName); $this->_resourcesMock->expects($this->once()) @@ -188,7 +188,7 @@ public function testGetTable() $this->_resourcesMock->expects($this->once())->method('getTableName')->with($data)->will( $this->returnValue('tableName') ); - $tablesProperty = new \ReflectionProperty('Magento\Framework\Model\ModelResource\Db\AbstractDb', '_tables'); + $tablesProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_tables'); $tablesProperty->setAccessible(true); $tablesProperty->setValue($this->_model, [$data]); $this->assertEquals($data, $this->_model->getTable($data)); @@ -232,7 +232,7 @@ public function getChecksumProvider() public function testResetUniqueField() { - $uniqueFields = new \ReflectionProperty('Magento\Framework\Model\ModelResource\Db\AbstractDb', '_uniqueFields'); + $uniqueFields = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_uniqueFields'); $uniqueFields->setAccessible(true); $uniqueFields->setValue($this->_model, ['uniqueField1', 'uniqueField2']); $this->_model->resetUniqueField(); @@ -242,7 +242,7 @@ public function testResetUniqueField() public function testGetUniqueFields() { $uniqueFieldsReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_uniqueFields' ); $uniqueFieldsReflection->setAccessible(true); @@ -270,12 +270,12 @@ public function testLoad() ); $value = 'some_value'; - $idFieldName = new \ReflectionProperty('Magento\Framework\Model\ModelResource\Db\AbstractDb', '_idFieldName'); + $idFieldName = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName'); $idFieldName->setAccessible(true); $idFieldName->setValue($this->_model, 'field_value'); $this->assertInstanceOf( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', $this->_model->load($abstractModelMock, $value, $idFieldName) ); } @@ -323,13 +323,13 @@ public function testDelete() $this->returnValue('tableName') ); $mainTableReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable' ); $mainTableReflection->setAccessible(true); $mainTableReflection->setValue($this->_model, 'tableName'); $idFieldNameReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName' ); $idFieldNameReflection->setAccessible(true); @@ -340,7 +340,7 @@ public function testDelete() $abstractModelMock->expects($this->once())->method('afterDelete'); $abstractModelMock->expects($this->once())->method('afterDeleteCommit'); $this->assertInstanceOf( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', $this->_model->delete($abstractModelMock) ); } @@ -384,7 +384,7 @@ public function testGetDataChanged($getOriginData, $expected) true, ['__wakeup', 'getOrigData', 'getData'] ); - $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ModelResource\Db\AbstractDb', '_mainTable'); + $mainTableProperty = new \ReflectionProperty('Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable'); $mainTableProperty->setAccessible(true); $mainTableProperty->setValue($this->_model, 'table'); @@ -417,7 +417,7 @@ public function testPrepareDataForUpdate() ); $registryMock = $this->getMock('\Magento\Framework\Registry', [], [], '', false); $resourceMock = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', [ '_construct', 'getConnection', @@ -448,13 +448,13 @@ public function testPrepareDataForUpdate() $this->returnValue('tableName') ); $mainTableReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_mainTable' ); $mainTableReflection->setAccessible(true); $mainTableReflection->setValue($this->_model, 'tableName'); $idFieldNameReflection = new \ReflectionProperty( - 'Magento\Framework\Model\ModelResource\Db\AbstractDb', + 'Magento\Framework\Model\ResourceModel\Db\AbstractDb', '_idFieldName' ); $idFieldNameReflection->setAccessible(true); @@ -499,7 +499,7 @@ public function testSaveNewObject($pkIncrement) /** * Mock SUT so as not to test extraneous logic */ - $model = $this->getMockBuilder('Magento\Framework\Model\ModelResource\Db\AbstractDb') + $model = $this->getMockBuilder('Magento\Framework\Model\ResourceModel\Db\AbstractDb') ->disableOriginalConstructor() ->setMethods(['_prepareDataForSave', 'getIdFieldName', 'getConnection', 'getMainTable']) ->getMockForAbstractClass(); diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/Collection/AbstractCollectionTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php similarity index 97% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/Collection/AbstractCollectionTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php index e64b46417dfd9..8e9abd11fef86 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/Collection/AbstractCollectionTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php @@ -6,10 +6,10 @@ // @codingStandardsIgnoreFile -namespace Magento\Framework\Model\Test\Unit\ModelResource\Db\Collection; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection; use Magento\Framework\DB\Select; -use Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; use Magento\Framework\DataObject as MagentoObject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; @@ -38,7 +38,7 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $managerMock; - /** @var \Magento\Framework\Model\ModelResource\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Model\ResourceModel\Db\AbstractDb|\PHPUnit_Framework_MockObject_MockObject */ protected $resourceMock; /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql|\PHPUnit_Framework_MockObject_MockObject */ @@ -103,14 +103,14 @@ protected function tearDown() protected function getUut() { return $this->objectManagerHelper->getObject( - 'Magento\Framework\Model\Test\Unit\ModelResource\Db\Collection\Uut', + 'Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection\Uut', [ 'entityFactory' => $this->entityFactoryMock, 'logger' => $this->loggerMock, 'fetchStrategy' => $this->fetchStrategyMock, 'eventManager' => $this->managerMock, 'connection' => $this->connectionMock, - // Magento\Framework\Flag\FlagResource extends Magento\Framework\Model\ModelResource\Db\AbstractDb + // Magento\Framework\Flag\FlagResource extends Magento\Framework\Model\ResourceModel\Db\AbstractDb 'resource' => $this->resourceMock, ] ); diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/MetadataTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php similarity index 91% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/MetadataTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php index cb8768fbf06ce..014909543bc56 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/MetadataTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/MetadataTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\Test\Unit\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\VersionControl; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,7 +13,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\VersionControl\Metadata + * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata */ protected $entityMetadata; @@ -23,7 +23,7 @@ class MetadataTest extends \PHPUnit_Framework_TestCase protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Model\ModelResource\Db\AbstractDb + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $resource; @@ -64,7 +64,7 @@ protected function setUp() $this->model->expects($this->any())->method('getResource')->willReturn($this->resource); $this->resource->expects($this->any())->method('getConnection')->willReturn($this->connection); $this->entityMetadata = $objectManager->getObject( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\Metadata' + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata' ); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/RelationCompositeTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php similarity index 88% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/RelationCompositeTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php index e099a2d0ceecc..428e9bef37de4 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/RelationCompositeTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/RelationCompositeTest.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\Test\Unit\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\VersionControl; /** * Class RelationCompositeTest @@ -12,7 +12,7 @@ class RelationCompositeTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite + * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite */ protected $entityRelationComposite; @@ -22,7 +22,7 @@ class RelationCompositeTest extends \PHPUnit_Framework_TestCase protected $modelMock; /** - * @var \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationInterface + * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface */ protected $relationProcessorMock; @@ -48,10 +48,10 @@ public function setUp() ->disableOriginalConstructor() ->getMockForAbstractClass(); $this->relationProcessorMock = $this->getMockBuilder( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\RelationInterface' + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationInterface' )->disableOriginalConstructor()->getMockForAbstractClass(); - $this->entityRelationComposite = new \Magento\Framework\Model\ModelResource\Db\VersionControl\RelationComposite( + $this->entityRelationComposite = new \Magento\Framework\Model\ResourceModel\Db\VersionControl\RelationComposite( $this->eventManagerMock, [ 'default' => $this->relationProcessorMock diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/SnapshotTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php similarity index 90% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/SnapshotTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php index 36dd2997d93ad..a228106db6487 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Db/VersionControl/SnapshotTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/VersionControl/SnapshotTest.php @@ -3,7 +3,7 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\Test\Unit\ModelResource\Db\VersionControl; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\VersionControl; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -13,12 +13,12 @@ class SnapshotTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot + * @var \Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot */ protected $entitySnapshot; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Model\ModelResource\Db\VersionControl\Metadata + * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata */ protected $entityMetadata; @@ -42,7 +42,7 @@ protected function setUp() ); $this->entityMetadata = $this->getMock( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\Metadata', + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Metadata', ['getFields'], [], '', @@ -50,7 +50,7 @@ protected function setUp() ); $this->entitySnapshot = $objectManager->getObject( - 'Magento\Framework\Model\ModelResource\Db\VersionControl\Snapshot', + 'Magento\Framework\Model\ResourceModel\Db\VersionControl\Snapshot', ['metadata' => $this->entityMetadata] ); } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/ConnectionFactoryTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/ConnectionFactoryTest.php similarity index 93% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/ConnectionFactoryTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/ConnectionFactoryTest.php index 8b3ee72e72289..011530e544ec5 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/ConnectionFactoryTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/ConnectionFactoryTest.php @@ -3,11 +3,11 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\Test\Unit\ModelResource\Type\Db; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Type\Db; use Magento\Framework\App\ResourceConnection\ConnectionAdapterInterface; use Magento\Framework\DB\LoggerInterface; -use Magento\Framework\Model\ModelResource\Type\Db\ConnectionFactory; +use Magento\Framework\Model\ResourceModel\Type\Db\ConnectionFactory; use Magento\Framework\ObjectManagerInterface; class ConnectionFactoryTest extends \PHPUnit_Framework_TestCase diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/Pdo/MysqlTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php similarity index 96% rename from lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/Pdo/MysqlTest.php rename to lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php index bab2946213e56..05c7a39503104 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ModelResource/Type/Db/Pdo/MysqlTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Type/Db/Pdo/MysqlTest.php @@ -4,9 +4,9 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Model\Test\Unit\ModelResource\Type\Db\Pdo; +namespace Magento\Framework\Model\Test\Unit\ResourceModel\Type\Db\Pdo; -use \Magento\Framework\Model\ModelResource\Type\Db\Pdo\Mysql; +use \Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql; class MysqlTest extends \PHPUnit_Framework_TestCase { diff --git a/lib/internal/Magento/Framework/Module/ModuleResource.php b/lib/internal/Magento/Framework/Module/ModuleResource.php index bbba5b3307368..10b49c469e594 100644 --- a/lib/internal/Magento/Framework/Module/ModuleResource.php +++ b/lib/internal/Magento/Framework/Module/ModuleResource.php @@ -11,7 +11,7 @@ /** * Resource Model */ -class ModuleResource extends \Magento\Framework\Model\ModelResource\Db\AbstractDb implements \Magento\Framework\Module\ResourceInterface +class ModuleResource extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb implements \Magento\Framework\Module\ResourceInterface { /** * Database versions diff --git a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php index 2a71963fb6614..4f2d966099d96 100644 --- a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php +++ b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php @@ -7,16 +7,34 @@ class Executor { + /** + * @var State + */ + private $state; + + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + + /** + * @var \Magento\Framework\App\State + */ + private $appState; + /** * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\Setup\SampleData\State $state + * @param State $state + * @param \Magento\Framework\App\State $appState */ public function __construct( \Psr\Log\LoggerInterface $logger, - \Magento\Framework\Setup\SampleData\State $state + \Magento\Framework\Setup\SampleData\State $state, + \Magento\Framework\App\State $appState ) { $this->logger = $logger; $this->state = $state; + $this->appState = $appState; } /** @@ -29,7 +47,7 @@ public function __construct( public function exec(InstallerInterface $installer) { try { - $installer->install(); + $this->appState->emulateAreaCode('setup', [$installer, 'install']); $this->state->setInstalled(); } catch (\Exception $e) { $this->state->setError(); diff --git a/lib/internal/Magento/Framework/Test/Unit/FlagTest.php b/lib/internal/Magento/Framework/Test/Unit/FlagTest.php index da7593745b826..4cf45055b9f43 100644 --- a/lib/internal/Magento/Framework/Test/Unit/FlagTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/FlagTest.php @@ -55,7 +55,7 @@ protected function createInstance(array $data = []) ->method('getConnection') ->will($this->returnValue($connection)); - $dbContextMock = $this->getMock('\Magento\Framework\Model\ModelResource\Db\Context', [], [], '', false); + $dbContextMock = $this->getMock('\Magento\Framework\Model\ResourceModel\Db\Context', [], [], '', false); $dbContextMock->expects($this->once())->method('getResources')->willReturn($appResource); $resource = $this->getMock( '\Magento\Framework\Flag\FlagResource', diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php index e1904afd558d3..aecb780b1087b 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Helper/ObjectManager.php @@ -17,7 +17,7 @@ class ObjectManager * @var array */ protected $_specialCases = [ - 'Magento\Framework\Model\ModelResource\AbstractResource' => '_getResourceModelMock', + 'Magento\Framework\Model\ResourceModel\AbstractResource' => '_getResourceModelMock', 'Magento\Framework\TranslateInterface' => '_getTranslatorMock', ]; diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd index 3790dec48e07b..f57cee5918faf 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_components.xsd @@ -114,6 +114,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd index 2cf581c0e9bb6..9cdf105649446 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_configuration.xsd @@ -34,6 +34,9 @@ + + + @@ -80,6 +83,8 @@ + + diff --git a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd b/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd index 75b710a0e8bf4..78cd48d5f43a2 100644 --- a/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd +++ b/lib/internal/Magento/Framework/Ui/etc/ui_definition.xsd @@ -48,11 +48,15 @@ + + + + diff --git a/lib/internal/Magento/Framework/View/Asset/ContentProcessorInterface.php b/lib/internal/Magento/Framework/View/Asset/ContentProcessorInterface.php new file mode 100644 index 0000000000000..a7df2aad78c42 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Asset/ContentProcessorInterface.php @@ -0,0 +1,27 @@ +filesystem = $filesystem; + } + + /** + * @inheritdoc + * @throws FileSystemException + */ + public function lockProcess($lockName) + { + $this->tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $this->lockFilePath = $this->getFilePath($lockName); + + while ($this->isProcessLocked()) { + sleep(1); + } + + $this->tmpDirectory->writeFile($this->lockFilePath, time()); + + } + + /** + * @inheritdoc + * @throws FileSystemException + */ + public function unlockProcess() + { + $this->tmpDirectory->delete($this->lockFilePath); + } + + /** + * Check whether generation process has already locked + * + * @return bool + * @throws FileSystemException + */ + private function isProcessLocked() + { + if ($this->tmpDirectory->isExist($this->lockFilePath)) { + $lockTime = (int) $this->tmpDirectory->readFile($this->lockFilePath); + if ((time() - $lockTime) >= self::MAX_LOCK_TIME) { + $this->tmpDirectory->delete($this->lockFilePath); + + return false; + } + + return true; + } + + return false; + } + + /** + * Get name of lock file + * + * @param string $name + * @return string + */ + private function getFilePath($name) + { + return DirectoryList::TMP . DIRECTORY_SEPARATOR . $name . self::LOCK_EXTENSION; + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/LockerProcessInterface.php b/lib/internal/Magento/Framework/View/Asset/LockerProcessInterface.php new file mode 100644 index 0000000000000..d719653a5f18d --- /dev/null +++ b/lib/internal/Magento/Framework/View/Asset/LockerProcessInterface.php @@ -0,0 +1,23 @@ +objectManager = $objectManager; + $this->lockerProcess = $lockerProcess; + $this->sorter = $sorter; + $this->alternatives = $alternatives; + $this->lockName = $lockName; + $this->assetBuilder = $assetBuilder; + } + + /** + * @inheritdoc + * @throws \UnexpectedValueException + */ + public function process(Chain $chain) + { + $path = $chain->getAsset()->getFilePath(); + $content = $chain->getContent(); + if (trim($content) !== '') { + return; + } + + try { + $this->lockerProcess->lockProcess($this->lockName . sprintf('%x', crc32($path . $content))); + + $module = $chain->getAsset()->getModule(); + + /** @var FallbackContext $context */ + $context = $chain->getAsset()->getContext(); + $chain->setContent($this->processContent($path, $content, $module, $context)); + } finally { + $this->lockerProcess->unlockProcess(); + } + } + + /** + * Preparation of content for the destination file + * + * @param string $path + * @param string $content + * @param string $module + * @param FallbackContext $context + * @return string + * @throws \UnexpectedValueException + */ + private function processContent($path, $content, $module, FallbackContext $context) + { + if ($this->alternativesSorted === null) { + $this->alternativesSorted = $this->sorter->sort($this->alternatives); + } + + foreach ($this->alternativesSorted as $name => $alternative) { + $asset = $this->assetBuilder->setArea($context->getAreaCode()) + ->setTheme($context->getThemePath()) + ->setLocale($context->getLocale()) + ->setModule($module) + ->setPath(preg_replace( + '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#', + '.' . $name, + $path + ))->build(); + + $processor = $this->objectManager->get($alternative[self::PROCESSOR_CLASS]); + if (!$processor instanceof ContentProcessorInterface) { + throw new \UnexpectedValueException( + '"' . $alternative[self::PROCESSOR_CLASS] . '" has to implement the ContentProcessorInterface.' + ); + } + $content = $processor->processContent($asset); + + if (trim($content) !== '') { + return $content; + } + } + + return $content; + } + + /** + * @inheritdoc + */ + public function getAlternativesExtensionsNames() + { + return array_keys($this->alternatives); + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource/AssetBuilder.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource/AssetBuilder.php new file mode 100644 index 0000000000000..79f13bb5632a4 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource/AssetBuilder.php @@ -0,0 +1,134 @@ +repository = $repository; + } + + /** + * Set area + * + * @param string $area + * @return $this + */ + public function setArea($area) + { + $this->area = $area; + return $this; + } + + /** + * Set theme + * + * @param string $theme + * @return $this + */ + public function setTheme($theme) + { + $this->theme = $theme; + return $this; + } + + /** + * Set locale + * + * @param string $locale + * @return $this + */ + public function setLocale($locale) + { + $this->locale = $locale; + return $this; + } + + /** + * Set module + * + * @param string $module + * @return $this + */ + public function setModule($module) + { + $this->module = $module; + return $this; + } + + /** + * Set path + * + * @param string $path + * @return $this + */ + public function setPath($path) + { + $this->path = $path; + return $this; + } + + /** + * @return File + */ + public function build() + { + $params = [ + 'area' => $this->area, + 'theme' => $this->theme, + 'locale' => $this->locale, + 'module' => $this->module, + ]; + + $asset = $this->repository->createAsset($this->path, $params); + + unset($this->path, $this->module, $this->locale, $this->theme, $this->area); + + return $asset; + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSourceInterface.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSourceInterface.php new file mode 100644 index 0000000000000..43a20b7480944 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSourceInterface.php @@ -0,0 +1,21 @@ +result = []; + $this->array = $array; + + $nodes = []; + $structure = []; + foreach ($this->array as $name => $item) { + $nodes[$name] = isset($nodes[$name]) ? $nodes[$name] : [self::NEXT_KEY => null]; + if (isset($item[self::DIRECTIVE])) { + $nodes[$item[self::DIRECTIVE]][self::NEXT_KEY][$name] = &$nodes[$name]; + continue; + } + $structure[$name] = &$nodes[$name]; + } + + $this->fillResult($structure); + + return $this->result; + } + + /** + * @param array $structure + * @return void + */ + private function fillResult(array $structure) + { + foreach ($structure as $name => $item) { + $this->result[$name] = $this->array[$name]; + if (!empty($item[self::NEXT_KEY])) { + $this->fillResult($item[self::NEXT_KEY]); + } + } + } +} diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/Helper/SortInterface.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/Helper/SortInterface.php new file mode 100644 index 0000000000000..130add1da0108 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/Helper/SortInterface.php @@ -0,0 +1,23 @@ + ['after' => 'xxx', 'data' => [...]] + * 'name-2' => ['after' => 'xxx', 'data' => [...]] + * ] + * @param array $array + * @return array + */ + public function sort(array $array); +} diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/Pool.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/Pool.php index 7a8fee000db44..ee891d9672076 100644 --- a/lib/internal/Magento/Framework/View/Asset/PreProcessor/Pool.php +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/Pool.php @@ -14,24 +14,51 @@ */ class Pool { + const PREPROCESSOR_CLASS = 'class'; + /** - * @var ObjectManagerInterface + * @var array */ - private $objectManager; + private $preprocessors; /** * @var array */ - private $preProcessorClasses = []; + private $instances; + + /** + * @var Helper\SortInterface + */ + private $sorter; + + /** + * @var string + */ + private $defaultPreprocessor; /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * Constructor + * * @param ObjectManagerInterface $objectManager - * @param array $preProcessors + * @param Helper\SortInterface $sorter + * @param string $defaultPreprocessor + * @param array $preprocessors */ - public function __construct(ObjectManagerInterface $objectManager, array $preProcessors = []) - { + public function __construct( + ObjectManagerInterface $objectManager, + Helper\SortInterface $sorter, + $defaultPreprocessor, + array $preprocessors = [] + ) { + $this->preprocessors = $preprocessors; + $this->sorter = $sorter; + $this->defaultPreprocessor = $defaultPreprocessor; $this->objectManager = $objectManager; - $this->preProcessorClasses = $preProcessors; } /** @@ -42,9 +69,8 @@ public function __construct(ObjectManagerInterface $objectManager, array $prePro */ public function process(Chain $chain) { - $fromType = $chain->getOrigContentType(); - $toType = $chain->getTargetContentType(); - foreach ($this->getPreProcessors($fromType, $toType) as $preProcessor) { + $type = $chain->getTargetContentType(); + foreach ($this->getPreProcessors($type) as $preProcessor) { $preProcessor->process($chain); } } @@ -52,28 +78,35 @@ public function process(Chain $chain) /** * Retrieve preProcessors by types * - * @param string $fromType - * @param string $toType + * @param string $type * @return PreProcessorInterface[] + * @throws \UnexpectedValueException */ - private function getPreProcessors($fromType, $toType) + private function getPreProcessors($type) { - $preProcessors = []; - if (isset($this->preProcessorClasses[$fromType]) && isset($this->preProcessorClasses[$fromType][$toType])) { - $preProcessors = $this->preProcessorClasses[$fromType][$toType]; + if (isset($this->instances[$type])) { + return $this->instances[$type]; + } + + if (isset($this->preprocessors[$type])) { + $preprocessors = $this->sorter->sort($this->preprocessors[$type]); } else { - $preProcessors[] = 'Magento\Framework\View\Asset\PreProcessor\Passthrough'; + $preprocessors = [ + 'default' => [self::PREPROCESSOR_CLASS => $this->defaultPreprocessor] + ]; } - $processorInstances = []; - foreach ($preProcessors as $preProcessor) { - $processorInstance = $this->objectManager->get($preProcessor); - if (!$processorInstance instanceof PreProcessorInterface) { - throw new \UnexpectedValueException("{$preProcessor} has to implement the PreProcessorInterface."); + $this->instances[$type] = []; + foreach ($preprocessors as $preprocessor) { + $instance = $this->objectManager->get($preprocessor[self::PREPROCESSOR_CLASS]); + if (!$instance instanceof PreProcessorInterface) { + throw new \UnexpectedValueException( + '"' . $preprocessor[self::PREPROCESSOR_CLASS] . '" has to implement the PreProcessorInterface.' + ); } - $processorInstances[] = $processorInstance; + $this->instances[$type][] = $instance; } - return $processorInstances; + return $this->instances[$type]; } } diff --git a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Alternative.php b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Alternative.php index f943656b1cd92..c8872027ad2af 100644 --- a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Alternative.php +++ b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/Resolver/Alternative.php @@ -30,7 +30,7 @@ class Alternative extends Simple public function __construct( Filesystem $filesystem, \Magento\Framework\View\Design\Fallback\RulePool $rulePool, - array $alternativeExtensions + array $alternativeExtensions = [] ) { foreach ($alternativeExtensions as $extension => $newExtensions) { if (!is_string($extension) || !is_array($newExtensions)) { diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php index 1dd81a187c750..3ea8c49a43d61 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php @@ -7,6 +7,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\View\Element\UiComponent\Processor; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\Control\ActionPoolFactory; use Magento\Framework\View\Element\UiComponent\Control\ActionPoolInterface; @@ -84,6 +85,11 @@ class Context implements ContextInterface */ protected $urlBuilder; + /** + * @var Processor + */ + protected $processor; + /** * @param PageLayoutInterface $pageLayout * @param RequestInterface $request @@ -91,8 +97,9 @@ class Context implements ContextInterface * @param ActionPoolFactory $actionPoolFactory * @param ContentTypeFactory $contentTypeFactory * @param UrlInterface $urlBuilder + * @param Processor $processor * @param DataProviderInterface|null $dataProvider - * @param string $namespace + * @param null $namespace */ public function __construct( PageLayoutInterface $pageLayout, @@ -101,6 +108,7 @@ public function __construct( ActionPoolFactory $actionPoolFactory, ContentTypeFactory $contentTypeFactory, UrlInterface $urlBuilder, + Processor $processor, DataProviderInterface $dataProvider = null, $namespace = null ) { @@ -112,7 +120,7 @@ public function __construct( $this->actionPool = $actionPoolFactory->create(['context' => $this]); $this->contentTypeFactory = $contentTypeFactory; $this->urlBuilder = $urlBuilder; - + $this->processor = $processor; $this->setAcceptType(); } @@ -362,4 +370,12 @@ protected function prepareDataSource(array & $data, UiComponentInterface $compon } $data = $component->prepareDataSource($data); } + + /** + * @inheritDoc + */ + public function getProcessor() + { + return $this->processor; + } } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php index 55ed8e0d0657d..bd89985dc1490 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ContextInterface.php @@ -5,6 +5,7 @@ */ namespace Magento\Framework\View\Element\UiComponent; +use Magento\Framework\View\Element\UiComponent\Processor; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\ContentType\ContentTypeInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; @@ -136,4 +137,11 @@ public function getRenderEngine(); * @return string */ public function getUrl($route = '', $params = []); + + /** + * Get component processor + * + * @return Processor + */ + public function getProcessor(); } diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/CollectionFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/CollectionFactory.php index bc0b10094d9fe..5adce4658a7d0 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/CollectionFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/CollectionFactory.php @@ -6,7 +6,7 @@ namespace Magento\Framework\View\Element\UiComponent\DataProvider; -use Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; use Magento\Framework\ObjectManagerInterface; /** diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php index 456b6f137b1c7..b2e3894c00b56 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProviderInterface.php @@ -5,7 +5,7 @@ */ namespace Magento\Framework\View\Element\UiComponent\DataProvider; -use Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; /** * Interface DataProviderInterface 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 09b29cad87129..f53fbf5d1f472 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/FulltextFilter.php @@ -7,7 +7,7 @@ namespace Magento\Framework\View\Element\UiComponent\DataProvider; use Magento\Framework\Data\Collection\AbstractDb as DbCollection; -use Magento\Framework\Model\ModelResource\Db\AbstractDb as DbResource; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb as DbResource; use Magento\Framework\Api\Filter; /** diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php index ab9038ca12861..4dd0dab9f343e 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php @@ -7,7 +7,7 @@ namespace Magento\Framework\View\Element\UiComponent\DataProvider; use Magento\Framework\Api; -use Magento\Framework\Model\ModelResource\Db\Collection\AbstractCollection; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; use Magento\Framework\Event\ManagerInterface as EventManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php new file mode 100644 index 0000000000000..b9cbce56acb0f --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/ObserverInterface.php @@ -0,0 +1,22 @@ + ObserverInterface[], + * 'component_type2' => ObserverInterface[], + * ] + * + * @var array + */ + protected $observers = []; + + + /** + * @inheritDoc + */ + public function register(UiComponentInterface $component) + { + $this->components[] = $component; + } + + /** + * @inheritDoc + */ + public function getComponents() + { + return $this->components; + } + + /** + * @inheritDoc + */ + public function attach($type, ObserverInterface $observer) + { + $this->observers[$type][] = $observer; + } + + /** + * @inheritDoc + */ + public function detach($type, ObserverInterface $observer) + { + if (!isset($this->observers[$type])) { + return; + } + + $key = array_search($observer, $this->observers[$type], true); + if ($key !== false) { + unset($this->observers[$type][$key]); + } + } + + /** + * @inheritDoc + */ + public function notify($type) + { + $componentType = $this->normalizeType($type); + if (!isset($this->observers[$componentType])) { + return; + } + + /** @var UiComponentInterface $component */ + foreach ($this->getComponents() as $component) { + if ($component->getComponentName() != $type) { + continue; + } + + /** @var ObserverInterface $observer */ + foreach ($this->observers[$componentType] as $observer) { + $observer->update($component); + } + } + } + + /** + * Normalize type to component type + * + * @param string $type + * @return string + */ + protected function normalizeType($type) + { + $componentType = (strpos($type, '.') !== false) ? substr($type, 0, strpos($type, '.')) : $type; + return $componentType; + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php b/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php new file mode 100644 index 0000000000000..6b16644405389 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/SubjectInterface.php @@ -0,0 +1,35 @@ +build(false); + return reset($title); + } + + /** + * @param bool $withConfigValues * @return array */ - protected function build() + protected function build($withConfigValues = true) { - return array_merge($this->prependedValues, [$this->addConfigValues($this->textValue)], $this->appendedValues); + return array_merge( + $this->prependedValues, + [$withConfigValues ? $this->addConfigValues($this->textValue) : $this->textValue], + $this->appendedValues + ); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php new file mode 100644 index 0000000000000..8cd6a99610b09 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php @@ -0,0 +1,155 @@ +fileName = DirectoryList::TMP . DIRECTORY_SEPARATOR . self::LOCK_NAME . LockerProcess::LOCK_EXTENSION; + + $this->filesystemMock = $this->getMockBuilder('Magento\Framework\Filesystem') + ->disableOriginalConstructor() + ->getMock(); + + $this->lockerProcess = new LockerProcess($this->filesystemMock); + } + + /** + * Test for lockProcess method + * + * @param string $method + * + * @dataProvider dataProviderTestLockProcess + */ + public function testLockProcess($method) + { + $this->filesystemMock->expects(self::once()) + ->method('getDirectoryWrite') + ->with(DirectoryList::VAR_DIR) + ->willReturn($this->$method()); + + $this->lockerProcess->lockProcess(self::LOCK_NAME); + } + + /** + * Test for unlockProcess method + */ + public function testUnlockProcess() + { + $this->filesystemMock->expects(self::once()) + ->method('getDirectoryWrite') + ->with(DirectoryList::VAR_DIR) + ->willReturn($this->getTmpDirectoryMockFalse(1)); + + $this->lockerProcess->lockProcess(self::LOCK_NAME); + $this->lockerProcess->unlockProcess(); + } + + /** + * @return array + */ + public function dataProviderTestLockProcess() + { + return [ + ['method' => 'getTmpDirectoryMockTrue'], + ['method' => 'getTmpDirectoryMockFalse'] + ]; + } + + /** + * @return WriteInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected function getTmpDirectoryMockTrue() + { + $tmpDirectoryMock = $this->getTmpDirectoryMock(); + + $tmpDirectoryMock->expects(self::atLeastOnce()) + ->method('isExist') + ->with($this->fileName) + ->willReturn(true); + + $tmpDirectoryMock->expects(self::atLeastOnce()) + ->method('readFile') + ->with($this->fileName) + ->willReturn(time() - 25); + + + $tmpDirectoryMock->expects(self::once()) + ->method('writeFile') + ->with($this->fileName, self::matchesRegularExpression('#\d+#')); + + return $tmpDirectoryMock; + } + + /** + * @param int $exactly + * @return WriteInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected function getTmpDirectoryMockFalse($exactly = 0) + { + $tmpDirectoryMock = $this->getTmpDirectoryMock(); + + $tmpDirectoryMock->expects(self::atLeastOnce()) + ->method('isExist') + ->with($this->fileName) + ->willReturn(false); + + $tmpDirectoryMock->expects(self::never()) + ->method('readFile'); + + $tmpDirectoryMock->expects(self::exactly($exactly)) + ->method('delete') + ->with($this->fileName); + + $tmpDirectoryMock->expects(self::once()) + ->method('writeFile') + ->with($this->fileName, self::matchesRegularExpression('#\d+#')); + + return $tmpDirectoryMock; + } + + /** + * @return WriteInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private function getTmpDirectoryMock() + { + $tmpDirectoryMock = $this->getMockBuilder('Magento\Framework\Filesystem\Directory\WriteInterface') + ->getMockForAbstractClass(); + + return $tmpDirectoryMock; + } +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/ProcessorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/ProcessorTest.php new file mode 100644 index 0000000000000..5989389bdd2d5 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/ProcessorTest.php @@ -0,0 +1,185 @@ +loggerMock = $this->getMockBuilder('Psr\Log\LoggerInterface') + ->getMockForAbstractClass(); + $this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') + ->disableOriginalConstructor() + ->getMock(); + $this->assetSourceMock = $this->getMockBuilder('Magento\Framework\View\Asset\Source') + ->disableOriginalConstructor() + ->getMock(); + $this->temporaryFileMock = $this->getMockBuilder('Magento\Framework\Css\PreProcessor\File\Temporary') + ->disableOriginalConstructor() + ->getMock(); + + $this->processor = new Processor( + $this->loggerMock, + $this->appStateMock, + $this->assetSourceMock, + $this->temporaryFileMock + ); + } + + /** + * Test for processContent method (exception) + */ + public function testProcessContentException() + { + $assetMock = $this->getAssetMock(); + + $this->appStateMock->expects(self::once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->assetSourceMock->expects(self::once()) + ->method('getContent') + ->with($assetMock) + ->willThrowException(new \Exception(self::ERROR_MESSAGE)); + + $this->loggerMock->expects(self::once()) + ->method('critical') + ->with(Processor::ERROR_MESSAGE_PREFIX . self::ERROR_MESSAGE); + + $this->temporaryFileMock->expects(self::never()) + ->method('createFile'); + + $assetMock->expects(self::never()) + ->method('getPath'); + + $content = $this->processor->processContent($assetMock); + + self::assertEquals(Processor::ERROR_MESSAGE_PREFIX . self::ERROR_MESSAGE, $content); + } + + /** + * Test for processContent method (empty content) + */ + public function testProcessContentEmpty() + { + $assetMock = $this->getAssetMock(); + + $this->appStateMock->expects(self::once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->assetSourceMock->expects(self::once()) + ->method('getContent') + ->with($assetMock) + ->willReturn(''); + + $this->temporaryFileMock->expects(self::never()) + ->method('createFile'); + + $assetMock->expects(self::never()) + ->method('getPath'); + + $this->loggerMock->expects(self::never()) + ->method('critical'); + + $this->processor->processContent($assetMock); + } + + /** + * Test for processContent method (not empty content) + */ + public function testProcessContentNotEmpty() + { + $assetMock = $this->getAssetMock(); + + $this->appStateMock->expects(self::once()) + ->method('getMode') + ->willReturn(State::MODE_DEVELOPER); + + $this->assetSourceMock->expects(self::once()) + ->method('getContent') + ->with($assetMock) + ->willReturn(self::TEST_CONTENT); + + $this->temporaryFileMock->expects(self::once()) + ->method('createFile') + ->with(self::ASSET_PATH, self::TEST_CONTENT) + ->willReturn(__DIR__ . '/' . self::TMP_PATH_LESS); + + $assetMock->expects(self::once()) + ->method('getPath') + ->willReturn(self::ASSET_PATH); + + $this->loggerMock->expects(self::never()) + ->method('critical'); + + $clearSymbol = ["\n", "\r", "\t", ' ']; + self::assertEquals( + trim(str_replace($clearSymbol, '', file_get_contents(__DIR__ . '/' . self::TMP_PATH_CSS))), + trim(str_replace($clearSymbol, '', $this->processor->processContent($assetMock))) + ); + } + + /** + * @return File|\PHPUnit_Framework_MockObject_MockObject + */ + private function getAssetMock() + { + $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + ->disableOriginalConstructor() + ->getMock(); + + return $assetMock; + } +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.css b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.css new file mode 100644 index 0000000000000..7c30a79a3a751 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.css @@ -0,0 +1,19 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +body { + background: #333333; + color: #454545; +} +a { + color: #ff9900; +} +h1, +h2, +h3, +h4, +h5, +h6 { + color: #333333; +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.less b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.less new file mode 100644 index 0000000000000..6ecc83aa9dae6 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Adapter/Less/_file/test.less @@ -0,0 +1,19 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +@color-orange: #ff9900; +@color-gray_light: #cccccc; +@color-black_dark: #333333; +@color-black_medium: #454545; + +body { + background: @color-black_dark; + color: @color-black_medium; +} +a { + color:@color-orange; +} +h1, h2, h3, h4, h5, h6 { + color: @color-black_dark; +} \ No newline at end of file diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php new file mode 100644 index 0000000000000..2c3591ffbb6f2 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/AlternativeSourceTest.php @@ -0,0 +1,363 @@ +sorterMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Helper\SortInterface') + ->getMockForAbstractClass(); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->getMockForAbstractClass(); + $this->lockerProcessMock = $this->getMockBuilder('Magento\Framework\View\Asset\LockerProcessInterface') + ->getMockForAbstractClass(); + $this->assetBuilderMock = $this->getMockBuilder( + 'Magento\Framework\View\Asset\PreProcessor\AlternativeSource\AssetBuilder' + )->disableOriginalConstructor() + ->getMock(); + $this->alternativeMock = $this->getMockBuilder('Magento\Framework\View\Asset\ContentProcessorInterface') + ->getMockForAbstractClass(); + } + + /** + * Run test for process method (exception) + */ + public function testProcessException() + { + $alternatives = [ + 'processor' => [ + AlternativeSource::PROCESSOR_CLASS => 'stdClass' + ] + ]; + + $this->lockerProcessMock->expects(self::once()) + ->method('lockProcess') + ->with(self::isType('string')); + $this->lockerProcessMock->expects(self::once()) + ->method('unlockProcess'); + + $this->sorterMock->expects(self::once()) + ->method('sort') + ->with($alternatives) + ->willReturn($alternatives); + + $this->assetBuilderMock->expects(self::once()) + ->method('setArea') + ->with(self::AREA) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setTheme') + ->with(self::THEME) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setLocale') + ->with(self::LOCALE) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setModule') + ->with(self::MODULE) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setPath') + ->with(self::FILE_PATH) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('build') + ->willReturn($this->getAssetNew()); + + $this->objectManagerMock->expects(self::once()) + ->method('get') + ->with('stdClass') + ->willReturn(new \stdClass()); + + $alternativeSource = new AlternativeSource( + $this->objectManagerMock, + $this->lockerProcessMock, + $this->sorterMock, + $this->assetBuilderMock, + 'lock', + $alternatives + ); + try { + $alternativeSource->process($this->getChainMockExpects('', 0)); + } catch (\UnexpectedValueException $e) { + self::assertInstanceOf('\UnexpectedValueException', $e); + } + } + + /** + * Run test for process method + */ + public function testProcess() + { + $alternatives = [ + 'processor' => [ + AlternativeSource::PROCESSOR_CLASS => 'Magento\Framework\View\Asset\ContentProcessorInterface' + ] + ]; + + $this->lockerProcessMock->expects(self::once()) + ->method('lockProcess') + ->with(self::isType('string')); + $this->lockerProcessMock->expects(self::once()) + ->method('unlockProcess'); + + $this->sorterMock->expects(self::once()) + ->method('sort') + ->with($alternatives) + ->willReturn($alternatives); + + $assetMock = $this->getAssetNew(); + + $this->assetBuilderMock->expects(self::once()) + ->method('setArea') + ->with(self::AREA) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setTheme') + ->with(self::THEME) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setLocale') + ->with(self::LOCALE) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setModule') + ->with(self::MODULE) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('setPath') + ->with(self::FILE_PATH) + ->willReturnSelf(); + $this->assetBuilderMock->expects(self::once()) + ->method('build') + ->willReturn($assetMock); + + $this->objectManagerMock->expects(self::once()) + ->method('get') + ->with('Magento\Framework\View\Asset\ContentProcessorInterface') + ->willReturn($this->getProcessorMock($assetMock)); + + $alternativeSource = new AlternativeSource( + $this->objectManagerMock, + $this->lockerProcessMock, + $this->sorterMock, + $this->assetBuilderMock, + 'lock', + $alternatives + ); + + $alternativeSource->process($this->getChainMockExpects()); + } + + /** + * Run test for process method (content not empty) + */ + public function testProcessContentNotEmpty() + { + $chainMock = $this->getChainMock(); + $assetMock = $this->getAssetMock(); + + $chainMock->expects(self::once()) + ->method('getContent') + ->willReturn('test-content'); + + $chainMock->expects(self::once()) + ->method('getAsset') + ->willReturn($assetMock); + + $this->lockerProcessMock->expects(self::never()) + ->method('lockProcess'); + $this->lockerProcessMock->expects(self::never()) + ->method('unlockProcess'); + + $alternativeSource = new AlternativeSource( + $this->objectManagerMock, + $this->lockerProcessMock, + $this->sorterMock, + $this->assetBuilderMock, + 'lock', + [] + ); + + $alternativeSource->process($chainMock); + } + + /** + * @param \PHPUnit_Framework_MockObject_MockObject $asset + * @return ContentProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private function getProcessorMock($asset) + { + $processorMock = $this->getMockBuilder('Magento\Framework\View\Asset\ContentProcessorInterface') + ->getMockForAbstractClass(); + + $processorMock->expects(self::once()) + ->method('processContent') + ->with($asset) + ->willReturn(self::NEW_CONTENT); + + return $processorMock; + } + + /** + * @return Chain|\PHPUnit_Framework_MockObject_MockObject + */ + private function getChainMock() + { + $chainMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') + ->disableOriginalConstructor() + ->getMock(); + + return $chainMock; + } + + /** + * @param string $content + * @param int $contentExactly + * @return Chain|\PHPUnit_Framework_MockObject_MockObject + */ + private function getChainMockExpects($content = '', $contentExactly = 1) + { + $chainMock = $this->getChainMock(); + + $chainMock->expects(self::once()) + ->method('getContent') + ->willReturn($content); + $chainMock->expects(self::exactly(3)) + ->method('getAsset') + ->willReturn($this->getAssetMockExpects()); + $chainMock->expects(self::exactly($contentExactly)) + ->method('setContent') + ->willReturn(self::NEW_CONTENT); + + return $chainMock; + } + + /** + * @return File|\PHPUnit_Framework_MockObject_MockObject + */ + private function getAssetNew() + { + $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\File') + ->disableOriginalConstructor() + ->getMock(); + + return $assetMock; + } + + /** + * @return LocalInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private function getAssetMock() + { + $assetMock = $this->getMockBuilder('Magento\Framework\View\Asset\LocalInterface') + ->disableOriginalConstructor() + ->getMock(); + + return $assetMock; + } + + /** + * @return LocalInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private function getAssetMockExpects() + { + $assetMock = $this->getAssetMock(); + + $assetMock->expects(self::once()) + ->method('getContext') + ->willReturn($this->getContextMock()); + $assetMock->expects(self::once()) + ->method('getFilePath') + ->willReturn(self::FILE_PATH); + $assetMock->expects(self::once()) + ->method('getModule') + ->willReturn(self::MODULE); + + return $assetMock; + } + + /** + * @return FallbackContext|\PHPUnit_Framework_MockObject_MockObject + */ + private function getContextMock() + { + $contextMock = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') + ->disableOriginalConstructor() + ->getMock(); + + $contextMock->expects(self::once()) + ->method('getAreaCode') + ->willReturn(self::AREA); + $contextMock->expects(self::once()) + ->method('getThemePath') + ->willReturn(self::THEME); + $contextMock->expects(self::once()) + ->method('getLocale') + ->willReturn(self::LOCALE); + + return $contextMock; + } +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Helper/SortTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Helper/SortTest.php new file mode 100644 index 0000000000000..35e0431432660 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/Helper/SortTest.php @@ -0,0 +1,195 @@ +sort($arrayData); + + static::assertEquals($expected, array_keys($result), $message); + } + + /** + * @return array + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function dataProviderTestSorting() + { + return [ + [ + 'arrayData' => [ + 'name-1' => [ // 2 + 'after' => 'name-3', + 'processor' => new \stdClass() + ], + 'name-2' => [ // 0 + 'processor' => new \stdClass() + ], + 'name-3' => [ // 1 + 'after' => 'name-2', + 'processor' => new \stdClass() + ], + ], + 'expected' => [ + 'name-2', 'name-3', 'name-1' + ], + 'message' => 'variation-1', + ], + [ + 'arrayData' => [ + 'name-1' => [ // 3 + 'after' => 'name-6', + 'processor' => new \stdClass() + ], + 'name-2' => [ // 1 + 'processor' => new \stdClass() + ], + 'name-3' => [ // 6 + 'after' => 'name-5', + 'processor' => new \stdClass() + ], + 'name-4' => [ // 4 + 'after' => 'name-1', + 'processor' => new \stdClass() + ], + 'name-5' => [ // 5 + 'after' => 'name-4', + 'processor' => new \stdClass() + ], + 'name-6' => [ // 2 + 'after' => 'name-2', + 'processor' => new \stdClass() + ], + ], + 'expected' => [ + 'name-2', 'name-6', 'name-1', 'name-4', 'name-5', 'name-3' + ], + 'message' => 'variation-2', + ], + [ + 'arrayData' => [ + 'name-1' => [ // 3 + 'after' => 'name-6', + 'processor' => new \stdClass() + ], + 'name-3' => [ // 6 + 'after' => 'name-5', + 'processor' => new \stdClass() + ], + 'name-4' => [ // 4 + 'after' => 'name-1', + 'processor' => new \stdClass() + ], + 'name-5' => [ // 5 + 'after' => 'name-4', + 'processor' => new \stdClass() + ], + 'name-6' => [ // 2 + 'after' => 'name-2', + 'processor' => new \stdClass() + ], + 'name-2' => [ // 1 + 'processor' => new \stdClass() + ], + ], + 'expected' => [ + 'name-2', 'name-6', 'name-1', 'name-4', 'name-5', 'name-3' + ], + 'message' => 'variation-3', + ], + [ + 'arrayData' => [ + 'name-1' => [ // 3 + 'after' => 'name-6', + 'processor' => new \stdClass() + ], + 'name-2' => [ // 1 + 'processor' => new \stdClass() + ], + 'name-3' => [ // 6 + 'after' => 'name-5', + 'processor' => new \stdClass() + ], + 'name-4' => [ // 4 + 'after' => 'name-1', + 'processor' => new \stdClass() + ], + 'name-5' => [ // 5 + 'after' => 'name-4', + 'processor' => new \stdClass() + ], + 'name-6' => [ // 2 + 'after' => 'name-2', + 'processor' => new \stdClass() + ], + 'name-7' => [ // end + 'processor' => new \stdClass() + ], + 'name-8' => [ // end + 'processor' => new \stdClass() + ], + ], + 'expected' => [ + 'name-2', 'name-6', 'name-1', 'name-4', 'name-5', 'name-3', 'name-7', 'name-8' + ], + 'message' => 'variation-4', + ], + [ + 'arrayData' => [ + 'name-1' => [ // xxx + 'after' => 'name-6', + 'processor' => new \stdClass() + ], + 'name-2' => [ // 1 + 'processor' => new \stdClass() + ], + 'name-3' => [ // xxx + 'after' => 'name-XXX', + 'processor' => new \stdClass() + ] + ], + 'expected' => ['name-2'], + 'message' => 'variation-5', + ], + [ + 'arrayData' => [ + 'name-1' => [ // xxx + 'after' => 'name-3', + 'processor' => new \stdClass() + ], + 'name-2' => [ // xxx + 'after' => 'name-1', + 'processor' => new \stdClass() + ], + 'name-3' => [ // xxx + 'after' => 'name-2', + 'processor' => new \stdClass() + ] + ], + 'expected' => [], + 'message' => 'variation-6', + ], + ]; + } +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php index eb41418aaefed..d7fd211ef7949 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Asset/PreProcessor/PoolTest.php @@ -6,127 +6,181 @@ namespace Magento\Framework\View\Test\Unit\Asset\PreProcessor; -use \Magento\Framework\View\Asset\PreProcessor\Pool; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Asset\PreProcessor\Pool; +use Magento\Framework\View\Asset\PreProcessor\Chain; +use Magento\Framework\View\Asset\PreProcessorInterface; +use Magento\Framework\View\Asset\PreProcessor\Helper\SortInterface; +/** + * Class PoolTest + * + * @see \Magento\Framework\View\Asset\PreProcessor\Pool + */ class PoolTest extends \PHPUnit_Framework_TestCase { + const DEFAULT_PREPROCESSOR = 'defaul/preprocessor'; + + const CONTENT_TYPE = 'test-type'; + + const PREPROCESSOR_CLASS = 'Magento\Framework\View\Asset\PreProcessorInterface'; + /** - * @var \Magento\Framework\View\Asset\PreProcessor\Pool + * @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $processorPool; + private $objectManagerMock; /** - * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var SortInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; + private $sorterMock; /** - * @var \Magento\Framework\View\Asset\PreProcessor\Chain|\PHPUnit_Framework_MockObject_MockObject + * Set up + * + * @return void */ - protected $processorChain; - - protected function setUp() + public function setUp() { - $this->objectManager = $this->getMockForAbstractClass('Magento\Framework\ObjectManagerInterface'); + $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') + ->getMockForAbstractClass(); + $this->sorterMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Helper\SortInterface') + ->getMockForAbstractClass(); + } - $this->processorChain = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') + /** + * @return Chain|\PHPUnit_Framework_MockObject_MockObject + */ + private function getChainMock($type) + { + /** @var Chain|\PHPUnit_Framework_MockObject_MockObject $chainMock */ + $chainMock = $this->getMockBuilder('Magento\Framework\View\Asset\PreProcessor\Chain') ->disableOriginalConstructor() - ->setMethods([]) ->getMock(); - $this->processorPool = new Pool( - $this->objectManager, - [ - 'less' => [ - 'css' => - [ - 'Magento\Framework\Css\PreProcessor\Less', - 'Magento\Framework\View\Asset\PreProcessor\VariableNotation', - 'Magento\Framework\View\Asset\PreProcessor\ModuleNotation', - ], - 'less' => - [ - 'Magento\Framework\Css\PreProcessor\Instruction\MagentoImport', - 'Magento\Framework\Css\PreProcessor\Instruction\Import', - ], - ], - 'css' => [ - 'css' => [ - 'Magento\Framework\View\Asset\PreProcessor\VariableNotation', - 'Magento\Framework\View\Asset\PreProcessor\ModuleNotation', - ] - ], + $chainMock->expects(self::once()) + ->method('getTargetContentType') + ->willReturn($type); + + return $chainMock; + } + + /** + * @param Chain|\PHPUnit_Framework_MockObject_MockObject $chainMock + * @return PreProcessorInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private function getPreprocessorMock($chainMock) + { + /** @var PreProcessorInterface|\PHPUnit_Framework_MockObject_MockObject $preprocessorMock */ + $preprocessorMock = $this->getMockBuilder(self::PREPROCESSOR_CLASS) + ->getMockForAbstractClass(); + + $preprocessorMock->expects(self::once()) + ->method('process') + ->with($chainMock); + + return $preprocessorMock; + } + + /** + * Run test for process method + */ + public function testProcess() + { + $preprocessors = [ + self::CONTENT_TYPE => [ + 'test' => [ + Pool::PREPROCESSOR_CLASS => self::PREPROCESSOR_CLASS + ] ] + ]; + + $pool = new Pool( + $this->objectManagerMock, + $this->sorterMock, + self::DEFAULT_PREPROCESSOR, + $preprocessors ); + + $this->sorterMock->expects(self::once()) + ->method('sort') + ->with($preprocessors[self::CONTENT_TYPE]) + ->willReturn($preprocessors[self::CONTENT_TYPE]); + + $chainMock = $this->getChainMock(self::CONTENT_TYPE); + + $this->objectManagerMock->expects(self::once()) + ->method('get') + ->with(self::PREPROCESSOR_CLASS) + ->willReturn($this->getPreprocessorMock($chainMock)); + + $pool->process($chainMock); } /** - * @param string $sourceContentType - * @param string $targetContentType - * @param array $expectedResult - * - * @dataProvider getPreProcessorsDataProvider + * Run test for process method (default preprocessor) */ - public function testProcess($sourceContentType, $targetContentType, array $expectedResult) + public function testProcessDefault() { + $preprocessors = [ + 'bad-type' => [], + ]; - $this->processorChain->expects($this->any()) - ->method('getOrigContentType') - ->willReturn($sourceContentType); - $this->processorChain->expects($this->any()) - ->method('getTargetContentType') - ->willReturn($targetContentType); - $processorMaps = []; - foreach ($expectedResult as $processor) { - $processorMock = $this->getMock($processor, ['process'], [], '', false); - $processorMock->expects($this->any()) - ->method('process') - ->with($this->processorChain); - $processorMaps[] = [$processor, $processorMock]; - } - $this->objectManager - ->expects(static::atLeastOnce()) + $pool = new Pool( + $this->objectManagerMock, + $this->sorterMock, + self::DEFAULT_PREPROCESSOR, + $preprocessors + ); + + $this->sorterMock->expects(self::never()) + ->method('sort'); + + $chainMock = $this->getChainMock(self::CONTENT_TYPE); + + $this->objectManagerMock->expects(self::once()) ->method('get') - ->willReturnMap($processorMaps); + ->with(self::DEFAULT_PREPROCESSOR) + ->willReturn($this->getPreprocessorMock($chainMock)); - $this->processorPool->process($this->processorChain); + $pool->process($chainMock); } - public function getPreProcessorsDataProvider() + /** + * Run test for process method (exception) + * + * @expectedException \UnexpectedValueException + * @expectedExceptionMessage "stdClass" has to implement the PreProcessorInterface. + */ + public function testProcessBadInterface() { - return [ - 'css => css' => [ - 'css', 'css', - [ - 'Magento\Framework\View\Asset\PreProcessor\VariableNotation', - 'Magento\Framework\View\Asset\PreProcessor\ModuleNotation', - ], - ], - //all undefined types will be processed by Passthrough preprocessor - 'css => less' => [ - 'css', 'less', - ['Magento\Framework\View\Asset\PreProcessor\Passthrough'], - ], - 'less => css' => [ - 'less', 'css', - [ - 'Magento\Framework\Css\PreProcessor\Less', - 'Magento\Framework\View\Asset\PreProcessor\VariableNotation', - 'Magento\Framework\View\Asset\PreProcessor\ModuleNotation', - ], - ], - 'less => less' => [ - 'less', 'less', - [ - 'Magento\Framework\Css\PreProcessor\Instruction\MagentoImport', - 'Magento\Framework\Css\PreProcessor\Instruction\Import', - ], - ], - //all undefined types will be processed by Passthrough preprocessor - 'txt => log (undefined)' => [ - 'txt', 'log', - ['Magento\Framework\View\Asset\PreProcessor\Passthrough'], - ], + $preprocessors = [ + self::CONTENT_TYPE => [ + 'test' => [ + Pool::PREPROCESSOR_CLASS => 'stdClass' + ] + ] ]; + + $pool = new Pool( + $this->objectManagerMock, + $this->sorterMock, + self::DEFAULT_PREPROCESSOR, + $preprocessors + ); + + $this->sorterMock->expects(self::once()) + ->method('sort') + ->with($preprocessors[self::CONTENT_TYPE]) + ->willReturn($preprocessors[self::CONTENT_TYPE]); + + $chainMock = $this->getChainMock(self::CONTENT_TYPE); + + $this->objectManagerMock->expects(self::once()) + ->method('get') + ->with('stdClass') + ->willReturn(new \stdClass()); + + $pool->process($chainMock); } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php new file mode 100644 index 0000000000000..c10d6fe61c3aa --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/ProcessorTest.php @@ -0,0 +1,78 @@ +component = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + $this->observer = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ObserverInterface') + ->getMockForAbstractClass(); + $this->processor = new Processor(); + } + + public function testRegisterGetComponents() + { + $this->assertCount(0, $this->processor->getComponents()); + $this->processor->register($this->component); + $this->assertCount(1, $this->processor->getComponents()); + } + + public function testAttachAndNotify() + { + $type = 'test_type'; + $this->component->expects($this->any()) + ->method('getComponentName') + ->willReturn($type); + $this->observer->expects($this->any()) + ->method('update') + ->with($this->component); + /** @var UiComponentInterface $component2 */ + $component2 = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface') + ->getMockForAbstractClass(); + $component2->expects($this->any()) + ->method('getComponentName') + ->willReturn('other_type'); + + $this->processor->register($this->component); + $this->processor->register($component2); + $this->processor->attach($type, $this->observer); + $this->processor->notify($type); + } + + public function testDetach() + { + $this->processor->detach('unexists_type', $this->observer); + $this->processor->attach('some_type', $this->observer); + $this->processor->notify('unexists_type'); + $this->processor->detach('some_type', $this->observer); + } +} diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php index ee9e035252dce..cea9a66f29ece 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Page/TitleTest.php @@ -23,6 +23,9 @@ class TitleTest extends \PHPUnit_Framework_TestCase */ protected $scopeConfigMock; + /** + * @return void + */ public function setUp() { $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface') @@ -36,6 +39,9 @@ public function setUp() ); } + /** + * @return void + */ public function testSet() { $value = 'test_value'; @@ -43,6 +49,9 @@ public function testSet() $this->assertEquals($value, $this->title->get()); } + /** + * @return void + */ public function testUnset() { $value = 'test'; @@ -52,6 +61,9 @@ public function testUnset() $this->assertEmpty($this->title->get()); } + /** + * @return void + */ public function testGet() { $value = 'test'; @@ -61,16 +73,19 @@ public function testGet() $this->scopeConfigMock->expects($this->any()) ->method('getValue') - ->will($this->returnValueMap( + ->willReturnMap( [ ['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix], ['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix], ] - )); + ); $this->title->set($value); $this->assertEquals($expected, $this->title->get()); } + /** + * @return void + */ public function testGetShort() { $value = 'some_title'; @@ -81,6 +96,46 @@ public function testGetShort() $this->assertEquals($value, $this->title->getShort()); } + /** + * @return void + */ + public function testGetShortWithSuffixAndPrefix() + { + $value = 'some_title'; + $prefix = 'prefix'; + $suffix = 'suffix'; + $expected = $prefix . ' ' . $value . ' ' . $suffix; + $this->title->set($value); + + $this->scopeConfigMock->expects($this->any()) + ->method('getValue') + ->willReturnMap( + [ + ['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix], + ['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix], + ] + ); + + $this->assertEquals($expected, $this->title->getShort()); + } + + /** + * @return void + */ + public function testGetShortHeading() + { + $value = 'some_title'; + $this->title->set($value); + + $this->scopeConfigMock->expects($this->never()) + ->method('getValue'); + + $this->assertEquals($value, $this->title->getShortHeading()); + } + + /** + * @return void + */ public function testGetDefault() { $defaultTitle = 'default title'; @@ -90,16 +145,19 @@ public function testGetDefault() $this->scopeConfigMock->expects($this->any()) ->method('getValue') - ->will($this->returnValueMap( + ->willReturnMap( [ ['design/head/title_prefix', ScopeInterface::SCOPE_STORE, null, $prefix], ['design/head/title_suffix', ScopeInterface::SCOPE_STORE, null, $suffix], ['design/head/default_title', ScopeInterface::SCOPE_STORE, null, $defaultTitle], ] - )); + ); $this->assertEquals($expected, $this->title->getDefault()); } + /** + * @return void + */ public function testAppendPrepend() { $value = 'title'; diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index 061a0f9c765c6..3e39db19a43cf 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -17,6 +17,7 @@ "ext-curl": "*", "ext-iconv": "*", "ext-gd": "*", + "ext-openssl": "*", "lib-libxml": "*", "ext-xsl": "*" }, diff --git a/lib/web/css/source/components/_modals.less b/lib/web/css/source/components/_modals.less index 005b0ff36c95e..7bf5699bbfb40 100644 --- a/lib/web/css/source/components/_modals.less +++ b/lib/web/css/source/components/_modals.less @@ -201,7 +201,7 @@ body { .lib-vendor-prefix-flex-shrink(0); } .modal-header { - padding-bottom: @modal-popup__padding; + padding-bottom: @modal-popup__padding / 2.5; padding-top: @modal-popup__padding; } .modal-footer { @@ -212,36 +212,6 @@ body { .modal-footer-actions { text-align: right; } - &.confirm { - .modal-inner-wrap { - left: 50%; - margin-left: -(@modal-popup-confirm__width/2); - width: @modal-popup-confirm__width; - } - .modal-footer { - text-align: right; - } - } - &._image-box { - .modal-inner-wrap { - margin: 5rem auto; - max-width: @modal-popup-image-box__max-width; - position: static; - } - .thumbnail-preview { - padding-bottom: @indent__l; - text-align: center; - .thumbnail-preview-image-block { - border: 1px solid @modal-popup-image-box__border-color; - margin: 0 auto @indent__base; - max-width: @modal-popup-image-box-preview__max-width; - padding: @indent__base; - } - .thumbnail-preview-image { - max-height: @modal-popup-image-box-preview-image__max-height; - } - } - } } // diff --git a/lib/web/css/source/lib/variables/_popups.less b/lib/web/css/source/lib/variables/_popups.less index bd574bd093003..7769ae923a90c 100644 --- a/lib/web/css/source/lib/variables/_popups.less +++ b/lib/web/css/source/lib/variables/_popups.less @@ -7,7 +7,7 @@ // Popup variables // _____________________________________________ -@popup__width: auto; +@popup__width: 100%; @popup__height: auto; @popup__padding: 22px; @popup__background: @color-white; diff --git a/lib/web/fotorama/fotorama.js b/lib/web/fotorama/fotorama.js index 9d74f25391769..445fe7d30c52c 100644 --- a/lib/web/fotorama/fotorama.js +++ b/lib/web/fotorama/fotorama.js @@ -5,7 +5,7 @@ fotoramaVersion = '4.6.4'; (function (window, document, location, $, undefined) { "use strict"; var _fotoramaClass = 'fotorama', - _fullscreenClass = 'fullscreen', + _fullscreenClass = 'fotorama__fullscreen', wrapClass = _fotoramaClass + '__wrap', wrapCss2Class = wrapClass + '--css2', @@ -37,6 +37,9 @@ fotoramaVersion = '4.6.4'; navClass = _fotoramaClass + '__nav', navWrapClass = navClass + '-wrap', navShaftClass = navClass + '__shaft', + navShaftVerticalClass = navWrapClass + '--vertical', + navShaftListClass = navWrapClass + '--list', + navShafthorizontalClass = navWrapClass + '--horizontal', navDotsClass = navClass + '--dots', navThumbsClass = navClass + '--thumbs', navFrameClass = navClass + '__frame', @@ -49,6 +52,8 @@ fotoramaVersion = '4.6.4'; shadowsClass = shadowClass + 's', shadowsLeftClass = shadowsClass + '--left', shadowsRightClass = shadowsClass + '--right', + shadowsTopClass = shadowsClass + '--top', + shadowsBottomClass = shadowsClass + '--bottom', activeClass = _fotoramaClass + '__active', selectClass = _fotoramaClass + '__select', @@ -70,6 +75,8 @@ fotoramaVersion = '4.6.4'; imgFullClass = imgClass + '--full', thumbClass = _fotoramaClass + '__thumb', + thumbArrLeft = thumbClass + '__arr--left', + thumbArrRight = thumbClass + '__arr--right', thumbBorderClass = thumbClass + '-border', htmlClass = _fotoramaClass + '__html', @@ -81,7 +88,7 @@ fotoramaVersion = '4.6.4'; spinnerClass = _fotoramaClass + '__spinner', - horizontalImageClass = _fotoramaClass + '_horisontal_ratio', + horizontalImageClass = _fotoramaClass + '_horizontal_ratio', verticalImageClass = _fotoramaClass + '_vertical_ratio'; var JQUERY_VERSION = $ && $.fn.jquery.split('.'); @@ -90,7 +97,7 @@ fotoramaVersion = '4.6.4'; || (JQUERY_VERSION[0] == 1 && JQUERY_VERSION[1] < 8)) { throw 'Fotorama requires jQuery 1.8 or later and will not run without it.'; } -// My Underscore :-) + var _ = {}; /* Modernizr 2.8.3 (Custom Build) | MIT & BSD * Build: http://modernizr.com/download/#-csstransforms3d-csstransitions-touch-prefixed @@ -483,7 +490,7 @@ fotoramaVersion = '4.6.4'; , n for (n in prop) el[n] = prop[n] - return el; + return el } /** @@ -859,6 +866,7 @@ fotoramaVersion = '4.6.4'; } return encodedFuncName; } + var $WINDOW = $(window), $DOCUMENT = $(document), $HTML, @@ -899,6 +907,12 @@ fotoramaVersion = '4.6.4'; MAX_WIDTH = 1200, + /** + * Number of thumbnails in slide. Calculated only on setOptions and resize. + * @type {number} + */ + thumbsPerSlide = 1, + OPTIONS = { /** @@ -978,7 +992,7 @@ fotoramaVersion = '4.6.4'; arrows: true, click: true, - swipe: true, + swipe: false, trackpad: false, shuffle: false, @@ -987,7 +1001,23 @@ fotoramaVersion = '4.6.4'; shadows: true, spinner: null, - showcaption: true + showcaption: true, + + /** + * Set type of thumbnail navigation + */ + navdir: 'horizontal', + + /** + * Set configuration to show or hide arrows in thumb navigation + */ + navarrows: true, + + /** + * Set type of navigation. Can be thumbs or slides + */ + navtype: 'thumbs' + }, KEYBOARD_OPTIONS = { @@ -999,6 +1029,7 @@ fotoramaVersion = '4.6.4'; home: false, end: false }; + function noop() { } @@ -1006,24 +1037,39 @@ fotoramaVersion = '4.6.4'; return Math.max(isNaN(min) ? -Infinity : min, Math.min(isNaN(max) ? Infinity : max, value)); } - function readTransform(css) { - return css.match(/ma/) && css.match(/-?\d+(?!d)/g)[css.match(/3d/) ? 12 : 4]; + function readTransform(css, dir) { + return css.match(/ma/) && css.match(/-?\d+(?!d)/g)[css.match(/3d/) ? + (dir === 'vertical' ? 13 : 12) : (dir === 'vertical' ? 5 : 4) + ] } - function readPosition($el) { + function readPosition($el, dir) { if (CSS3) { - return +readTransform($el.css('transform')); + return +readTransform($el.css('transform'), dir); } else { - return +$el.css('left').replace('px', ''); + return +$el.css(dir === 'vertical' ? 'top' : 'left').replace('px', ''); } } - function getTranslate(pos/*, _001*/) { + function getTranslate(pos, direction) { var obj = {}; + if (CSS3) { - obj.transform = 'translate3d(' + (pos/* + (_001 ? 0.001 : 0)*/) + 'px,0,0)'; // 0.001 to remove Retina artifacts + + switch (direction) { + case 'vertical': + obj.transform = 'translate3d(0, ' + (pos) + 'px,0)'; + break; + case 'list': + break; + default : + obj.transform = 'translate3d(' + (pos) + 'px,0,0)'; + break; + } } else { - obj.left = pos; + direction === 'vertical' ? + obj.top = pos : + obj.left = pos; } return obj; } @@ -1104,7 +1150,8 @@ fotoramaVersion = '4.6.4'; } - function stop($el, left/*, _001*/) { + function stop($el, pos/*, _001*/) { + var dir = $el.navdir || 'horizontal'; if ($el.length) { var elData = $el.data(); if (CSS3) { @@ -1114,12 +1161,12 @@ fotoramaVersion = '4.6.4'; } else { $el.stop(); } - var lockedLeft = getNumber(left, function () { - return readPosition($el); + var lockedPos = getNumber(pos, function () { + return readPosition($el, dir); }); - $el.css(getTranslate(lockedLeft/*, _001*/));//.width(); // `.width()` for reflow - return lockedLeft; + $el.css(getTranslate(lockedPos, dir/*, _001*/));//.width(); // `.width()` for reflow + return lockedPos; } } @@ -1195,7 +1242,10 @@ fotoramaVersion = '4.6.4'; dataType: 'jsonp', success: function (json) { dataFrame.thumbsReady = true; - updateData(data, {img: json[0].thumbnail_large, thumb: json[0].thumbnail_small}, dataFrame.i, fotorama); + updateData(data, { + img: json[0].thumbnail_large, + thumb: json[0].thumbnail_small + }, dataFrame.i, fotorama); } }); } else { @@ -1354,8 +1404,11 @@ fotoramaVersion = '4.6.4'; } } - function findShadowEdge(pos, min, max) { - return min === max ? false : pos <= min ? 'left' : pos >= max ? 'right' : 'left right'; + function findShadowEdge(pos, min, max, dir) { + return min === max ? false : + dir === 'vertical' ? + (pos <= min ? 'top' : pos >= max ? 'bottom' : 'top bottom') : + (pos <= min ? 'left' : pos >= max ? 'right' : 'left right'); } function smartClick($el, fn, _options) { @@ -1378,7 +1431,6 @@ fotoramaVersion = '4.6.4'; onMove: _options.onMove || noop, onTouchEnd: _options.onTouchEnd || noop, onEnd: function (result) { - ////console.log('smartClick → result.moved', result.moved); if (result.moved) return; fn.call(this, startEvent); } @@ -1468,6 +1520,56 @@ fotoramaVersion = '4.6.4'; el.addEventListener ? el.addEventListener(e, fn, !!bool) : el.attachEvent('on' + e, fn); } + /** + * + * @param position guess position for navShaft + * @param restriction object contains min and max values for position + * @returns {*} filtered value of position + */ + function validateRestrictions(position, restriction) { + if (position > restriction.max) { + position = restriction.max; + } else { + if (position < restriction.min) { + position = restriction.min; + } + } + return position; + } + + function validateSlidePos(opt, navShaftTouchTail, guessIndex, offsetNav, $guessNavFrame, $navWrap, dir) { + var position, + size, + wrapSize; + if (dir === 'horizontal') { + size = opt.thumbwidth; + wrapSize = $navWrap.width(); + } else { + size = opt.thumbheight; + wrapSize = $navWrap.height(); + } + if ( (size + opt.margin) * (guessIndex + 1) >= (wrapSize - offsetNav) ) { + if (dir === 'horizontal') { + position = -$guessNavFrame.position().left; + } else { + position = -$guessNavFrame.position().top; + } + } else { + if ((size + opt.margin) * (guessIndex) <= Math.abs(offsetNav)) { + if (dir === 'horizontal') { + position = -$guessNavFrame.position().left + wrapSize - (size + opt.margin); + } else { + position = -$guessNavFrame.position().top + wrapSize - (size + opt.margin); + } + } else { + position = offsetNav; + } + } + position = validateRestrictions(position, navShaftTouchTail); + + return position || 0; + } + function elIsDisabled(el) { return !!el.getAttribute('disabled'); } @@ -1562,6 +1664,7 @@ fotoramaVersion = '4.6.4'; }; }(UTIL || {}, jQuery)); + function slide($el, options) { var elData = $el.data(), elPos = Math.round(options.pos), @@ -1574,27 +1677,18 @@ fotoramaVersion = '4.6.4'; if (typeof options.overPos !== 'undefined' && options.overPos !== options.pos) { elPos = options.overPos; - onEndFn = function () { - slide($el, $.extend({}, options, { - overPos: options.pos, - time: Math.max(TRANSITION_DURATION, options.time / 2) - })); - }; } - ////////console.time('var translate = $.extend'); - var translate = $.extend(getTranslate(elPos/*, options._001*/), options.width && {width: options.width}); - ////////console.timeEnd('var translate = $.extend'); + var translate = $.extend(getTranslate(elPos, options.direction), options.width && {width: options.width}, options.height && {height: options.height}); if (elData && elData.sliding) { elData.sliding = true; } if (CSS3) { $el.css($.extend(getDuration(options.time), translate)); + if (options.time > 10) { - ////////console.time('afterTransition'); afterTransition($el, 'transform', onEndFn, options.time); - ////////console.timeEnd('afterTransition'); } else { onEndFn(); } @@ -1643,10 +1737,12 @@ fotoramaVersion = '4.6.4'; (_$el1 && crossfadeFLAG) || _$el2 || onEndFn(); } + var lastEvent, moveEventType, preventEvent, - preventEventTimeout; + preventEventTimeout, + dragDomEl; function extendEvent(e) { var touch = (e.touches || [])[0] || e; @@ -1720,7 +1816,6 @@ fotoramaVersion = '4.6.4'; stopEvent(e); } } else { - ////console.log('onMove e.preventDefault'); stopEvent(e); (options.onMove || noop).call(el, e, {touch: touchFLAG}); } @@ -1797,11 +1892,12 @@ fotoramaVersion = '4.6.4'; .on('mousemove', onMove) .on('mouseup', onEnd); } - - $el.on('click', 'a', function (e) { - if (!Modernizr.touch) { - e.preventDefault(); - } + if (Modernizr.touch) { + dragDomEl = 'a'; + } else { + dragDomEl = 'div'; + } + $el.on('click', dragDomEl, function (e) { tail.checked && stopEvent(e); }); @@ -1823,6 +1919,7 @@ fotoramaVersion = '4.6.4'; min, max, snap, + dir, slowFLAG, controlFLAG, moved, @@ -1830,7 +1927,7 @@ fotoramaVersion = '4.6.4'; function startTracking(e, noStop) { tracked = true; - startCoo = coo = e._x; + startCoo = coo = (dir === 'vertical') ? e._y : e._x; startTime = e._now; moveTrack = [ @@ -1845,7 +1942,9 @@ fotoramaVersion = '4.6.4'; function onStart(e, result) { min = tail.min; max = tail.max; - snap = tail.snap; + snap = tail.snap, + dir = tail.direction || 'horizontal', + $el.navdir = dir; slowFLAG = e.altKey; tracked = moved = false; @@ -1862,14 +1961,13 @@ fotoramaVersion = '4.6.4'; if (!tracked) { startTracking(e); } - - coo = e._x; + coo = (dir === 'vertical') ? e._y : e._x; moveTrack.push([e._now, coo]); moveElPos = startElPos - (startCoo - coo); - edge = findShadowEdge(moveElPos, min, max); + edge = findShadowEdge(moveElPos, min, max, dir); if (moveElPos <= min) { moveElPos = edgeResistance(moveElPos, min); @@ -1878,7 +1976,7 @@ fotoramaVersion = '4.6.4'; } if (!tail.noMove) { - $el.css(getTranslate(moveElPos/*, options._001*/)); + $el.css(getTranslate(moveElPos, dir)); if (!moved) { moved = true; // only for mouse @@ -1891,15 +1989,12 @@ fotoramaVersion = '4.6.4'; } function onEnd(result) { - //////console.time('moveontouch.js onEnd'); if (tail.noSwipe && result.moved) return; if (!tracked) { startTracking(result.startEvent, true); } - ////console.log('onEnd'); - result.touch || MS_POINTER || $el.removeClass(grabbingClass); endTime = $.now(); @@ -1970,7 +2065,8 @@ fotoramaVersion = '4.6.4'; pos: moveElPos, newPos: newPos, overPos: overPos, - time: time + time: time, + dir: dir })); } @@ -1982,6 +2078,7 @@ fotoramaVersion = '4.6.4'; return tail; } + function wheel($el, options) { var el = $el[0], lockFLAG, @@ -2026,6 +2123,7 @@ fotoramaVersion = '4.6.4'; return tail; } + jQuery.Fotorama = function ($fotorama, opts) { $HTML = $('html'); $BODY = $('body'); @@ -2062,6 +2160,8 @@ fotoramaVersion = '4.6.4'; navShaftData = $navShaft.data(), $thumbBorder = $fotorama.find(cls(thumbBorderClass)), + $thumbArrLeft = $fotorama.find(cls(thumbArrLeft)), + $thumbArrRight = $fotorama.find(cls(thumbArrRight)), $fullscreenIcon = $fotorama.find(cls(fullscreenIconClass)), fullscreenIcon = $fullscreenIcon[0], @@ -2129,7 +2229,11 @@ fotoramaVersion = '4.6.4'; stageLeft = 0, fadeStack = []; - $wrap[STAGE_FRAME_KEY] = $(''); + if (Modernizr.touch) { + $wrap[STAGE_FRAME_KEY] = $(''); + } else { + $wrap[STAGE_FRAME_KEY] = $('
'); + } $wrap[NAV_THUMB_FRAME_KEY] = $($.Fotorama.jst.thumb()); @@ -2171,11 +2275,34 @@ fotoramaVersion = '4.6.4'; return o_keyboard[key] || that.fullScreen; } + function setStagePosition() { + if ($stage !== undefined) { + + if (opts.navdir == 'vertical') { + var padding = opts.thumbwidth + opts.thumbmargin; + + $stage.css('left', padding); + $arrNext.css('right', padding); + $fullscreenIcon.css('right', padding); + $wrap.css('width', $wrap.css('width') + padding); + $stageShaft.css('max-width', $wrap.width() - padding); + } else { + $stage.css('left', ''); + $arrNext.css('right', ''); + $fullscreenIcon.css('right', ''); + $wrap.css('width', $wrap.css('width') + padding); + $stageShaft.css('max-width', ''); + } + } + } + function bindGlobalEvents(FLAG) { var keydownCommon = 'keydown.' + _fotoramaClass, localStamp = _fotoramaClass + stamp, keydownLocal = 'keydown.' + localStamp, - resizeLocal = 'resize.' + localStamp + ' ' + 'orientationchange.' + localStamp; + keyupLocal = 'keyup.' + localStamp, + resizeLocal = 'resize.' + localStamp + ' ' + 'orientationchange.' + localStamp, + showParams; if (FLAG) { $DOCUMENT @@ -2191,20 +2318,37 @@ fotoramaVersion = '4.6.4'; catched = true; that.cancelFullScreen(); } else if ((e.shiftKey && e.keyCode === 32 && allowKey('space')) || (e.keyCode === 37 && allowKey('left')) || (e.keyCode === 38 && allowKey('up'))) { + that.longPress.progress(); index = '<'; } else if ((e.keyCode === 32 && allowKey('space')) || (e.keyCode === 39 && allowKey('right')) || (e.keyCode === 40 && allowKey('down'))) { + that.longPress.progress(); index = '>'; } else if (e.keyCode === 36 && allowKey('home')) { + that.longPress.progress(); index = '<<'; } else if (e.keyCode === 35 && allowKey('end')) { + that.longPress.progress(); index = '>>'; } } (catched || index) && stopEvent(e); - index && that.show({index: index, slow: e.altKey, user: true}); + showParams = {index: index, slow: e.altKey, user: true}; + index && (that.longPress.inProgress ? + that.showWhileLongPress(showParams) : + that.show(showParams)); }); + if (FLAG) { + $DOCUMENT + .on(keyupLocal, function (e) { + if (that.longPress.inProgress) { + that.showEndLongPress({user:true}); + } + that.longPress.reset(); + }); + } + if (!that.index) { $DOCUMENT .off(keydownCommon) @@ -2250,7 +2394,7 @@ fotoramaVersion = '4.6.4'; data = that.data = data || clone(opts.data) || getDataFromHtml($fotorama); size = that.size = data.length; - !ready.ok && opts.shuffle && shuffle(data); + ready.ok && opts.shuffle && shuffle(data); checkForVideo(); @@ -2273,11 +2417,31 @@ fotoramaVersion = '4.6.4'; opts.autoplay = Math.max(+interval || AUTOPLAY_INTERVAL, o_transitionDuration * 1.5); } + function updateThumbArrow(opt) { + if (opt.navarrows && opt.nav === 'thumbs') { + $thumbArrLeft.show(); + $thumbArrRight.show(); + } else { + $thumbArrLeft.hide(); + $thumbArrRight.hide(); + } + + } + + function getThumbsInSlide($el, opts) { + return Math.floor($wrap.width() / (opts.thumbwidth + opts.thumbmargin)); + } + /** * Options on the fly * */ function setOptions() { + if (!opts.nav || opts.nav === 'dots') { + opts.navdir = 'horizontal' + } + that.options = opts = optionsToLowerCase(opts); + thumbsPerSlide = getThumbsInSlide($wrap, opts); o_fade = (opts.transition === 'crossfade' || opts.transition === 'dissolve'); @@ -2288,7 +2452,7 @@ fotoramaVersion = '4.6.4'; o_rtl = opts.direction === 'rtl'; o_keyboard = $.extend({}, opts.keyboard && KEYBOARD_OPTIONS, opts.keyboard); - + updateThumbArrow(opts); var classes = {add: [], remove: []}; function addOrRemoveClass(FLAG, value) { @@ -2300,7 +2464,7 @@ fotoramaVersion = '4.6.4'; o_navTop = opts.navposition === 'top'; classes.remove.push(selectClass); - $arrs.toggle(!!opts.arrows); + $arrs.toggle(opts.arrows); } else { o_nav = false; $arrs.hide(); @@ -2311,7 +2475,7 @@ fotoramaVersion = '4.6.4'; arrsUpdate(); stageWheelUpdate(); - + thumbArrUpdate(); if (opts.autoplay) setAutoplayInterval(opts.autoplay); o_thumbSide = numberFromMeasure(opts.thumbwidth) || THUMB_SIZE; @@ -2332,7 +2496,6 @@ fotoramaVersion = '4.6.4'; frameDraw(size, 'navThumb'); $navFrame = $navThumbFrame; - // navFrameKey = NAV_THUMB_FRAME_KEY; setStyle($style, $.Fotorama.jst.style({ @@ -2397,6 +2560,7 @@ fotoramaVersion = '4.6.4'; .removeClass(classes.remove.join(' ')); lastOptions = $.extend({}, opts); + setStagePosition(); } function normalizeIndex(index) { @@ -2426,8 +2590,13 @@ fotoramaVersion = '4.6.4'; } function setNavShaftMinMax() { - navShaftTouchTail.min = Math.min(0, measures.nw - $navShaft.width()); + + var isVerticalDir = (opts.navdir === 'vertical'); + var param = isVerticalDir ? $navShaft.height() : $navShaft.width(); + var mainParam = isVerticalDir ? measures.h : measures.nw; + navShaftTouchTail.min = Math.min(0, mainParam - param); navShaftTouchTail.max = 0; + navShaftTouchTail.direction = opts.navdir; $navShaft.toggleClass(grabClass, !(navShaftTouchTail.noMove = navShaftTouchTail.min === navShaftTouchTail.max)); } @@ -2530,10 +2699,10 @@ fotoramaVersion = '4.6.4'; function loaded() { $.Fotorama.measures[src] = imgData.measures = $.Fotorama.measures[src] || { - width: img.width, - height: img.height, - ratio: img.width / img.height - }; + width: img.width, + height: img.height, + ratio: img.width / img.height + }; setMeasures(imgData.measures.width, imgData.measures.height, imgData.measures.ratio, index); @@ -2547,7 +2716,7 @@ fotoramaVersion = '4.6.4'; } fit($img, ( - $.isFunction(specialMeasures) ? specialMeasures() : specialMeasures) || measures); + $.isFunction(specialMeasures) ? specialMeasures() : specialMeasures) || measures); $.Fotorama.cache[src] = frameData.state = 'loaded'; @@ -2735,10 +2904,20 @@ fotoramaVersion = '4.6.4'; } function thumbsDraw(pos, loadFLAG) { + var leftLimit, + rightLimit, + exceedLimit; + + if (o_nav !== 'thumbs' || isNaN(pos)) return; - var leftLimit = -pos, - rightLimit = -pos + measures.nw; + leftLimit = -pos; + rightLimit = -pos + measures.nw; + + if (opts.navdir === 'vertical') { + pos = pos - opts.thumbheight; + rightLimit = -pos + measures.h; + } $navThumbFrame.each(function () { var $this = $(this), @@ -2751,12 +2930,12 @@ fotoramaVersion = '4.6.4'; } }, specialMeasures = getSpecialMeasures(), - dataFrame = data[eq] || {}; - + exceedLimit = opts.navdir === 'vertical' ? + thisData.t > rightLimit : thisData.l > rightLimit; specialMeasures.w = thisData.w; if (thisData.l + thisData.w < leftLimit - || thisData.l > rightLimit + || exceedLimit || callFit(thisData.$img, specialMeasures)) return; loadFLAG && loadImg([eq], 'navThumb', getSpecialMeasures); @@ -2767,7 +2946,8 @@ fotoramaVersion = '4.6.4'; if (!frameAppend[type]) { var thumbsFLAG = type === 'nav' && o_navThumbs, - left = 0; + left = 0, + top = 0; $shaft.append( $frames @@ -2798,13 +2978,16 @@ fotoramaVersion = '4.6.4'; var $this = $(this), frameData = $this.data(), - thumbwidth = Math.round(o_thumbSide2 * frameData.data.thumbratio) || o_thumbSide; - + thumbwidth = Math.round(o_thumbSide2 * frameData.data.thumbratio) || o_thumbSide, + thumbheight = Math.round(o_thumbSide / frameData.data.thumbratio) || o_thumbSide2; + frameData.t = top; + frameData.h = thumbheight; frameData.l = left; frameData.w = thumbwidth; $this.css({width: thumbwidth}); + top += thumbheight + opts.thumbmargin; left += thumbwidth + opts.thumbmargin; }) ); @@ -2832,6 +3015,26 @@ fotoramaVersion = '4.6.4'; .attr(disableAttr(disableNext)); } + function thumbArrUpdate() { + var isLeftDisable = false, + isRightDisable = false; + if (opts.navtype === 'thumbs' && !opts.loop) { + (activeIndex == 0) ? isLeftDisable = true : isLeftDisable = false; + (activeIndex == opts.data.length - 1) ? isRightDisable = true : isRightDisable = false; + } + if (opts.navtype === 'slides') { + var pos = readPosition($navShaft, opts.navdir); + pos >= navShaftTouchTail.max ? isLeftDisable = true : isLeftDisable = false; + pos <= navShaftTouchTail.min ? isRightDisable = true : isRightDisable = false; + } + $thumbArrLeft + .toggleClass(arrDisabledClass, isLeftDisable) + .attr(disableAttr(isLeftDisable)); + $thumbArrRight + .toggleClass(arrDisabledClass, isRightDisable) + .attr(disableAttr(isRightDisable)); + } + function stageWheelUpdate() { if (stageWheelTail.ok) { stageWheelTail.prevent = {'<': disableDirrection(0), '>': disableDirrection(1)}; @@ -2841,51 +3044,97 @@ fotoramaVersion = '4.6.4'; function getNavFrameBounds($navFrame) { var navFrameData = $navFrame.data(), left, - width; + top, + width, + height; if (o_navThumbs) { left = navFrameData.l; + top = navFrameData.t; width = navFrameData.w; + height = navFrameData.h; } else { left = $navFrame.position().left; width = $navFrame.width(); } - return { + var horizontalBounds = { c: left + width / 2, min: -left + opts.thumbmargin * 10, max: -left + measures.w - width - opts.thumbmargin * 10 }; + + var verticalBounds = { + c: top + height / 2, + min: -top + opts.thumbmargin * 10, + max: -top + measures.h - height - opts.thumbmargin * 10 + }; + + return opts.navdir === 'vertical' ? verticalBounds : horizontalBounds; } function slideThumbBorder(time) { var navFrameData = activeFrame[navFrameKey].data(); slide($thumbBorder, { time: time * 1.2, - pos: navFrameData.l, - width: navFrameData.w + pos: (opts.navdir === 'vertical' ? navFrameData.t : navFrameData.l), + width: navFrameData.w, + height: navFrameData.h, + direction: opts.navdir }); } function slideNavShaft(options) { - var $guessNavFrame = data[options.guessIndex][navFrameKey]; + var $guessNavFrame = data[options.guessIndex][navFrameKey], + typeOfAnimation = opts.navtype; + + var overflowFLAG, + time, + minMax, + boundTop, + boundLeft, + l, + pos, + x; + if ($guessNavFrame) { - var overflowFLAG = navShaftTouchTail.min !== navShaftTouchTail.max, - minMax = options.minMax || overflowFLAG && getNavFrameBounds(activeFrame[navFrameKey]), - l = overflowFLAG && (options.keep && slideNavShaft.l ? slideNavShaft.l : minMaxLimit((options.coo || measures.nw / 2) - getNavFrameBounds($guessNavFrame).c, minMax.min, minMax.max)), - pos = overflowFLAG && minMaxLimit(l, navShaftTouchTail.min, navShaftTouchTail.max), + if (typeOfAnimation === 'thumbs') { + overflowFLAG = navShaftTouchTail.min !== navShaftTouchTail.max; + minMax = options.minMax || overflowFLAG && getNavFrameBounds(activeFrame[navFrameKey]); + boundTop = overflowFLAG && (options.keep && slideNavShaft.t ? slideNavShaft.l : minMaxLimit((options.coo || measures.nw / 2) - getNavFrameBounds($guessNavFrame).c, minMax.min, minMax.max)); + boundLeft = overflowFLAG && (options.keep && slideNavShaft.l ? slideNavShaft.l : minMaxLimit((options.coo || measures.nw / 2) - getNavFrameBounds($guessNavFrame).c, minMax.min, minMax.max)); + l = (opts.navdir === 'vertical' ? boundTop : boundLeft); + pos = overflowFLAG && minMaxLimit(l, navShaftTouchTail.min, navShaftTouchTail.max) || 0; time = options.time * 1.1; + slide($navShaft, { + time: time, + pos: pos, + direction: opts.navdir, + onEnd: function () { + thumbsDraw(pos, true); + thumbArrUpdate(); + } + }); - slide($navShaft, { - time: time, - pos: pos || 0, - onEnd: function () { - thumbsDraw(pos, true); - } - }); + setShadow($nav, findShadowEdge(pos, navShaftTouchTail.min, navShaftTouchTail.max, opts.navdir)); + slideNavShaft.l = l; + } else { + x = readPosition($navShaft, opts.navdir); + time = options.time * 1.11; + + pos = validateSlidePos(opts, navShaftTouchTail, options.guessIndex, x, $guessNavFrame, $navWrap, opts.navdir); - setShadow($nav, findShadowEdge(pos, navShaftTouchTail.min, navShaftTouchTail.max)); - slideNavShaft.l = l; + slide($navShaft, { + time: time, + pos: pos, + direction: opts.navdir, + onEnd: function () { + thumbsDraw(pos, true); + thumbArrUpdate(); + } + }); + setShadow($nav, findShadowEdge(pos, navShaftTouchTail.min, navShaftTouchTail.max, opts.navdir)); + } } } @@ -2929,13 +3178,19 @@ fotoramaVersion = '4.6.4'; $frame.attr('aria-hidden', 'false'); } - skipOnEnd || that.show.onEnd(true); + skipOnEnd || that.showStage.onEnd(true); stop($stageShaft, 0, true); detachFrames(STAGE_FRAME_KEY); stageFramePosition(activeIndexes); setStageShaftMinmaxAndSnap(); setNavShaftMinMax(); + addEnterUp($stageShaft[0], function () { + if (!$fotorama.hasClass(fullscreenClass)) { + that.requestFullScreen(); + $(fullscreenIcon).trigger('focus'); + } + }); } } @@ -3050,7 +3305,70 @@ fotoramaVersion = '4.6.4'; return this; }; - that.show = function (options) { + that.showSlide = function (slideDir) { + var currentPosition = readPosition($navShaft, opts.navdir), + pos, + time = 500 * 1.1, + size = opts.navdir === 'horizontal' ? opts.thumbwidth : opts.thumbheight, + onEnd = function () { + thumbArrUpdate(); + }; + if (slideDir === 'next') { + pos = currentPosition - (size + opts.margin) * thumbsPerSlide; + } + if (slideDir === 'prev') { + pos = currentPosition + (size + opts.margin) * thumbsPerSlide; + } + pos = validateRestrictions(pos, navShaftTouchTail); + thumbsDraw(pos, true); + slide($navShaft, { + time: time, + pos: pos, + direction: opts.navdir, + onEnd: onEnd + }); + }; + + that.showWhileLongPress = function (options) { + if (that.longPress.singlePressInProgress) + { + return; + } + + var index = calcActiveIndex(options); + calcGlobalIndexes(index); + var time = calcTime(options)/50; + var _activeFrame = activeFrame; + that.activeFrame = activeFrame = data[activeIndex]; + var silent = _activeFrame === activeFrame && !options.user; + + that.showNav(silent, options, time); + + return this; + }; + + that.showEndLongPress = function (options) { + if (that.longPress.singlePressInProgress) + { + return; + } + + var index = calcActiveIndex(options); + calcGlobalIndexes(index); + var time = calcTime(options)/50; + var _activeFrame = activeFrame; + that.activeFrame = activeFrame = data[activeIndex]; + + var silent = _activeFrame === activeFrame && !options.user; + + that.showStage(silent, options, time); + + showedFLAG = typeof lastActiveIndex !== 'undefined' && lastActiveIndex !== activeIndex; + lastActiveIndex = activeIndex; + return this; + }; + + function calcActiveIndex (options) { var index; if (typeof options !== 'object') { @@ -3064,6 +3382,10 @@ fotoramaVersion = '4.6.4'; index = isNaN(index) ? undefined : index; index = typeof index === 'undefined' ? activeIndex || 0 : index; + return index; + } + + function calcGlobalIndexes (index) { that.activeIndex = activeIndex = edgeIndex(index); prevIndex = getPrevIndex(activeIndex); nextIndex = getNextIndex(activeIndex); @@ -3071,20 +3393,22 @@ fotoramaVersion = '4.6.4'; activeIndexes = [activeIndex, prevIndex, nextIndex]; dirtyIndex = o_loop ? index : activeIndex; + } + function calcTime (options) { var diffIndex = Math.abs(lastActiveIndex - dirtyIndex), time = getNumber(options.time, function () { return Math.min(o_transitionDuration * (1 + (diffIndex - 1) / 12), o_transitionDuration * 2); - }), - overPos = options.overPos; - - if (options.slow) time *= 10; + }); - var _activeFrame = activeFrame; - that.activeFrame = activeFrame = data[activeIndex]; + if (options.slow) { + time *= 10; + } - var silent = _activeFrame === activeFrame && !options.user; + return time; + } + that.showStage = function (silent, options, time) { unloadVideo($videoPlaying, activeFrame.i !== data[normalizeIndex(repositionIndex)].i); frameDraw(activeIndexes, 'stage'); stageFramePosition(SLOW ? [dirtyIndex] : [dirtyIndex, getPrevIndex(dirtyIndex), getNextIndex(dirtyIndex)]); @@ -3097,7 +3421,8 @@ fotoramaVersion = '4.6.4'; pausedAutoplayFLAG = true; - var onEnd = that.show.onEnd = function (skipReposition) { + var overPos = options.overPos; + var onEnd = that.showStage.onEnd = function (skipReposition) { if (onEnd.ok) return; onEnd.ok = true; @@ -3131,12 +3456,11 @@ fotoramaVersion = '4.6.4'; pos: -getPosByIndex(dirtyIndex, measures.w, opts.margin, repositionIndex), overPos: overPos, time: time, - onEnd: onEnd/*, - _001: true*/ + onEnd: onEnd }); } else { var $activeFrame = activeFrame[STAGE_FRAME_KEY], - $prevActiveFrame = activeIndex !== lastActiveIndex ? data[lastActiveIndex][STAGE_FRAME_KEY] : null; + $prevActiveFrame = data[lastActiveIndex] && activeIndex !== lastActiveIndex ? data[lastActiveIndex][STAGE_FRAME_KEY] : null; fade($activeFrame, $prevActiveFrame, $stageFrame, { time: time, @@ -3146,7 +3470,10 @@ fotoramaVersion = '4.6.4'; } arrsUpdate(); + }; + that.showNav = function(silent, options, time){ + thumbArrUpdate(); if (o_nav) { navUpdate(); @@ -3157,12 +3484,27 @@ fotoramaVersion = '4.6.4'; guessIndex: typeof options.coo !== 'undefined' ? guessIndex : activeIndex, keep: silent }); - if (o_navThumbs) slideThumbBorder(time); } + }; + + that.show = function (options) { + that.longPress.singlePressInProgress = true; + + var index = calcActiveIndex(options); + calcGlobalIndexes(index); + var time = calcTime(options); + var _activeFrame = activeFrame; + that.activeFrame = activeFrame = data[activeIndex]; + + var silent = _activeFrame === activeFrame && !options.user; + + that.showStage(silent, options, time); + that.showNav(silent, options, time); showedFLAG = typeof lastActiveIndex !== 'undefined' && lastActiveIndex !== activeIndex; lastActiveIndex = activeIndex; + that.longPress.singlePressInProgress = false; return this; }; @@ -3258,11 +3600,12 @@ fotoramaVersion = '4.6.4'; var time = arguments[1] || 0, setFLAG = arguments[2]; + thumbsPerSlide = getThumbsInSlide($wrap, opts); extendMeasures(!that.fullScreen ? optionsToLowerCase(options) : { - width: '100%', + width: $(window).width(), maxwidth: null, minwidth: null, - height: '100%', + height: $(window).height(), maxheight: null, minheight: null }, [measures, setFLAG || that.fullScreen || opts]); @@ -3273,13 +3616,15 @@ fotoramaVersion = '4.6.4'; windowHeight = $WINDOW.height() - (o_nav ? $nav.height() : 0); if (measureIsValid(width)) { + $wrap.css({width: ''}); + $wrap.css({height: ''}); $stage.css({width: ''}); $stage.css({height: ''}); + $stage.css({'line-height': ''}); $stageShaft.css({width: ''}); $stageShaft.css({height: ''}); $nav.css({width: ''}); $nav.css({height: ''}); - $stage.css({'line-height': ''}); $wrap.css({minWidth: measures.minwidth || 0, maxWidth: measures.maxwidth || MAX_WIDTH}); width = measures.W = measures.w = $wrap.width(); @@ -3294,27 +3639,63 @@ fotoramaVersion = '4.6.4'; if (height) { width = Math.round(width); height = measures.h = Math.round(minMaxLimit(height, numberFromWhatever(measures.minheight, windowHeight), numberFromWhatever(measures.maxheight, windowHeight))); - $stage.css({'width': width, 'height': height, 'line-height': height + 'px'}); - stageShaftReposition(); + if (opts.navdir === 'vertical' && !that.fullscreen) { + $nav.width(opts.thumbwidth + opts.thumbmargin * 2); + } + + if (opts.navdir === 'horizontal' && !that.fullscreen) { + $nav.height(opts.thumbheight + opts.thumbmargin * 2); + } + + if (opts.navdir === 'vertical' && that.fullScreen) { + $stage.css('height', $(window).height()); + } + + if (opts.navdir === 'horizontal' && that.fullScreen) { + $stage.css('height', $(window).height() - (opts.thumbheight + opts.thumbmargin * 2)); + } if (o_nav) { - $nav - .stop() - .animate({width: measures.nw}, time); + switch (opts.navdir) { + case 'vertical': + $navWrap.removeClass(navShafthorizontalClass); + $navWrap.removeClass(navShaftListClass); + $navWrap.addClass(navShaftVerticalClass); + $nav + .stop() + .animate({height: measures.h, width: opts.thumbwidth}, time); + break; + case 'list': + $navWrap.removeClass(navShaftVerticalClass); + $navWrap.removeClass(navShafthorizontalClass); + $navWrap.addClass(navShaftListClass); + break; + default: + $navWrap.removeClass(navShaftVerticalClass); + $navWrap.removeClass(navShaftListClass); + $navWrap.addClass(navShafthorizontalClass); + $nav + .stop() + .animate({width: measures.nw}, time); + break; + } + stageShaftReposition(); slideNavShaft({guessIndex: activeIndex, time: time, keep: true}); if (o_navThumbs && frameAppend.nav) slideThumbBorder(time); } measuresSetFLAG = setFLAG || true; + ready.ok = true; ready(); } } stageLeft = $stage.offset().left; + setStagePosition(); return this; }; @@ -3333,10 +3714,33 @@ fotoramaVersion = '4.6.4'; function setShadow($el, edge) { if (o_shadows) { $el.removeClass(shadowsLeftClass + ' ' + shadowsRightClass); + $el.removeClass(shadowsTopClass + ' ' + shadowsBottomClass); edge && !$videoPlaying && $el.addClass(edge.replace(/^|\s/g, ' ' + shadowsClass + '--')); } } + that.longPress = { + threshold: 1, + count: 0, + thumbSlideTime: 20, + progress: function(){ + if (!this.inProgress) { + this.count++; + this.inProgress = this.count > this.threshold; + } + }, + end: function(){ + if(this.inProgress) { + this.isEnded = true + } + }, + reset: function(){ + this.count = 0; + this.inProgress = false; + this.isEnded = false; + } + }; + that.destroy = function () { that.cancelFullScreen(); that.stopAutoplay(); @@ -3466,7 +3870,11 @@ fotoramaVersion = '4.6.4'; toggleControlsClass(); } else if (opts.click) { - clickToShow({index: e.shiftKey || getDirectionSign(getDirection(e._x)), slow: e.altKey, user: true}); + clickToShow({ + index: e.shiftKey || getDirectionSign(getDirection(e._x)), + slow: e.altKey, + user: true + }); } } } @@ -3503,7 +3911,9 @@ fotoramaVersion = '4.6.4'; timeHigh: 1, friction: 2, select: '.' + selectClass + ', .' + selectClass + ' *', - $wrap: $stage + $wrap: $stage, + direction: 'horizontal' + }); navShaftTouchTail = moveOnTouch($navShaft, { @@ -3519,6 +3929,7 @@ fotoramaVersion = '4.6.4'; releaseAutoplay(); changeAutoplay(); thumbsDraw(result.newPos, true); + thumbArrUpdate(); } if (!result.moved) { @@ -3530,10 +3941,11 @@ fotoramaVersion = '4.6.4'; time: result.time, pos: result.newPos, overPos: result.overPos, + direction: opts.navdir, onEnd: onEnd }); thumbsDraw(result.newPos); - o_shadows && setShadow($nav, findShadowEdge(result.newPos, navShaftTouchTail.min, navShaftTouchTail.max)); + o_shadows && setShadow($nav, findShadowEdge(result.newPos, navShaftTouchTail.min, navShaftTouchTail.max, result.dir)); } else { onEnd(); } @@ -3541,7 +3953,8 @@ fotoramaVersion = '4.6.4'; timeLow: .5, timeHigh: 2, friction: 5, - $wrap: $nav + $wrap: $nav, + direction: opts.navdir }); stageWheelTail = wheel($stage, { @@ -3558,8 +3971,8 @@ fotoramaVersion = '4.6.4'; onTouchStart(); onTouchEnd(); var newPos = stop($navShaft) + direction * .25; - $navShaft.css(getTranslate(minMaxLimit(newPos, navShaftTouchTail.min, navShaftTouchTail.max))); - o_shadows && setShadow($nav, findShadowEdge(newPos, navShaftTouchTail.min, navShaftTouchTail.max)); + $navShaft.css(getTranslate(minMaxLimit(newPos, navShaftTouchTail.min, navShaftTouchTail.max), opts.navdir)); + o_shadows && setShadow($nav, findShadowEdge(newPos, navShaftTouchTail.min, navShaftTouchTail.max, opts.navdir)); navWheelTail.prevent = {'<': newPos >= navShaftTouchTail.max, '>': newPos <= navShaftTouchTail.min}; clearTimeout(navWheelTail.t); navWheelTail.t = setTimeout(function () { @@ -3578,7 +3991,6 @@ fotoramaVersion = '4.6.4'; }, 0); }, function () { - //console.log("click"); if (!hoverFLAG) return; toggleControlsClass(!(hoverFLAG = false)); } @@ -3586,7 +3998,12 @@ fotoramaVersion = '4.6.4'; function onNavFrameClick(e) { var index = $(this).data().eq; - clickToShow({index: index, slow: e.altKey, user: true, coo: e._x - $nav.offset().left}); + + if (opts.navtype === 'thumbs') { + clickToShow({index: index, slow: e.altKey, user: true, coo: e._x - $nav.offset().left}); + } else { + clickToShow({index: index, slow: e.altKey, user: true}); + } } function onArrClick(e) { @@ -3604,6 +4021,27 @@ fotoramaVersion = '4.6.4'; onTouchEnd: onTouchEnd }); + smartClick($thumbArrLeft, function (e) { + stopEvent(e); + if (opts.navtype === 'thumbs') { + + that.show('<'); + } else { + that.showSlide('prev') + } + }); + + smartClick($thumbArrRight, function (e) { + stopEvent(e); + if (opts.navtype === 'thumbs') { + that.show('>'); + } else { + that.showSlide('next') + } + + }); + + function addFocusOnControls(el) { addFocus(el, function () { setTimeout(function () { @@ -3620,7 +4058,10 @@ fotoramaVersion = '4.6.4'; addFocusOnControls(this); }); - addEnterUp(fullscreenIcon, that.toggleFullScreen); + addEnterUp(fullscreenIcon, function () { + that.toggleFullScreen(); + $(fullscreenIcon).trigger('focus'); + }); addFocusOnControls(fullscreenIcon); function reset() { @@ -3679,16 +4120,14 @@ fotoramaVersion = '4.6.4'; }); function ready() { - if (!ready.ok) { - ready.ok = true; + if (ready.ok) { + ready.ok = false; triggerEvent('ready'); } } reset(); }; - - $.fn.fotorama = function (opts) { return this.each(function () { var that = this, @@ -3733,49 +4172,50 @@ fotoramaVersion = '4.6.4'; $.Fotorama.instances.splice(instance.index, 1); calculateIndexes(); } + $.Fotorama.cache = {}; $.Fotorama.measures = {}; $ = $ || {}; $.Fotorama = $.Fotorama || {}; $.Fotorama.jst = $.Fotorama.jst || {}; - $.Fotorama.jst.dots = function(v) { + $.Fotorama.jst.dots = function (v) { var __t, __p = '', __e = _.escape; - __p += '
\r\n
\r\n
'; + __p += '
\r\n
\r\n
'; return __p }; - $.Fotorama.jst.frameCaption = function(v) { + $.Fotorama.jst.frameCaption = function (v) { var __t, __p = '', __e = _.escape; __p += '\r\n'; + ((__t = ( v.labelledby )) == null ? '' : __t) + + '">' + + ((__t = ( v.caption )) == null ? '' : __t) + + '
\r\n
\r\n'; return __p }; - $.Fotorama.jst.style = function(v) { + $.Fotorama.jst.style = function (v) { var __t, __p = '', __e = _.escape; __p += '.fotorama' + - ((__t = ( v.s )) == null ? '' : __t) + - ' .fotorama__nav--thumbs .fotorama__nav__frame{\r\npadding:' + - ((__t = ( v.m )) == null ? '' : __t) + - 'px;\r\nheight:' + - ((__t = ( v.h )) == null ? '' : __t) + - 'px}\r\n.fotorama' + - ((__t = ( v.s )) == null ? '' : __t) + - ' .fotorama__thumb-border{\r\nheight:' + - ((__t = ( v.h )) == null ? '' : __t) + - 'px;\r\nborder-width:' + - ((__t = ( v.b )) == null ? '' : __t) + - 'px;\r\nmargin-top:' + - ((__t = ( v.m )) == null ? '' : __t) + - 'px}'; + ((__t = ( v.s )) == null ? '' : __t) + + ' .fotorama__nav--thumbs .fotorama__nav__frame{\r\npadding:' + + ((__t = ( v.m )) == null ? '' : __t) + + 'px;\r\nheight:' + + ((__t = ( v.h )) == null ? '' : __t) + + 'px}\r\n.fotorama' + + ((__t = ( v.s )) == null ? '' : __t) + + ' .fotorama__thumb-border{\r\nheight:' + + ((__t = ( v.h )) == null ? '' : __t) + + 'px;\r\nborder-width:' + + ((__t = ( v.b )) == null ? '' : __t) + + 'px;\r\nmargin-top:' + + ((__t = ( v.m )) == null ? '' : __t) + + 'px}'; return __p }; - $.Fotorama.jst.thumb = function(v) { + $.Fotorama.jst.thumb = function (v) { var __t, __p = '', __e = _.escape; __p += '
\r\n
\r\n
\r\n
'; return __p diff --git a/lib/web/fotorama/fotorama.min.js b/lib/web/fotorama/fotorama.min.js new file mode 100644 index 0000000000000..dbce341e32242 --- /dev/null +++ b/lib/web/fotorama/fotorama.min.js @@ -0,0 +1,5 @@ +/*! + * Fotorama 4.6.4 | http://fotorama.io/license/ + */ +fotoramaVersion="4.6.4",function(t,e,n,o,i){"use strict";function r(t){var e="bez_"+o.makeArray(arguments).join("_").replace(".","p");if("function"!=typeof o.easing[e]){var n=function(t,e){var n=[null,null],o=[null,null],i=[null,null],r=function(r,a){return i[a]=3*t[a],o[a]=3*(e[a]-t[a])-i[a],n[a]=1-i[a]-o[a],r*(i[a]+r*(o[a]+r*n[a]))},a=function(t){return i[0]+t*(2*o[0]+3*n[0]*t)},s=function(t){for(var e,n=t,o=0;++o<14&&(e=r(n,0)-t,!(Math.abs(e)<.001));)n-=e/a(n);return n};return function(t){return r(s(t),1)}};o.easing[e]=function(e,o,i,r,a){return r*n([t[0],t[1]],[t[2],t[3]])(o/a)+i}}return e}function a(){}function s(t,e,n){return Math.max(isNaN(e)?-1/0:e,Math.min(isNaN(n)?1/0:n,t))}function u(t,e){return t.match(/ma/)&&t.match(/-?\d+(?!d)/g)[t.match(/3d/)?"vertical"===e?13:12:"vertical"===e?5:4]}function l(t,e){return On?+u(t.css("transform"),e):+t.css("vertical"===e?"top":"left").replace("px","")}function c(t,e){var n={};if(On)switch(e){case"vertical":n.transform="translate3d(0, "+t+"px,0)";break;case"list":break;default:n.transform="translate3d("+t+"px,0,0)"}else"vertical"===e?n.top=t:n.left=t;return n}function d(t){return{"transition-duration":t+"ms"}}function f(t,e){return isNaN(t)?e:t}function h(t,e){return f(+String(t).replace(e||"px",""))}function m(t){return/%$/.test(t)?h(t,"%"):i}function p(t,e){return f(m(t)/100*e,h(t))}function v(t){return(!isNaN(h(t))||!isNaN(h(t,"%")))&&t}function g(t,e,n,o){return(t-(o||0))*(e+(n||0))}function w(t,e,n,o){return-Math.round(t/(e+(n||0))-(o||0))}function y(t){var e=t.data();if(!e.tEnd){var n=t[0],o={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",msTransition:"MSTransitionEnd",transition:"transitionend"};V(n,o[Tn.prefixed("transition")],function(t){e.tProp&&t.propertyName.match(e.tProp)&&e.onEndFn()}),e.tEnd=!0}}function b(t,e,n,o){var i,r=t.data();r&&(r.onEndFn=function(){i||(i=!0,clearTimeout(r.tT),n())},r.tProp=e,clearTimeout(r.tT),r.tT=setTimeout(function(){r.onEndFn()},1.5*o),y(t))}function x(t,e){var n=t.navdir||"horizontal";if(t.length){var o=t.data();On?(t.css(d(0)),o.onEndFn=a,clearTimeout(o.tT)):t.stop();var i=_(e,function(){return l(t,n)});return t.css(c(i,n)),i}}function _(){for(var t,e=0,n=arguments.length;n>e&&(t=e?arguments[e]():arguments[e],"number"!=typeof t);e++);return t}function C(t,e){return Math.round(t+(e-t)/1.5)}function k(){return k.p=k.p||("https:"===n.protocol?"https://":"http://"),k.p}function T(t){var n=e.createElement("a");return n.href=t,n}function P(t,e){if("string"!=typeof t)return t;t=T(t);var n,o;if(t.host.match(/youtube\.com/)&&t.search){if(n=t.search.split("v=")[1]){var i=n.indexOf("&");-1!==i&&(n=n.substring(0,i)),o="youtube"}}else t.host.match(/youtube\.com|youtu\.be/)?(n=t.pathname.replace(/^\/(embed\/|v\/)?/,"").replace(/\/.*/,""),o="youtube"):t.host.match(/vimeo\.com/)&&(o="vimeo",n=t.pathname.replace(/^\/(video\/)?/,"").replace(/\/.*/,""));return n&&o||!e||(n=t.href,o="custom"),n?{id:n,type:o,s:t.search.replace(/^\?/,""),p:k()}:!1}function S(t,e,n){var i,r,a=t.video;return"youtube"===a.type?(r=k()+"img.youtube.com/vi/"+a.id+"/default.jpg",i=r.replace(/\/default.jpg$/,"/hqdefault.jpg"),t.thumbsReady=!0):"vimeo"===a.type?o.ajax({url:k()+"vimeo.com/api/v2/video/"+a.id+".json",dataType:"jsonp",success:function(o){t.thumbsReady=!0,M(e,{img:o[0].thumbnail_large,thumb:o[0].thumbnail_small},t.i,n)}}):t.thumbsReady=!0,{img:i,thumb:r}}function M(t,e,n,i){for(var r=0,a=t.length;a>r;r++){var s=t[r];if(s.i===n&&s.thumbsReady){var u={videoReady:!0};u[to]=u[no]=u[eo]=!1,i.splice(r,1,o.extend({},s,u,e));break}}}function E(t){function e(t,e,i){var r=t.children("img").eq(0),a=t.attr("href"),s=t.attr("src"),u=r.attr("src"),l=e.video,c=i?P(a,l===!0):!1;c?a=!1:c=l,n(t,r,o.extend(e,{video:c,img:e.img||a||s||u,thumb:e.thumb||u||s||a}))}function n(t,e,n){var i=n.thumb&&n.img!==n.thumb,r=h(n.width||t.attr("width")),a=h(n.height||t.attr("height"));o.extend(n,{width:r,height:a,thumbratio:K(n.thumbratio||h(n.thumbwidth||e&&e.attr("width")||i||r)/h(n.thumbheight||e&&e.attr("height")||i||a))})}var i=[];return t.children().each(function(){var t=o(this),r=H(o.extend(t.data(),{id:t.attr("id")}));if(t.is("a, img"))e(t,r,!0);else{if(t.is(":empty"))return;n(t,null,o.extend(r,{html:this,_html:t.html()}))}i.push(r)}),i}function F(t){return 0===t.offsetWidth&&0===t.offsetHeight}function j(t){return!o.contains(e.documentElement,t)}function z(t,e,n,o){return z.i||(z.i=1,z.ii=[!0]),o=o||z.i,"undefined"==typeof z.ii[o]&&(z.ii[o]=!0),t()?e():z.ii[o]&&setTimeout(function(){z.ii[o]&&z(t,e,n,o)},n||100),z.i++}function N(t,e){var n=t.data(),o=n.measures;if(o&&(!n.l||n.l.W!==o.width||n.l.H!==o.height||n.l.r!==o.ratio||n.l.w!==e.w||n.l.h!==e.h)){var i=s(e.h,0,o.height),r=i*o.ratio;po.setRatio(t,r,i),n.l={W:o.width,H:o.height,r:o.ratio,w:e.w,h:e.h}}return!0}function $(t,e){var n=t[0];n.styleSheet?n.styleSheet.cssText=e:t.html(e)}function q(t,e,n,o){return e===n?!1:"vertical"===o?e>=t?"top":t>=n?"bottom":"top bottom":e>=t?"left":t>=n?"right":"left right"}function L(t,e,n){n=n||{},t.each(function(){var t,i=o(this),r=i.data();r.clickOn||(r.clickOn=!0,o.extend(oe(i,{onStart:function(e){t=e,(n.onStart||a).call(this,e)},onMove:n.onMove||a,onTouchEnd:n.onTouchEnd||a,onEnd:function(n){n.moved||e.call(this,t)}}),{noMove:!0}))})}function A(t,e){return'
'+(e||"")+"
"}function I(t){return"."+t}function O(t){var e='';return e}function D(t){for(var e=t.length;e;){var n=Math.floor(Math.random()*e--),o=t[e];t[e]=t[n],t[n]=o}return t}function R(t){return"[object Array]"==Object.prototype.toString.call(t)&&o.map(t,function(t){return o.extend({},t)})}function W(t,e,n){t.scrollLeft(e||0).scrollTop(n||0)}function H(t){if(t){var e={};return o.each(t,function(t,n){e[t.toLowerCase()]=n}),e}}function K(t){if(t){var e=+t;return isNaN(e)?(e=t.split("/"),+e[0]/+e[1]||i):e}}function V(t,e,n,o){e&&(t.addEventListener?t.addEventListener(e,n,!!o):t.attachEvent("on"+e,n))}function B(t,e){return t>e.max?t=e.max:t=l-o?"horizontal"===a?-i.position().left:-i.position().top:(u+t.margin)*n<=Math.abs(o)?"horizontal"===a?-i.position().left+l-(u+t.margin):-i.position().top+l-(u+t.margin):o,s=B(s,e),s||0}function X(t){return!!t.getAttribute("disabled")}function U(t){return{tabindex:-1*t+"",disabled:t}}function Y(t,e){V(t,"keyup",function(n){X(t)||13==n.keyCode&&e.call(t,n)})}function G(t,e){V(t,"focus",t.onfocusin=function(n){e.call(t,n)},!0)}function J(t,e){t.preventDefault?t.preventDefault():t.returnValue=!1,e&&t.stopPropagation&&t.stopPropagation()}function Z(t){return t?">":"<"}function te(t,e){var n=t.data(),i=Math.round(e.pos),r=function(){n&&n.sliding&&(n.sliding=!1),(e.onEnd||a)()};"undefined"!=typeof e.overPos&&e.overPos!==e.pos&&(i=e.overPos);var s=o.extend(c(i,e.direction),e.width&&{width:e.width},e.height&&{height:e.height});n&&n.sliding&&(n.sliding=!0),On?(t.css(o.extend(d(e.time),s)),e.time>10?b(t,"transform",r,e.time):r()):t.stop().animate(s,e.time,io,r)}function ee(t,e,n,i,r,s){var u="undefined"!=typeof s;if(u||(r.push(arguments),Array.prototype.push.call(arguments,r.length),!(r.length>1))){t=t||o(t),e=e||o(e);var l=t[0],c=e[0],d="crossfade"===i.method,f=function(){if(!f.done){f.done=!0;var t=(u||r.shift())&&r.shift();t&&ee.apply(this,t),(i.onEnd||a)(!!t)}},h=i.time/(s||1);n.removeClass(Ke+" "+He),t.stop().addClass(Ke),e.stop().addClass(He),d&&c&&t.fadeTo(0,0),t.fadeTo(d?h:0,1,d&&f),e.fadeTo(h,0,f),l&&d||c||f()}}function ne(t){var e=(t.touches||[])[0]||t;t._x=e.pageX,t._y=e.clientY,t._now=o.now()}function oe(t,n){function i(t){return f=o(t.target),b.checked=p=v=w=!1,c||b.flow||t.touches&&t.touches.length>1||t.which>1||lo&&lo.type!==t.type&&fo||(p=n.select&&f.is(n.select,y))?p:(m="touchstart"===t.type,v=f.is("a, a *",y),h=b.control,g=b.noMove||b.noSwipe||h?16:b.snap?0:4,ne(t),d=lo=t,co=t.type.replace(/down|start/,"move").replace(/Down/,"Move"),(n.onStart||a).call(y,t,{control:h,$target:f}),c=b.flow=!0,void((!m||b.go)&&J(t)))}function r(t){if(t.touches&&t.touches.length>1||Kn&&!t.isPrimary||co!==t.type||!c)return c&&s(),void(n.onTouchEnd||a)();ne(t);var e=Math.abs(t._x-d._x),o=Math.abs(t._y-d._y),i=e-o,r=(b.go||b.x||i>=0)&&!b.noSwipe,u=0>i;m&&!b.checked?(c=r)&&J(t):(J(t),(n.onMove||a).call(y,t,{touch:m})),!w&&Math.sqrt(Math.pow(e,2)+Math.pow(o,2))>g&&(w=!0),b.checked=b.checked||r||u}function s(t){(n.onTouchEnd||a)();var e=c;b.control=c=!1,e&&(b.flow=!1),!e||v&&!b.checked||(t&&J(t),fo=!0,clearTimeout(ho),ho=setTimeout(function(){fo=!1},1e3),(n.onEnd||a).call(y,{moved:w,$target:f,control:h,touch:m,startEvent:d,aborted:!t||"MSPointerCancel"===t.type}))}function u(){b.flow||setTimeout(function(){b.flow=!0},10)}function l(){b.flow&&setTimeout(function(){b.flow=!1},Bn)}var c,d,f,h,m,p,v,g,w,y=t[0],b={};return Kn?(V(y,"MSPointerDown",i),V(e,"MSPointerMove",r),V(e,"MSPointerCancel",s),V(e,"MSPointerUp",s)):(V(y,"touchstart",i),V(y,"touchmove",r),V(y,"touchend",s),V(e,"touchstart",u),V(e,"touchend",l),V(e,"touchcancel",l),qn.on("scroll",l),t.on("mousedown",i),Ln.on("mousemove",r).on("mouseup",s)),mo=Tn.touch?"a":"div",t.on("click",mo,function(t){b.checked&&J(t)}),b}function ie(t,e){function n(n,o){S=!0,l=d="vertical"===_?n._y:n._x,v=n._now,p=[[v,l]],f=h=F.noMove||o?0:x(t,(e.getPos||a)()),(e.onStart||a).call(M,n)}function i(e,o){w=F.min,y=F.max,b=F.snap,_=F.direction||"horizontal",t.navdir=_,k=e.altKey,S=P=!1,T=o.control,T||E.sliding||n(e)}function r(o,i){F.noSwipe||(S||n(o),d="vertical"===_?o._y:o._x,p.push([o._now,d]),h=f-(l-d),m=q(h,w,y,_),w>=h?h=C(h,w):h>=y&&(h=C(h,y)),F.noMove||(t.css(c(h,_)),P||(P=!0,i.touch||Kn||t.addClass(un)),(e.onMove||a).call(M,o,{pos:h,edge:m})))}function u(i){if(!F.noSwipe||!i.moved){S||n(i.startEvent,!0),i.touch||Kn||t.removeClass(un),g=o.now();for(var r,u,l,c,m,v,x,C,T,P=g-Bn,E=null,j=Qn,z=e.friction,N=p.length-1;N>=0;N--){if(r=p[N][0],u=Math.abs(r-P),null===E||l>u)E=r,c=p[N][1];else if(E===P||u>l)break;l=u}x=s(h,w,y);var $=c-d,q=$>=0,L=g-E,A=L>Bn,I=!A&&h!==f&&x===h;b&&(x=s(Math[I?q?"floor":"ceil":"round"](h/b)*b,w,y),w=y=x),I&&(b||x===h)&&(T=-($/L),j*=s(Math.abs(T),e.timeLow,e.timeHigh),m=Math.round(h+T*j/z),b||(x=m),(!q&&m>y||q&&w>m)&&(v=q?w:y,C=m-v,b||(x=v),C=s(x+.03*C,v-50,v+50),j=Math.abs((h-C)/(T/z)))),j*=k?10:1,(e.onEnd||a).call(M,o.extend(i,{moved:i.moved||A&&b,pos:h,newPos:x,overPos:C,time:j,dir:_}))}}var l,d,f,h,m,p,v,g,w,y,b,_,k,T,P,S,M=t[0],E=t.data(),F={};return F=o.extend(oe(e.$wrap,o.extend({},e,{onStart:i,onMove:r,onEnd:u})),F)}function re(t,e){var n,i,r,s=t[0],u={prevent:{}};return V(s,Vn,function(t){var s=t.wheelDeltaY||-1*t.deltaY||0,l=t.wheelDeltaX||-1*t.deltaX||0,c=Math.abs(l)&&!Math.abs(s),d=Z(0>l),f=i===d,h=o.now(),m=Bn>h-r;i=d,r=h,c&&u.ok&&(!u.prevent[d]||n)&&(J(t,!0),n&&f&&m||(e.shift&&(n=!0,clearTimeout(u.t),u.t=setTimeout(function(){n=!1},Xn)),(e.onEnd||a)(t,e.shift?d:l)))}),u}function ae(){o.each(o.Fotorama.instances,function(t,e){e.index=t})}function se(t){o.Fotorama.instances.push(t),ae()}function ue(t){o.Fotorama.instances.splice(t.index,1),ae()}var le="fotorama",ce="fotorama__fullscreen",de=le+"__wrap",fe=de+"--css2",he=de+"--css3",me=de+"--video",pe=de+"--fade",ve=de+"--slide",ge=de+"--no-controls",we=de+"--no-shadows",ye=de+"--pan-y",be=de+"--rtl",xe=de+"--no-captions",_e=de+"--toggle-arrows",Ce=le+"__stage",ke=Ce+"__frame",Te=ke+"--video",Pe=Ce+"__shaft",Se=le+"__grab",Me=le+"__pointer",Ee=le+"__arr",Fe=Ee+"--disabled",je=Ee+"--prev",ze=Ee+"--next",Ne=le+"__nav",$e=Ne+"-wrap",qe=Ne+"__shaft",Le=$e+"--vertical",Ae=$e+"--list",Ie=$e+"--horizontal",Oe=Ne+"--dots",De=Ne+"--thumbs",Re=Ne+"__frame",We=le+"__fade",He=We+"-front",Ke=We+"-rear",Ve=le+"__shadow",Be=Ve+"s",Qe=Be+"--left",Xe=Be+"--right",Ue=Be+"--top",Ye=Be+"--bottom",Ge=le+"__active",Je=le+"__select",Ze=le+"--hidden",tn=le+"--fullscreen",en=le+"__fullscreen-icon",nn=le+"__error",on=le+"__loading",rn=le+"__loaded",an=rn+"--full",sn=rn+"--img",un=le+"__grabbing",ln=le+"__img",cn=ln+"--full",dn=le+"__thumb",fn=dn+"__arr--left",hn=dn+"__arr--right",mn=dn+"-border",pn=le+"__html",vn=le+"-video-container",gn=le+"__video",wn=gn+"-play",yn=gn+"-close",bn=le+"__spinner",xn=le+"_horizontal_ratio",_n=le+"_vertical_ratio",Cn=o&&o.fn.jquery.split(".");if(!Cn||Cn[0]<1||1==Cn[0]&&Cn[1]<8)throw"Fotorama requires jQuery 1.8 or later and will not run without it.";var kn={},Tn=function(t,e,n){function o(t){g.cssText=t}function i(t,e){return typeof t===e}function r(t,e){return!!~(""+t).indexOf(e)}function a(t,e){for(var o in t){var i=t[o];if(!r(i,"-")&&g[i]!==n)return"pfx"==e?i:!0}return!1}function s(t,e,o){for(var r in t){var a=e[t[r]];if(a!==n)return o===!1?t[r]:i(a,"function")?a.bind(o||e):a}return!1}function u(t,e,n){var o=t.charAt(0).toUpperCase()+t.slice(1),r=(t+" "+b.join(o+" ")+o).split(" ");return i(e,"string")||i(e,"undefined")?a(r,e):(r=(t+" "+x.join(o+" ")+o).split(" "),s(r,e,n))}var l,c,d,f="2.8.3",h={},m=e.documentElement,p="modernizr",v=e.createElement(p),g=v.style,w=({}.toString," -webkit- -moz- -o- -ms- ".split(" ")),y="Webkit Moz O ms",b=y.split(" "),x=y.toLowerCase().split(" "),_={},C=[],k=C.slice,T=function(t,n,o,i){var r,a,s,u,l=e.createElement("div"),c=e.body,d=c||e.createElement("body");if(parseInt(o,10))for(;o--;)s=e.createElement("div"),s.id=i?i[o]:p+(o+1),l.appendChild(s);return r=["­",'"].join(""),l.id=p,(c?l:d).innerHTML+=r,d.appendChild(l),c||(d.style.background="",d.style.overflow="hidden",u=m.style.overflow,m.style.overflow="hidden",m.appendChild(d)),a=n(l,t),c?l.parentNode.removeChild(l):(d.parentNode.removeChild(d),m.style.overflow=u),!!a},P={}.hasOwnProperty;d=i(P,"undefined")||i(P.call,"undefined")?function(t,e){return e in t&&i(t.constructor.prototype[e],"undefined")}:function(t,e){return P.call(t,e)},Function.prototype.bind||(Function.prototype.bind=function(t){var e=this;if("function"!=typeof e)throw new TypeError;var n=k.call(arguments,1),o=function(){if(this instanceof o){var i=function(){};i.prototype=e.prototype;var r=new i,a=e.apply(r,n.concat(k.call(arguments)));return Object(a)===a?a:r}return e.apply(t,n.concat(k.call(arguments)))};return o}),_.touch=function(){var n;return"ontouchstart"in t||t.DocumentTouch&&e instanceof DocumentTouch?n=!0:T(["@media (",w.join("touch-enabled),("),p,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(t){n=9===t.offsetTop}),n},_.csstransforms3d=function(){var t=!!u("perspective");return t&&"webkitPerspective"in m.style&&T("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(e){t=9===e.offsetLeft&&3===e.offsetHeight}),t},_.csstransitions=function(){return u("transition")};for(var S in _)d(_,S)&&(c=S.toLowerCase(),h[c]=_[S](),C.push((h[c]?"":"no-")+c));return h.addTest=function(t,e){if("object"==typeof t)for(var o in t)d(t,o)&&h.addTest(o,t[o]);else{if(t=t.toLowerCase(),h[t]!==n)return h;e="function"==typeof e?e():e,"undefined"!=typeof enableClasses&&enableClasses&&(m.className+=" "+(e?"":"no-")+t),h[t]=e}return h},o(""),v=l=null,h._version=f,h._prefixes=w,h._domPrefixes=x,h._cssomPrefixes=b,h.testProp=function(t){return a([t])},h.testAllProps=u,h.testStyles=T,h.prefixed=function(t,e,n){return e?u(t,e,n):u(t,"pfx")},h}(t,e),Pn={ok:!1,is:function(){return!1},request:function(){},cancel:function(){},event:"",prefix:""},Sn="webkit moz o ms khtml".split(" ");if("undefined"!=typeof e.cancelFullScreen)Pn.ok=!0;else for(var Mn=0,En=Sn.length;En>Mn;Mn++)if(Pn.prefix=Sn[Mn],"undefined"!=typeof e[Pn.prefix+"CancelFullScreen"]){Pn.ok=!0;break}Pn.ok&&(Pn.event=Pn.prefix+"fullscreenchange",Pn.is=function(){switch(this.prefix){case"":return e.fullScreen;case"webkit":return e.webkitIsFullScreen;default:return e[this.prefix+"FullScreen"]}},Pn.request=function(t){return""===this.prefix?t.requestFullScreen():t[this.prefix+"RequestFullScreen"]()},Pn.cancel=function(){return""===this.prefix?e.cancelFullScreen():e[this.prefix+"CancelFullScreen"]()});var Fn,jn={lines:12,length:5,width:2,radius:7,corners:1,rotate:15,color:"rgba(128, 128, 128, .75)",hwaccel:!0},zn={top:"auto",left:"auto",className:""};!function(t,e){Fn=e()}(this,function(){function t(t,n){var o,i=e.createElement(t||"div");for(o in n)i[o]=n[o];return i}function n(t){for(var e=1,n=arguments.length;n>e;e++)t.appendChild(arguments[e]);return t}function o(t,e,n,o){var i=["opacity",e,~~(100*t),n,o].join("-"),r=.01+n/o*100,a=Math.max(1-(1-t)/e*(100-r),t),s=f.substring(0,f.indexOf("Animation")).toLowerCase(),u=s&&"-"+s+"-"||"";return m[i]||(p.insertRule("@"+u+"keyframes "+i+"{0%{opacity:"+a+"}"+r+"%{opacity:"+t+"}"+(r+.01)+"%{opacity:1}"+(r+e)%100+"%{opacity:"+t+"}100%{opacity:"+a+"}}",p.cssRules.length),m[i]=1),i}function r(t,e){var n,o,r=t.style;for(e=e.charAt(0).toUpperCase()+e.slice(1),o=0;o',n)}p.addRule(".spin-vml","behavior:url(#default#VML)"),c.prototype.lines=function(t,o){function i(){return a(e("group",{coordsize:c+" "+c,coordorigin:-u+" "+-u}),{width:c,height:c})}function r(t,r,s){n(f,n(a(i(),{rotation:360/o.lines*t+"deg",left:~~r}),n(a(e("roundrect",{arcsize:o.corners}),{width:u,height:o.width,left:o.radius,top:-o.width>>1,filter:s}),e("fill",{color:l(o.color,t),opacity:o.opacity}),e("stroke",{opacity:0}))))}var s,u=o.length+o.width,c=2*u,d=2*-(o.width+o.length)+"px",f=a(i(),{position:"absolute",top:d,left:d});if(o.shadow)for(s=1;s<=o.lines;s++)r(s,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(s=1;s<=o.lines;s++)r(s);return n(t,f)},c.prototype.opacity=function(t,e,n,o){var i=t.firstChild;o=o.shadow&&o.lines||0,i&&e+o>1):parseInt(r.left,10)+l)+"px",top:("auto"==r.top?o.y-n.y+(e.offsetHeight>>1):parseInt(r.top,10)+l)+"px"})),s.setAttribute("role","progressbar"),i.lines(s,i.opts),!f){var c,d=0,h=(r.lines-1)*(1-r.direction)/2,m=r.fps,p=m/r.speed,v=(1-r.opacity)/(p*r.trail/100),g=p/r.lines;!function w(){d++;for(var t=0;t>1)+"px"})}for(var s,u=0,c=(i.lines-1)*(1-i.direction)/2;u=o?(t.parent().removeClass(xn),t.parent().addClass(_n)):(t.parent().removeClass(_n),t.parent().addClass(xn))}function e(t,e,n){var r=n;t.attr(r)||t.attr(r)===i||t.attr(r,e),t.find("["+r+"]").length&&t.find("["+r+"]").each(function(){o(this).attr(r,e)})}function n(t,e,n){var o,i=!1;return o=t.showCaption===n||t.showCaption===!0?!0:!1,e?(t.caption&&o&&(i=!0),i):!1}return{setRatio:t,setThumbAttr:e,isExpectedCaption:n}}(po||{},jQuery);jQuery.Fotorama=function(n,r){function a(){o.each(Ro,function(t,e){if(!e.i){e.i=Ei++;var n=P(e.video,!0);if(n){var o={};e.video=n,e.img||e.thumb?e.thumbsReady=!0:o=S(e,Ro,Ti),M(Ro,{img:o.img,thumb:o.thumb},e.i,Ti)}}})}function u(t){return mi[t]||Ti.fullScreen}function f(){if($i!==i)if("vertical"==r.navdir){var t=r.thumbwidth+r.thumbmargin;$i.css("left",t),Ii.css("right",t),Xi.css("right",t),Ni.css("width",Ni.css("width")+t),qi.css("max-width",Ni.width()-t)}else $i.css("left",""),Ii.css("right",""),Xi.css("right",""),Ni.css("width",Ni.css("width")+t),qi.css("max-width","")}function m(t){var e,n="keydown."+le,o=le+Pi,i="keydown."+o,a="keyup."+o,s="resize."+o+" orientationchange."+o;t?(Ln.on(i,function(t){var n,o;Vo&&27===t.keyCode?(n=!0,Eo(Vo,!0,!0)):(Ti.fullScreen||r.keyboard&&!Ti.index)&&(27===t.keyCode?(n=!0,Ti.cancelFullScreen()):t.shiftKey&&32===t.keyCode&&u("space")||37===t.keyCode&&u("left")||38===t.keyCode&&u("up")?(Ti.longPress.progress(),o="<"):32===t.keyCode&&u("space")||39===t.keyCode&&u("right")||40===t.keyCode&&u("down")?(Ti.longPress.progress(),o=">"):36===t.keyCode&&u("home")?(Ti.longPress.progress(),o="<<"):35===t.keyCode&&u("end")&&(Ti.longPress.progress(),o=">>")),(n||o)&&J(t),e={index:o,slow:t.altKey,user:!0},o&&(Ti.longPress.inProgress?Ti.showWhileLongPress(e):Ti.show(e))}),t&&Ln.on(a,function(){Ti.longPress.inProgress&&Ti.showEndLongPress({user:!0}),Ti.longPress.reset()}),Ti.index||Ln.off(n).on(n,"textarea, input, select",function(t){!$n.hasClass(ce)&&t.stopPropagation()}),qn.on(s,Ti.resize)):(Ln.off(i),qn.off(s))}function y(t){t!==y.f&&(t?(n.addClass(le+" "+Si).before(zi).before(ji),se(Ti)):(zi.detach(),ji.detach(),n.html(Fi.urtext).removeClass(Si),ue(Ti)),m(t),y.f=t)}function b(){Ro=Ti.data=Ro||R(r.data)||E(n),Wo=Ti.size=Ro.length,Do.ok&&r.shuffle&&D(Ro),a(),tr=oe(tr),Wo&&y(!0)}function C(){var t=2>Wo||Vo;or.noMove=t||si,or.noSwipe=t||!r.swipe,!di&&qi.toggleClass(Se,!r.click&&!or.noMove&&!or.noSwipe),Kn&&Ni.toggleClass(ye,!or.noSwipe)}function k(t){t===!0&&(t=""),r.autoplay=Math.max(+t||Un,1.5*ci)}function T(t){t.navarrows&&"thumbs"===t.nav?(Bi.show(),Qi.show()):(Bi.hide(),Qi.hide())}function F(t,e){return Math.floor(Ni.width()/(e.thumbwidth+e.thumbmargin))}function X(){function t(t,n){e[t?"add":"remove"].push(n)}r.nav&&"dots"!==r.nav||(r.navdir="horizontal"),Ti.options=r=H(r),ao=F(Ni,r),si="crossfade"===r.transition||"dissolve"===r.transition,ei=r.loop&&(Wo>2||si&&(!di||"slide"!==di)),ci=+r.transitionduration||Qn,hi="rtl"===r.direction,mi=o.extend({},r.keyboard&&uo,r.keyboard),T(r);var e={add:[],remove:[]};Wo>1?(ni=r.nav,ii="top"===r.navposition,e.remove.push(Je),Oi.toggle(r.arrows)):(ni=!1,Oi.hide()),Cn(),Ko=new Fn(o.extend(jn,r.spinner,zn,{direction:hi?-1:1})),Yn(),so(),io(),r.autoplay&&k(r.autoplay),ui=h(r.thumbwidth)||Gn,li=h(r.thumbheight)||Gn,ir.ok=ar.ok=r.trackpad&&!Hn,C(),wo(r,[nr]),oi="thumbs"===ni,Di.filter(":hidden")&&ni&&Di.show(),oi?(Mn(Wo,"navThumb"),Ho=Ki,ki=no,$(ji,o.Fotorama.jst.style({w:ui,h:li,b:r.thumbborderwidth,m:r.thumbmargin,s:Pi,q:!Dn})),Ri.addClass(De).removeClass(Oe)):"dots"===ni?(Mn(Wo,"navDot"),Ho=Hi,ki=eo,Ri.addClass(Oe).removeClass(De)):(Di.hide(),ni=!1,Ri.removeClass(De+" "+Oe)),ni&&(ii?Di.insertBefore($i):Di.insertAfter($i),Wn.nav=!1,Wn(Ho,Wi,"nav")),ri=r.allowfullscreen,ri?(Xi.prependTo($i),ai=Rn&&"native"===ri):(Xi.detach(),ai=!1),t(si,pe),t(!si,ve),t(!r.captions,xe),t(hi,be),t("always"!==r.arrows,_e),fi=r.shadows&&!Hn,t(!fi,we),Ni.addClass(e.add.join(" ")).removeClass(e.remove.join(" ")),er=o.extend({},r),f()}function ne(t){return 0>t?(Wo+t%Wo)%Wo:t>=Wo?t%Wo:t}function oe(t){return s(t,0,Wo-1)}function ae(t){return ei?ne(t):oe(t)}function We(t){return t>0||ei?t-1:!1}function He(t){return Wo-1>t||ei?t+1:!1}function Ke(){or.min=ei?-1/0:-g(Wo-1,nr.w,r.margin,Xo),or.max=ei?1/0:-g(0,nr.w,r.margin,Xo),or.snap=nr.w+r.margin}function Ve(){var t="vertical"===r.navdir,e=t?Wi.height():Wi.width(),n=t?nr.h:nr.nw;rr.min=Math.min(0,n-e),rr.max=0,rr.direction=r.navdir,Wi.toggleClass(Se,!(rr.noMove=rr.min===rr.max))}function un(t,e,n){if("number"==typeof t){t=new Array(t);var i=!0}return o.each(t,function(t,o){if(i&&(o=t),"number"==typeof o){var r=Ro[ne(o)];if(r){var a="$"+e+"Frame",s=r[a];n.call(this,t,o,r,s,a,s&&s.data())}}})}function dn(t,e,n,o){(!pi||"*"===pi&&o===ti)&&(t=v(r.width)||v(t)||Jn,e=v(r.height)||v(e)||Zn,Ti.resize({width:t,ratio:r.ratio||n||t/e},0,o!==ti&&"*"))}function xn(t,e,n,i){un(t,e,function(t,a,s,u,l,c){function d(t){var e=ne(a);yo(t,{index:e,src:b,frame:Ro[e]})}function f(){g.remove(),o.Fotorama.cache[b]="error",s.html&&"stage"===e||!x||x===b?(!b||s.html||p?"stage"===e&&(u.trigger("f:load").removeClass(on+" "+nn).addClass(rn),d("load"),dn()):(u.trigger("f:error").removeClass(on).addClass(nn),d("error")),c.state="error",!(Wo>1&&Ro[a]===s)||s.html||s.deleted||s.video||p||(s.deleted=!0,Ti.splice(a,1))):(s[y]=b=x,xn([a],e,n,!0))}function h(){o.Fotorama.measures[b]=w.measures=o.Fotorama.measures[b]||{width:v.width,height:v.height,ratio:v.width/v.height},dn(w.measures.width,w.measures.height,w.measures.ratio,a),g.off("load error").addClass(ln+(p?" "+cn:"")).prependTo(u),u.hasClass(ke)&&!u.hasClass(vn)&&u.attr("href",g.attr("src")),N(g,(o.isFunction(n)?n():n)||nr),o.Fotorama.cache[b]=c.state="loaded",setTimeout(function(){u.trigger("f:load").removeClass(on+" "+nn).addClass(rn+" "+(p?an:sn)),"stage"===e?d("load"):(s.thumbratio===oo||!s.thumbratio&&r.thumbratio===oo)&&(s.thumbratio=w.measures.ratio,Io())},0)}function m(){var t=10;z(function(){return!_i||!t--&&!Hn},function(){h()})}if(u){var p=Ti.fullScreen&&s.full&&s.full!==s.img&&!c.$full&&"stage"===e;if(!c.$img||i||p){var v=new Image,g=o(v),w=g.data();c[p?"$full":"$img"]=g;var y="stage"===e?p?"full":"img":"thumb",b=s[y],x=p?null:s["stage"===e?"thumb":"img"];if("navThumb"===e&&(u=c.$wrap),!b)return void f();o.Fotorama.cache[b]?!function _(){"error"===o.Fotorama.cache[b]?f():"loaded"===o.Fotorama.cache[b]?setTimeout(m,0):setTimeout(_,100)}():(o.Fotorama.cache[b]="*",g.on("load",m).on("error",f)),c.state="",v.src=b,c.data.caption&&(v.alt=c.data.caption||""),po.isExpectedCaption(s,r.showcaption)&&o(v).attr("aria-labelledby",s.labelledby)}}})}function _n(t){Zi.append(Ko.spin().el).appendTo(t)}function Cn(){Zi.detach(),Ko&&Ko.stop()}function kn(){var t=Bo[to];t&&!t.data().state&&(_n(t),t.on("f:load f:error",function(){t.off("f:load f:error"),Cn()}))}function Sn(t){Y(t,qo),G(t,function(){setTimeout(function(){W(Ri)},0),fo({time:ci,guessIndex:o(this).data().eq,minMax:rr})})}function Mn(t,e){un(t,e,function(t,n,i,a,s,u){if(!a){a=i[s]=Ni[s].clone(),u=a.data(),u.data=i;var l=a[0],c="labelledby"+o.now();"stage"===e?(i.html&&o('
').append(i._html?o(i.html).removeAttr("id").html(i._html):i.html).appendTo(a),i.id&&(c=i.id||c),i.labelledby=c,po.isExpectedCaption(i,r.showcaption)&&o(o.Fotorama.jst.frameCaption({caption:i.caption,labelledby:c})).appendTo(a),i.video&&a.addClass(Te).append(Yi.clone()),G(l,function(){setTimeout(function(){W($i)},0),zo({index:u.eq,user:!0})}),Li=Li.add(a)):"navDot"===e?(Sn(l),Hi=Hi.add(a)):"navThumb"===e&&(Sn(l),u.$wrap=a.children(":first"),Ki=Ki.add(a),i.video&&u.$wrap.append(Yi.clone()))}})}function En(t,e){return t&&t.length&&N(t,e)}function An(t){un(t,"stage",function(t,e,n,i,a,s){if(i){var u=ne(e);s.eq=u,ur[to][u]=i.css(o.extend({left:si?0:g(e,nr.w,r.margin,Xo)},si&&d(0))),j(i[0])&&(i.appendTo(qi),Eo(n.$video)),En(s.$img,nr),En(s.$full,nr),!i.hasClass(ke)||"false"===i.attr("aria-hidden")&&i.hasClass(Ge)||i.attr("aria-hidden","true")}})}function In(t,e){var n,i;"thumbs"!==ni||isNaN(t)||(n=-t,i=-t+nr.nw,"vertical"===r.navdir&&(t-=r.thumbheight,i=-t+nr.h),Ki.each(function(){var t=o(this),a=t.data(),s=a.eq,u=function(){return{h:li,w:a.w}},l=u(),c="vertical"===r.navdir?a.t>i:a.l>i;l.w=a.w,a.l+a.wi;i++)if(n.data===Ro[i]){t=!0,n.eq=i;break}return t||e.remove()&&!1}).sort(function(t,e){return o(t).data().eq-o(e).data().eq}).each(function(){var t=o(this),e=t.data();po.setThumbAttr(t,e.data.caption,"aria-label")}).each(function(){if(i){var t=o(this),e=t.data(),n=Math.round(li*e.data.thumbratio)||ui,u=Math.round(ui/e.data.thumbratio)||li;e.t=s,e.h=u,e.l=a,e.w=n,t.css({width:n}),s+=u+r.thumbmargin,a+=n+r.thumbmargin}})),Wn[n]=!0}}function Vn(t){return t-lr>nr.w/3}function Xn(t){return!(ei||tr+t&&tr-Wo+t||Vo)}function Yn(){var t=Xn(0),e=Xn(1);Ai.toggleClass(Fe,t).attr(U(t)),Ii.toggleClass(Fe,e).attr(U(e))}function io(){var t=!1,e=!1;if("thumbs"!==r.navtype||r.loop||(t=0==tr?!0:!1,e=tr==r.data.length-1?!0:!1),"slides"===r.navtype){var n=l(Wi,r.navdir);t=n>=rr.max?!0:!1,e=n<=rr.min?!0:!1}Bi.toggleClass(Fe,t).attr(U(t)),Qi.toggleClass(Fe,e).attr(U(e))}function so(){ir.ok&&(ir.prevent={"<":Xn(0),">":Xn(1)})}function lo(t){var e,n,o,i,a=t.data();oi?(e=a.l,n=a.t,o=a.w,i=a.h):(e=t.position().left,o=t.width());var s={c:e+o/2,min:-e+10*r.thumbmargin,max:-e+nr.w-o-10*r.thumbmargin},u={c:n+i/2,min:-n+10*r.thumbmargin,max:-n+nr.h-i-10*r.thumbmargin};return"vertical"===r.navdir?u:s}function co(t){var e=Bo[ki].data();te(Vi,{time:1.2*t,pos:"vertical"===r.navdir?e.t:e.l,width:e.w,height:e.h,direction:r.navdir})}function fo(t){var e,n,o,i,a,u,c,d,f=Ro[t.guessIndex][ki],h=r.navtype;f&&("thumbs"===h?(e=rr.min!==rr.max,o=t.minMax||e&&lo(Bo[ki]),i=e&&(t.keep&&fo.t?fo.l:s((t.coo||nr.nw/2)-lo(f).c,o.min,o.max)),a=e&&(t.keep&&fo.l?fo.l:s((t.coo||nr.nw/2)-lo(f).c,o.min,o.max)),u="vertical"===r.navdir?i:a,c=e&&s(u,rr.min,rr.max)||0,n=1.1*t.time,te(Wi,{time:n,pos:c,direction:r.navdir,onEnd:function(){In(c,!0),io()}}),Mo(Ri,q(c,rr.min,rr.max,r.navdir)),fo.l=u):(d=l(Wi,r.navdir),n=1.11*t.time,c=Q(r,rr,t.guessIndex,d,f,Di,r.navdir),te(Wi,{time:n,pos:c,direction:r.navdir,onEnd:function(){In(c,!0),io() +}}),Mo(Ri,q(c,rr.min,rr.max,r.navdir))))}function ho(){mo(ki),sr[ki].push(Bo[ki].addClass(Ge).attr("data-active",!0))}function mo(t){for(var e=sr[t];e.length;)e.shift().removeClass(Ge).attr("data-active",!1)}function vo(t){var e=ur[t];o.each(Qo,function(t,n){delete e[ne(n)]}),o.each(e,function(t,n){delete e[t],n.detach()})}function go(t){Xo=Uo=tr;var e=Bo[to];e&&(mo(to),sr[to].push(e.addClass(Ge).attr("data-active",!0)),e.hasClass(ke)&&e.attr("aria-hidden","false"),t||Ti.showStage.onEnd(!0),x(qi,0,!0),vo(to),An(Qo),Ke(),Ve(),Y(qi[0],function(){n.hasClass(tn)||(Ti.requestFullScreen(),o(Ui).trigger("focus"))}))}function wo(t,e){t&&o.each(e,function(e,n){n&&o.extend(n,{width:t.width||n.width,height:t.height,minwidth:t.minwidth,maxwidth:t.maxwidth,minheight:t.minheight,maxheight:t.maxheight,ratio:K(t.ratio)})})}function yo(t,e){n.trigger(le+":"+t,[Ti,e])}function bo(){clearTimeout(xo.t),_i=1,r.stopautoplayontouch?Ti.stopAutoplay():yi=!0}function xo(){_i&&(r.stopautoplayontouch||(_o(),Co()),xo.t=setTimeout(function(){_i=0},Qn+Bn))}function _o(){yi=!(!Vo&&!bi)}function Co(){if(clearTimeout(Co.t),z.stop(Co.w),!r.autoplay||yi)return void(Ti.autoplay&&(Ti.autoplay=!1,yo("stopautoplay")));Ti.autoplay||(Ti.autoplay=!0,yo("startautoplay"));var t=tr,e=Bo[to].data();Co.w=z(function(){return e.state||t!==tr},function(){Co.t=setTimeout(function(){if(!yi&&t===tr){var e=Zo,n=Ro[e][to].data();Co.w=z(function(){return n.state||e!==Zo},function(){yi||e!==Zo||Ti.show(ei?Z(!hi):Zo)})}},r.autoplay)})}function ko(t){var e;return"object"!=typeof t?(e=t,t={}):e=t.index,e=">"===e?Uo+1:"<"===e?Uo-1:"<<"===e?0:">>"===e?Wo-1:e,e=isNaN(e)?i:e,e="undefined"==typeof e?tr||0:e}function To(t){Ti.activeIndex=tr=ae(t),Go=We(tr),Jo=He(tr),Zo=ne(tr+(hi?-1:1)),Qo=[tr,Go,Jo],Uo=ei?t:tr}function Po(t){var e=Math.abs(Yo-Uo),n=_(t.time,function(){return Math.min(ci*(1+(e-1)/12),2*ci)});return t.slow&&(n*=10),n}function So(){Ti.fullScreen&&(Ti.fullScreen=!1,Rn&&Pn.cancel(Mi),$n.removeClass(ce),Nn.removeClass(ce),n.removeClass(tn).insertAfter(zi),nr=o.extend({},xi),Eo(Vo,!0,!0),$o("x",!1),Ti.resize(),xn(Qo,"stage"),W(qn,gi,vi),yo("fullscreenexit"))}function Mo(t,e){fi&&(t.removeClass(Qe+" "+Xe),t.removeClass(Ue+" "+Ye),e&&!Vo&&t.addClass(e.replace(/^|\s/g," "+Be+"--")))}function Eo(t,e,n){e&&(Ni.removeClass(me),Vo=!1,C()),t&&t!==Vo&&(t.remove(),yo("unloadvideo")),n&&(_o(),Co())}function Fo(t){Ni.toggleClass(ge,t)}function jo(t){if(!or.flow){var e=t?t.pageX:jo.x,n=e&&!Xn(Vn(e))&&r.click;jo.p!==n&&$i.toggleClass(Me,n)&&(jo.p=n,jo.x=e)}}function zo(t){clearTimeout(zo.t),r.clicktransition&&r.clicktransition!==r.transition?setTimeout(function(){var e=r.transition;Ti.setOptions({transition:r.clicktransition}),di=e,zo.t=setTimeout(function(){Ti.show(t)},10)},0):Ti.show(t)}function No(t,e){var n=t.target,i=o(n);i.hasClass(wn)?Ti.playVideo():n===Ui?Ti.toggleFullScreen():Vo?n===Ji&&Eo(Vo,!0,!0):e?Fo():r.click&&zo({index:t.shiftKey||Z(Vn(t._x)),slow:t.altKey,user:!0})}function $o(t,e){or[t]=rr[t]=e}function qo(t){var e=o(this).data().eq;zo("thumbs"===r.navtype?{index:e,slow:t.altKey,user:!0,coo:t._x-Ri.offset().left}:{index:e,slow:t.altKey,user:!0})}function Lo(t){zo({index:Oi.index(this)?">":"<",slow:t.altKey,user:!0})}function Ao(t){G(t,function(){setTimeout(function(){W($i)},0),Fo(!1)})}function Io(){if(b(),X(),!Io.i){Io.i=!0;var t=r.startindex;tr=Xo=Uo=Yo=ti=ae(t)||0}if(Wo){if(Oo())return;Vo&&Eo(Vo,!0),Qo=[],vo(to),Io.ok=!0,Ti.show({index:tr,time:0}),Ti.resize()}else Ti.destroy()}function Oo(){return!Oo.f===hi?(Oo.f=hi,tr=Wo-1-tr,Ti.reverse(),!0):void 0}function Do(){Do.ok&&(Do.ok=!1,yo("ready"))}Nn=o("html"),$n=o("body");var Ro,Wo,Ho,Ko,Vo,Bo,Qo,Xo,Uo,Yo,Go,Jo,Zo,ti,ei,ni,oi,ii,ri,ai,si,ui,li,ci,di,fi,hi,mi,pi,vi,gi,wi,yi,bi,xi,_i,Ci,ki,Ti=this,Pi=o.now(),Si=le+Pi,Mi=n[0],Ei=1,Fi=n.data(),ji=o(""),zi=o(A(Ze)),Ni=n.find(I(de)),$i=Ni.find(I(Ce)),qi=($i[0],n.find(I(Pe))),Li=o(),Ai=n.find(I(je)),Ii=n.find(I(ze)),Oi=n.find(I(Ee)),Di=n.find(I($e)),Ri=Di.find(I(Ne)),Wi=Ri.find(I(qe)),Hi=o(),Ki=o(),Vi=(qi.data(),Wi.data(),n.find(I(mn))),Bi=n.find(I(fn)),Qi=n.find(I(hn)),Xi=n.find(I(en)),Ui=Xi[0],Yi=o(A(wn)),Gi=n.find(I(yn)),Ji=Gi[0],Zi=o(A(bn)),tr=!1,er={},nr={},or={},ir={},rr={},ar={},sr={},ur={},lr=0,cr=[];Ni[to]=o(Tn.touch?'':'
'),Ni[no]=o(o.Fotorama.jst.thumb()),Ni[eo]=o(o.Fotorama.jst.dots()),sr[to]=[],sr[no]=[],sr[eo]=[],ur[to]={},Ni.addClass(On?he:fe),Fi.fotorama=this,Ti.startAutoplay=function(t){return Ti.autoplay?this:(yi=bi=!1,k(t||r.autoplay),Co(),this)},Ti.stopAutoplay=function(){return Ti.autoplay&&(yi=bi=!0,Co()),this},Ti.showSlide=function(t){var e,n=l(Wi,r.navdir),o=550,i="horizontal"===r.navdir?r.thumbwidth:r.thumbheight,a=function(){io()};"next"===t&&(e=n-(i+r.margin)*ao),"prev"===t&&(e=n+(i+r.margin)*ao),e=B(e,rr),In(e,!0),te(Wi,{time:o,pos:e,direction:r.navdir,onEnd:a})},Ti.showWhileLongPress=function(t){if(!Ti.longPress.singlePressInProgress){var e=ko(t);To(e);var n=Po(t)/50,o=Bo;Ti.activeFrame=Bo=Ro[tr];var i=o===Bo&&!t.user;return Ti.showNav(i,t,n),this}},Ti.showEndLongPress=function(t){if(!Ti.longPress.singlePressInProgress){var e=ko(t);To(e);var n=Po(t)/50,o=Bo;Ti.activeFrame=Bo=Ro[tr];var i=o===Bo&&!t.user;return Ti.showStage(i,t,n),wi="undefined"!=typeof Yo&&Yo!==tr,Yo=tr,this}},Ti.showStage=function(t,e,n){Eo(Vo,Bo.i!==Ro[ne(Xo)].i),Mn(Qo,"stage"),An(Hn?[Uo]:[Uo,We(Uo),He(Uo)]),$o("go",!0),t||yo("show",{user:e.user,time:n}),yi=!0;var o=e.overPos,i=Ti.showStage.onEnd=function(n){if(!i.ok){if(i.ok=!0,n||go(!0),t||yo("showend",{user:e.user}),!n&&di&&di!==r.transition)return Ti.setOptions({transition:di}),void(di=!1);kn(),xn(Qo,"stage"),$o("go",!1),so(),jo(),_o(),Co()}};if(si){var a=Bo[to],s=Ro[Yo]&&tr!==Yo?Ro[Yo][to]:null;ee(a,s,Li,{time:n,method:r.transition,onEnd:i},cr)}else te(qi,{pos:-g(Uo,nr.w,r.margin,Xo),overPos:o,time:n,onEnd:i});Yn()},Ti.showNav=function(t,e,n){if(io(),ni){ho();var o=oe(tr+s(Uo-Yo,-1,1));fo({time:n,coo:o!==tr&&e.coo,guessIndex:"undefined"!=typeof e.coo?o:tr,keep:t}),oi&&co(n)}},Ti.show=function(t){Ti.longPress.singlePressInProgress=!0;var e=ko(t);To(e);var n=Po(t),o=Bo;Ti.activeFrame=Bo=Ro[tr];var i=o===Bo&&!t.user;return Ti.showStage(i,t,n),Ti.showNav(i,t,n),wi="undefined"!=typeof Yo&&Yo!==tr,Yo=tr,Ti.longPress.singlePressInProgress=!1,this},Ti.requestFullScreen=function(){return ri&&!Ti.fullScreen&&(vi=qn.scrollTop(),gi=qn.scrollLeft(),W(qn),$o("x",!0),xi=o.extend({},nr),n.addClass(tn).appendTo($n.addClass(ce)),Nn.addClass(ce),Eo(Vo,!0,!0),Ti.fullScreen=!0,ai&&Pn.request(Mi),Ti.resize(),xn(Qo,"stage"),kn(),yo("fullscreenenter")),this},Ti.cancelFullScreen=function(){return ai&&Pn.is()?Pn.cancel(e):So(),this},Ti.toggleFullScreen=function(){return Ti[(Ti.fullScreen?"cancel":"request")+"FullScreen"]()},V(e,Pn.event,function(){!Ro||Pn.is()||Vo||So()}),Ti.resize=function(e){if(!Ro)return this;var n=arguments[1]||0,i=arguments[2];ao=F(Ni,r),wo(Ti.fullScreen?{width:o(t).width(),maxwidth:null,minwidth:null,height:o(t).height(),maxheight:null,minheight:null}:H(e),[nr,i||Ti.fullScreen||r]);var a=nr.width,u=nr.height,l=nr.ratio,c=qn.height()-(ni?Ri.height():0);if(v(a)&&(Ni.css({width:""}),Ni.css({height:""}),$i.css({width:""}),$i.css({height:""}),$i.css({"line-height":""}),qi.css({width:""}),qi.css({height:""}),Ri.css({width:""}),Ri.css({height:""}),Ni.css({minWidth:nr.minwidth||0,maxWidth:nr.maxwidth||ro}),a=nr.W=nr.w=Ni.width(),nr.nw=ni&&p(r.navwidth,a)||a,qi.css({width:nr.w,marginLeft:(nr.W-nr.w)/2}),u=p(u,c),u=u||l&&a/l)){if(a=Math.round(a),u=nr.h=Math.round(s(u,p(nr.minheight,c),p(nr.maxheight,c))),$i.css({width:a,height:u,"line-height":u+"px"}),"vertical"!==r.navdir||Ti.fullscreen||Ri.width(r.thumbwidth+2*r.thumbmargin),"horizontal"!==r.navdir||Ti.fullscreen||Ri.height(r.thumbheight+2*r.thumbmargin),"vertical"===r.navdir&&Ti.fullScreen&&$i.css("height",o(t).height()),"horizontal"===r.navdir&&Ti.fullScreen&&$i.css("height",o(t).height()-(r.thumbheight+2*r.thumbmargin)),ni){switch(r.navdir){case"vertical":Di.removeClass(Ie),Di.removeClass(Ae),Di.addClass(Le),Ri.stop().animate({height:nr.h,width:r.thumbwidth},n);break;case"list":Di.removeClass(Le),Di.removeClass(Ie),Di.addClass(Ae);break;default:Di.removeClass(Le),Di.removeClass(Ae),Di.addClass(Ie),Ri.stop().animate({width:nr.nw},n)}go(),fo({guessIndex:tr,time:n,keep:!0}),oi&&Wn.nav&&co(n)}pi=i||!0,Do.ok=!0,Do()}return lr=$i.offset().left,f(),this},Ti.setOptions=function(t){return o.extend(r,t),Io(),this},Ti.shuffle=function(){return Ro&&D(Ro)&&Io(),this},Ti.longPress={threshold:1,count:0,thumbSlideTime:20,progress:function(){this.inProgress||(this.count++,this.inProgress=this.count>this.threshold)},end:function(){this.inProgress&&(this.isEnded=!0)},reset:function(){this.count=0,this.inProgress=!1,this.isEnded=!1}},Ti.destroy=function(){return Ti.cancelFullScreen(),Ti.stopAutoplay(),Ro=Ti.data=null,y(),Qo=[],vo(to),Io.ok=!1,this},Ti.playVideo=function(){var t=Bo,e=t.video,n=tr;return"object"==typeof e&&t.videoReady&&(ai&&Ti.fullScreen&&Ti.cancelFullScreen(),z(function(){return!Pn.is()||n!==tr},function(){n===tr&&(t.$video=t.$video||o(A(gn)).append(O(e)),t.$video.appendTo(t[to]),Ni.addClass(me),Vo=t.$video,C(),Oi.blur(),Xi.blur(),yo("loadvideo"))})),this},Ti.stopVideo=function(){return Eo(Vo,!0,!0),this},$i.on("mousemove",jo),or=ie(qi,{onStart:bo,onMove:function(t,e){Mo($i,e.edge)},onTouchEnd:xo,onEnd:function(t){Mo($i);var e=(Kn&&!Ci||t.touch)&&r.arrows&&"always"!==r.arrows;if(t.moved||e&&t.pos!==t.newPos&&!t.control){var n=w(t.newPos,nr.w,r.margin,Xo);Ti.show({index:n,time:si?ci:t.time,overPos:t.overPos,user:!0})}else t.aborted||t.control||No(t.startEvent,e)},timeLow:1,timeHigh:1,friction:2,select:"."+Je+", ."+Je+" *",$wrap:$i,direction:"horizontal"}),rr=ie(Wi,{onStart:bo,onMove:function(t,e){Mo(Ri,e.edge)},onTouchEnd:xo,onEnd:function(t){function e(){fo.l=t.newPos,_o(),Co(),In(t.newPos,!0),io()}if(t.moved)t.pos!==t.newPos?(yi=!0,te(Wi,{time:t.time,pos:t.newPos,overPos:t.overPos,direction:r.navdir,onEnd:e}),In(t.newPos),fi&&Mo(Ri,q(t.newPos,rr.min,rr.max,t.dir))):e();else{var n=t.$target.closest("."+Re,Wi)[0];n&&qo.call(n,t.startEvent)}},timeLow:.5,timeHigh:2,friction:5,$wrap:Ri,direction:r.navdir}),ir=re($i,{shift:!0,onEnd:function(t,e){bo(),xo(),Ti.show({index:e,slow:t.altKey})}}),ar=re(Ri,{onEnd:function(t,e){bo(),xo();var n=x(Wi)+.25*e;Wi.css(c(s(n,rr.min,rr.max),r.navdir)),fi&&Mo(Ri,q(n,rr.min,rr.max,r.navdir)),ar.prevent={"<":n>=rr.max,">":n<=rr.min},clearTimeout(ar.t),ar.t=setTimeout(function(){fo.l=n,In(n,!0)},Bn),In(n)}}),Ni.hover(function(){setTimeout(function(){_i||Fo(!(Ci=!0))},0)},function(){Ci&&Fo(!(Ci=!1))}),L(Oi,function(t){J(t),Lo.call(this,t)},{onStart:function(){bo(),or.control=!0},onTouchEnd:xo}),L(Bi,function(t){J(t),"thumbs"===r.navtype?Ti.show("<"):Ti.showSlide("prev")}),L(Qi,function(t){J(t),"thumbs"===r.navtype?Ti.show(">"):Ti.showSlide("next")}),Oi.each(function(){Y(this,function(t){Lo.call(this,t)}),Ao(this)}),Y(Ui,function(){Ti.toggleFullScreen(),o(Ui).trigger("focus")}),Ao(Ui),o.each("load push pop shift unshift reverse sort splice".split(" "),function(t,e){Ti[e]=function(){return Ro=Ro||[],"load"!==e?Array.prototype[e].apply(Ro,arguments):arguments[0]&&"object"==typeof arguments[0]&&arguments[0].length&&(Ro=R(arguments[0])),Io(),Ti}}),Io()},o.fn.fotorama=function(e){return this.each(function(){var n=this,i=o(this),r=i.data(),a=r.fotorama;a?a.setOptions(e,!0):z(function(){return!F(n)},function(){r.urtext=i.html(),new o.Fotorama(i,o.extend({},so,t.fotoramaDefaults,e,r))})})},o.Fotorama.instances=[],o.Fotorama.cache={},o.Fotorama.measures={},o=o||{},o.Fotorama=o.Fotorama||{},o.Fotorama.jst=o.Fotorama.jst||{},o.Fotorama.jst.dots=function(){{var t="";kn.escape}return t+='
\r\n
\r\n
'},o.Fotorama.jst.frameCaption=function(t){{var e,n="";kn.escape}return n+='\r\n"},o.Fotorama.jst.style=function(t){{var e,n="";kn.escape}return n+=".fotorama"+(null==(e=t.s)?"":e)+" .fotorama__nav--thumbs .fotorama__nav__frame{\r\npadding:"+(null==(e=t.m)?"":e)+"px;\r\nheight:"+(null==(e=t.h)?"":e)+"px}\r\n.fotorama"+(null==(e=t.s)?"":e)+" .fotorama__thumb-border{\r\nheight:"+(null==(e=t.h)?"":e)+"px;\r\nborder-width:"+(null==(e=t.b)?"":e)+"px;\r\nmargin-top:"+(null==(e=t.m)?"":e)+"px}"},o.Fotorama.jst.thumb=function(){{var t="";kn.escape}return t+='
\r\n
\r\n
\r\n
'}}(window,document,location,"undefined"!=typeof jQuery&&jQuery); \ No newline at end of file diff --git a/lib/web/knockoutjs/knockout-es5.js b/lib/web/knockoutjs/knockout-es5.js new file mode 100644 index 0000000000000..899edd79aa3e3 --- /dev/null +++ b/lib/web/knockoutjs/knockout-es5.js @@ -0,0 +1,468 @@ +/*! + * Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5 + * Copyright (c) Steve Sanderson + * MIT license + */ + +(function(global, undefined) { + 'use strict'; + + var ko; + + // Model tracking + // -------------- + // + // This is the central feature of Knockout-ES5. We augment model objects by converting properties + // into ES5 getter/setter pairs that read/write an underlying Knockout observable. This means you can + // use plain JavaScript syntax to read/write the property while still getting the full benefits of + // Knockout's automatic dependency detection and notification triggering. + // + // For comparison, here's Knockout ES3-compatible syntax: + // + // var firstNameLength = myModel.user().firstName().length; // Read + // myModel.user().firstName('Bert'); // Write + // + // ... versus Knockout-ES5 syntax: + // + // var firstNameLength = myModel.user.firstName.length; // Read + // myModel.user.firstName = 'Bert'; // Write + + // `ko.track(model)` converts each property on the given model object into a getter/setter pair that + // wraps a Knockout observable. Optionally specify an array of property names to wrap; otherwise we + // wrap all properties. If any of the properties are already observables, we replace them with + // ES5 getter/setter pairs that wrap your original observable instances. In the case of readonly + // ko.computed properties, we simply do not define a setter (so attempted writes will be ignored, + // which is how ES5 readonly properties normally behave). + // + // By design, this does *not* recursively walk child object properties, because making literally + // everything everywhere independently observable is usually unhelpful. When you do want to track + // child object properties independently, define your own class for those child objects and put + // a separate ko.track call into its constructor --- this gives you far more control. + /** + * @param {object} obj + * @param {object|array.} propertyNamesOrSettings + * @param {boolean} propertyNamesOrSettings.deep Use deep track. + * @param {array.} propertyNamesOrSettings.fields Array of property names to wrap. + * todo: @param {array.} propertyNamesOrSettings.exclude Array of exclude property names to wrap. + * todo: @param {function(string, *):boolean} propertyNamesOrSettings.filter Function to filter property + * names to wrap. A function that takes ... params + * @return {object} + */ + function track(obj, propertyNamesOrSettings) { + if (!obj || typeof obj !== 'object') { + throw new Error('When calling ko.track, you must pass an object as the first parameter.'); + } + + var propertyNames; + + if ( isPlainObject(propertyNamesOrSettings) ) { + // defaults + propertyNamesOrSettings.deep = propertyNamesOrSettings.deep || false; + propertyNamesOrSettings.fields = propertyNamesOrSettings.fields || Object.getOwnPropertyNames(obj); + propertyNamesOrSettings.lazy = propertyNamesOrSettings.lazy || false; + + wrap(obj, propertyNamesOrSettings.fields, propertyNamesOrSettings); + } else { + propertyNames = propertyNamesOrSettings || Object.getOwnPropertyNames(obj); + wrap(obj, propertyNames, {}); + } + + return obj; + } + + // fix for ie + var rFunctionName = /^function\s*([^\s(]+)/; + function getFunctionName( ctor ){ + if (ctor.name) { + return ctor.name; + } + return (ctor.toString().trim().match( rFunctionName ) || [])[1]; + } + + function canTrack(obj) { + return obj && typeof obj === 'object' && getFunctionName(obj.constructor) === 'Object'; + } + + function createPropertyDescriptor(originalValue, prop, map) { + var isObservable = ko.isObservable(originalValue); + var isArray = !isObservable && Array.isArray(originalValue); + var observable = isObservable ? originalValue + : isArray ? ko.observableArray(originalValue) + : ko.observable(originalValue); + + map[prop] = function () { return observable; }; + + // add check in case the object is already an observable array + if (isArray || (isObservable && 'push' in observable)) { + notifyWhenPresentOrFutureArrayValuesMutate(ko, observable); + } + + return { + configurable: true, + enumerable: true, + get: observable, + set: ko.isWriteableObservable(observable) ? observable : undefined + }; + } + + function createLazyPropertyDescriptor(originalValue, prop, map) { + if (ko.isObservable(originalValue)) { + // no need to be lazy if we already have an observable + return createPropertyDescriptor(originalValue, prop, map); + } + + var observable; + + function getOrCreateObservable(value, writing) { + if (observable) { + return writing ? observable(value) : observable; + } + + if (Array.isArray(value)) { + observable = ko.observableArray(value); + notifyWhenPresentOrFutureArrayValuesMutate(ko, observable); + return observable; + } + + return (observable = ko.observable(value)); + } + + map[prop] = function () { return getOrCreateObservable(originalValue); }; + return { + configurable: true, + enumerable: true, + get: function () { return getOrCreateObservable(originalValue)(); }, + set: function (value) { getOrCreateObservable(value, true); } + }; + } + + function wrap(obj, props, options) { + if (!props.length) { + return; + } + + var allObservablesForObject = getAllObservablesForObject(obj, true); + var descriptors = {}; + + props.forEach(function (prop) { + // Skip properties that are already tracked + if (prop in allObservablesForObject) { + return; + } + + // Skip properties where descriptor can't be redefined + if (Object.getOwnPropertyDescriptor(obj, prop).configurable === false){ + return; + } + + var originalValue = obj[prop]; + descriptors[prop] = (options.lazy ? createLazyPropertyDescriptor : createPropertyDescriptor) + (originalValue, prop, allObservablesForObject); + + if (options.deep && canTrack(originalValue)) { + wrap(originalValue, Object.keys(originalValue), options); + } + }); + + Object.defineProperties(obj, descriptors); + } + + function isPlainObject( obj ){ + return !!obj && typeof obj === 'object' && obj.constructor === Object; + } + + // Lazily created by `getAllObservablesForObject` below. Has to be created lazily because the + // WeakMap factory isn't available until the module has finished loading (may be async). + var objectToObservableMap; + + // Gets or creates the hidden internal key-value collection of observables corresponding to + // properties on the model object. + function getAllObservablesForObject(obj, createIfNotDefined) { + if (!objectToObservableMap) { + objectToObservableMap = weakMapFactory(); + } + + var result = objectToObservableMap.get(obj); + if (!result && createIfNotDefined) { + result = {}; + objectToObservableMap.set(obj, result); + } + return result; + } + + // Removes the internal references to observables mapped to the specified properties + // or the entire object reference if no properties are passed in. This allows the + // observables to be replaced and tracked again. + function untrack(obj, propertyNames) { + if (!objectToObservableMap) { + return; + } + + if (arguments.length === 1) { + objectToObservableMap['delete'](obj); + } else { + var allObservablesForObject = getAllObservablesForObject(obj, false); + if (allObservablesForObject) { + propertyNames.forEach(function(propertyName) { + delete allObservablesForObject[propertyName]; + }); + } + } + } + + // Computed properties + // ------------------- + // + // The preceding code is already sufficient to upgrade ko.computed model properties to ES5 + // getter/setter pairs (or in the case of readonly ko.computed properties, just a getter). + // These then behave like a regular property with a getter function, except they are smarter: + // your evaluator is only invoked when one of its dependencies changes. The result is cached + // and used for all evaluations until the next time a dependency changes). + // + // However, instead of forcing developers to declare a ko.computed property explicitly, it's + // nice to offer a utility function that declares a computed getter directly. + + // Implements `ko.defineProperty` + function defineComputedProperty(obj, propertyName, evaluatorOrOptions) { + var ko = this, + computedOptions = { owner: obj, deferEvaluation: true }; + + if (typeof evaluatorOrOptions === 'function') { + computedOptions.read = evaluatorOrOptions; + } else { + if ('value' in evaluatorOrOptions) { + throw new Error('For ko.defineProperty, you must not specify a "value" for the property. ' + + 'You must provide a "get" function.'); + } + + if (typeof evaluatorOrOptions.get !== 'function') { + throw new Error('For ko.defineProperty, the third parameter must be either an evaluator function, ' + + 'or an options object containing a function called "get".'); + } + + computedOptions.read = evaluatorOrOptions.get; + computedOptions.write = evaluatorOrOptions.set; + } + + obj[propertyName] = ko.computed(computedOptions); + track.call(ko, obj, [propertyName]); + return obj; + } + + // Array handling + // -------------- + // + // Arrays are special, because unlike other property types, they have standard mutator functions + // (`push`/`pop`/`splice`/etc.) and it's desirable to trigger a change notification whenever one of + // those mutator functions is invoked. + // + // Traditionally, Knockout handles this by putting special versions of `push`/`pop`/etc. on observable + // arrays that mutate the underlying array and then trigger a notification. That approach doesn't + // work for Knockout-ES5 because properties now return the underlying arrays, so the mutator runs + // in the context of the underlying array, not any particular observable: + // + // // Operates on the underlying array value + // myModel.someCollection.push('New value'); + // + // To solve this, Knockout-ES5 detects array values, and modifies them as follows: + // 1. Associates a hidden subscribable with each array instance that it encounters + // 2. Intercepts standard mutators (`push`/`pop`/etc.) and makes them trigger the subscribable + // Then, for model properties whose values are arrays, the property's underlying observable + // subscribes to the array subscribable, so it can trigger a change notification after mutation. + + // Given an observable that underlies a model property, watch for any array value that might + // be assigned as the property value, and hook into its change events + function notifyWhenPresentOrFutureArrayValuesMutate(ko, observable) { + var watchingArraySubscription = null; + ko.computed(function () { + // Unsubscribe to any earlier array instance + if (watchingArraySubscription) { + watchingArraySubscription.dispose(); + watchingArraySubscription = null; + } + + // Subscribe to the new array instance + var newArrayInstance = observable(); + if (newArrayInstance instanceof Array) { + watchingArraySubscription = startWatchingArrayInstance(ko, observable, newArrayInstance); + } + }); + } + + // Listens for array mutations, and when they happen, cause the observable to fire notifications. + // This is used to make model properties of type array fire notifications when the array changes. + // Returns a subscribable that can later be disposed. + function startWatchingArrayInstance(ko, observable, arrayInstance) { + var subscribable = getSubscribableForArray(ko, arrayInstance); + return subscribable.subscribe(observable); + } + + // Lazily created by `getSubscribableForArray` below. Has to be created lazily because the + // WeakMap factory isn't available until the module has finished loading (may be async). + var arraySubscribablesMap; + + // Gets or creates a subscribable that fires after each array mutation + function getSubscribableForArray(ko, arrayInstance) { + if (!arraySubscribablesMap) { + arraySubscribablesMap = weakMapFactory(); + } + + var subscribable = arraySubscribablesMap.get(arrayInstance); + if (!subscribable) { + subscribable = new ko.subscribable(); + arraySubscribablesMap.set(arrayInstance, subscribable); + + var notificationPauseSignal = {}; + wrapStandardArrayMutators(arrayInstance, subscribable, notificationPauseSignal); + addKnockoutArrayMutators(ko, arrayInstance, subscribable, notificationPauseSignal); + } + + return subscribable; + } + + // After each array mutation, fires a notification on the given subscribable + function wrapStandardArrayMutators(arrayInstance, subscribable, notificationPauseSignal) { + ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'].forEach(function(fnName) { + var origMutator = arrayInstance[fnName]; + arrayInstance[fnName] = function() { + var result = origMutator.apply(this, arguments); + if (notificationPauseSignal.pause !== true) { + subscribable.notifySubscribers(this); + } + return result; + }; + }); + } + + // Adds Knockout's additional array mutation functions to the array + function addKnockoutArrayMutators(ko, arrayInstance, subscribable, notificationPauseSignal) { + ['remove', 'removeAll', 'destroy', 'destroyAll', 'replace'].forEach(function(fnName) { + // Make it a non-enumerable property for consistency with standard Array functions + Object.defineProperty(arrayInstance, fnName, { + enumerable: false, + value: function() { + var result; + + // These additional array mutators are built using the underlying push/pop/etc. + // mutators, which are wrapped to trigger notifications. But we don't want to + // trigger multiple notifications, so pause the push/pop/etc. wrappers and + // delivery only one notification at the end of the process. + notificationPauseSignal.pause = true; + try { + // Creates a temporary observableArray that can perform the operation. + result = ko.observableArray.fn[fnName].apply(ko.observableArray(arrayInstance), arguments); + } + finally { + notificationPauseSignal.pause = false; + } + subscribable.notifySubscribers(arrayInstance); + return result; + } + }); + }); + } + + // Static utility functions + // ------------------------ + // + // Since Knockout-ES5 sets up properties that return values, not observables, you can't + // trivially subscribe to the underlying observables (e.g., `someProperty.subscribe(...)`), + // or tell them that object values have mutated, etc. To handle this, we set up some + // extra utility functions that can return or work with the underlying observables. + + // Returns the underlying observable associated with a model property (or `null` if the + // model or property doesn't exist, or isn't associated with an observable). This means + // you can subscribe to the property, e.g.: + // + // ko.getObservable(model, 'propertyName') + // .subscribe(function(newValue) { ... }); + function getObservable(obj, propertyName) { + if (!obj || typeof obj !== 'object') { + return null; + } + + var allObservablesForObject = getAllObservablesForObject(obj, false); + if (allObservablesForObject && propertyName in allObservablesForObject) { + return allObservablesForObject[propertyName](); + } + + return null; + } + + // Returns a boolean indicating whether the property on the object has an underlying + // observables. This does the check in a way not to create an observable if the + // object was created with lazily created observables + function isTracked(obj, propertyName) { + if (!obj || typeof obj !== 'object') { + return false; + } + + var allObservablesForObject = getAllObservablesForObject(obj, false); + return !!allObservablesForObject && propertyName in allObservablesForObject; + } + + // Causes a property's associated observable to fire a change notification. Useful when + // the property value is a complex object and you've modified a child property. + function valueHasMutated(obj, propertyName) { + var observable = getObservable(obj, propertyName); + + if (observable) { + observable.valueHasMutated(); + } + } + + // Module initialisation + // --------------------- + // + // When this script is first evaluated, it works out what kind of module loading scenario + // it is in (Node.js or a browser `