diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 33a6ef02ace1..54479c5d99c3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,7 +11,7 @@ Fields marked with (*) are required. Please don't remove the template. ### Preconditions (*) 1. 2. diff --git a/CHANGELOG.md b/CHANGELOG.md index d357d3a67d1c..4661c4875737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,415 @@ +2.3.3 +============= +* GitHub issues: + * [#533](https://github.com/magento/magento2/issues/533) -- By default Allow all access in .htaccess (fixed in [magento/graphql-ce#578](https://github.com/magento/graphql-ce/pull/578)) + * [#601](https://github.com/magento/magento2/issues/601) -- Admin tabs js error. (fixed in [magento/graphql-ce#632](https://github.com/magento/graphql-ce/pull/632)) + * [#631](https://github.com/magento/magento2/issues/631) -- Image Management / Editing (fixed in [magento/graphql-ce#634](https://github.com/magento/graphql-ce/pull/634)) + * [#20124](https://github.com/magento/magento2/issues/20124) -- Sort By label is hidden by Shop By Menu on listing page in iphone5 device (fixed in [magento/magento2#20135](https://github.com/magento/magento2/pull/20135)) + * [#21978](https://github.com/magento/magento2/issues/21978) -- Adding product image: File doesn't exist (fixed in [magento/magento2#22020](https://github.com/magento/magento2/pull/22020)) + * [#22045](https://github.com/magento/magento2/issues/22045) -- Instant Purchase on product page not working properly. (fixed in [magento/magento2#22260](https://github.com/magento/magento2/pull/22260)) + * [#22134](https://github.com/magento/magento2/issues/22134) -- Paypal buttons disable issue - Magento 2.3.1 (fixed in [magento/magento2#22260](https://github.com/magento/magento2/pull/22260)) + * [#22249](https://github.com/magento/magento2/issues/22249) -- Configurable Product Gallery Images Out of Order when More than 10 images (fixed in [magento/magento2#22287](https://github.com/magento/magento2/pull/22287)) + * [#22527](https://github.com/magento/magento2/issues/22527) -- Wishlist and compare icon align issue in product listing page (fixed in [magento/magento2#22532](https://github.com/magento/magento2/pull/22532)) + * [#628](https://github.com/magento/magento2/issues/628) -- Feature Request: Parent entities links in child entities grid. (fixed in [magento/graphql-ce#636](https://github.com/magento/graphql-ce/pull/636)) + * [#640](https://github.com/magento/magento2/issues/640) -- [Insight] Files should not be executable (fixed in [magento/graphql-ce#648](https://github.com/magento/graphql-ce/pull/648)) + * [#603](https://github.com/magento/magento2/issues/603) -- 'Continue' button is disabled even though "I've read OSL licence" is checked (fixed in [magento/graphql-ce#653](https://github.com/magento/graphql-ce/pull/653)) + * [#22406](https://github.com/magento/magento2/issues/22406) -- Store view specific labels cut in left navigation menu (fixed in [magento/magento2#22423](https://github.com/magento/magento2/pull/22423)) + * [#19515](https://github.com/magento/magento2/issues/19515) -- Create new order from backend saves the credit card when it is told not to (fixed in [magento/magento2#19767](https://github.com/magento/magento2/pull/19767)) + * [#21473](https://github.com/magento/magento2/issues/21473) -- Form element validation is not triggered when validation rules change (fixed in [magento/magento2#21992](https://github.com/magento/magento2/pull/21992)) + * [#22641](https://github.com/magento/magento2/issues/22641) -- Typo Issue and Missing header title at Customer Sales order grid (fixed in [magento/magento2#22643](https://github.com/magento/magento2/pull/22643)) + * [#22647](https://github.com/magento/magento2/issues/22647) -- In customer account create page word not readable, should use '-' after break to new line In mobile view (fixed in [magento/magento2#22656](https://github.com/magento/magento2/pull/22656)) + * [#22395](https://github.com/magento/magento2/issues/22395) -- config:set -le and -lc short form options don't work (fixed in [magento/magento2#22720](https://github.com/magento/magento2/pull/22720)) + * [#198](https://github.com/magento/magento2/issues/198) -- Better Search Please!! NOW (fixed in [magento/graphql-ce#371](https://github.com/magento/graphql-ce/pull/371)) + * [#436](https://github.com/magento/magento2/issues/436) -- [Feature request]custom option attach an image (fixed in [magento/graphql-ce#445](https://github.com/magento/graphql-ce/pull/445)) + * [#309](https://github.com/magento/magento2/issues/309) -- Terrible UI in Backend (fixed in [magento/graphql-ce#504](https://github.com/magento/graphql-ce/pull/504)) + * [#535](https://github.com/magento/magento2/issues/535) -- A few bugs (fixed in [magento/graphql-ce#650](https://github.com/magento/graphql-ce/pull/650)) + * [#658](https://github.com/magento/magento2/issues/658) -- Inline translate malfunctioning (fixed in [magento/graphql-ce#665](https://github.com/magento/graphql-ce/pull/665) and [magento/graphql-ce#744](https://github.com/magento/graphql-ce/pull/744)) + * [#657](https://github.com/magento/magento2/issues/657) -- Feature Request: Grid paging options at the top and the bottom of the grid. (fixed in [magento/graphql-ce#666](https://github.com/magento/graphql-ce/pull/666)) + * [#12612](https://github.com/magento/magento2/issues/12612) -- Array to String conversion error on checkout page when changin country - how to debug (fixed in [magento/magento2#22558](https://github.com/magento/magento2/pull/22558)) + * [#22556](https://github.com/magento/magento2/issues/22556) -- VatValidator::validate returns error if region in quoteAddress is not set (fixed in [magento/magento2#22558](https://github.com/magento/magento2/pull/22558)) + * [#20843](https://github.com/magento/magento2/issues/20843) -- Uncaught TypeError: panel.addClass is not a function when Swatches are disabled (fixed in [magento/magento2#22560](https://github.com/magento/magento2/pull/22560)) + * [#22636](https://github.com/magento/magento2/issues/22636) -- arrow toggle not changing only showing to down It should be toggle as every where is working (fixed in [magento/magento2#22644](https://github.com/magento/magento2/pull/22644)) + * [#22640](https://github.com/magento/magento2/issues/22640) -- Add tax rule form checkbox design is not as per the magento admin panel checkbox design, It is showing default design (fixed in [magento/magento2#22655](https://github.com/magento/magento2/pull/22655)) + * [#20906](https://github.com/magento/magento2/issues/20906) -- Magento backend catalog "Cost" without currency symbol (fixed in [magento/magento2#22739](https://github.com/magento/magento2/pull/22739)) + * [#22771](https://github.com/magento/magento2/issues/22771) -- Magento 2.3.0 can't change text area field height admin form using Ui component (fixed in [magento/magento2#22779](https://github.com/magento/magento2/pull/22779)) + * [#22788](https://github.com/magento/magento2/issues/22788) -- New Shipment emails do not generate (fixed in [magento/magento2#22791](https://github.com/magento/magento2/pull/22791)) + * [#18651](https://github.com/magento/magento2/issues/18651) -- Tierprice can't save float percentage value (fixed in [magento/magento2#19584](https://github.com/magento/magento2/pull/19584)) + * [#21672](https://github.com/magento/magento2/issues/21672) -- Database Media Storage - Design Config fails to save transactional email logo correctly (fixed in [magento/magento2#21675](https://github.com/magento/magento2/pull/21675) and [magento/magento2#21674](https://github.com/magento/magento2/pull/21674)) + * [#22028](https://github.com/magento/magento2/issues/22028) -- Unable to update products via csv file, when products ids from file are from wide id range (fixed in [magento/magento2#22575](https://github.com/magento/magento2/pull/22575)) + * [#21558](https://github.com/magento/magento2/issues/21558) -- Navigation issue of review from product listing when click on review count (fixed in [magento/magento2#22794](https://github.com/magento/magento2/pull/22794)) + * [#22127](https://github.com/magento/magento2/issues/22127) -- Magento 2.3.0: getSize call on configurable collection leads to exception, if no product filters are applied (fixed in [magento/magento2#22186](https://github.com/magento/magento2/pull/22186)) + * [#22639](https://github.com/magento/magento2/issues/22639) -- Without select attribute click on add attribute it display all selected when add attribute again. (fixed in [magento/magento2#22724](https://github.com/magento/magento2/pull/22724)) + * [#22676](https://github.com/magento/magento2/issues/22676) -- Compare Products counter, and My Wish List counter vertical not aligned (fixed in [magento/magento2#22742](https://github.com/magento/magento2/pull/22742)) + * [#6659](https://github.com/magento/magento2/issues/6659) -- Disabled payment methods show in Customer Dashboard (fixed in [magento/magento2#22850](https://github.com/magento/magento2/pull/22850)) + * [#4628](https://github.com/magento/magento2/issues/4628) -- .lib-font-face mixin - Fixed font formats (fixed in [magento/magento2#22854](https://github.com/magento/magento2/pull/22854)) + * [#3795](https://github.com/magento/magento2/issues/3795) -- Validation messages missing from datepicker form elements (fixed in [magento/magento2#21397](https://github.com/magento/magento2/pull/21397)) + * [#22786](https://github.com/magento/magento2/issues/22786) -- The validation for UPS configurations triggers even if UPS is disabled for checkout (fixed in [magento/magento2#22787](https://github.com/magento/magento2/pull/22787)) + * [#22822](https://github.com/magento/magento2/issues/22822) -- [Shipping] The contact us link isn't showing on order tracking page (fixed in [magento/magento2#22823](https://github.com/magento/magento2/pull/22823)) + * [#21852](https://github.com/magento/magento2/issues/21852) -- Random Error while waiting for package deployed (fixed in [magento/magento2#22607](https://github.com/magento/magento2/pull/22607)) + * [#22563](https://github.com/magento/magento2/issues/22563) -- Parallelised execution of static content deploy is broken on 2.3-develop (fixed in [magento/magento2#22607](https://github.com/magento/magento2/pull/22607)) + * [#22736](https://github.com/magento/magento2/issues/22736) -- Cursor position not in right side of search keyword in search box when click on search again (Mobile issue) (fixed in [magento/magento2#22795](https://github.com/magento/magento2/pull/22795)) + * [#22875](https://github.com/magento/magento2/issues/22875) -- Billing Agreements page title need to be improved (fixed in [magento/magento2#22876](https://github.com/magento/magento2/pull/22876)) + * [#21214](https://github.com/magento/magento2/issues/21214) -- Luma theme Apply Discount Code section design improvement (fixed in [magento/magento2#21215](https://github.com/magento/magento2/pull/21215)) + * [#22143](https://github.com/magento/magento2/issues/22143) -- Varnish health check failing due to presence of id_prefix in env.php (fixed in [magento/magento2#22307](https://github.com/magento/magento2/pull/22307)) + * [#22317](https://github.com/magento/magento2/issues/22317) -- CodeSniffer should not mark correctly aligned DocBlock elements as code style violation. (fixed in [magento/magento2#22444](https://github.com/magento/magento2/pull/22444)) + * [#22396](https://github.com/magento/magento2/issues/22396) -- config:set fails with JSON values (fixed in [magento/magento2#22513](https://github.com/magento/magento2/pull/22513)) + * [#22506](https://github.com/magento/magento2/issues/22506) -- Search suggestion panel overlapping on advance reporting button (fixed in [magento/magento2#22520](https://github.com/magento/magento2/pull/22520)) + * [#22869](https://github.com/magento/magento2/issues/22869) -- REST: Updating a customer without store_id sets the store_id to default (fixed in [magento/magento2#22893](https://github.com/magento/magento2/pull/22893)) + * [#22924](https://github.com/magento/magento2/issues/22924) -- Store view label not in the middle of panel (fixed in [magento/magento2#22926](https://github.com/magento/magento2/pull/22926)) + * [#20186](https://github.com/magento/magento2/issues/20186) -- phpcs error on rule classes - must be of the type integer (fixed in [magento/magento2#22947](https://github.com/magento/magento2/pull/22947)) + * [#574](https://github.com/magento/magento2/issues/574) -- Maximum function nesting level of '100' reached (fixed in [magento/graphql-ce#694](https://github.com/magento/graphql-ce/pull/694)) + * [#686](https://github.com/magento/magento2/issues/686) -- Product save validation errors in the admin don't hide the overlay (fixed in [magento/graphql-ce#695](https://github.com/magento/graphql-ce/pull/695)) + * [#22380](https://github.com/magento/magento2/issues/22380) -- Checkout totals order in specific store (fixed in [magento/magento2#22387](https://github.com/magento/magento2/pull/22387)) + * [#18183](https://github.com/magento/magento2/issues/18183) -- Magento 2.2.6 coupon codes don't work anymore (fixed in [magento/magento2#22718](https://github.com/magento/magento2/pull/22718)) + * [#22899](https://github.com/magento/magento2/issues/22899) -- Incorrect return type at getListByCustomerId in PaymentTokenManagementInterface (fixed in [magento/magento2#22914](https://github.com/magento/magento2/pull/22914)) + * [#22686](https://github.com/magento/magento2/issues/22686) -- Shipment Create via API salesShipmentRepositoryV1 throw Fatal error in Admin Order -> Shipment -> View (fixed in [magento/magento2#22687](https://github.com/magento/magento2/pull/22687)) + * [#22767](https://github.com/magento/magento2/issues/22767) -- Not clear logic for loading CMS Pages with setStoreId function (fixed in [magento/magento2#22772](https://github.com/magento/magento2/pull/22772)) + * [#20788](https://github.com/magento/magento2/issues/20788) -- Listing page no equal spacing in product in list view (fixed in [magento/magento2#22931](https://github.com/magento/magento2/pull/22931)) + * [#23030](https://github.com/magento/magento2/issues/23030) -- Magento2 Swatch change Image does not slide to first Image (fixed in [magento/magento2#23033](https://github.com/magento/magento2/pull/23033)) + * [#23034](https://github.com/magento/magento2/issues/23034) -- Wrong behaviour of validation scroll (fixed in [magento/magento2#23035](https://github.com/magento/magento2/pull/23035)) + * [#12696](https://github.com/magento/magento2/issues/12696) -- Integration tests create stub modules in app/code (fixed in [magento/magento2#18459](https://github.com/magento/magento2/pull/18459)) + * [#13266](https://github.com/magento/magento2/issues/13266) -- Topmenu 'last' class not being set if the a parent is inactive (fixed in [magento/magento2#22071](https://github.com/magento/magento2/pull/22071)) + * [#22882](https://github.com/magento/magento2/issues/22882) -- Static content deploy - Don't shows error message, just stack trace (fixed in [magento/magento2#22884](https://github.com/magento/magento2/pull/22884)) + * [#23045](https://github.com/magento/magento2/issues/23045) -- Exceptions from data patches do not show root cause (fixed in [magento/magento2#23046](https://github.com/magento/magento2/pull/23046)) + * [#16446](https://github.com/magento/magento2/issues/16446) -- magento 2.2.2 text swatch switches product image even if attribute feature is disabled (fixed in [magento/magento2#19184](https://github.com/magento/magento2/pull/19184)) + * [#14492](https://github.com/magento/magento2/issues/14492) -- Creating Customer without password is directly confirmed (fixed in [magento/magento2#21394](https://github.com/magento/magento2/pull/21394)) + * [#21671](https://github.com/magento/magento2/issues/21671) -- Database Media Storage - Transaction emails logo not used when pub/media cleared (fixed in [magento/magento2#21674](https://github.com/magento/magento2/pull/21674)) + * [#22425](https://github.com/magento/magento2/issues/22425) -- wrong url redirect when edit product review from Customer view page (fixed in [magento/magento2#22426](https://github.com/magento/magento2/pull/22426)) + * [#22511](https://github.com/magento/magento2/issues/22511) -- Special From Date set to today's date when Use Default Date checked in Store scope (fixed in [magento/magento2#22521](https://github.com/magento/magento2/pull/22521)) + * [#23080](https://github.com/magento/magento2/issues/23080) -- Missing whitespace in mobile navigation for non-English websites (fixed in [magento/magento2#23081](https://github.com/magento/magento2/pull/23081)) + * [#19872](https://github.com/magento/magento2/issues/19872) -- Magento 2.3 category edit page "Select from gallery" button not working. (fixed in [magento/magento2#21131](https://github.com/magento/magento2/pull/21131)) + * [#22092](https://github.com/magento/magento2/issues/22092) -- Assigning Catalog Image from Gallery, then Saving Twice, Clears Image (fixed in [magento/magento2#21131](https://github.com/magento/magento2/pull/21131)) + * [#22087](https://github.com/magento/magento2/issues/22087) -- Products Ordered Report - Not grouped by product (fixed in [magento/magento2#22646](https://github.com/magento/magento2/pull/22646)) + * [#21546](https://github.com/magento/magento2/issues/21546) -- [2.3] Database Media Storage - New Product Images fail to be processed correctly (fixed in [magento/magento2#21605](https://github.com/magento/magento2/pull/21605)) + * [#21604](https://github.com/magento/magento2/issues/21604) -- Database Media Storage - Admin Product Edit page does not handle product images correctly in database storage mode (fixed in [magento/magento2#21605](https://github.com/magento/magento2/pull/21605)) + * [#4247](https://github.com/magento/magento2/issues/4247) -- getProductUrl does not allow to override the scope in backend context (fixed in [magento/magento2#21876](https://github.com/magento/magento2/pull/21876)) + * [#22940](https://github.com/magento/magento2/issues/22940) -- Reset feature does not clear the date (fixed in [magento/magento2#23007](https://github.com/magento/magento2/pull/23007)) + * [#23053](https://github.com/magento/magento2/issues/23053) -- Sendfriend works for products with visibility not visible individually (fixed in [magento/magento2#23118](https://github.com/magento/magento2/pull/23118)) + * [#675](https://github.com/magento/magento2/issues/675) -- Textarea element cols and rows (fixed in [magento/graphql-ce#677](https://github.com/magento/graphql-ce/pull/677)) + * [#682](https://github.com/magento/magento2/issues/682) -- \Magento\Framework\Pricing\PriceCurrencyInterface depends on Magento application code (fixed in [magento/graphql-ce#700](https://github.com/magento/graphql-ce/pull/700)) + * [#681](https://github.com/magento/magento2/issues/681) -- Magento\Framework\Xml\Parser class issues (fixed in [magento/graphql-ce#711](https://github.com/magento/graphql-ce/pull/711)) + * [#22484](https://github.com/magento/magento2/issues/22484) -- Customer address States are duplicated in backend (fixed in [magento/magento2#22637](https://github.com/magento/magento2/pull/22637)) + * [#23138](https://github.com/magento/magento2/issues/23138) -- Magento_Theme. Incorrect configuration file location (fixed in [magento/magento2#23140](https://github.com/magento/magento2/pull/23140)) + * [#22004](https://github.com/magento/magento2/issues/22004) -- ce231 - can't update attribute for all product (fixed in [magento/magento2#22704](https://github.com/magento/magento2/pull/22704)) + * [#22870](https://github.com/magento/magento2/issues/22870) -- ProductRepository fails to update an existing product with a changed SKU (fixed in [magento/magento2#22933](https://github.com/magento/magento2/pull/22933)) + * [#22808](https://github.com/magento/magento2/issues/22808) -- php bin/magento catalog:image:resize error if image is missing (fixed in [magento/magento2#23005](https://github.com/magento/magento2/pull/23005)) + * [#674](https://github.com/magento/magento2/issues/674) -- Widgets in content pages. (fixed in [magento/graphql-ce#709](https://github.com/magento/graphql-ce/pull/709)) + * [#683](https://github.com/magento/magento2/issues/683) -- CMS Router not routing correctly (fixed in [magento/graphql-ce#717](https://github.com/magento/graphql-ce/pull/717)) + * [#9113](https://github.com/magento/magento2/issues/9113) -- [Bug or Feature?] url_path attribute value is not populated for any product (fixed in [magento/graphql-ce#721](https://github.com/magento/graphql-ce/pull/721)) + * [#18337](https://github.com/magento/magento2/issues/18337) -- #search input is missing required attribute aria-expanded. (fixed in [magento/magento2#22942](https://github.com/magento/magento2/pull/22942)) + * [#23213](https://github.com/magento/magento2/issues/23213) -- Static content deploy showing percentage(%) two times in progress bar (fixed in [magento/magento2#23216](https://github.com/magento/magento2/pull/23216)) + * [#23238](https://github.com/magento/magento2/issues/23238) -- Apply coupon button act like remove coupon while create new order from admin (fixed in [magento/magento2#23250](https://github.com/magento/magento2/pull/23250)) + * [#4788](https://github.com/magento/magento2/issues/4788) -- Wrong sitemap product url (fixed in [magento/magento2#23129](https://github.com/magento/magento2/pull/23129)) + * [#22934](https://github.com/magento/magento2/issues/22934) -- Incorrect work of "Use Categories Path for Product URLs" in sitemap generation. (fixed in [magento/magento2#23129](https://github.com/magento/magento2/pull/23129)) + * [#23266](https://github.com/magento/magento2/issues/23266) -- Cannot filter admin user by ID (fixed in [magento/magento2#23267](https://github.com/magento/magento2/pull/23267)) + * [#23285](https://github.com/magento/magento2/issues/23285) -- Credit memo submit button(refund) stays disable after validation fails & unable to enable button (fixed in [magento/magento2#23286](https://github.com/magento/magento2/pull/23286)) + * [#486](https://github.com/magento/magento2/issues/486) -- Take inspiration from other frameworks (fixed in [magento/graphql-ce#714](https://github.com/magento/graphql-ce/pull/714)) + * [#716](https://github.com/magento/magento2/issues/716) -- Wrong mimetype returned by getMimeType from Magento library (fixed in [magento/graphql-ce#723](https://github.com/magento/graphql-ce/pull/723)) + * [#687](https://github.com/magento/magento2/issues/687) -- Improvement Idea: /var/cache/mage--X (fixed in [magento/graphql-ce#749](https://github.com/magento/graphql-ce/pull/749)) + * [#20038](https://github.com/magento/magento2/issues/20038) -- loading icon disappearing before background process completes for braintree payment (Admin order) (fixed in [magento/magento2#22675](https://github.com/magento/magento2/pull/22675)) + * [#23074](https://github.com/magento/magento2/issues/23074) -- Magento 2.3.1 - URL rewrite rules are not creating for product after update url key (fixed in [magento/magento2#23309](https://github.com/magento/magento2/pull/23309)) + * [#622](https://github.com/magento/magento2/issues/622) -- FIX Magento Search Please! (fixed in [magento/graphql-ce#626](https://github.com/magento/graphql-ce/pull/626)) + * [#732](https://github.com/magento/magento2/issues/732) -- Inconsistency between Select and Multiselect form elements. (fixed in [magento/graphql-ce#734](https://github.com/magento/graphql-ce/pull/734)) + * [#13227](https://github.com/magento/magento2/issues/13227) -- Knockout Recently Viewed contains wrong product url (with category path), also not correct url on product view page (fixed in [magento/magento2#22650](https://github.com/magento/magento2/pull/22650)) + * [#22638](https://github.com/magento/magento2/issues/22638) -- Asterisk(*) sign position does not consistent in admin (fixed in [magento/magento2#22800](https://github.com/magento/magento2/pull/22800)) + * [#22266](https://github.com/magento/magento2/issues/22266) -- Product Alert after login shows 404 page (fixed in [magento/magento2#23218](https://github.com/magento/magento2/pull/23218)) + * [#23230](https://github.com/magento/magento2/issues/23230) -- Sticky header floating under top when there is no buttons in the toolbar (fixed in [magento/magento2#23247](https://github.com/magento/magento2/pull/23247)) + * [#23333](https://github.com/magento/magento2/issues/23333) -- Incorrect payment method translation in order emails (fixed in [magento/magento2#23338](https://github.com/magento/magento2/pull/23338)) + * [#23346](https://github.com/magento/magento2/issues/23346) -- 'Test Connection' button is over-spanned (fixed in [magento/magento2#23367](https://github.com/magento/magento2/pull/23367)) + * [#21380](https://github.com/magento/magento2/issues/21380) -- Cron schedule is being duplicated (fixed in [magento/magento2#23312](https://github.com/magento/magento2/pull/23312)) + * [#21136](https://github.com/magento/magento2/issues/21136) -- Magento installation via metapackage: checkExtensions fails (fixed in [magento/magento2#22116](https://github.com/magento/magento2/pull/22116)) + * [#23233](https://github.com/magento/magento2/issues/23233) -- Alert widget doesn't trigger always method on showing the message (fixed in [magento/magento2#23234](https://github.com/magento/magento2/pull/23234)) + * [#21974](https://github.com/magento/magento2/issues/21974) -- Changes for PayPal affect core config fields with tooltip (fixed in [magento/magento2#23393](https://github.com/magento/magento2/pull/23393)) + * [#23377](https://github.com/magento/magento2/issues/23377) -- Mini cart loader not working first time magento2 (fixed in [magento/magento2#23394](https://github.com/magento/magento2/pull/23394)) + * [#22998](https://github.com/magento/magento2/issues/22998) -- POST on /orders fails when properties in the body are out of sequence (fixed in [magento/magento2#23048](https://github.com/magento/magento2/pull/23048)) + * [#23522](https://github.com/magento/magento2/issues/23522) -- UPS shipping booking and label generation gives error when shipper's street given more than 35 chars (fixed in [magento/magento2#23523](https://github.com/magento/magento2/pull/23523)) + * [#8298](https://github.com/magento/magento2/issues/8298) -- Mobile Menu Behavior at Incorrect Breakpoint (fixed in [magento/magento2#23528](https://github.com/magento/magento2/pull/23528)) + * [#22103](https://github.com/magento/magento2/issues/22103) -- Character Encoding in Plain Text Emails Fails since 2.2.8/2.3.0 due to emails no longer being sent as MIME (fixed in [magento/magento2#23535](https://github.com/magento/magento2/pull/23535)) + * [#23199](https://github.com/magento/magento2/issues/23199) -- NO sender in email header for magento 2 sales order and password change emails to customer (fixed in [magento/magento2#23535](https://github.com/magento/magento2/pull/23535)) + * [#23538](https://github.com/magento/magento2/issues/23538) -- wrong validation happen for max-words validation class (fixed in [magento/magento2#23541](https://github.com/magento/magento2/pull/23541)) + * [#21126](https://github.com/magento/magento2/issues/21126) -- Backend Import behavior design break (fixed in [magento/magento2#21128](https://github.com/magento/magento2/pull/21128)) + * [#23471](https://github.com/magento/magento2/issues/23471) -- Tooltip missing at store view lable in Cms page and Cms block (fixed in [magento/magento2#23474](https://github.com/magento/magento2/pull/23474)) + * [#23466](https://github.com/magento/magento2/issues/23466) -- Cart empty after update qty with -1 and change address. (fixed in [magento/magento2#23477](https://github.com/magento/magento2/pull/23477)) + * [#23467](https://github.com/magento/magento2/issues/23467) -- Phone and Zip not update if customer have no saved address (fixed in [magento/magento2#23494](https://github.com/magento/magento2/pull/23494)) + * [#23222](https://github.com/magento/magento2/issues/23222) -- setup:upgrade should return failure when app:config:import failed (fixed in [magento/magento2#23310](https://github.com/magento/magento2/pull/23310)) + * [#23354](https://github.com/magento/magento2/issues/23354) -- Data saving problem error showing when leave blank qty and update it (fixed in [magento/magento2#23360](https://github.com/magento/magento2/pull/23360)) + * [#23424](https://github.com/magento/magento2/issues/23424) -- Search by keyword didn't work properly with "0" value (fixed in [magento/magento2#23427](https://github.com/magento/magento2/pull/23427)) + * [#16234](https://github.com/magento/magento2/issues/16234) -- Unable to enter `+` character in widget content (fixed in [magento/magento2#23496](https://github.com/magento/magento2/pull/23496)) + * [#9798](https://github.com/magento/magento2/issues/9798) -- Problem adding attribute options to configurable product via REST Api (fixed in [magento/magento2#23529](https://github.com/magento/magento2/pull/23529)) + * [#6287](https://github.com/magento/magento2/issues/6287) -- Customer Admin Shopping Cart View Missing (fixed in [magento/magento2#20918](https://github.com/magento/magento2/pull/20918)) + * [#22545](https://github.com/magento/magento2/issues/22545) -- Status downloadable product stays pending after succesfull payment (fixed in [magento/magento2#22658](https://github.com/magento/magento2/pull/22658)) + * [#23383](https://github.com/magento/magento2/issues/23383) -- Products which are not assigned to any store are automatically being force-assigned a store ID after being saved (fixed in [magento/magento2#23500](https://github.com/magento/magento2/pull/23500)) + * [#22950](https://github.com/magento/magento2/issues/22950) -- Spacing issue for Gift message section in my account (fixed in [magento/magento2#23226](https://github.com/magento/magento2/pull/23226)) + * [#23606](https://github.com/magento/magento2/issues/23606) -- Default value for report filters might result in errors (fixed in [magento/magento2#23607](https://github.com/magento/magento2/pull/23607)) + * [#736](https://github.com/magento/magento2/issues/736) -- Access to Zend Framework classes (fixed in [magento/graphql-ce#747](https://github.com/magento/graphql-ce/pull/747)) + * [#739](https://github.com/magento/magento2/issues/739) -- Command line install script no longer exists. (fixed in [magento/graphql-ce#753](https://github.com/magento/graphql-ce/pull/753)) + * [#23435](https://github.com/magento/magento2/issues/23435) -- Catalog Products Filter in 2.3.2 (fixed in [magento/magento2#23444](https://github.com/magento/magento2/pull/23444)) + * [#12817](https://github.com/magento/magento2/issues/12817) -- Coupon code with canceled order (fixed in [magento/magento2#20579](https://github.com/magento/magento2/pull/20579)) + * [#23386](https://github.com/magento/magento2/issues/23386) -- Copy Service does not works properly for Entities which extends Data Object and implements ExtensibleDataInterface (fixed in [magento/magento2#23387](https://github.com/magento/magento2/pull/23387)) + * [#23345](https://github.com/magento/magento2/issues/23345) -- Creditmemo getOrder() method loads order incorrectly (fixed in [magento/magento2#23358](https://github.com/magento/magento2/pull/23358)) + * [#22814](https://github.com/magento/magento2/issues/22814) -- Product stock alert - unsubscribe not working (fixed in [magento/magento2#23459](https://github.com/magento/magento2/pull/23459)) + * [#23594](https://github.com/magento/magento2/issues/23594) -- Database Media Storage : php bin/magento catalog:images:resize fails when image does not exist locally (fixed in [magento/magento2#23598](https://github.com/magento/magento2/pull/23598)) + * [#23595](https://github.com/magento/magento2/issues/23595) -- Database Media Storage : php bin/magento catalog:images:resize fails to generate cached images in database (fixed in [magento/magento2#23598](https://github.com/magento/magento2/pull/23598)) + * [#23596](https://github.com/magento/magento2/issues/23596) -- Database Media Storage : Add new product image, cached images not generated (fixed in [magento/magento2#23598](https://github.com/magento/magento2/pull/23598)) + * [#23643](https://github.com/magento/magento2/issues/23643) -- Mime parts of email are no more encoded with quoted printable (fixed in [magento/magento2#23649](https://github.com/magento/magento2/pull/23649)) + * [#23597](https://github.com/magento/magento2/issues/23597) -- Database Media Storage : Difficulty changing mode to database media storage due to poor "Use Default Value" checkbox behaviour (fixed in [magento/magento2#23710](https://github.com/magento/magento2/pull/23710)) + * [#23510](https://github.com/magento/magento2/issues/23510) -- Product customizable options of Area type render issue in Dashboard (fixed in [magento/magento2#23524](https://github.com/magento/magento2/pull/23524)) + * [#22890](https://github.com/magento/magento2/issues/22890) -- Disabled config can be overwritten via admin (fixed in [magento/magento2#22891](https://github.com/magento/magento2/pull/22891)) + * [#23054](https://github.com/magento/magento2/issues/23054) -- Cron job not running after crashed once (fixed in [magento/magento2#23125](https://github.com/magento/magento2/pull/23125)) + * [#23135](https://github.com/magento/magento2/issues/23135) -- Insert Variable popup missing template variables for new templates (fixed in [magento/magento2#23173](https://github.com/magento/magento2/pull/23173)) + * [#23211](https://github.com/magento/magento2/issues/23211) -- Zero Subtotal Checkout erroneously says the default value for "Automatically Invoice All Items" is "Yes" (fixed in [magento/magento2#23688](https://github.com/magento/magento2/pull/23688)) + * [#23624](https://github.com/magento/magento2/issues/23624) -- [Authorize.net accept.js] "Place Order" button not being disabled (fixed in [magento/magento2#23718](https://github.com/magento/magento2/pull/23718)) + * [#23717](https://github.com/magento/magento2/issues/23717) -- dependency injection fails for \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface (fixed in [magento/magento2#23753](https://github.com/magento/magento2/pull/23753)) + * [#758](https://github.com/magento/magento2/issues/758) -- Coding standards: arrays (fixed in [magento/graphql-ce#759](https://github.com/magento/graphql-ce/pull/759)) + * [#14071](https://github.com/magento/magento2/issues/14071) -- Not able to change a position of last two related products in case of I've 20+ related products. (fixed in [magento/magento2#22984](https://github.com/magento/magento2/pull/22984)) + * [#22112](https://github.com/magento/magento2/issues/22112) -- Shipping address information is lost in billing step (fixed in [magento/magento2#23656](https://github.com/magento/magento2/pull/23656)) + * [#23654](https://github.com/magento/magento2/issues/23654) -- Frontend Label For Custom Order Status not Editable in Magento Admin in Single Store Mode (fixed in [magento/magento2#23681](https://github.com/magento/magento2/pull/23681)) + * [#23751](https://github.com/magento/magento2/issues/23751) -- Database Media Storage : PDF Logo file not database aware (fixed in [magento/magento2#23752](https://github.com/magento/magento2/pull/23752)) + * [#23678](https://github.com/magento/magento2/issues/23678) -- Can't see "Zero Subtotal Checkout" payment method settings if "Offline Payments" module is disabled (fixed in [magento/magento2#23679](https://github.com/magento/magento2/pull/23679)) + * [#23777](https://github.com/magento/magento2/issues/23777) -- "Discount Amount" field is validated after the page load without any action from user in Create New Catalog Rule form (fixed in [magento/magento2#23779](https://github.com/magento/magento2/pull/23779)) + * [#23789](https://github.com/magento/magento2/issues/23789) -- CommentLevelsSniff works incorrect with @magento_import statement. (fixed in [magento/magento2#23790](https://github.com/magento/magento2/pull/23790)) + * [#22702](https://github.com/magento/magento2/issues/22702) -- Toggle icon not working in create configuration Product creation Page (fixed in [magento/magento2#23803](https://github.com/magento/magento2/pull/23803)) + * [#167](https://github.com/magento/magento2/issues/167) -- Fatal error: Class 'Mage' not found (fixed in [magento/graphql-ce#351](https://github.com/magento/graphql-ce/pull/351)) + * [#438](https://github.com/magento/magento2/issues/438) -- [Feature request] Price slider (fixed in [magento/graphql-ce#699](https://github.com/magento/graphql-ce/pull/699)) + * [#702](https://github.com/magento/magento2/issues/702) -- Base table or view not found (fixed in [magento/graphql-ce#779](https://github.com/magento/graphql-ce/pull/779)) + * [#738](https://github.com/magento/magento2/issues/738) -- pub/setup missing in 0.1.0-alpha103 (fixed in [magento/graphql-ce#789](https://github.com/magento/graphql-ce/pull/789)) + * [#23405](https://github.com/magento/magento2/issues/23405) -- 2.3.2 installed and bin/magento setup:upgrade not working (fixed in [magento/magento2#23866](https://github.com/magento/magento2/pull/23866)) + * [#23900](https://github.com/magento/magento2/issues/23900) -- Report->Product->Downloads has wrong ACL (fixed in [magento/magento2#23901](https://github.com/magento/magento2/pull/23901)) + * [#23904](https://github.com/magento/magento2/issues/23904) -- No auto-focus after validation at "Create Configurations" button => User can not see the error message (fixed in [magento/magento2#23905](https://github.com/magento/magento2/pull/23905)) + * [#23916](https://github.com/magento/magento2/issues/23916) -- Missing Validation at some Payment Method Settings (fixed in [magento/magento2#23917](https://github.com/magento/magento2/pull/23917)) + * [#23932](https://github.com/magento/magento2/issues/23932) -- Decimal quantity is not displayed for wishlist items. (fixed in [magento/magento2#23933](https://github.com/magento/magento2/pull/23933)) +* GitHub pull requests: + * [magento/magento2#20135](https://github.com/magento/magento2/pull/20135) -- issue fixed #20124 Sort By label is hidden by Shop By Menu on listing (by @cedarvinda) + * [magento/magento2#22020](https://github.com/magento/magento2/pull/22020) -- Non existing file, when adding image to gallery with move option. Fix for #21978 (by @dudzio12) + * [magento/magento2#22260](https://github.com/magento/magento2/pull/22260) -- Disabling "Display on Product Details Page" the button is shown anyway. (by @Nazar65) + * [magento/magento2#22287](https://github.com/magento/magento2/pull/22287) -- #222249 configurable product images wrong sorting fix (by @Wirson) + * [magento/magento2#22526](https://github.com/magento/magento2/pull/22526) -- code cleanup (http to https) (by @ravi-chandra3197) + * [magento/magento2#22532](https://github.com/magento/magento2/pull/22532) -- fixed issue 22527 wishlist and compare icon alignment (by @sanjaychouhan-webkul) + * [magento/magento2#22423](https://github.com/magento/magento2/pull/22423) -- Store view specific labels cut in left navigation menu #22406 (by @sudhanshu-bajaj) + * [magento/magento2#22561](https://github.com/magento/magento2/pull/22561) -- [Catalog|Eav] Revert change of PR magento/magento2#13302 not included into revert commit (by @Den4ik) + * [magento/magento2#22569](https://github.com/magento/magento2/pull/22569) -- 2.3 develop pr1 (by @abhinay111222) + * [magento/magento2#22594](https://github.com/magento/magento2/pull/22594) -- Fixed typo issue (by @AfreenScarlet) + * [magento/magento2#22599](https://github.com/magento/magento2/pull/22599) -- Correct spelling (by @ravi-chandra3197) + * [magento/magento2#22621](https://github.com/magento/magento2/pull/22621) -- Resolved Typo (by @UdgamN) + * [magento/magento2#19767](https://github.com/magento/magento2/pull/19767) -- Prevent display of token when save for later is not selected (by @pmclain) + * [magento/magento2#21744](https://github.com/magento/magento2/pull/21744) -- Custom option type select - Allow modify list of single selection option types (by @ihor-sviziev) + * [magento/magento2#21992](https://github.com/magento/magento2/pull/21992) -- #21473: Form element validation is not triggered when validation rules... (by @kisroman) + * [magento/magento2#22493](https://github.com/magento/magento2/pull/22493) -- Update credit-card-number-validator.js (by @justin-at-bounteous) + * [magento/magento2#22643](https://github.com/magento/magento2/pull/22643) -- Fixed typo issue and added missing header in customer sales order grid (by @vishal-7037) + * [magento/magento2#22656](https://github.com/magento/magento2/pull/22656) -- issues #22647 fixed, In customer account create page word not readable, should use '-' after break to new line In mobile view (by @cedarvinda) + * [magento/magento2#22720](https://github.com/magento/magento2/pull/22720) -- Fixed:#22395 (by @satyaprakashpatel) + * [magento/magento2#22558](https://github.com/magento/magento2/pull/22558) -- Additional condition in getRegion() method (by @Leone) + * [magento/magento2#22560](https://github.com/magento/magento2/pull/22560) -- Fix undefined methods 'addClass' and `removeClass` on a PrototypeJS Element (by @markvds) + * [magento/magento2#22606](https://github.com/magento/magento2/pull/22606) -- Fix Exception While Creating an Order in the Admin (by @justin-at-bounteous) + * [magento/magento2#22628](https://github.com/magento/magento2/pull/22628) -- Add a missting colon in the pdf page. (by @Hailong) + * [magento/magento2#22644](https://github.com/magento/magento2/pull/22644) -- Issue fixed #22636 arrow toggle not changing only showing to down It should be toggle as every where is working (by @cedarvinda) + * [magento/magento2#22664](https://github.com/magento/magento2/pull/22664) -- Fixed Typo Error (by @LuciferStrome) + * [magento/magento2#22729](https://github.com/magento/magento2/pull/22729) -- Fixed Typo Issue (by @jitendra-cedcoss) + * [magento/magento2#22734](https://github.com/magento/magento2/pull/22734) -- Ignores allure-results in git. (by @hostep) + * [magento/magento2#22758](https://github.com/magento/magento2/pull/22758) -- Correct spelling (by @ravi-chandra3197) + * [magento/magento2#22798](https://github.com/magento/magento2/pull/22798) -- Disable Travis builds - 2.3-develop (by @okorshenko) + * [magento/magento2#22126](https://github.com/magento/magento2/pull/22126) -- Remove unnecessary form on order success page (by @danielgoodwin97) + * [magento/magento2#22655](https://github.com/magento/magento2/pull/22655) -- Fixed Issue #22640 (by @Surabhi-Cedcoss) + * [magento/magento2#22657](https://github.com/magento/magento2/pull/22657) -- 404 not found form validation url when updating quantity in cart page (by @gulshanchitransh) + * [magento/magento2#22739](https://github.com/magento/magento2/pull/22739) -- Revert "Magento backend catalog cost without currency symbol" as Cost... (by @orlangur) + * [magento/magento2#22779](https://github.com/magento/magento2/pull/22779) -- #22771 Remove hardcoded height for admin textarea (by @serhiyzhovnir) + * [magento/magento2#22791](https://github.com/magento/magento2/pull/22791) -- Fixed issue #22788 (by @gauravagarwal1001) + * [magento/magento2#19584](https://github.com/magento/magento2/pull/19584) -- Tierprice can t save float percentage value 18651 (by @novikor) + * [magento/magento2#21675](https://github.com/magento/magento2/pull/21675) -- [2.3] Database Media Storage - Design Config Save functions to be Database Media Storage aware (by @gwharton) + * [magento/magento2#21917](https://github.com/magento/magento2/pull/21917) -- Prevent duplicate variation error during import of configurable products with numerical SKUs (by @alexander-aleman) + * [magento/magento2#22463](https://github.com/magento/magento2/pull/22463) -- Set timezone on DateTime object not in constructor (by @NathMorgan) + * [magento/magento2#22575](https://github.com/magento/magento2/pull/22575) -- Fix for update products via csv file (fix for 22028) (by @mtwegrzycki) + * [magento/magento2#22794](https://github.com/magento/magento2/pull/22794) -- fixed issue #21558 - Navigation issue of review from product listing (by @sanjaychouhan-webkul) + * [magento/magento2#22844](https://github.com/magento/magento2/pull/22844) -- Allow to specify a field to be checked in the response (by @diazwatson) + * [magento/magento2#22186](https://github.com/magento/magento2/pull/22186) -- 22127: check that products is set (by @davidverholen) + * [magento/magento2#22418](https://github.com/magento/magento2/pull/22418) -- Patch the prototype pollution vulnerability in jQuery < 3.4.0 (CVE-2019-11358) (by @DanielRuf) + * [magento/magento2#22724](https://github.com/magento/magento2/pull/22724) -- Fixed issue #22639: Without select attribute click on add attribute it display all selected when add attribute again. (by @maheshWebkul721) + * [magento/magento2#22742](https://github.com/magento/magento2/pull/22742) -- issue #22676 fixed - Compare Products counter, and My Wish List count... (by @sanjaychouhan-webkul) + * [magento/magento2#22850](https://github.com/magento/magento2/pull/22850) -- only show customer account sections if payment method is active (by @torhoehn) + * [magento/magento2#22854](https://github.com/magento/magento2/pull/22854) -- fix #4628 font-face mixin add fromat option (by @Karlasa) + * [magento/magento2#22868](https://github.com/magento/magento2/pull/22868) -- fix date calculation for report's years interval (by @polkan-msk) + * [magento/magento2#21397](https://github.com/magento/magento2/pull/21397) -- Fixed Validation messages missing from datepicker form elements (by @ravi-chandra3197) + * [magento/magento2#22694](https://github.com/magento/magento2/pull/22694) -- Fixed Issue #20234 (by @surbhi-ranosys) + * [magento/magento2#22787](https://github.com/magento/magento2/pull/22787) -- #22786 Add dependency for UPS required fields to avoid validation for these fields if UPS Shipping is not active (by @serhiyzhovnir) + * [magento/magento2#22823](https://github.com/magento/magento2/pull/22823) -- [Shipping] Adjusting the Contact Us Xpath (by @eduard13) + * [magento/magento2#22830](https://github.com/magento/magento2/pull/22830) -- Removing "if" block and making code more legible (by @matheusgontijo) + * [magento/magento2#22839](https://github.com/magento/magento2/pull/22839) -- FIX: Add missing Stories and Severity to Test cases (by @lbajsarowicz) + * [magento/magento2#22858](https://github.com/magento/magento2/pull/22858) -- Grammatical mistake in the comments (by @sudhanshu-bajaj) + * [magento/magento2#22889](https://github.com/magento/magento2/pull/22889) -- Replace hardcoded CarierCode from createShippingMethod() (by @wigman) + * [magento/magento2#22922](https://github.com/magento/magento2/pull/22922) -- [BUGFIX] Set correct cron instance for catalog_product_frontend_actio... (by @lewisvoncken) + * [magento/magento2#22607](https://github.com/magento/magento2/pull/22607) -- Implement Better Error Handling and Fix Waits on Null PIDs in Parallel SCD Execution (by @davidalger) + * [magento/magento2#22795](https://github.com/magento/magento2/pull/22795) -- fixed issue #22736 - Cursor position not in right side of search keyword in mobile (by @sanjaychouhan-webkul) + * [magento/magento2#22876](https://github.com/magento/magento2/pull/22876) -- Fixed issue #22875 Billing Agreements page title need to be improved (by @amitvishvakarma) + * [magento/magento2#21215](https://github.com/magento/magento2/pull/21215) -- fixed-Discount-Code-improvement-21214 (by @abrarpathan19) + * [magento/magento2#22307](https://github.com/magento/magento2/pull/22307) -- Varnish health check failing due to presence of id_prefix in env.php (by @Nazar65) + * [magento/magento2#22444](https://github.com/magento/magento2/pull/22444) -- magento/magento2#22317: PR#22321 fix. (by @p-bystritsky) + * [magento/magento2#22513](https://github.com/magento/magento2/pull/22513) -- Fixed #22396 config:set fails with JSON values (by @shikhamis11) + * [magento/magento2#22520](https://github.com/magento/magento2/pull/22520) -- Fixed #22506: Search suggestion panel overlapping on advance reporting button (by @webkul-ajaysaini) + * [magento/magento2#22760](https://github.com/magento/magento2/pull/22760) -- [Forwardport] Magento Catalog - fix custom option type text price conversion for mu... (by @ihor-sviziev) + * [magento/magento2#22893](https://github.com/magento/magento2/pull/22893) -- #22869 - defaulting customer storeId fix (by @Wirson) + * [magento/magento2#22926](https://github.com/magento/magento2/pull/22926) -- Store view label not in the middle of panel (by @speedy008) + * [magento/magento2#22947](https://github.com/magento/magento2/pull/22947) -- phpcs error on rule classes - must be of the type integer (by @Nazar65) + * [magento/magento2#22951](https://github.com/magento/magento2/pull/22951) -- Update the contributing.md to match the new beginners guide (by @dmanners) + * [magento/magento2#22387](https://github.com/magento/magento2/pull/22387) -- Checkout totals order in specific store (by @krnshah) + * [magento/magento2#22718](https://github.com/magento/magento2/pull/22718) -- Resolved issue coupon codes don't work anymore #18183 (by @this-adarsh) + * [magento/magento2#22914](https://github.com/magento/magento2/pull/22914) -- #22899 Fix the issue with Incorrect return type at getListByCustomerId in PaymentTokenManagementInterface (by @serhiyzhovnir) + * [magento/magento2#22687](https://github.com/magento/magento2/pull/22687) -- #22686 Shipment view fixed for Fatal error. (by @milindsingh) + * [magento/magento2#22772](https://github.com/magento/magento2/pull/22772) -- Fixed issue #22767: Not clear logic for loading CMS Pages with setStoreId function (by @maheshWebkul721) + * [magento/magento2#22931](https://github.com/magento/magento2/pull/22931) -- [Fixed-20788: Listing page no equal spacing in product in list view] (by @hitesh-wagento) + * [magento/magento2#22965](https://github.com/magento/magento2/pull/22965) -- Simplify if else catalog search full text data provider (by @sankalpshekhar) + * [magento/magento2#23011](https://github.com/magento/magento2/pull/23011) -- Fix typehint (by @amenk) + * [magento/magento2#22920](https://github.com/magento/magento2/pull/22920) -- Mview Indexers getList should return integer values of id's and not strings (by @mhodge13) + * [magento/magento2#23020](https://github.com/magento/magento2/pull/23020) -- Remove direct use of object manager (by @AnshuMishra17) + * [magento/magento2#23033](https://github.com/magento/magento2/pull/23033) -- Issue fix #23030: Swatch change Image does not slide to first Image (by @milindsingh) + * [magento/magento2#23035](https://github.com/magento/magento2/pull/23035) -- [Validator] Fix wrong behaviour of validation scroll (by @Den4ik) + * [magento/magento2#18459](https://github.com/magento/magento2/pull/18459) -- 12696 Delete all test modules after integration tests (by @avstudnitz) + * [magento/magento2#19897](https://github.com/magento/magento2/pull/19897) -- Re-enable PriceBox block caching (by @brucemead) + * [magento/magento2#21200](https://github.com/magento/magento2/pull/21200) -- [FEATURE] Don't load product collection in review observer (by @Den4ik) + * [magento/magento2#22071](https://github.com/magento/magento2/pull/22071) -- Make sure 'last' class is set on top menu (by @arnoudhgz) + * [magento/magento2#22821](https://github.com/magento/magento2/pull/22821) -- Customer Account Forgot Password page title fix (by @textarea) + * [magento/magento2#22884](https://github.com/magento/magento2/pull/22884) -- Show exception message during SCD failure (by @ihor-sviziev) + * [magento/magento2#22989](https://github.com/magento/magento2/pull/22989) -- Properly transliterate German Umlauts (by @amenk) + * [magento/magento2#23036](https://github.com/magento/magento2/pull/23036) -- [Framework] Reassign fields variable after converting to array (by @Den4ik) + * [magento/magento2#23040](https://github.com/magento/magento2/pull/23040) -- Don't create a new account-nav block - use existing instead. (by @vovayatsyuk) + * [magento/magento2#23046](https://github.com/magento/magento2/pull/23046) -- Add more descriptive exception when data patch fails to apply. (by @ashsmith) + * [magento/magento2#23067](https://github.com/magento/magento2/pull/23067) -- Create Security.md file to show on GitHub Security/Policy page (by @piotrekkaminski) + * [magento/magento2#14384](https://github.com/magento/magento2/pull/14384) -- Don't throw shipping method exception when creating quote with only virtual products in API (by @Maikel-Koek) + * [magento/magento2#19184](https://github.com/magento/magento2/pull/19184) -- Fixed magento text swatch switches product image even if attribute feature is disabled #16446 (by @ravi-chandra3197) + * [magento/magento2#21394](https://github.com/magento/magento2/pull/21394) -- [2.3]creating customer without password is directly confirmed 14492 (by @novikor) + * [magento/magento2#21674](https://github.com/magento/magento2/pull/21674) -- [2.3] Database Media Storage - Transactional Emails will now extract image from database in Database Media Storage mode (by @gwharton) + * [magento/magento2#22336](https://github.com/magento/magento2/pull/22336) -- fix clean_cache plugin flush mode (by @thomas-kl1) + * [magento/magento2#22426](https://github.com/magento/magento2/pull/22426) -- Fixed wrong url redirect when edit product review from Customer view page (by @ravi-chandra3197) + * [magento/magento2#22521](https://github.com/magento/magento2/pull/22521) -- Fixed 22511 (by @maheshWebkul721) + * [magento/magento2#22626](https://github.com/magento/magento2/pull/22626) -- resolved typo error (by @nehaguptacedcoss) + * [magento/magento2#22834](https://github.com/magento/magento2/pull/22834) -- #16445 - getRegionHtmlSelect does not have configuration - resolved (by @nikunjskd20) + * [magento/magento2#22937](https://github.com/magento/magento2/pull/22937) -- Mark Elasticsearch 6 support for synonyms (by @aapokiiso) + * [magento/magento2#23081](https://github.com/magento/magento2/pull/23081) -- Fix missing whitespace in mobile navigation for non-English websites (by @alexeya-ven) + * [magento/magento2#21131](https://github.com/magento/magento2/pull/21131) -- Fix Issue #19872 - checking if image is in media directory (by @Bartlomiejsz) + * [magento/magento2#22341](https://github.com/magento/magento2/pull/22341) -- Apply coupoun and scroll top to check. applied successfully or not (by @krnshah) + * [magento/magento2#22646](https://github.com/magento/magento2/pull/22646) -- Fixed Issue #22087 (by @Surabhi-Cedcoss) + * [magento/magento2#23025](https://github.com/magento/magento2/pull/23025) -- Re-enable XML as request and response types within the SwaggerUI (by @sweikenb) + * [magento/magento2#20848](https://github.com/magento/magento2/pull/20848) -- Partial docs fixes in Newsletter module (by @SikailoISM) + * [magento/magento2#21605](https://github.com/magento/magento2/pull/21605) -- [2.3] Database Media Storage - Admin Product Edit Page handles recreates images correctly when pub/media/catalog is cleared. (by @gwharton) + * [magento/magento2#21876](https://github.com/magento/magento2/pull/21876) -- $product->getUrlInStore() does not allow to override the scope in backend context (by @Nazar65) + * [magento/magento2#23007](https://github.com/magento/magento2/pull/23007) -- [Fixed] Reset feature does not clear the date (by @niravkrish) + * [magento/magento2#23118](https://github.com/magento/magento2/pull/23118) -- #23053 : sendfriend verifies product visibility instead of status (by @Wirson) + * [magento/magento2#22637](https://github.com/magento/magento2/pull/22637) -- Fixed #22484 Customer address States are duplicated in backend (by @shikhamis11) + * [magento/magento2#23140](https://github.com/magento/magento2/pull/23140) -- magento/magento2#23138: Magento_Theme. Incorrect configuration file location (by @atwixfirster) + * [magento/magento2#23179](https://github.com/magento/magento2/pull/23179) -- Fix for translation function (by @kkdg) + * [magento/magento2#22704](https://github.com/magento/magento2/pull/22704) -- Fixed #22004 can't update attribute for all product (by @shikhamis11) + * [magento/magento2#22933](https://github.com/magento/magento2/pull/22933) -- magento/magento2#22870: ProductRepository fails to update an existing product with a changed SKU. (by @p-bystritsky) + * [magento/magento2#23005](https://github.com/magento/magento2/pull/23005) -- Improve command catalog:images:resize (by @tdgroot) + * [magento/magento2#22942](https://github.com/magento/magento2/pull/22942) -- Fixed issue #18337 (by @geet07) + * [magento/magento2#23216](https://github.com/magento/magento2/pull/23216) -- Fixed #23213 Static content deploy showing percentage symbol two times in progress bar (by @amitvishvakarma) + * [magento/magento2#23244](https://github.com/magento/magento2/pull/23244) -- Update CONTRIBUTING.md (by @diazwatson) + * [magento/magento2#23248](https://github.com/magento/magento2/pull/23248) -- fix tooltip toggle selector typo (by @Karlasa) + * [magento/magento2#23250](https://github.com/magento/magento2/pull/23250) -- Fixed #23238 Apply button act like remove button while create new order from admin (by @gauravagarwal1001) + * [magento/magento2#22211](https://github.com/magento/magento2/pull/22211) -- Show converted value for validateForRefund error message (by @kassner) + * [magento/magento2#23129](https://github.com/magento/magento2/pull/23129) -- #22934 Improved sitemap product generation logic (by @sergiy-v) + * [magento/magento2#23201](https://github.com/magento/magento2/pull/23201) -- MFTF: Use AdminLoginActionGroup for AdminLoginTest - easiest use of ActionGroup (by @lbajsarowicz) + * [magento/magento2#23100](https://github.com/magento/magento2/pull/23100) -- Resolve issue with improper EAV attribute join statement (by @udovicic) + * [magento/magento2#23267](https://github.com/magento/magento2/pull/23267) -- Add filter index for ID column in adminhtml user grid (by @JeroenVanLeusden) + * [magento/magento2#23286](https://github.com/magento/magento2/pull/23286) -- Fixed Credit memo submit button(refund) stays disable after validation fails & unable to enable button issue. (by @nishantjariwala) + * [magento/magento2#23292](https://github.com/magento/magento2/pull/23292) -- revert Properly transliterate German Umlauts (by @Nazar65) + * [magento/magento2#23307](https://github.com/magento/magento2/pull/23307) -- [Ui] Allow to define listing configuration via ui component xml (by @Den4ik) + * [magento/magento2#23335](https://github.com/magento/magento2/pull/23335) -- Correct spelling (by @ravi-chandra3197) + * [magento/magento2#22675](https://github.com/magento/magento2/pull/22675) -- Fixed #20038 loading icon disappearing before background process completes for Braintree payment in Admin (by @kunal-rtpl) + * [magento/magento2#23174](https://github.com/magento/magento2/pull/23174) -- Move Quote related Plugins to correct module (by @sankalpshekhar) + * [magento/magento2#23309](https://github.com/magento/magento2/pull/23309) -- magento/magento2#23074: update correct product URL rewrites after changing category url key (by @sta1r) + * [magento/magento2#23347](https://github.com/magento/magento2/pull/23347) -- Fixes incorrect file reference in a comment in a .htaccess file. (by @hostep) + * [magento/magento2#22650](https://github.com/magento/magento2/pull/22650) -- Fixes issue #13227 (by @atishgoswami) + * [magento/magento2#22800](https://github.com/magento/magento2/pull/22800) -- fixed issue #22638 - Asterisk(*) sign position does not consistent in admin (by @sanjaychouhan-webkul) + * [magento/magento2#22910](https://github.com/magento/magento2/pull/22910) -- Do an empty check instead of isset check on image removed (by @arnoudhgz) + * [magento/magento2#23218](https://github.com/magento/magento2/pull/23218) -- Fixed #22266: 404 message for product alerts when not logged in (by @ArjenMiedema) + * [magento/magento2#23247](https://github.com/magento/magento2/pull/23247) -- Fixed 23230 : Sticky header floating under top when there is no buttons in the toolbar (by @konarshankar07) + * [magento/magento2#23338](https://github.com/magento/magento2/pull/23338) -- Fix issue with incorrect payment translation in sales emails (by @alexeya-ven) + * [magento/magento2#23366](https://github.com/magento/magento2/pull/23366) -- Correct spelling (by @ravi-chandra3197) + * [magento/magento2#23367](https://github.com/magento/magento2/pull/23367) -- #23346: 'Test Connection' button is over-spanned (by @konarshankar07) + * [magento/magento2#22671](https://github.com/magento/magento2/pull/22671) -- Change exportButton option cvs (by @ajeetsinghcedcoss) + * [magento/magento2#23240](https://github.com/magento/magento2/pull/23240) -- Refactor: Improve mview code readability (by @lbajsarowicz) + * [magento/magento2#23280](https://github.com/magento/magento2/pull/23280) -- Ensure page is loaded after order click actions (by @fooman) + * [magento/magento2#23306](https://github.com/magento/magento2/pull/23306) -- FS/23038 Decimal qty with Increment is with specific values are not adding in cart (by @sertlab) + * [magento/magento2#23312](https://github.com/magento/magento2/pull/23312) -- Added function to check against running/pending/successful cron tasks (by @chickenland) + * [magento/magento2#22116](https://github.com/magento/magento2/pull/22116) -- Fix magento root package identification for metapackage installation (by @oleksii-lisovyi) + * [magento/magento2#23234](https://github.com/magento/magento2/pull/23234) -- [Ui] Calling the always action on opening and closing the modal. (by @eduard13) + * [magento/magento2#23353](https://github.com/magento/magento2/pull/23353) -- Get review entity id by code instead hard-coded. (by @DaniloEmpire) + * [magento/magento2#23393](https://github.com/magento/magento2/pull/23393) -- Fixed issue #21974 (by @geet07) + * [magento/magento2#23394](https://github.com/magento/magento2/pull/23394) -- Fixed issue #23377 (by @geet07) + * [magento/magento2#23403](https://github.com/magento/magento2/pull/23403) -- Remove rogue closing tag from store-switcher template (by @sta1r) + * [magento/magento2#22987](https://github.com/magento/magento2/pull/22987) -- Fixed apply discount coupons for bundle product (by @NikolasSumrak) + * [magento/magento2#23048](https://github.com/magento/magento2/pull/23048) -- #22998 : failing order creation with api when no address email is provided (by @Wirson) + * [magento/magento2#23390](https://github.com/magento/magento2/pull/23390) -- Changed logic so that _scrollToTopIfVisible is called only if element is in viewport. Previously it was called only when the element was outside it. (by @oskarolaussen) + * [magento/magento2#23425](https://github.com/magento/magento2/pull/23425) -- The best practices for SEO meta sequence. (by @vaseemishak) + * [magento/magento2#23523](https://github.com/magento/magento2/pull/23523) -- Issue #23522 UPS shipping booking and label generation gives error when shipper's street given more than 35 chars (by @ankurvr) + * [magento/magento2#23528](https://github.com/magento/magento2/pull/23528) -- move breakpoint by -1px to make nav work correctly at viewport 768 (by @bobemoe) + * [magento/magento2#23532](https://github.com/magento/magento2/pull/23532) -- Correct array type hints in Visibility model (by @pmclain) + * [magento/magento2#23535](https://github.com/magento/magento2/pull/23535) -- [2.3] Plain Text Emails are now sent with correct MIME Encoding (by @gwharton) + * [magento/magento2#23541](https://github.com/magento/magento2/pull/23541) -- fix validation class for max-words (by @sunilit42) + * [magento/magento2#21128](https://github.com/magento/magento2/pull/21128) -- Fix issue 21126 : Import design break issue resolved (by @speedy008) + * [magento/magento2#22213](https://github.com/magento/magento2/pull/22213) -- Date column ui component locale date format (by @Karlasa) + * [magento/magento2#23457](https://github.com/magento/magento2/pull/23457) -- Update CartTotalRepository.php (by @UlyanaKiklevich) + * [magento/magento2#23474](https://github.com/magento/magento2/pull/23474) -- Fixed tooltip missing at store view lable in Cms page and Cms block (by @dipeshrangani) + * [magento/magento2#23477](https://github.com/magento/magento2/pull/23477) -- Added quantity validation on Shipping Multiple Address Page (by @nirmalraval18) + * [magento/magento2#23494](https://github.com/magento/magento2/pull/23494) -- Removed editor from phone and zipcode (by @kazim-krish) + * [magento/magento2#23310](https://github.com/magento/magento2/pull/23310) -- magento/magento-2#23222: setup:upgrade should return failure when app... (by @ProcessEight) + * [magento/magento2#23360](https://github.com/magento/magento2/pull/23360) -- #23354 : Data saving problem error showing when leave blank qty and update it (by @konarshankar07) + * [magento/magento2#23427](https://github.com/magento/magento2/pull/23427) -- 23424: fixed search with 0 (by @jeysmook) + * [magento/magento2#23496](https://github.com/magento/magento2/pull/23496) -- Resolved + character issue in custom widget (by @sarfarazbheda) + * [magento/magento2#23529](https://github.com/magento/magento2/pull/23529) -- Feature/9798 updating configurable product options based on produc id and sku (by @lpouwelse) + * [magento/magento2#20918](https://github.com/magento/magento2/pull/20918) -- Enabled 'Shopping Cart' tab for customer edit interface in admin (by @rav-redchamps) + * [magento/magento2#22624](https://github.com/magento/magento2/pull/22624) -- Resolve Typo (by @prashantsharmacedcoss) + * [magento/magento2#22658](https://github.com/magento/magento2/pull/22658) -- Fixed #22545 Status downloadable product stays pending after succesfu... (by @shikhamis11) + * [magento/magento2#23500](https://github.com/magento/magento2/pull/23500) -- Fixed issue #23383 (by @manishgoswamij) + * [magento/magento2#23226](https://github.com/magento/magento2/pull/23226) -- Spacing issue for Gift message section in my account (by @amjadm61) + * [magento/magento2#23272](https://github.com/magento/magento2/pull/23272) -- hide or show the select for regions instead of enabling/disabling in customer registration (by @UB3RL33T) + * [magento/magento2#23593](https://github.com/magento/magento2/pull/23593) -- A small fix to improve format customer acl xml. (by @mrkhoa99) + * [magento/magento2#23607](https://github.com/magento/magento2/pull/23607) -- Default filter for reports set to past month (by @rogyar) + * [magento/magento2#22138](https://github.com/magento/magento2/pull/22138) -- BeanShells are changed to correct using of variables (by @AnnaShepa) + * [magento/magento2#22733](https://github.com/magento/magento2/pull/22733) -- Adds module:config:status command which checks if the module config i... (by @hostep) + * [magento/magento2#23351](https://github.com/magento/magento2/pull/23351) -- Fix some framework coding issues (by @fooman) + * [magento/magento2#23444](https://github.com/magento/magento2/pull/23444) -- Fix missing attribute_id condition from filter (by @mattijv) + * [magento/magento2#20579](https://github.com/magento/magento2/pull/20579) -- magento/magento2#12817: [Forwardport] Coupon code with canceled order. (by @p-bystritsky) + * [magento/magento2#23387](https://github.com/magento/magento2/pull/23387) -- magento/magento2#23386: Copy Service does not work properly for Entities which extends Data Object and implements ExtensibleDataInterface. (by @swnsma) + * [magento/magento2#23358](https://github.com/magento/magento2/pull/23358) -- magento/magento2#23345: Creditmemo getOrder() method loads order incorrectly. (by @p-bystritsky) + * [magento/magento2#23459](https://github.com/magento/magento2/pull/23459) -- magento/magento2#22814: Product stock alert - unsubscribe not working (by @yuriichayka) + * [magento/magento2#23598](https://github.com/magento/magento2/pull/23598) -- [2.3] magento catalog:images:resize now Database Media Storage mode aware (by @gwharton) + * [magento/magento2#23291](https://github.com/magento/magento2/pull/23291) -- Optimized dev:urn-catalog:generate for PHPStorm (by @JeroenBoersma) + * [magento/magento2#23592](https://github.com/magento/magento2/pull/23592) -- [Unit] Fix broken unit tests (by @Den4ik) + * [magento/magento2#23649](https://github.com/magento/magento2/pull/23649) -- [2.3] Transfer Encoding of emails changed to QUOTED-PRINTABLE (by @gwharton) + * [magento/magento2#23652](https://github.com/magento/magento2/pull/23652) -- Add missing getClass() to image.phtml so it is more like image_with_borders.phtml (by @woutersamaey) + * [magento/magento2#23710](https://github.com/magento/magento2/pull/23710) -- [2.3] Improve Database Media Storage Configuration settings usability (by @gwharton) + * [magento/magento2#23735](https://github.com/magento/magento2/pull/23735) -- Fixed typo in deploy module README.md (by @arnolds) + * [magento/magento2#22717](https://github.com/magento/magento2/pull/22717) -- Getting 404 url while updating quantity on multiple address cart page (by @vikalps4) + * [magento/magento2#23166](https://github.com/magento/magento2/pull/23166) -- Fix 22085 (by @geet07) + * [magento/magento2#23524](https://github.com/magento/magento2/pull/23524) -- remove html tag from option html from order page (by @sunilit42) + * [magento/magento2#22891](https://github.com/magento/magento2/pull/22891) -- Check if setting is disabled on default scope (by @kassner) + * [magento/magento2#23099](https://github.com/magento/magento2/pull/23099) -- fix customer data race condition when bundling is enabled (by @davidverholen) + * [magento/magento2#23125](https://github.com/magento/magento2/pull/23125) -- Catch throwables in mview updating (by @QuentinFarizonAfrimarket) + * [magento/magento2#23173](https://github.com/magento/magento2/pull/23173) -- Fixed issue #23135: Insert Variable popup missing template variables for new templates (by @maheshWebkul721) + * [magento/magento2#23688](https://github.com/magento/magento2/pull/23688) -- Resolve "Automatically Invoice All Items" is "Yes" but no invoice is created (Zero Subtotal Checkout) (by @edenduong) + * [magento/magento2#23718](https://github.com/magento/magento2/pull/23718) -- Resolve [Authorize.net accept.js] "Place Order" button not being disabled when editing billing address (by @edenduong) + * [magento/magento2#23753](https://github.com/magento/magento2/pull/23753) -- Add Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface to di.xml in issue23717 (by @edenduong) + * [magento/magento2#22984](https://github.com/magento/magento2/pull/22984) -- magento/magento2#14071: Not able to change a position of last two rel... (by @m-a-x-i-m) + * [magento/magento2#23656](https://github.com/magento/magento2/pull/23656) -- Fixes issue 22112 (https://github.com/magento/magento2/issues/22112) ... (by @rsimmons07) + * [magento/magento2#23666](https://github.com/magento/magento2/pull/23666) -- magento/magento2#: Fix storeId param type in the EmailNotification::newAccount, EmailNotificationInterface::newAccount methods (by @atwixfirster) + * [magento/magento2#23681](https://github.com/magento/magento2/pull/23681) -- Resolve Frontend Label For Custom Order Status not Editable in Magento Admin in Single Store Mode (by @edenduong) + * [magento/magento2#23752](https://github.com/magento/magento2/pull/23752) -- [2.3] Database Media Storage : PDF Logo file now database aware (by @gwharton) + * [magento/magento2#23679](https://github.com/magento/magento2/pull/23679) -- Moved Zero Subtotal Checkout Payment Settings (by @textarea) + * [magento/magento2#23779](https://github.com/magento/magento2/pull/23779) -- Resolve "Discount Amount" field is validated after the page load without any action from user in Create New Catalog Rule form issue23777 (by @edenduong) + * [magento/magento2#23787](https://github.com/magento/magento2/pull/23787) -- Fix for PHP_CodeSniffer error after app:config:dump (by @dng-dev) + * [magento/magento2#23790](https://github.com/magento/magento2/pull/23790) -- magento/magento2#23789: CommentLevelsSniff works incorrect with @magento_import statement. (by @p-bystritsky) + * [magento/magento2#23794](https://github.com/magento/magento2/pull/23794) -- Remove duplicate declaration (by @gfernandes410) + * [magento/magento2#23803](https://github.com/magento/magento2/pull/23803) -- Resolve Toggle icon not working in create configuration Product creation Page issue 22702 (by @edenduong) + * [magento/magento2#23782](https://github.com/magento/magento2/pull/23782) -- Cleaning some code gaps (by @Stepa4man) + * [magento/magento2#23840](https://github.com/magento/magento2/pull/23840) -- Fix regular expression comment on function isNameValid() in ImageContentValidator.php (by @nimbus2300) + * [magento/magento2#23845](https://github.com/magento/magento2/pull/23845) -- Add custom added url key to decoded directive string in WYSIWYG editor (by @JeroenVanLeusden) + * [magento/magento2#23866](https://github.com/magento/magento2/pull/23866) -- additional check for correct version of sodium (by @matei) + * [magento/magento2#23901](https://github.com/magento/magento2/pull/23901) -- Resolve Report->Product->Downloads has wrong ACL issue 23900 (by @edenduong) + * [magento/magento2#23905](https://github.com/magento/magento2/pull/23905) -- Resolve No auto-focus after validation at "Create Configurations" button => User can not see the error message issue23904 (by @edenduong) + * [magento/magento2#23917](https://github.com/magento/magento2/pull/23917) -- Resolve Missing Validation at some Payment Method Settings issue 23916 (by @edenduong) + * [magento/magento2#23919](https://github.com/magento/magento2/pull/23919) -- class ApplyAttributesUpdate should use \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE instead of fixing "bundle" (by @edenduong) + * [magento/magento2#23933](https://github.com/magento/magento2/pull/23933) -- Fix display of decimal quantities for wishlist items (by @mfickers) + 2.3.2 ============= * GitHub issues: diff --git a/README.md b/README.md index 7662290cc09c..5fa6150d2be0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a ## Install Magento -* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). +* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). ## Learn More About GraphQL in Magento 2 @@ -18,7 +18,7 @@ Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a

Contributing to the Magento 2 Code Base

Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions. -To learn about how to make a contribution, click [here][1]. +To learn about how to contribute, click [here][1]. To learn about issues, click [here][2]. To open an issue, click [here][3]. @@ -37,7 +37,7 @@ The members of this team have been recognized for their outstanding commitment t

Top Contributors

-Magento is thankful for any contribution that can improve our code base, documentation or increase test coverage. We always recognize our most active members, as their contributions are the foundation of the Magento Open Source platform. +Magento is thankful for any contribution that can improve our codebase, documentation or increase test coverage. We always recognize our most active members, as their contributions are the foundation of the Magento Open Source platform. @@ -48,7 +48,7 @@ Please review the [Code Contributions guide](https://devdocs.magento.com/guides/ ## Reporting Security Issues -To report security vulnerabilities or learn more about reporting security issues in Magento software or web sites visit the [Magento Bug Bounty Program](https://hackerone.com/magento) on hackerone. Please create a hackerone account [there](https://hackerone.com/magento) to submit and follow-up your issue. +To report security vulnerabilities or learn more about reporting security issues in Magento software or web sites visit the [Magento Bug Bounty Program](https://hackerone.com/magento) on hackerone. Please create a hackerone account [there](https://hackerone.com/magento) to submit and follow-up on your issue. Stay up-to-date on the latest security news and patches for Magento by signing up for [Security Alert Notifications](https://magento.com/security/sign-up). @@ -64,7 +64,7 @@ Please see LICENSE_EE.txt for the full text of the MEE License or visit https:// ## Community Engineering Slack -To connect with Magento and the Community, join us on the [Magento Community Engineering Slack](https://magentocommeng.slack.com). If you are interested in joining Slack, or a specific channel, send us request at [engcom@adobe.com](mailto:engcom@adobe.com) or [self signup](https://tinyurl.com/engcom-slack). +To connect with Magento and the Community, join us on the [Magento Community Engineering Slack](https://magentocommeng.slack.com). If you are interested in joining Slack, or a specific channel, send us a request at [engcom@adobe.com](mailto:engcom@adobe.com) or [self signup](https://opensource.magento.com/slack). We have channels for each project. These channels are recommended for new members: diff --git a/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/DisableAdminUsage.php b/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/DisableAdminUsage.php new file mode 100644 index 000000000000..34a9ef4f75b9 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/DisableAdminUsage.php @@ -0,0 +1,104 @@ +configFactory = $configFactory; + $this->productMetadata = $productMetadata; + $this->notificationLogger = $notificationLogger; + } + + /** + * Change the value of config/admin/usage/enabled + */ + private function disableAdminUsage() + { + $configModel = $this->configFactory->create(); + $configModel->setDataByPath('admin/usage/enabled', 0); + $configModel->save(); + } + + /** + * Log information about the last admin usage selection + * + * @return ResultInterface + */ + private function markUserNotified(): ResultInterface + { + $responseContent = [ + 'success' => $this->notificationLogger->log( + $this->productMetadata->getVersion() + ), + 'error_message' => '' + ]; + + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + return $resultJson->setData($responseContent); + } + + /** + * Log information about the last shown advertisement + * + * @return ResultInterface + */ + public function execute() + { + $this->disableAdminUsage(); + $this->markUserNotified(); + } + + /** + * @inheritDoc + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed(static::ADMIN_RESOURCE); + } +} diff --git a/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/EnableAdminUsage.php b/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/EnableAdminUsage.php new file mode 100644 index 000000000000..f70dd57aa59d --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Controller/Adminhtml/Config/EnableAdminUsage.php @@ -0,0 +1,102 @@ +configFactory = $configFactory; + $this->productMetadata = $productMetadata; + $this->notificationLogger = $notificationLogger; + } + + /** + * Change the value of config/admin/usage/enabled + */ + private function enableAdminUsage() + { + $configModel = $this->configFactory->create(); + $configModel->setDataByPath('admin/usage/enabled', 1); + $configModel->save(); + } + + /** + * Log information about the last user response + * + * @return ResultInterface + */ + private function markUserNotified(): ResultInterface + { + $responseContent = [ + 'success' => $this->notificationLogger->log( + $this->productMetadata->getVersion() + ), + 'error_message' => '' + ]; + + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); + return $resultJson->setData($responseContent); + } + + /** + * Log information about the last shown advertisement + * + * @return \Magento\Framework\Controller\ResultInterface + */ + public function execute() + { + $this->enableAdminUsage(); + $this->markUserNotified(); + } + + /** + * @inheritDoc + */ + protected function _isAllowed() + { + return $this->_authorization->isAllowed(static::ADMIN_RESOURCE); + } +} diff --git a/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php b/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php new file mode 100644 index 000000000000..222261d4abfb --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Model/Condition/CanViewNotification.php @@ -0,0 +1,84 @@ +viewerLogger = $viewerLogger; + $this->cacheStorage = $cacheStorage; + } + + /** + * Validate if notification popup can be shown and set the notification flag + * + * @param array $arguments Attributes from element node. + * @inheritdoc + */ + public function isVisible(array $arguments): bool + { + $cacheKey = self::$cachePrefix; + $value = $this->cacheStorage->load($cacheKey); + if ($value !== 'log-exists') { + $logExists = $this->viewerLogger->checkLogExists(); + if ($logExists) { + $this->cacheStorage->save('log-exists', $cacheKey); + } + return !$logExists; + } + return false; + } + + /** + * Get condition name + * + * @return string + */ + public function getName(): string + { + return self::$conditionName; + } +} diff --git a/app/code/Magento/AdminAnalytics/Model/ResourceModel/Viewer/Logger.php b/app/code/Magento/AdminAnalytics/Model/ResourceModel/Viewer/Logger.php new file mode 100644 index 000000000000..c66f31e3d3bc --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Model/ResourceModel/Viewer/Logger.php @@ -0,0 +1,111 @@ +resource = $resource; + $this->logFactory = $logFactory; + } + + /** + * Save (insert new or update existing) log. + * + * @param string $lastViewVersion + * @return bool + */ + public function log(string $lastViewVersion): bool + { + /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ + $connection = $this->resource->getConnection(ResourceConnection::DEFAULT_CONNECTION); + $connection->insertOnDuplicate( + $this->resource->getTableName(self::LOG_TABLE_NAME), + [ + 'last_viewed_in_version' => $lastViewVersion, + ], + [ + 'last_viewed_in_version', + ] + ); + return true; + } + + /** + * Get log by the last view version. + * + * @return Log + */ + public function get(): Log + { + return $this->logFactory->create(['data' => $this->loadLatestLogData()]); + } + + /** + * Checks is log already exists. + * + * @return boolean + */ + public function checkLogExists(): bool + { + $data = $this->logFactory->create(['data' => $this->loadLatestLogData()]); + $lastViewedVersion = $data->getLastViewVersion(); + return isset($lastViewedVersion); + } + + /** + * Load release notification viewer log data by last view version + * + * @return array + */ + private function loadLatestLogData(): array + { + $connection = $this->resource->getConnection(); + $select = $connection->select() + ->from(['log_table' => $this->resource->getTableName(self::LOG_TABLE_NAME)]) + ->order('log_table.id desc') + ->limit(['count' => 1]); + + $data = $connection->fetchRow($select); + if (!$data) { + $data = []; + } + return $data; + } +} diff --git a/app/code/Magento/AdminAnalytics/Model/Viewer/Log.php b/app/code/Magento/AdminAnalytics/Model/Viewer/Log.php new file mode 100644 index 000000000000..0c3b6b81ec81 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Model/Viewer/Log.php @@ -0,0 +1,36 @@ +getData('id'); + } + + /** + * Get last viewed product version + * + * @return string + */ + public function getLastViewVersion() : ?string + { + return $this->getData('last_viewed_in_version'); + } +} diff --git a/app/code/Magento/AdminAnalytics/README.md b/app/code/Magento/AdminAnalytics/README.md new file mode 100644 index 000000000000..e905344031ad --- /dev/null +++ b/app/code/Magento/AdminAnalytics/README.md @@ -0,0 +1 @@ +The Magento\AdminAnalytics module gathers information about the features Magento administrators use. This information will be used to help improve the user experience on the Magento Admin. \ No newline at end of file diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/CloseAllDialogBoxesActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/CloseAllDialogBoxesActionGroup.xml new file mode 100644 index 000000000000..4fd7fd17c57e --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/CloseAllDialogBoxesActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml new file mode 100644 index 000000000000..d9f5e5dbcb10 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAdminWithCredentialsActionGroup.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml new file mode 100644 index 000000000000..5cf7be8a6fe1 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/LoginAsAdminActionGroup.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/SelectAdminUsageSettingActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/SelectAdminUsageSettingActionGroup.xml new file mode 100644 index 000000000000..3b302fe5be18 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/SelectAdminUsageSettingActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminHeaderSection.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminHeaderSection.xml new file mode 100644 index 000000000000..cc9f495a6002 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminHeaderSection.xml @@ -0,0 +1,15 @@ + + + + +
+ + +
+
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageConfigSection.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageConfigSection.xml new file mode 100644 index 000000000000..634ebf855d94 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageConfigSection.xml @@ -0,0 +1,15 @@ + + + + +
+ + +
+
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageNotificationSection.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageNotificationSection.xml new file mode 100644 index 000000000000..8bd6263d35e3 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Section/AdminUsageNotificationSection.xml @@ -0,0 +1,15 @@ + + + + +
+ + +
+
diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml new file mode 100644 index 000000000000..58bcacc190cf --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Mftf/Test/TrackingScriptTest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + <description value="Checks to see if the tracking script is in the dom of admin and if setting is turned to no it checks if the tracking script in the dom was removed"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-18192"/> + <group value="backend"/> + <group value="login"/> + </annotations> + + <!-- Logging in Magento admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php new file mode 100644 index 000000000000..7819f2f017a0 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Test/Unit/Condition/CanViewNotificationTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\AdminAnalytics\Test\Unit\Condition; + +use Magento\AdminAnalytics\Model\Condition\CanViewNotification; +use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger; +use Magento\AdminAnalytics\Model\Viewer\Log; +use Magento\Framework\App\ProductMetadataInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\App\CacheInterface; + +/** + * Class CanViewNotificationTest + */ +class CanViewNotificationTest extends \PHPUnit\Framework\TestCase +{ + /** @var CanViewNotification */ + private $canViewNotification; + + /** @var Logger|\PHPUnit_Framework_MockObject_MockObject */ + private $viewerLoggerMock; + + /** @var ProductMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $productMetadataMock; + + /** @var Log|\PHPUnit_Framework_MockObject_MockObject */ + private $logMock; + + /** @var $cacheStorageMock \PHPUnit_Framework_MockObject_MockObject|CacheInterface */ + private $cacheStorageMock; + + public function setUp() + { + $this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class) + ->getMockForAbstractClass(); + $this->logMock = $this->getMockBuilder(Log::class) + ->getMock(); + $this->viewerLoggerMock = $this->getMockBuilder(Logger::class) + ->disableOriginalConstructor() + ->getMock(); + $this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $objectManager = new ObjectManager($this); + $this->canViewNotification = $objectManager->getObject( + CanViewNotification::class, + [ + 'viewerLogger' => $this->viewerLoggerMock, + 'productMetadata' => $this->productMetadataMock, + 'cacheStorage' => $this->cacheStorageMock, + ] + ); + } + + /** + * @param $expected + * @param $cacheResponse + * @param $logExists + * @dataProvider isVisibleProvider + */ + public function testIsVisibleLoadDataFromLog($expected, $cacheResponse, $logExists) + { + $this->cacheStorageMock->expects($this->once()) + ->method('load') + ->with('admin-usage-notification-popup') + ->willReturn($cacheResponse); + $this->viewerLoggerMock + ->method('checkLogExists') + ->willReturn($logExists); + $this->cacheStorageMock + ->method('save') + ->with('log-exists', 'admin-usage-notification-popup'); + $this->assertEquals($expected, $this->canViewNotification->isVisible([])); + } + + /** + * @return array + */ + public function isVisibleProvider() + { + return [ + [true, false, false], + [false, 'log-exists', true], + [false, false, true], + ]; + } +} diff --git a/app/code/Magento/AdminAnalytics/Ui/DataProvider/AdminUsageNotificationDataProvider.php b/app/code/Magento/AdminAnalytics/Ui/DataProvider/AdminUsageNotificationDataProvider.php new file mode 100644 index 000000000000..961a5663730a --- /dev/null +++ b/app/code/Magento/AdminAnalytics/Ui/DataProvider/AdminUsageNotificationDataProvider.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\AdminAnalytics\Ui\DataProvider; + +use Magento\Ui\DataProvider\AbstractDataProvider; +use Magento\Framework\Api\Filter; + +/** + * Data Provider for the Admin usage UI component. + */ +class AdminUsageNotificationDataProvider extends AbstractDataProvider +{ + /** + * @inheritdoc + */ + public function getData() + { + return $this->data; + } + + /** + * @inheritdoc + */ + public function addFilter(Filter $filter) + { + return null; + } +} diff --git a/app/code/Magento/AdminAnalytics/ViewModel/Metadata.php b/app/code/Magento/AdminAnalytics/ViewModel/Metadata.php new file mode 100644 index 000000000000..9b1accbe0c82 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/ViewModel/Metadata.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\AdminAnalytics\ViewModel; + +use Magento\Framework\App\ProductMetadataInterface; +use Magento\Backend\Model\Auth\Session; +use Magento\Framework\App\State; +use Magento\Framework\View\Element\Block\ArgumentInterface; + +/** + * Gets user version and mode + */ +class Metadata implements ArgumentInterface +{ + /** + * @var State + */ + private $appState; + + /** + * @var Session + */ + private $authSession; + + /** + * @var ProductMetadataInterface + */ + private $productMetadata; + + /** + * @param ProductMetadataInterface $productMetadata + * @param Session $authSession + * @param State $appState + */ + public function __construct( + ProductMetadataInterface $productMetadata, + Session $authSession, + State $appState + ) { + $this->productMetadata = $productMetadata; + $this->authSession = $authSession; + $this->appState = $appState; + } + + /** + * Get product version + * + * @return string + */ + public function getMagentoVersion() :string + { + return $this->productMetadata->getVersion(); + } + + /** + * Get current user id (hash generated from email) + * + * @return string + */ + public function getCurrentUser() :string + { + return hash('sha512', 'ADMIN_USER' . $this->authSession->getUser()->getEmail()); + } + /** + * Get Magento mode that the user is using + * + * @return string + */ + public function getMode() :string + { + return $this->appState->getMode(); + } +} diff --git a/app/code/Magento/AdminAnalytics/ViewModel/Notification.php b/app/code/Magento/AdminAnalytics/ViewModel/Notification.php new file mode 100644 index 000000000000..030e027b83fc --- /dev/null +++ b/app/code/Magento/AdminAnalytics/ViewModel/Notification.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\AdminAnalytics\ViewModel; + +use Magento\Framework\View\Element\Block\ArgumentInterface; +use Magento\AdminAnalytics\Model\Condition\CanViewNotification as AdminAnalyticsNotification; +use Magento\ReleaseNotification\Model\Condition\CanViewNotification as ReleaseNotification; + +/** + * Control display of admin analytics and release notification modals + */ +class Notification implements ArgumentInterface +{ + /** + * @var AdminAnalyticsNotification + */ + private $canViewNotificationAnalytics; + + /** + * @var ReleaseNotification + */ + private $canViewNotificationRelease; + + /** + * @param AdminAnalyticsNotification $canViewNotificationAnalytics + * @param ReleaseNotification $canViewNotificationRelease + */ + public function __construct( + AdminAnalyticsNotification $canViewNotificationAnalytics, + ReleaseNotification $canViewNotificationRelease + ) { + $this->canViewNotificationAnalytics = $canViewNotificationAnalytics; + $this->canViewNotificationRelease = $canViewNotificationRelease; + } + + /** + * Determine if the analytics popup is visible + * + * @return bool + */ + public function isAnalyticsVisible(): bool + { + return $this->canViewNotificationAnalytics->isVisible([]); + } + + /** + * Determine if the release popup is visible + * + * @return bool + */ + public function isReleaseVisible(): bool + { + return $this->canViewNotificationRelease->isVisible([]); + } +} diff --git a/app/code/Magento/AdminAnalytics/composer.json b/app/code/Magento/AdminAnalytics/composer.json new file mode 100644 index 000000000000..0b977a23ad3c --- /dev/null +++ b/app/code/Magento/AdminAnalytics/composer.json @@ -0,0 +1,29 @@ +{ + "name": "magento/module-admin-analytics", + "description": "N/A", + "config": { + "sort-packages": true + }, + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/framework": "*", + "magento/module-backend": "*", + "magento/module-config": "*", + "magento/module-ui": "*", + "magento/module-release-notification": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\AdminAnalytics\\": "" + } + } +} + diff --git a/app/code/Magento/AdminAnalytics/etc/adminhtml/routes.xml b/app/code/Magento/AdminAnalytics/etc/adminhtml/routes.xml new file mode 100644 index 000000000000..5b5f2b52210b --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/adminhtml/routes.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd"> + <router id="admin"> + <route id="adminAnalytics" frontName="adminAnalytics"> + <module name="Magento_AdminAnalytics" /> + </route> + </router> +</config> diff --git a/app/code/Magento/AdminAnalytics/etc/adminhtml/system.xml b/app/code/Magento/AdminAnalytics/etc/adminhtml/system.xml new file mode 100644 index 000000000000..d6867e74c476 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/adminhtml/system.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> + <system> + <section id="admin"> + <group id="usage" translate="label" type="text" sortOrder="2000" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Admin Usage</label> + <field id="enabled" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="0" showInStore="0"> + <label>Enable Admin Usage Tracking</label> + <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> + <comment>Allow Magento to track admin usage in order to improve the quality and user experience.</comment> + </field> + </group> + </section> + </system> +</config> diff --git a/app/code/Magento/AdminAnalytics/etc/config.xml b/app/code/Magento/AdminAnalytics/etc/config.xml new file mode 100644 index 000000000000..ba683f13c11e --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/config.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> + <default> + <admin> + <usage> + <enabled> + 1 + </enabled> + </usage> + </admin> + </default> +</config> \ No newline at end of file diff --git a/app/code/Magento/AdminAnalytics/etc/db_schema.xml b/app/code/Magento/AdminAnalytics/etc/db_schema.xml new file mode 100644 index 000000000000..ef1a657dc824 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/db_schema.xml @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="admin_analytics_usage_version_log" resource="default" engine="innodb" + comment="Admin Notification Viewer Log Table"> + <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" + comment="Log ID"/> + <column xsi:type="varchar" name="last_viewed_in_version" nullable="false" length="50" + comment="Viewer last viewed on product version"/> + <constraint xsi:type="primary" referenceId="PRIMARY"> + <column name="id"/> + </constraint> + <constraint xsi:type="unique" referenceId="ADMIN_ANALYTICS_USAGE_VERSION_LOG_LAST_VIEWED_IN_VERSION"> + <column name="last_viewed_in_version"/> + </constraint> + </table> +</schema> diff --git a/app/code/Magento/AdminAnalytics/etc/db_schema_whitelist.json b/app/code/Magento/AdminAnalytics/etc/db_schema_whitelist.json new file mode 100644 index 000000000000..626e3ec14bc9 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/db_schema_whitelist.json @@ -0,0 +1,12 @@ +{ + "admin_analytics_usage_version_log": { + "column": { + "id": true, + "last_viewed_in_version": true + }, + "constraint": { + "PRIMARY": true, + "ADMIN_ANALYTICS_USAGE_VERSION_LOG_LAST_VIEWED_IN_VERSION": true + } + } +} \ No newline at end of file diff --git a/app/code/Magento/AdminAnalytics/etc/module.xml b/app/code/Magento/AdminAnalytics/etc/module.xml new file mode 100644 index 000000000000..f0990b114e25 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/etc/module.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> + <module name="Magento_AdminAnalytics"/> +</config> diff --git a/app/code/Magento/AdminAnalytics/registration.php b/app/code/Magento/AdminAnalytics/registration.php new file mode 100644 index 000000000000..65c9955d396a --- /dev/null +++ b/app/code/Magento/AdminAnalytics/registration.php @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use \Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_AdminAnalytics', __DIR__); diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/layout/adminhtml_dashboard_index.xml b/app/code/Magento/AdminAnalytics/view/adminhtml/layout/adminhtml_dashboard_index.xml new file mode 100644 index 000000000000..3069db1ecc2b --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/layout/adminhtml_dashboard_index.xml @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <body> + <referenceContainer name="content"> + <uiComponent name="admin_usage_notification"> + <visibilityCondition name="can_view_admin_usage_notification" className="Magento\AdminAnalytics\Model\Condition\CanViewNotification"/> + </uiComponent> + <block name="tracking_notification" as="tracking_notification" template="Magento_AdminAnalytics::notification.phtml"> + <arguments> + <argument name="notification" xsi:type="object">Magento\AdminAnalytics\ViewModel\Notification</argument> + </arguments> + </block> + </referenceContainer> + </body> +</page> \ No newline at end of file diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/layout/default.xml b/app/code/Magento/AdminAnalytics/view/adminhtml/layout/default.xml new file mode 100644 index 000000000000..7e379a17c78d --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/layout/default.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" > + <body> + <referenceContainer name="header"> + <block name="tracking" as="tracking" template="Magento_AdminAnalytics::tracking.phtml" ifconfig="admin/usage/enabled"> + <arguments> + <argument name="tracking_url" xsi:type="string">//assets.adobedtm.com/launch-EN30eb7ffa064444f1b8b0368ef38fd3a9.min.js</argument> + <argument name="metadata" xsi:type="object">Magento\AdminAnalytics\ViewModel\Metadata</argument> + </arguments> + </block> + </referenceContainer> + </body> +</page> + + diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/requirejs-config.js b/app/code/Magento/AdminAnalytics/view/adminhtml/requirejs-config.js new file mode 100644 index 000000000000..136121092978 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/requirejs-config.js @@ -0,0 +1,14 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +var config = { + config: { + mixins: { + 'Magento_ReleaseNotification/js/modal/component': { + 'Magento_AdminAnalytics/js/release-notification/modal/component-mixin': true + } + } + } +}; diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/templates/notification.phtml b/app/code/Magento/AdminAnalytics/view/adminhtml/templates/notification.phtml new file mode 100644 index 000000000000..4b1f97167018 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/templates/notification.phtml @@ -0,0 +1,16 @@ + +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +?> + +<script> + define('analyticsPopupConfig', function () { + return { + analyticsVisible: <?= $block->getNotification()->isAnalyticsVisible() ? 1 : 0; ?>, + releaseVisible: <?= $block->getNotification()->isReleaseVisible() ? 1 : 0; ?>, + } + }); +</script> diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml b/app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml new file mode 100644 index 000000000000..0ea5c753c933 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +?> + +<script src="<?= $block->escapeUrl($block->getTrackingUrl()) ?>" async></script> +<script> + var adminAnalyticsMetadata = { + "version": "<?= $block->escapeJs($block->getMetadata()->getMagentoVersion()) ?>", + "user": "<?= $block->escapeJs($block->getMetadata()->getCurrentUser()) ?>", + "mode": "<?= $block->escapeJs($block->getMetadata()->getMode()) ?>" + }; +</script> diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml b/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml new file mode 100644 index 000000000000..3c35f1937783 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="provider" xsi:type="string">admin_usage_notification.admin_usage_notification_data_source</item> + </item> + <item name="label" xsi:type="string" translate="true">Admin Usage Notification</item> + <item name="template" xsi:type="string">templates/form/collapsible</item> + </argument> + <settings> + <namespace>admin_usage_notification</namespace> + <dataScope>data</dataScope> + <deps> + <dep>admin_usage_notification.admin_usage_notification_data_source</dep> + </deps> + </settings> + <dataSource name="admin_usage_notification_data_source"> + <argument name="dataProvider" xsi:type="configurableObject"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="data" xsi:type="array"> + <item name="enableLogAction" xsi:type="url" path="adminAnalytics/config/enableAdminUsage"/> + <item name="disableLogAction" xsi:type="url" path="adminAnalytics/config/disableAdminUsage"/> + + </item> + </item> + </argument> + </argument> + <argument name="data" xsi:type="array"> + <item name="js_config" xsi:type="array"> + <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item> + </item> + </argument> + <dataProvider class="Magento\AdminAnalytics\Ui\DataProvider\AdminUsageNotificationDataProvider" name="admin_usage_notification_data_source"> + <settings> + <requestFieldName>id</requestFieldName> + <primaryFieldName>entity_id</primaryFieldName> + </settings> + </dataProvider> + </dataSource> + <modal name="notification_modal_1" component="Magento_AdminAnalytics/js/modal/component"> + <settings> + <state>true</state> + <options> + <option name="modalClass" xsi:type="string">admin-usage-notification</option> + <option name="title" xsi:type="string" translate="true">Allow admin usage data collection</option> + <option name="autoOpen" xsi:type="boolean">true</option> + <option name="type" xsi:type="string">popup</option> + <option name="clickableOverlay" xsi:type="boolean">false</option> + <option name="responsive" xsi:type="boolean">true</option> + <option name="innerScroll" xsi:type="boolean">false</option> + <option name="buttons" xsi:type="array"> + <item name="0" xsi:type="array"> + <item name="text" xsi:type="string" translate="true">Don't Allow</item> + <item name="class" xsi:type="string">action-secondary</item> + <item name="actions" xsi:type="array"> + <item name="0" xsi:type="string">disableAdminUsage</item> + </item> + </item> + <item name="1" xsi:type="array"> + <item name="text" xsi:type="string" translate="true">Allow</item> + <item name="class" xsi:type="string">action-primary</item> + <item name="actions" xsi:type="array"> + <item name="0" xsi:type="string">enableAdminUsage</item> + </item> + </item> + </option> + </options> + </settings> + <fieldset name="notification_fieldset"> + <settings> + <label/> + </settings> + <container name="notification_text" template="ui/form/components/complex"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="label" xsi:type="string"/> + <item name="additionalClasses" xsi:type="string">release-notification-text</item> + <item name="text" xsi:type="string" translate="true"><![CDATA[ + <p>Help us improve Magento Admin by allowing us to collect usage data.</p> + <p>All usage data that we collect for this purpose cannot be used to individually identify you and is used only to improve the Magento Admin and related products and services.</p> + <p>You can learn more and opt out at any time by following the instructions in <a href="https://docs.magento.com/m2/ce/user_guide/stores/admin.html" target="_blank">merchant documentation</a>.</p> +]]></item> + </item> + </argument> + </container> + </fieldset> + </modal> +</form> diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js new file mode 100644 index 000000000000..bc09890d0d0b --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js @@ -0,0 +1,116 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'jquery', + 'Magento_Ui/js/modal/modal-component', + 'uiRegistry', + 'analyticsPopupConfig' +], + function (_, $, Modal, registry, analyticsPopupConfig) { + 'use strict'; + + return Modal.extend( + { + defaults: { + imports: { + enableLogAction: '${ $.provider }:data.enableLogAction', + disableLogAction: '${ $.provider }:data.disableLogAction' + }, + options: { + keyEventHandlers: { + /** + * Prevents escape key from exiting out of modal + */ + escapeKey: function () { + return; + } + } + }, + notificationWindow: null + }, + + /** + * Initializes modal on opened function + */ + initModal: function () { + this.options.opened = this.onOpened.bind(this); + this._super(); + }, + + /** + * Once the modal is opened it hides the X + */ + onOpened: function () { + $('.modal-header button.action-close').hide(); + }, + + /** + * Changes admin usage setting to yes + */ + enableAdminUsage: function () { + var data = { + 'form_key': window.FORM_KEY + }; + + $.ajax( + { + type: 'POST', + url: this.enableLogAction, + data: data, + showLoader: true + } + ).done( + function (xhr) { + if (xhr.error) { + self.onError(xhr); + } + } + ).fail(this.onError); + this.openReleasePopup(); + this.closeModal(); + }, + + /** + * Changes admin usage setting to no + */ + disableAdminUsage: function () { + var data = { + 'form_key': window.FORM_KEY + }; + + $.ajax( + { + type: 'POST', + url: this.disableLogAction, + data: data, + showLoader: true + } + ).done( + function (xhr) { + if (xhr.error) { + self.onError(xhr); + } + } + ).fail(this.onError); + this.openReleasePopup(); + this.closeModal(); + }, + + /** + * Allows admin usage popup to be shown first and then new release notification + */ + openReleasePopup: function () { + var notifiModal = registry.get('release_notification.release_notification.notification_modal_1'); + + if (analyticsPopupConfig.releaseVisible) { + notifiModal.initializeContentAfterAnalytics(); + } + } + } + ); + } +); diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/release-notification/modal/component-mixin.js b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/release-notification/modal/component-mixin.js new file mode 100644 index 000000000000..ffecd031cbb4 --- /dev/null +++ b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/release-notification/modal/component-mixin.js @@ -0,0 +1,39 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define(['jquery', 'analyticsPopupConfig'], function ($, analyticsPopupConfig) { + 'use strict'; + + var deferred = $.Deferred(), + + mixin = { + /** + * Initializes content only if its visible + */ + initializeContent: function () { + var initializeContent = this._super.bind(this); + + if (!analyticsPopupConfig.analyticsVisible) { + initializeContent(); + } else { + deferred.then(function () { + initializeContent(); + }); + } + }, + + /** + * Initializes release notification content after admin analytics + */ + initializeContentAfterAnalytics: function () { + deferred.resolve(); + } + }; + + return function (target) { + return target.extend(mixin); + }; +}); + diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php index 31b99bf71d11..39009e5c7b4e 100644 --- a/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php +++ b/app/code/Magento/AdvancedPricingImportExport/Model/Export/AdvancedPricing.php @@ -216,6 +216,7 @@ public function export() if ($entityCollection->count() == 0) { break; } + $entityCollection->clear(); $exportData = $this->getExportData(); foreach ($exportData as $dataRow) { $writer->writeRow($dataRow); diff --git a/app/code/Magento/Analytics/Model/ExportDataHandler.php b/app/code/Magento/Analytics/Model/ExportDataHandler.php index dc17a548763e..72a8e4ea0034 100644 --- a/app/code/Magento/Analytics/Model/ExportDataHandler.php +++ b/app/code/Magento/Analytics/Model/ExportDataHandler.php @@ -89,7 +89,7 @@ public function __construct( public function prepareExportData() { try { - $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); $this->prepareDirectory($tmpDirectory, $this->getTmpFilesDirRelativePath()); $this->reportWriter->write($tmpDirectory, $this->getTmpFilesDirRelativePath()); @@ -157,7 +157,9 @@ private function prepareDirectory(WriteInterface $directory, $path) private function prepareFileDirectory(WriteInterface $directory, $path) { $directory->delete($path); + // phpcs:ignore Magento2.Functions.DiscouragedFunction if (dirname($path) !== '.') { + // phpcs:ignore Magento2.Functions.DiscouragedFunction $directory->create(dirname($path)); } @@ -176,6 +178,7 @@ private function pack($source, $destination) $this->archive->pack( $source, $destination, + // phpcs:ignore Magento2.Functions.DiscouragedFunction is_dir($source) ?: false ); diff --git a/app/code/Magento/Analytics/Model/ReportXml/ModuleIterator.php b/app/code/Magento/Analytics/Model/ReportXml/ModuleIterator.php index 4d6234419740..fecbf2033c1b 100644 --- a/app/code/Magento/Analytics/Model/ReportXml/ModuleIterator.php +++ b/app/code/Magento/Analytics/Model/ReportXml/ModuleIterator.php @@ -5,7 +5,7 @@ */ namespace Magento\Analytics\Model\ReportXml; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; /** * Iterator for ReportXml modules diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php index cf00556cfe59..493fe71c9fbf 100644 --- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php @@ -13,7 +13,7 @@ use Magento\Framework\Archive; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Directory\WriteInterface; -use Magento\Framework\Filesystem\DirectoryList; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; class ExportDataHandlerTest extends \PHPUnit\Framework\TestCase @@ -137,7 +137,7 @@ public function testPrepareExportData($isArchiveSourceDirectory) $this->filesystemMock ->expects($this->once()) ->method('getDirectoryWrite') - ->with(DirectoryList::SYS_TMP) + ->with(DirectoryList::VAR_DIR) ->willReturn($this->directoryMock); $this->directoryMock ->expects($this->exactly(4)) @@ -238,7 +238,7 @@ public function testPrepareExportDataWithLocalizedException() $this->filesystemMock ->expects($this->once()) ->method('getDirectoryWrite') - ->with(DirectoryList::SYS_TMP) + ->with(DirectoryList::VAR_DIR) ->willReturn($this->directoryMock); $this->reportWriterMock ->expects($this->once()) diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php index b08d41ac829b..5288bcd306af 100644 --- a/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php +++ b/app/code/Magento/Analytics/Test/Unit/Model/ReportXml/ModuleIteratorTest.php @@ -7,7 +7,7 @@ namespace Magento\Analytics\Test\Unit\Model\ReportXml; use Magento\Analytics\Model\ReportXml\ModuleIterator; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; /** diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationSearchResults.php b/app/code/Magento/AsynchronousOperations/Model/OperationSearchResults.php new file mode 100644 index 000000000000..84f0952a836c --- /dev/null +++ b/app/code/Magento/AsynchronousOperations/Model/OperationSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\AsynchronousOperations\Model; + +use Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with bulk Operation search result. + */ +class OperationSearchResults extends SearchResults implements OperationSearchResultsInterface +{ +} diff --git a/app/code/Magento/AsynchronousOperations/etc/di.xml b/app/code/Magento/AsynchronousOperations/etc/di.xml index 42b62ff8ea37..94a4c56c19ce 100644 --- a/app/code/Magento/AsynchronousOperations/etc/di.xml +++ b/app/code/Magento/AsynchronousOperations/etc/di.xml @@ -16,7 +16,7 @@ <preference for="Magento\AsynchronousOperations\Api\Data\SummaryOperationStatusInterface" type="Magento\AsynchronousOperations\Model\OperationStatus" /> <preference for="Magento\AsynchronousOperations\Api\Data\DetailedBulkOperationsStatusInterface" type="Magento\AsynchronousOperations\Model\BulkStatus\Detailed" /> <preference for="Magento\AsynchronousOperations\Api\Data\BulkOperationsStatusInterface" type="Magento\AsynchronousOperations\Model\BulkStatus\Short" /> - <preference for="Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\AsynchronousOperations\Api\Data\OperationSearchResultsInterface" type="Magento\AsynchronousOperations\Model\OperationSearchResults" /> <preference for="Magento\AsynchronousOperations\Api\OperationRepositoryInterface" type="Magento\AsynchronousOperations\Model\OperationRepository" /> <type name="Magento\Framework\EntityManager\MetadataPool"> <arguments> diff --git a/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php index 95c67f67852d..a1547a056346 100644 --- a/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php +++ b/app/code/Magento/Authorizenet/Test/Unit/Model/DirectpostTest.php @@ -3,8 +3,19 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Authorizenet\Test\Unit\Model; +use Magento\Authorizenet\Helper\Backend\Data; +use Magento\Authorizenet\Helper\Data as HelperData; +use Magento\Authorizenet\Model\Directpost\Response; +use Magento\Authorizenet\Model\Directpost\Response\Factory as ResponseFactory; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\HTTP\ZendClient; +use Magento\Framework\HTTP\ZendClientFactory; +use Magento\Payment\Model\InfoInterface; +use Magento\Payment\Model\Method\ConfigInterface; use Magento\Sales\Api\PaymentFailuresInterface; use Magento\Framework\Simplexml\Element; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; @@ -13,118 +24,118 @@ use Magento\Authorizenet\Model\Request; use Magento\Authorizenet\Model\Directpost\Request\Factory; use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Payment; +use Magento\Sales\Model\Order\Payment\Transaction; use Magento\Sales\Model\Order\Payment\Transaction\Repository as TransactionRepository; +use PHPUnit\Framework\MockObject_MockBuilder; +use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject; +use ReflectionClass; /** * Class DirectpostTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class DirectpostTest extends \PHPUnit\Framework\TestCase +class DirectpostTest extends TestCase { const TOTAL_AMOUNT = 100.02; const INVOICE_NUM = '00000001'; const TRANSACTION_ID = '41a23x34fd124'; /** - * @var \Magento\Authorizenet\Model\Directpost + * @var Directpost */ protected $directpost; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ScopeConfigInterface|PHPUnit_Framework_MockObject_MockObject */ protected $scopeConfigMock; /** - * @var \Magento\Payment\Model\InfoInterface|\PHPUnit_Framework_MockObject_MockObject + * @var InfoInterface|PHPUnit_Framework_MockObject_MockObject */ protected $paymentMock; /** - * @var \Magento\Authorizenet\Helper\Data|\PHPUnit_Framework_MockObject_MockObject + * @var HelperData|PHPUnit_Framework_MockObject_MockObject */ protected $dataHelperMock; /** - * @var \Magento\Authorizenet\Model\Directpost\Response\Factory|\PHPUnit_Framework_MockObject_MockObject + * @var ResponseFactory|PHPUnit_Framework_MockObject_MockObject */ protected $responseFactoryMock; /** - * @var TransactionRepository|\PHPUnit_Framework_MockObject_MockObject + * @var TransactionRepository|PHPUnit_Framework_MockObject_MockObject */ protected $transactionRepositoryMock; /** - * @var \Magento\Authorizenet\Model\Directpost\Response|\PHPUnit_Framework_MockObject_MockObject + * @var Response|PHPUnit_Framework_MockObject_MockObject */ protected $responseMock; /** - * @var TransactionService|\PHPUnit_Framework_MockObject_MockObject + * @var TransactionService|PHPUnit_Framework_MockObject_MockObject */ protected $transactionServiceMock; /** - * @var \Magento\Framework\HTTP\ZendClient|\PHPUnit_Framework_MockObject_MockObject + * @var ZendClient|PHPUnit_Framework_MockObject_MockObject */ protected $httpClientMock; /** - * @var \Magento\Authorizenet\Model\Directpost\Request\Factory|\PHPUnit_Framework_MockObject_MockObject + * @var Factory|PHPUnit_Framework_MockObject_MockObject */ protected $requestFactory; /** - * @var PaymentFailuresInterface|\PHPUnit_Framework_MockObject_MockObject + * @var PaymentFailuresInterface|PHPUnit_Framework_MockObject_MockObject */ private $paymentFailures; + /** + * @var ZendClientFactory|PHPUnit_Framework_MockObject_MockObject + */ + private $httpClientFactoryMock; + /** * @inheritdoc */ protected function setUp() { - $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) - ->getMock(); - $this->paymentMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class) - ->disableOriginalConstructor() - ->setMethods([ - 'getOrder', 'getId', 'setAdditionalInformation', 'getAdditionalInformation', - 'setIsTransactionDenied', 'setIsTransactionClosed', 'decrypt', 'getCcLast4', - 'getParentTransactionId', 'getPoNumber' - ]) - ->getMock(); - $this->dataHelperMock = $this->getMockBuilder(\Magento\Authorizenet\Helper\Data::class) - ->disableOriginalConstructor() - ->getMock(); - + $this->initPaymentMock(); $this->initResponseFactoryMock(); + $this->initHttpClientMock(); - $this->transactionRepositoryMock = $this->getMockBuilder( - \Magento\Sales\Model\Order\Payment\Transaction\Repository::class - ) + $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)->getMock(); + $this->dataHelperMock = $this->getMockBuilder(HelperData::class)->disableOriginalConstructor()->getMock(); + $this->transactionRepositoryMock = $this->getMockBuilder(TransactionRepository::class) ->disableOriginalConstructor() ->setMethods(['getByTransactionId']) ->getMock(); - - $this->transactionServiceMock = $this->getMockBuilder(\Magento\Authorizenet\Model\TransactionService::class) + $this->transactionServiceMock = $this->getMockBuilder(TransactionService::class) ->disableOriginalConstructor() ->setMethods(['getTransactionDetails']) ->getMock(); - - $this->paymentFailures = $this->getMockBuilder( - PaymentFailuresInterface::class - ) + $this->paymentFailures = $this->getMockBuilder(PaymentFailuresInterface::class) ->disableOriginalConstructor() ->getMock(); - - $this->requestFactory = $this->getRequestFactoryMock(); - $httpClientFactoryMock = $this->getHttpClientFactoryMock(); + $this->requestFactory = $this->getMockBuilder(Factory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->httpClientFactoryMock = $this->getMockBuilder(ZendClientFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); $helper = new ObjectManagerHelper($this); $this->directpost = $helper->getObject( - \Magento\Authorizenet\Model\Directpost::class, + Directpost::class, [ 'scopeConfig' => $this->scopeConfigMock, 'dataHelper' => $this->dataHelperMock, @@ -132,18 +143,97 @@ protected function setUp() 'responseFactory' => $this->responseFactoryMock, 'transactionRepository' => $this->transactionRepositoryMock, 'transactionService' => $this->transactionServiceMock, - 'httpClientFactory' => $httpClientFactoryMock, + 'httpClientFactory' => $this->httpClientFactoryMock, 'paymentFailures' => $this->paymentFailures, ] ); } + /** + * Create mock for response factory + * + * @return void + */ + private function initResponseFactoryMock() + { + $this->responseFactoryMock = $this->getMockBuilder(ResponseFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $this->responseMock = $this->getMockBuilder(Response::class) + ->setMethods( + [ + 'isValidHash', + 'getXTransId', + 'getXResponseCode', + 'getXResponseReasonCode', + 'getXResponseReasonText', + 'getXAmount', + 'setXResponseCode', + 'setXResponseReasonCode', + 'setXAvsCode', + 'setXResponseReasonText', + 'setXTransId', + 'setXInvoiceNum', + 'setXAmount', + 'setXMethod', + 'setXType', + 'setData', + 'getData', + 'setXAccountNumber', + '__wakeup' + ] + ) + ->disableOriginalConstructor() + ->getMock(); + + $this->responseFactoryMock->expects($this->any())->method('create')->willReturn($this->responseMock); + } + + /** + * Create mock for payment + * + * @return void + */ + private function initPaymentMock() + { + $this->paymentMock = $this->getMockBuilder(Payment::class) + ->disableOriginalConstructor() + ->setMethods( + [ + 'getOrder', + 'setAmount', + 'setAnetTransType', + 'setXTransId', + 'getId', + 'setAdditionalInformation', + 'getAdditionalInformation', + 'setIsTransactionDenied', + 'setIsTransactionClosed', + 'decrypt', + 'getCcLast4', + 'getParentTransactionId', + 'getPoNumber' + ] + ) + ->getMock(); + } + + /** + * Create a mock for http client + * + * @return void + */ + private function initHttpClientMock() + { + $this->httpClientMock = $this->getMockBuilder(ZendClient::class) + ->disableOriginalConstructor() + ->setMethods(['request', 'getBody', '__wakeup']) + ->getMock(); + } + public function testGetConfigInterface() { - $this->assertInstanceOf( - \Magento\Payment\Model\Method\ConfigInterface::class, - $this->directpost->getConfigInterface() - ); + $this->assertInstanceOf(ConfigInterface::class, $this->directpost->getConfigInterface()); } public function testGetConfigValue() @@ -162,7 +252,7 @@ public function testSetDataHelper() $storeId = 'store-id'; $expectedResult = 'relay-url'; - $helperDataMock = $this->getMockBuilder(\Magento\Authorizenet\Helper\Backend\Data::class) + $helperDataMock = $this->getMockBuilder(Data::class) ->disableOriginalConstructor() ->getMock(); @@ -179,7 +269,7 @@ public function testAuthorize() { $paymentAction = 'some_action'; - $this->scopeConfigMock->expects($this->any()) + $this->scopeConfigMock->expects($this->once()) ->method('getValue') ->with('payment/authorizenet_directpost/payment_action', 'store', null) ->willReturn($paymentAction); @@ -190,11 +280,143 @@ public function testAuthorize() $this->directpost->authorize($this->paymentMock, 10); } + /** + * @dataProvider dataProviderCaptureWithInvalidAmount + * @expectedExceptionMessage Invalid amount for capture. + * @expectedException \Magento\Framework\Exception\LocalizedException + * + * @param int $invalidAmount + */ + public function testCaptureWithInvalidAmount($invalidAmount) + { + $this->directpost->capture($this->paymentMock, $invalidAmount); + } + + /** + * @return array + */ + public function dataProviderCaptureWithInvalidAmount() + { + return [ + [0], + [0.000], + [-1.000], + [-1], + [null], + ]; + } + + /** + * Test capture has parent transaction id. + * + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testCaptureHasParentTransactionId() + { + $amount = 10; + + $this->paymentMock->expects($this->once())->method('setAmount')->with($amount); + $this->paymentMock->expects($this->exactly(2))->method('getParentTransactionId')->willReturn(1); + $this->paymentMock->expects($this->once())->method('setAnetTransType')->willReturn('PRIOR_AUTH_CAPTURE'); + + $this->paymentMock->expects($this->once())->method('getId')->willReturn(1); + $orderMock = $this->getOrderMock(); + $orderMock->expects($this->once())->method('getId')->willReturn(1); + $this->paymentMock->expects($this->once())->method('getOrder')->willReturn($orderMock); + + $transactionMock = $this->getMockBuilder(Transaction::class)->disableOriginalConstructor()->getMock(); + $this->transactionRepositoryMock->expects($this->once()) + ->method('getByTransactionId') + ->with(1, 1, 1) + ->willReturn($transactionMock); + + $this->paymentMock->expects($this->once())->method('setXTransId'); + $this->responseMock->expects($this->once())->method('getData')->willReturn([1]); + + $this->directpost->capture($this->paymentMock, 10); + } + + /** + * @@expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testCaptureWithoutParentTransactionId() + { + $amount = 10; + + $this->paymentMock->expects($this->once())->method('setAmount')->with($amount); + $this->paymentMock->expects($this->once())->method('getParentTransactionId')->willReturn(null); + $this->responseMock->expects($this->once())->method('getData')->willReturn([1]); + + $this->directpost->capture($this->paymentMock, 10); + } + + public function testCaptureWithoutParentTransactionIdWithoutData() + { + $amount = 10; + + $this->paymentMock->expects($this->once())->method('setAmount')->with($amount); + $this->paymentMock->expects($this->exactly(2))->method('getParentTransactionId')->willReturn(null); + $this->responseMock->expects($this->once())->method('getData')->willReturn([]); + + $this->paymentMock->expects($this->once()) + ->method('setIsTransactionClosed') + ->with(0) + ->willReturnSelf(); + + $this->httpClientFactoryMock->expects($this->once())->method('create')->willReturn($this->httpClientMock); + $this->httpClientMock->expects($this->once())->method('request')->willReturnSelf(); + + $this->buildRequestTest(); + $this->postRequestTest(); + + $this->directpost->capture($this->paymentMock, 10); + } + + private function buildRequestTest() + { + $orderMock = $this->getOrderMock(); + $orderMock->expects($this->once())->method('getStoreId')->willReturn(1); + $orderMock->expects($this->exactly(2))->method('getIncrementId')->willReturn(self::INVOICE_NUM); + $this->paymentMock->expects($this->once())->method('getOrder')->willReturn($orderMock); + + $this->addRequestMockToRequestFactoryMock(); + } + + private function postRequestTest() + { + $this->httpClientFactoryMock->expects($this->once())->method('create')->willReturn($this->httpClientMock); + $this->httpClientMock->expects($this->once())->method('request')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXResponseCode')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXResponseReasonCode')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXResponseReasonText')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXAvsCode')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXTransId')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXInvoiceNum')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXAmount')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXMethod')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setXType')->willReturnSelf(); + $this->responseMock->expects($this->once())->method('setData')->willReturnSelf(); + + $response = $this->getRefundResponseBody( + Directpost::RESPONSE_CODE_APPROVED, + Directpost::RESPONSE_REASON_CODE_APPROVED, + 'Successful' + ); + $this->httpClientMock->expects($this->once())->method('getBody')->willReturn($response); + $this->responseMock->expects($this->once()) + ->method('getXResponseCode') + ->willReturn(Directpost::RESPONSE_CODE_APPROVED); + $this->responseMock->expects($this->once()) + ->method('getXResponseReasonCode') + ->willReturn(Directpost::RESPONSE_REASON_CODE_APPROVED); + $this->dataHelperMock->expects($this->never())->method('wrapGatewayError'); + } + public function testGetCgiUrl() { $url = 'cgi/url'; - $this->scopeConfigMock->expects($this->any()) + $this->scopeConfigMock->expects($this->once()) ->method('getValue') ->with('payment/authorizenet_directpost/cgi_url', 'store', null) ->willReturn($url); @@ -204,7 +426,7 @@ public function testGetCgiUrl() public function testGetCgiUrlWithEmptyConfigValue() { - $this->scopeConfigMock->expects($this->any()) + $this->scopeConfigMock->expects($this->once()) ->method('getValue') ->with('payment/authorizenet_directpost/cgi_url', 'store', null) ->willReturn(null); @@ -218,7 +440,7 @@ public function testGetRelayUrl() $url = 'relay/url'; $this->directpost->setData('store', $storeId); - $this->dataHelperMock->expects($this->any()) + $this->dataHelperMock->expects($this->exactly(2)) ->method('getRelayUrl') ->with($storeId) ->willReturn($url); @@ -268,7 +490,7 @@ public function testValidateResponseFailure() */ protected function prepareTestValidateResponse($transMd5, $login, $isValidHash) { - $this->scopeConfigMock->expects($this->any()) + $this->scopeConfigMock->expects($this->exactly(2)) ->method('getValue') ->willReturnMap( [ @@ -276,7 +498,7 @@ protected function prepareTestValidateResponse($transMd5, $login, $isValidHash) ['payment/authorizenet_directpost/login', 'store', null, $login] ] ); - $this->responseMock->expects($this->any()) + $this->responseMock->expects($this->exactly(1)) ->method('isValidHash') ->with($transMd5, $login) ->willReturn($isValidHash); @@ -328,6 +550,20 @@ public function checkResponseCodeSuccessDataProvider() ]; } + /** + * Checks response failures behaviour. + * + * @return void + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testCheckResponseCodeFailureDefault() + { + $responseCode = 999999; + $this->responseMock->expects($this->once())->method('getXResponseCode')->willReturn($responseCode); + + $this->directpost->checkResponseCode(); + } + /** * Checks response failures behaviour. * @@ -338,34 +574,24 @@ public function checkResponseCodeSuccessDataProvider() * @expectedException \Magento\Framework\Exception\LocalizedException * @dataProvider checkResponseCodeFailureDataProvider */ - public function testCheckResponseCodeFailure(int $responseCode, int $failuresHandlerCalls): void + public function testCheckResponseCodeFailureDeclinedOrError(int $responseCode, int $failuresHandlerCalls): void { $reasonText = 'reason text'; $this->responseMock->expects($this->once()) ->method('getXResponseCode') ->willReturn($responseCode); - $this->responseMock->expects($this->any()) - ->method('getXResponseReasonText') - ->willReturn($reasonText); - $this->dataHelperMock->expects($this->any()) + $this->responseMock->expects($this->once())->method('getXResponseReasonText')->willReturn($reasonText); + $this->dataHelperMock->expects($this->once()) ->method('wrapGatewayError') ->with($reasonText) ->willReturn(__('Gateway error: %1', $reasonText)); - $orderMock = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->getMock(); - - $orderMock->expects($this->exactly($failuresHandlerCalls)) - ->method('getQuoteId') - ->willReturn(1); - - $this->paymentFailures->expects($this->exactly($failuresHandlerCalls)) - ->method('handle') - ->with(1); + $this->paymentFailures->expects($this->exactly($failuresHandlerCalls))->method('handle')->with(1); + $orderMock = $this->getOrderMock($failuresHandlerCalls); - $reflection = new \ReflectionClass($this->directpost); + $orderMock->expects($this->exactly($failuresHandlerCalls))->method('getQuoteId')->willReturn(1); + $reflection = new ReflectionClass($this->directpost); $order = $reflection->getProperty('order'); $order->setAccessible(true); $order->setValue($this->directpost, $orderMock); @@ -381,7 +607,6 @@ public function checkResponseCodeFailureDataProvider(): array return [ ['responseCode' => Directpost::RESPONSE_CODE_DECLINED, 1], ['responseCode' => Directpost::RESPONSE_CODE_ERROR, 1], - ['responseCode' => 999999, 0], ]; } @@ -417,7 +642,7 @@ public function testCanCapture($isGatewayActionsLocked, $canCapture) { $this->directpost->setData('info_instance', $this->paymentMock); - $this->paymentMock->expects($this->any()) + $this->paymentMock->expects($this->once()) ->method('getAdditionalInformation') ->with(Directpost::GATEWAY_ACTIONS_LOCKED_STATE_KEY) ->willReturn($isGatewayActionsLocked); @@ -452,30 +677,16 @@ public function testFetchVoidedTransactionInfo($transactionId, $resultStatus, $r $paymentId = 36; $orderId = 36; - $this->paymentMock->expects(static::once()) - ->method('getId') - ->willReturn($paymentId); - - $orderMock = $this->getMockBuilder(\Magento\Sales\Model\Order::class) - ->disableOriginalConstructor() - ->setMethods(['getId', '__wakeup']) - ->getMock(); - $orderMock->expects(static::once()) - ->method('getId') - ->willReturn($orderId); + $this->paymentMock->expects($this->once())->method('getId')->willReturn($paymentId); - $this->paymentMock->expects(static::once()) - ->method('getOrder') - ->willReturn($orderMock); - - $transactionMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment\Transaction::class) - ->disableOriginalConstructor() - ->getMock(); - $this->transactionRepositoryMock->expects(static::once()) + $orderMock = $this->getOrderMock(); + $orderMock->expects($this->once())->method('getId')->willReturn($orderId); + $this->paymentMock->expects($this->once())->method('getOrder')->willReturn($orderMock); + $transactionMock = $this->getMockBuilder(Transaction::class)->disableOriginalConstructor()->getMock(); + $this->transactionRepositoryMock->expects($this->once()) ->method('getByTransactionId') ->with($transactionId, $paymentId, $orderId) ->willReturn($transactionMock); - $document = $this->getTransactionXmlDocument( $transactionId, TransactionService::PAYMENT_UPDATE_STATUS_CODE_SUCCESS, @@ -483,20 +694,15 @@ public function testFetchVoidedTransactionInfo($transactionId, $resultStatus, $r $responseStatus, $responseCode ); - $this->transactionServiceMock->expects(static::once()) + $this->transactionServiceMock->expects($this->once()) ->method('getTransactionDetails') ->with($this->directpost, $transactionId) ->willReturn($document); // transaction should be closed - $this->paymentMock->expects(static::once()) - ->method('setIsTransactionDenied') - ->with(true); - $this->paymentMock->expects(static::once()) - ->method('setIsTransactionClosed') - ->with(true); - $transactionMock->expects(static::once()) - ->method('close'); + $this->paymentMock->expects($this->once())->method('setIsTransactionDenied')->with(true); + $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(true); + $transactionMock->expects($this->once())->method('close'); $this->directpost->fetchTransactionInfo($this->paymentMock, $transactionId); } @@ -509,60 +715,41 @@ public function testSuccessRefund() { $card = 1111; - $this->paymentMock->expects(static::exactly(2)) - ->method('getCcLast4') - ->willReturn($card); - $this->paymentMock->expects(static::once()) - ->method('decrypt') - ->willReturn($card); - $this->paymentMock->expects(static::exactly(3)) + $this->paymentMock->expects($this->exactly(1))->method('getCcLast4')->willReturn($card); + $this->paymentMock->expects($this->once())->method('decrypt')->willReturn($card); + $this->paymentMock->expects($this->exactly(3)) ->method('getParentTransactionId') ->willReturn(self::TRANSACTION_ID . '-capture'); - $this->paymentMock->expects(static::once()) - ->method('getPoNumber') - ->willReturn(self::INVOICE_NUM); - $this->paymentMock->expects(static::once()) + $this->paymentMock->expects($this->once())->method('getPoNumber')->willReturn(self::INVOICE_NUM); + $this->paymentMock->expects($this->once()) ->method('setIsTransactionClosed') ->with(true) ->willReturnSelf(); + $this->addRequestMockToRequestFactoryMock(); + $orderMock = $this->getOrderMock(); - $this->paymentMock->expects(static::exactly(2)) - ->method('getOrder') - ->willReturn($orderMock); + $orderMock->expects($this->once())->method('getId')->willReturn(1); + $orderMock->expects($this->exactly(2))->method('getIncrementId')->willReturn(self::INVOICE_NUM); + $orderMock->expects($this->once())->method('getStoreId')->willReturn(1); + + $this->paymentMock->expects($this->exactly(2))->method('getOrder')->willReturn($orderMock); - $transactionMock = $this->getMockBuilder(Order\Payment\Transaction::class) + $transactionMock = $this->getMockBuilder(Transaction::class) ->disableOriginalConstructor() ->setMethods(['getAdditionalInformation']) ->getMock(); - $transactionMock->expects(static::once()) + $transactionMock->expects($this->once()) ->method('getAdditionalInformation') ->with(Directpost::REAL_TRANSACTION_ID_KEY) ->willReturn(self::TRANSACTION_ID); - $this->transactionRepositoryMock->expects(static::once()) + $this->transactionRepositoryMock->expects($this->once()) ->method('getByTransactionId') ->willReturn($transactionMock); - $response = $this->getRefundResponseBody( - Directpost::RESPONSE_CODE_APPROVED, - Directpost::RESPONSE_REASON_CODE_APPROVED, - 'Successful' - ); - $this->httpClientMock->expects(static::once()) - ->method('getBody') - ->willReturn($response); - - $this->responseMock->expects(static::once()) - ->method('getXResponseCode') - ->willReturn(Directpost::RESPONSE_CODE_APPROVED); - $this->responseMock->expects(static::once()) - ->method('getXResponseReasonCode') - ->willReturn(Directpost::RESPONSE_REASON_CODE_APPROVED); - - $this->dataHelperMock->expects(static::never()) - ->method('wrapGatewayError'); + $this->postRequestTest(); $this->directpost->refund($this->paymentMock, self::TOTAL_AMOUNT); } @@ -583,65 +770,6 @@ public function dataProviderTransaction() ]; } - /** - * Create mock for response factory - * @return void - */ - private function initResponseFactoryMock() - { - $this->responseFactoryMock = $this->getMockBuilder( - \Magento\Authorizenet\Model\Directpost\Response\Factory::class - )->disableOriginalConstructor()->getMock(); - $this->responseMock = $this->getMockBuilder(\Magento\Authorizenet\Model\Directpost\Response::class) - ->setMethods( - [ - 'isValidHash', - 'getXTransId', 'getXResponseCode', 'getXResponseReasonCode', 'getXResponseReasonText', 'getXAmount', - 'setXResponseCode', 'setXResponseReasonCode', 'setXAvsCode', 'setXResponseReasonText', - 'setXTransId', 'setXInvoiceNum', 'setXAmount', 'setXMethod', 'setXType', 'setData', - 'setXAccountNumber', - '__wakeup' - ] - ) - ->disableOriginalConstructor() - ->getMock(); - - $this->responseMock->expects(static::any()) - ->method('setXResponseCode') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXResponseReasonCode') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXResponseReasonText') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXAvsCode') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXTransId') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXInvoiceNum') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXAmount') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXMethod') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setXType') - ->willReturnSelf(); - $this->responseMock->expects(static::any()) - ->method('setData') - ->willReturnSelf(); - - $this->responseFactoryMock->expects($this->any()) - ->method('create') - ->willReturn($this->responseMock); - } - /** * Get transaction data * @param $transactionId @@ -694,80 +822,40 @@ private function getTransactionXmlDocument( /** * Get mock for authorize.net request factory - * @return \PHPUnit\Framework\MockObject_MockBuilder */ - private function getRequestFactoryMock() + private function addRequestMockToRequestFactoryMock() { - $requestFactory = $this->getMockBuilder(Factory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); $request = $this->getMockBuilder(Request::class) ->disableOriginalConstructor() ->setMethods(['__wakeup']) ->getMock(); - $requestFactory->expects(static::any()) + $this->requestFactory->expects($this->once()) ->method('create') ->willReturn($request); - return $requestFactory; } /** * Get mock for order - * @return \PHPUnit_Framework_MockObject_MockObject + * @return PHPUnit_Framework_MockObject_MockObject */ private function getOrderMock() { - $orderMock = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->setMethods([ - 'getId', 'getIncrementId', 'getStoreId', 'getBillingAddress', 'getShippingAddress', - 'getBaseCurrencyCode', 'getBaseTaxAmount', '__wakeup' - ]) - ->getMock(); - - $orderMock->expects(static::once()) - ->method('getId') - ->willReturn(1); - - $orderMock->expects(static::exactly(2)) - ->method('getIncrementId') - ->willReturn(self::INVOICE_NUM); - - $orderMock->expects(static::once()) - ->method('getStoreId') - ->willReturn(1); - - $orderMock->expects(static::once()) - ->method('getBaseCurrencyCode') - ->willReturn('USD'); - return $orderMock; - } - - /** - * Create and return mock for http client factory - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getHttpClientFactoryMock() - { - $this->httpClientMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClient::class) + return $this->getMockBuilder(Order::class) ->disableOriginalConstructor() - ->setMethods(['request', 'getBody', '__wakeup']) - ->getMock(); - - $this->httpClientMock->expects(static::any()) - ->method('request') - ->willReturnSelf(); - - $httpClientFactoryMock = $this->getMockBuilder(\Magento\Framework\HTTP\ZendClientFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) + ->setMethods( + [ + 'getId', + 'getQuoteId', + 'getIncrementId', + 'getStoreId', + 'getBillingAddress', + 'getShippingAddress', + 'getBaseCurrencyCode', + 'getBaseTaxAmount', + '__wakeup' + ] + ) ->getMock(); - - $httpClientFactoryMock->expects(static::any()) - ->method('create') - ->willReturn($this->httpClientMock); - return $httpClientFactoryMock; } /** @@ -788,7 +876,9 @@ private function getRefundResponseBody($code, $reasonCode, $reasonText) $result[9] = self::TOTAL_AMOUNT; // XAmount $result[10] = Directpost::REQUEST_METHOD_CC; // XMethod $result[11] = Directpost::REQUEST_TYPE_CREDIT; // XType + // @codingStandardsIgnoreStart $result[37] = md5(self::TRANSACTION_ID); // x_MD5_Hash + // @codingStandardsIgnoreEnd $result[50] = '48329483921'; // setXAccountNumber return implode(Directpost::RESPONSE_DELIM_CHAR, $result); } diff --git a/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js b/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js index e43341ca2b33..eb162034bc04 100644 --- a/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js +++ b/app/code/Magento/Authorizenet/view/adminhtml/web/js/direct-post.js @@ -3,18 +3,11 @@ * See COPYING.txt for license details. */ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define([ - 'jquery', - 'mage/backend/validation', - 'prototype' - ], factory); - } else { - factory(jQuery); - } -}(function (jQuery) { - +define([ + 'jquery', + 'mage/backend/validation', + 'prototype' +], function (jQuery) { window.directPost = Class.create(); directPost.prototype = { initialize: function (methodCode, iframeId, controller, orderSaveUrl, cgiUrl, nativeAction) { @@ -349,4 +342,4 @@ } } }; -})); +}); diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/ConfigTest.php b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/ConfigTest.php index da2b953d843b..646ad4f195b9 100644 --- a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/ConfigTest.php +++ b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/ConfigTest.php @@ -81,6 +81,9 @@ public function testGetSolutionIdSandbox($environment, $expectedSolution) $this->assertEquals($expectedSolution, $this->model->getSolutionId(123)); } + /** + * @return array + */ public function configMapProvider() { return [ @@ -97,6 +100,10 @@ public function configMapProvider() ['getTransactionInfoSyncKeys', 'transactionSyncKeys', 'a,b,c', ['a', 'b', 'c']], ]; } + + /** + * @return array + */ public function environmentUrlProvider() { return [ @@ -105,6 +112,9 @@ public function environmentUrlProvider() ]; } + /** + * @return array + */ public function environmentSolutionProvider() { return [ diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/AddressDataBuilderTest.php b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/AddressDataBuilderTest.php index 6ddb30a64af9..84c2f19040e1 100644 --- a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/AddressDataBuilderTest.php +++ b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Request/AddressDataBuilderTest.php @@ -108,6 +108,10 @@ public function testBuildWithBothAddresses() $this->assertEquals('abc', $result['transactionRequest']['customerIP']); } + /** + * @param $responseData + * @param $addressPrefix + */ private function validateAddressData($responseData, $addressPrefix) { foreach ($this->mockAddressData as $fieldValue => $field) { @@ -115,6 +119,11 @@ private function validateAddressData($responseData, $addressPrefix) } } + /** + * @param $prefix + * + * @return \PHPUnit\Framework\MockObject\MockObject + */ private function createAddressMock($prefix) { $addressAdapterMock = $this->createMock(AddressAdapterInterface::class); diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Response/PaymentReviewStatusHandlerTest.php b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Response/PaymentReviewStatusHandlerTest.php index a52a1b317fbb..197dc209ece6 100644 --- a/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Response/PaymentReviewStatusHandlerTest.php +++ b/app/code/Magento/AuthorizenetAcceptjs/Test/Unit/Gateway/Response/PaymentReviewStatusHandlerTest.php @@ -112,6 +112,9 @@ public function testDoesNothingWhenPending(string $status) $this->handler->handle($subject, $response); } + /** + * @return array + */ public function pendingTransactionStatusesProvider() { return [ @@ -120,6 +123,9 @@ public function pendingTransactionStatusesProvider() ]; } + /** + * @return array + */ public function declinedTransactionStatusesProvider() { return [ diff --git a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php index bca7f13b0cee..0a73430aad0f 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php +++ b/app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php @@ -19,21 +19,21 @@ class Grid extends \Magento\Backend\Block\Dashboard\Grid protected $_collectionFactory; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, array $data = [] ) { diff --git a/app/code/Magento/Backend/Block/Dashboard/Sales.php b/app/code/Magento/Backend/Block/Dashboard/Sales.php index 3455ff087a79..b38833946010 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Sales.php +++ b/app/code/Magento/Backend/Block/Dashboard/Sales.php @@ -18,20 +18,20 @@ class Sales extends \Magento\Backend\Block\Dashboard\Bar protected $_template = 'Magento_Backend::dashboard/salebar.phtml'; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_moduleManager = $moduleManager; diff --git a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php index 7dc897a62a32..a0b1571bd17b 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php +++ b/app/code/Magento/Backend/Block/Dashboard/Tab/Products/Ordered.php @@ -19,21 +19,21 @@ class Ordered extends \Magento\Backend\Block\Dashboard\Grid protected $_collectionFactory; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Sales\Model\ResourceModel\Report\Bestsellers\CollectionFactory $collectionFactory, array $data = [] ) { diff --git a/app/code/Magento/Backend/Block/Dashboard/Totals.php b/app/code/Magento/Backend/Block/Dashboard/Totals.php index e57a6249af47..20bcfebe31a8 100644 --- a/app/code/Magento/Backend/Block/Dashboard/Totals.php +++ b/app/code/Magento/Backend/Block/Dashboard/Totals.php @@ -22,20 +22,20 @@ class Totals extends \Magento\Backend\Block\Dashboard\Bar protected $_template = 'Magento_Backend::dashboard/totalbar.phtml'; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Reports\Model\ResourceModel\Order\CollectionFactory $collectionFactory, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_moduleManager = $moduleManager; diff --git a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php index 891b2a3ada72..284cb01148f6 100644 --- a/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php +++ b/app/code/Magento/Backend/Block/Widget/Grid/Massaction/AbstractMassaction.php @@ -3,26 +3,35 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Backend\Block\Widget\Grid\Massaction; +use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget; +use Magento\Backend\Block\Widget\Grid\Column; +use Magento\Backend\Block\Widget\Grid\ColumnSet; use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\DataObject; +use Magento\Framework\DB\Select; +use Magento\Framework\Json\EncoderInterface; +use Magento\Quote\Model\Quote; /** * Grid widget massaction block * + * phpcs:disable Magento2.Classes.AbstractApi * @api - * @method \Magento\Quote\Model\Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors + * @method Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors * @method boolean getHideFormElement() * @deprecated 100.2.0 in favour of UI component implementation * @since 100.0.2 */ -abstract class AbstractMassaction extends \Magento\Backend\Block\Widget +abstract class AbstractMassaction extends Widget { /** - * @var \Magento\Framework\Json\EncoderInterface + * @var EncoderInterface */ protected $_jsonEncoder; @@ -39,13 +48,13 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget protected $_template = 'Magento_Backend::widget/grid/massaction.phtml'; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Json\EncoderInterface $jsonEncoder + * @param Context $context + * @param EncoderInterface $jsonEncoder * @param array $data */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Json\EncoderInterface $jsonEncoder, + Context $context, + EncoderInterface $jsonEncoder, array $data = [] ) { $this->_jsonEncoder = $jsonEncoder; @@ -122,11 +131,7 @@ private function isVisible(DataObject $item) */ public function getItem($itemId) { - if (isset($this->_items[$itemId])) { - return $this->_items[$itemId]; - } - - return null; + return $this->_items[$itemId] ?? null; } /** @@ -161,7 +166,7 @@ public function getItemsJson() */ public function getCount() { - return sizeof($this->_items); + return count($this->_items); } /** @@ -288,11 +293,11 @@ public function getGridIdsJson() if ($collection instanceof AbstractDb) { $idsSelect = clone $collection->getSelect(); - $idsSelect->reset(\Magento\Framework\DB\Select::ORDER); - $idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_COUNT); - $idsSelect->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET); - $idsSelect->reset(\Magento\Framework\DB\Select::COLUMNS); - $idsSelect->columns($this->getMassactionIdField(), 'main_table'); + $idsSelect->reset(Select::ORDER); + $idsSelect->reset(Select::LIMIT_COUNT); + $idsSelect->reset(Select::LIMIT_OFFSET); + $idsSelect->reset(Select::COLUMNS); + $idsSelect->columns($this->getMassactionIdField()); $idList = $collection->getConnection()->fetchCol($idsSelect); } else { $idList = $collection->setPageSize(0)->getColumnValues($this->getMassactionIdField()); @@ -358,7 +363,7 @@ public function prepareMassactionColumn() { $columnId = 'massaction'; $massactionColumn = $this->getLayout()->createBlock( - \Magento\Backend\Block\Widget\Grid\Column::class + Column::class )->setData( [ 'index' => $this->getMassactionIdField(), @@ -378,7 +383,7 @@ public function prepareMassactionColumn() $gridBlock = $this->getParentBlock(); $massactionColumn->setSelected($this->getSelected())->setGrid($gridBlock)->setId($columnId); - /** @var $columnSetBlock \Magento\Backend\Block\Widget\Grid\ColumnSet */ + /** @var $columnSetBlock ColumnSet */ $columnSetBlock = $gridBlock->getColumnSet(); $childNames = $columnSetBlock->getChildNames(); $siblingElement = count($childNames) ? current($childNames) : 0; diff --git a/app/code/Magento/Backend/Model/Locale/Resolver.php b/app/code/Magento/Backend/Model/Locale/Resolver.php index b9be471cd599..9086e2af83e2 100644 --- a/app/code/Magento/Backend/Model/Locale/Resolver.php +++ b/app/code/Magento/Backend/Model/Locale/Resolver.php @@ -7,8 +7,10 @@ /** * Backend locale model + * * @api * @since 100.0.2 + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class Resolver extends \Magento\Framework\Locale\Resolver { @@ -40,7 +42,7 @@ class Resolver extends \Magento\Framework\Locale\Resolver * @param Manager $localeManager * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Validator\Locale $localeValidator - * @param null $locale + * @param string|null $locale * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -76,7 +78,7 @@ public function setLocale($locale = null) $sessionLocale = $this->_session->getSessionLocale(); $userLocale = $this->_localeManager->getUserInterfaceLocale(); - $localeCodes = array_filter([$forceLocale, $sessionLocale, $userLocale]); + $localeCodes = array_filter([$forceLocale, $locale, $sessionLocale, $userLocale]); if (count($localeCodes)) { $locale = reset($localeCodes); diff --git a/app/code/Magento/Backend/Model/Menu/Item.php b/app/code/Magento/Backend/Model/Menu/Item.php index d535e9c84df2..67c6216cbbc0 100644 --- a/app/code/Magento/Backend/Model/Menu/Item.php +++ b/app/code/Magento/Backend/Model/Menu/Item.php @@ -145,7 +145,7 @@ class Item protected $_moduleList; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $_moduleManager; @@ -163,7 +163,7 @@ class Item * @param \Magento\Backend\Model\MenuFactory $menuFactory * @param \Magento\Backend\Model\UrlInterface $urlModel * @param \Magento\Framework\Module\ModuleListInterface $moduleList - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( @@ -173,7 +173,7 @@ public function __construct( \Magento\Backend\Model\MenuFactory $menuFactory, \Magento\Backend\Model\UrlInterface $urlModel, \Magento\Framework\Module\ModuleListInterface $moduleList, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_validator = $validator; diff --git a/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml b/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml new file mode 100644 index 000000000000..a8db2f94d69a --- /dev/null +++ b/app/code/Magento/Backend/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminGeneralSetStoreNameConfigData"> + <data key="path">general/store_information/name</data> + <data key="value">New Store Information</data> + </entity> + <entity name="AdminGeneralSetStorePhoneConfigData"> + <data key="path">general/store_information/phone</data> + </entity> + <entity name="AdminGeneralSetCountryConfigData"> + <data key="path">general/store_information/country_id</data> + </entity> + <entity name="AdminGeneralSetCityConfigData"> + <data key="path">general/store_information/city</data> + </entity> + <entity name="AdminGeneralSetPostcodeConfigData"> + <data key="path">general/store_information/postcode</data> + </entity> + <entity name="AdminGeneralSetStreetAddressConfigData"> + <data key="path">general/store_information/street_line1</data> + </entity> + <entity name="AdminGeneralSetStreetAddress2ConfigData"> + <data key="path">general/store_information/street_line2</data> + </entity> +</entities> diff --git a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php index e62b73f39241..51411ce04aac 100644 --- a/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php +++ b/app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/MassactionTest.php @@ -4,14 +4,19 @@ * See COPYING.txt for license details. */ -/** - * Test class for \Magento\Backend\Block\Widget\Grid\Massaction - */ namespace Magento\Backend\Test\Unit\Block\Widget\Grid; use Magento\Backend\Block\Widget\Grid\Massaction\VisibilityCheckerInterface as VisibilityChecker; use Magento\Framework\Authorization; +use Magento\Framework\Data\Collection\AbstractDb as Collection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Select; +/** + * Test class for \Magento\Backend\Block\Widget\Grid\Massaction + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MassactionTest extends \PHPUnit\Framework\TestCase { /** @@ -54,6 +59,21 @@ class MassactionTest extends \PHPUnit\Framework\TestCase */ private $visibilityCheckerMock; + /** + * @var Collection|\PHPUnit\Framework\MockObject\MockObject + */ + private $gridCollectionMock; + + /** + * @var Select|\PHPUnit\Framework\MockObject\MockObject + */ + private $gridCollectionSelectMock; + + /** + * @var AdapterInterface|\PHPUnit\Framework\MockObject\MockObject + */ + private $connectionMock; + protected function setUp() { $this->_gridMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid::class) @@ -97,6 +117,18 @@ protected function setUp() ->setMethods(['isAllowed']) ->getMock(); + $this->gridCollectionMock = $this->createMock(Collection::class); + $this->gridCollectionSelectMock = $this->createMock(Select::class); + $this->connectionMock = $this->createMock(AdapterInterface::class); + + $this->gridCollectionMock->expects($this->any()) + ->method('getSelect') + ->willReturn($this->gridCollectionSelectMock); + + $this->gridCollectionMock->expects($this->any()) + ->method('getConnection') + ->willReturn($this->connectionMock); + $arguments = [ 'layout' => $this->_layoutMock, 'request' => $this->_requestMock, @@ -269,6 +301,41 @@ public function testGetGridIdsJsonWithoutUseSelectAll() $this->assertEmpty($this->_block->getGridIdsJson()); } + /** + * Test for getGridIdsJson when select all functionality flag set to true. + */ + public function testGetGridIdsJsonWithUseSelectAll() + { + $this->_block->setUseSelectAll(true); + + $this->_gridMock->expects($this->once()) + ->method('getCollection') + ->willReturn($this->gridCollectionMock); + + $this->gridCollectionSelectMock->expects($this->exactly(4)) + ->method('reset') + ->withConsecutive( + [Select::ORDER], + [Select::LIMIT_COUNT], + [Select::LIMIT_OFFSET], + [Select::COLUMNS] + ); + + $this->gridCollectionSelectMock->expects($this->once()) + ->method('columns') + ->with('test_id'); + + $this->connectionMock->expects($this->once()) + ->method('fetchCol') + ->with($this->gridCollectionSelectMock) + ->willReturn([1, 2, 3]); + + $this->assertEquals( + '1,2,3', + $this->_block->getGridIdsJson() + ); + } + /** * @param string $itemId * @param array|\Magento\Framework\DataObject $item diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml index 343ecc0ee3d5..4a92ed8124bf 100644 --- a/app/code/Magento/Backend/etc/adminhtml/system.xml +++ b/app/code/Magento/Backend/etc/adminhtml/system.xml @@ -323,7 +323,8 @@ </field> <field id="port" translate="label comment" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Port (25)</label> - <comment>For Windows server only.</comment> + <validate>validate-digits validate-digits-range digits-range-0-65535</validate> + <comment>Please enter at least 0 and at most 65535 (For Windows server only).</comment> </field> <field id="set_return_path" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Set Return-Path</label> @@ -481,22 +482,22 @@ <field id="base_url" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Base URL</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>Specify URL or {{base_url}} placeholder.</comment> + <comment><![CDATA[Specify URL or {{base_url}} placeholder.]]></comment> </field> <field id="base_link_url" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Base Link URL</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May start with {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May start with {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="base_static_url" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Base URL for Static View Files</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May be empty or start with {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May be empty or start with {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="base_media_url" translate="label comment" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Base URL for User Media Files</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May be empty or start with {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May be empty or start with {{unsecure_base_url}} placeholder.]]></comment> </field> </group> <group id="secure" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1"> @@ -505,22 +506,22 @@ <field id="base_url" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Secure Base URL</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>Specify URL or {{base_url}}, or {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[Specify URL or {{base_url}}, or {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="base_link_url" translate="label comment" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Secure Base Link URL</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May start with {{secure_base_url}} or {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May start with {{secure_base_url}} or {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="base_static_url" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Secure Base URL for Static View Files</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="base_media_url" translate="label comment" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Secure Base URL for User Media Files</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> - <comment>May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder.</comment> + <comment><![CDATA[May be empty or start with {{secure_base_url}}, or {{unsecure_base_url}} placeholder.]]></comment> </field> <field id="use_in_frontend" translate="label comment" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Use Secure URLs on Storefront</label> @@ -585,11 +586,6 @@ <label>Validate HTTP_USER_AGENT</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> - <field id="use_frontend_sid" translate="label comment" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> - <label>Use SID on Storefront</label> - <comment>Allows customers to stay logged in when switching between different stores.</comment> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> - </field> </group> </section> </system> diff --git a/app/code/Magento/Backend/view/adminhtml/requirejs-config.js b/app/code/Magento/Backend/view/adminhtml/requirejs-config.js index ae0e84e2d27f..e886f28cd158 100644 --- a/app/code/Magento/Backend/view/adminhtml/requirejs-config.js +++ b/app/code/Magento/Backend/view/adminhtml/requirejs-config.js @@ -6,7 +6,8 @@ var config = { map: { '*': { - 'mediaUploader': 'Magento_Backend/js/media-uploader' + 'mediaUploader': 'Magento_Backend/js/media-uploader', + 'mage/translate': 'Magento_Backend/js/translate' } } }; diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml index b712bc6c9531..7f6f2bbd13fa 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid.phtml @@ -170,6 +170,9 @@ $numColumns = $block->getColumns() !== null ? count($block->getColumns()) : 0; <?php if ($block->getSortableUpdateCallback()) : ?> <?= $block->escapeJs($block->getJsObjectName()) ?>.sortableUpdateCallback = <?= /* @noEscape */ $block->getSortableUpdateCallback() ?>; <?php endif; ?> + <?php if ($block->getFilterKeyPressCallback()) : ?> + <?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>; + <?php endif; ?> <?= $block->escapeJs($block->getJsObjectName()) ?>.bindSortable(); <?php if ($block->getRowInitCallback()) : ?> <?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>; diff --git a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml index 0bb453f25d7c..527ddc436207 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/widget/grid/extended.phtml @@ -272,6 +272,9 @@ $numColumns = count($block->getColumns()); <?php if ($block->getCheckboxCheckCallback()) : ?> <?= $block->escapeJs($block->getJsObjectName()) ?>.checkboxCheckCallback = <?= /* @noEscape */ $block->getCheckboxCheckCallback() ?>; <?php endif; ?> + <?php if ($block->getFilterKeyPressCallback()) : ?> + <?= $block->escapeJs($block->getJsObjectName()) ?>.filterKeyPressCallback = <?= /* @noEscape */ $block->getFilterKeyPressCallback() ?>; + <?php endif; ?> <?php if ($block->getRowInitCallback()) : ?> <?= $block->escapeJs($block->getJsObjectName()) ?>.initRowCallback = <?= /* @noEscape */ $block->getRowInitCallback() ?>; <?= $block->escapeJs($block->getJsObjectName()) ?>.initGridRows(); diff --git a/app/code/Magento/Backend/view/adminhtml/web/js/translate.js b/app/code/Magento/Backend/view/adminhtml/web/js/translate.js new file mode 100644 index 000000000000..d6e1547600c4 --- /dev/null +++ b/app/code/Magento/Backend/view/adminhtml/web/js/translate.js @@ -0,0 +1,48 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/* eslint-disable strict */ +define([ + 'jquery', + 'mage/mage' +], function ($) { + $.extend(true, $, { + mage: { + translate: (function () { + /** + * Key-value translations storage + * @type {Object} + * @private + */ + var _data = {}; + + /** + * Add new translation (two string parameters) or several translations (object) + */ + this.add = function () { + if (arguments.length > 1) { + _data[arguments[0]] = arguments[1]; + } else if (typeof arguments[0] === 'object') { + $.extend(_data, arguments[0]); + } + }; + + /** + * Make a translation with parsing (to handle case when _data represents tuple) + * @param {String} text + * @return {String} + */ + this.translate = function (text) { + return _data[text] ? _data[text] : text; + }; + + return this; + }()) + } + }); + $.mage.__ = $.proxy($.mage.translate.translate, $.mage.translate); + + return $.mage.__; +}); diff --git a/app/code/Magento/Braintree/Gateway/Validator/ErrorCodeProvider.php b/app/code/Magento/Braintree/Gateway/Validator/ErrorCodeProvider.php index 58ce33305da8..2f73dd8f380d 100644 --- a/app/code/Magento/Braintree/Gateway/Validator/ErrorCodeProvider.php +++ b/app/code/Magento/Braintree/Gateway/Validator/ErrorCodeProvider.php @@ -11,6 +11,7 @@ use Braintree\Error\Validation; use Braintree\Result\Error; use Braintree\Result\Successful; +use Braintree\Transaction; /** * Processes errors codes from Braintree response. @@ -38,12 +39,14 @@ public function getErrorCodes($response): array $result[] = $error->code; } - if (isset($response->transaction) && $response->transaction->status === 'gateway_rejected') { - $result[] = $response->transaction->gatewayRejectionReason; - } + if (isset($response->transaction) && $response->transaction) { + if ($response->transaction->status === Transaction::GATEWAY_REJECTED) { + $result[] = $response->transaction->gatewayRejectionReason; + } - if (isset($response->transaction) && $response->transaction->status === 'processor_declined') { - $result[] = $response->transaction->processorResponseCode; + if ($response->transaction->status === Transaction::PROCESSOR_DECLINED) { + $result[] = $response->transaction->processorResponseCode; + } } return $result; diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js index ac97e4fa5eb5..5f06d26e2acf 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js @@ -246,8 +246,10 @@ define( return; } - self.setPaymentPayload(payload); - self.placeOrder(); + if (self.validateCardType()) { + self.setPaymentPayload(payload); + self.placeOrder(); + } }); } }, diff --git a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html index 9bcb5dad8b63..8da8927a3b24 100644 --- a/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html +++ b/app/code/Magento/Braintree/view/frontend/web/template/payment/form.html @@ -23,7 +23,7 @@ <!-- ko template: getTemplate() --><!-- /ko --> <!--/ko--> </div> - <form id="co-transparent-form-braintree" class="form" data-bind="" method="post" action="#" novalidate="novalidate"> + <form id="co-transparent-form-braintree" class="form" data-bind="afterRender: initHostedFields" method="post" action="#" novalidate="novalidate"> <fieldset data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + getCode()}"> <legend class="legend"> <span><!-- ko i18n: 'Credit Card Information'--><!-- /ko --></span> @@ -87,7 +87,7 @@ <span><!-- ko i18n: 'Card Verification Number'--><!-- /ko --></span> </label> <div class="control _with-tooltip"> - <div data-bind="afterRender: initHostedFields, attr: {id: getCode() + '_cc_cid'}" class="hosted-control hosted-cid"></div> + <div data-bind="attr: {id: getCode() + '_cc_cid'}" class="hosted-control hosted-cid"></div> <div class="hosted-error"><!-- ko i18n: 'Please, enter valid Card Verification Number'--><!-- /ko --></div> <div class="field-tooltip toggle"> diff --git a/app/code/Magento/BraintreeGraphQl/README.md b/app/code/Magento/BraintreeGraphQl/README.md index f6740e4d250e..4e8eecc93a92 100644 --- a/app/code/Magento/BraintreeGraphQl/README.md +++ b/app/code/Magento/BraintreeGraphQl/README.md @@ -1,4 +1,9 @@ -# BraintreeGraphQl +# Magento_BraintreeGraphQl module -**BraintreeGraphQl** provides type and resolver for method additional -information. \ No newline at end of file +The Magento_BraintreeGraphQl module provides type and resolver information for the GraphQL module to pass payment information data from the client to Magento. + +## Extensibility + +Extension developers can interact with the Magento_BraintreeGraphQl module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_BraintreeGraphQl module. diff --git a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php index c0a2d9d43034..863f27322569 100644 --- a/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php @@ -32,7 +32,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer * @param \Magento\Framework\Url\Helper\Data $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param PriceCurrencyInterface $priceCurrency - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param InterpretationStrategyInterface $messageInterpretationStrategy * @param Configuration $bundleProductConfiguration * @param array $data @@ -46,7 +46,7 @@ public function __construct( \Magento\Framework\Url\Helper\Data $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, PriceCurrencyInterface $priceCurrency, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, InterpretationStrategyInterface $messageInterpretationStrategy, Configuration $bundleProductConfiguration, array $data = [] diff --git a/app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php b/app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php index 61559df4d2cf..ecbf4cc80a3a 100644 --- a/app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php +++ b/app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php @@ -8,6 +8,9 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Type; +/** + * Provides duplicating bundle options and selections + */ class Bundle implements \Magento\Catalog\Model\Product\CopyConstructorInterface { /** @@ -27,7 +30,17 @@ public function build(Product $product, Product $duplicate) $bundleOptions = $product->getExtensionAttributes()->getBundleProductOptions() ?: []; $duplicatedBundleOptions = []; foreach ($bundleOptions as $key => $bundleOption) { - $duplicatedBundleOptions[$key] = clone $bundleOption; + $duplicatedBundleOption = clone $bundleOption; + /** + * Set option and selection ids to 'null' in order to create new option(selection) for duplicated product, + * but not modifying existing one, which led to lost of option(selection) in original product. + */ + $productLinks = $duplicatedBundleOption->getProductLinks() ?: []; + foreach ($productLinks as $productLink) { + $productLink->setSelectionId(null); + } + $duplicatedBundleOption->setOptionId(null); + $duplicatedBundleOptions[$key] = $duplicatedBundleOption; } $duplicate->getExtensionAttributes()->setBundleProductOptions($duplicatedBundleOptions); } diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php index b71853cde41a..077ebd4422aa 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Indexer/Price.php @@ -85,7 +85,7 @@ class Price implements DimensionalIndexerInterface private $eventManager; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManager; @@ -97,7 +97,7 @@ class Price implements DimensionalIndexerInterface * @param BasePriceModifier $basePriceModifier * @param JoinAttributeProcessor $joinAttributeProcessor * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param bool $fullReindexAction * @param string $connectionName * @@ -111,7 +111,7 @@ public function __construct( BasePriceModifier $basePriceModifier, JoinAttributeProcessor $joinAttributeProcessor, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, $fullReindexAction = false, $connectionName = 'indexer' ) { @@ -139,16 +139,16 @@ public function executeByDimensions(array $dimensions, \Traversable $entityIds) $temporaryPriceTable = $this->indexTableStructureFactory->create( [ - 'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions), - 'entityField' => 'entity_id', - 'customerGroupField' => 'customer_group_id', - 'websiteField' => 'website_id', - 'taxClassField' => 'tax_class_id', - 'originalPriceField' => 'price', - 'finalPriceField' => 'final_price', - 'minPriceField' => 'min_price', - 'maxPriceField' => 'max_price', - 'tierPriceField' => 'tier_price', + 'tableName' => $this->tableMaintainer->getMainTmpTable($dimensions), + 'entityField' => 'entity_id', + 'customerGroupField' => 'customer_group_id', + 'websiteField' => 'website_id', + 'taxClassField' => 'tax_class_id', + 'originalPriceField' => 'price', + 'finalPriceField' => 'final_price', + 'minPriceField' => 'min_price', + 'maxPriceField' => 'max_price', + 'tierPriceField' => 'tier_price', ] ); @@ -335,9 +335,9 @@ private function prepareBundlePriceByType($priceType, array $dimensions, $entity ); $finalPrice = $connection->getLeastSql( [ - $price, - $connection->getIfNullSql($specialPriceExpr, $price), - $connection->getIfNullSql($tierPrice, $price), + $price, + $connection->getIfNullSql($specialPriceExpr, $price), + $connection->getIfNullSql($tierPrice, $price), ] ); } else { @@ -477,8 +477,8 @@ private function calculateBundleSelectionPrice($dimensions, $priceType) $priceExpr = $connection->getLeastSql( [ - $priceExpr, - $connection->getIfNullSql($tierExpr, $priceExpr), + $priceExpr, + $connection->getIfNullSql($tierExpr, $priceExpr), ] ); } else { @@ -495,8 +495,8 @@ private function calculateBundleSelectionPrice($dimensions, $priceType) ); $priceExpr = $connection->getLeastSql( [ - $specialExpr, - $connection->getIfNullSql($tierExpr, $price), + $specialExpr, + $connection->getIfNullSql($tierExpr, $price), ] ); } diff --git a/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php b/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php index 21ba1f75ba90..7b3f6dd8bbef 100644 --- a/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php +++ b/app/code/Magento/Bundle/Model/ResourceModel/Selection/Collection.php @@ -61,7 +61,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -88,7 +88,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Bundle/Setup/Patch/Schema/ChangeTmpTablesEngine.php b/app/code/Magento/Bundle/Setup/Patch/Schema/ChangeTmpTablesEngine.php deleted file mode 100644 index c6a67cc5a110..000000000000 --- a/app/code/Magento/Bundle/Setup/Patch/Schema/ChangeTmpTablesEngine.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Bundle\Setup\Patch\Schema; - -use Magento\Framework\Setup\Patch\SchemaPatchInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Change engine for temporary tables to InnoDB. - */ -class ChangeTmpTablesEngine implements SchemaPatchInterface -{ - /** - * @var SchemaSetupInterface - */ - private $schemaSetup; - - /** - * @param SchemaSetupInterface $schemaSetup - */ - public function __construct(SchemaSetupInterface $schemaSetup) - { - $this->schemaSetup = $schemaSetup; - } - - /** - * @inheritdoc - */ - public function apply() - { - $this->schemaSetup->startSetup(); - - $tables = [ - 'catalog_product_index_price_bundle_tmp', - 'catalog_product_index_price_bundle_sel_tmp', - 'catalog_product_index_price_bundle_opt_tmp', - ]; - foreach ($tables as $table) { - $tableName = $this->schemaSetup->getTable($table); - if ($this->schemaSetup->getConnection()->isTableExists($tableName)) { - $this->schemaSetup->getConnection()->changeTableEngine($tableName, 'InnoDB'); - } - } - - $this->schemaSetup->endSetup(); - } - - /** - * @inheritdoc - */ - public static function getDependencies() - { - return []; - } - - /** - * @inheritdoc - */ - public function getAliases() - { - return []; - } -} diff --git a/app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml index 6e7e4a7a1657..e5f557dd22de 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Data/ProductData.xml @@ -61,6 +61,20 @@ <requiredEntity type="custom_attribute">CustomAttributeDynamicPrice</requiredEntity> <requiredEntity type="custom_attribute">CustomAttributePriceView</requiredEntity> </entity> + <entity name="ApiBundleProductUnderscoredSku" type="product2"> + <data key="name" unique="suffix">Api Bundle Product</data> + <data key="sku" unique="suffix">api_bundle_product</data> + <data key="type_id">bundle</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="urlKey" unique="suffix">api-bundle-product</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute">ApiProductShortDescription</requiredEntity> + <requiredEntity type="custom_attribute">CustomAttributeDynamicPrice</requiredEntity> + <requiredEntity type="custom_attribute">CustomAttributePriceView</requiredEntity> + </entity> <entity name="ApiBundleProductPriceViewRange" type="product2"> <data key="name" unique="suffix">Api Bundle Product</data> <data key="sku" unique="suffix">api-bundle-product</data> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultImageBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultImageBundleProductTest.xml index 1438958b92b6..730df90b31be 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultImageBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultImageBundleProductTest.xml @@ -24,6 +24,10 @@ <createData entity="SimpleProduct2" stepKey="simpleProduct2"/> </before> <after> + <!-- Delete the bundled product we created in the test body --> + <actionGroup ref="deleteProductBySku" stepKey="deleteBundleProduct"> + <argument name="sku" value="{{BundleProduct.sku}}"/> + </actionGroup> <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> <deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> <deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml index 52bce6760088..c6aab0ea54ea 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml @@ -17,6 +17,47 @@ <severity value="MAJOR"/> <testCaseId value="MC-139"/> <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchBundleByNameMysqlTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20472"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -56,7 +97,7 @@ <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="ApiBundleProductUnderscoredSku" stepKey="product"/> <createData entity="DropDownBundleOption" stepKey="bundleOption"> <requiredEntity createDataKey="product"/> </createData> @@ -87,6 +128,47 @@ <severity value="MAJOR"/> <testCaseId value="MC-242"/> <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchBundleByDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20473"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -122,6 +204,47 @@ <severity value="MAJOR"/> <testCaseId value="MC-250"/> <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchBundleByShortDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20474"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -157,6 +280,56 @@ <severity value="MAJOR"/> <testCaseId value="MC-251"/> <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <getData entity="GetProduct" stepKey="arg1"> + <requiredEntity createDataKey="product"/> + </getData> + <getData entity="GetProduct" stepKey="arg2"> + <requiredEntity createDataKey="simple1"/> + </getData> + <getData entity="GetProduct" stepKey="arg3"> + <requiredEntity createDataKey="simple2"/> + </getData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchBundleByPriceMysqlTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product price using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product price the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20475"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml new file mode 100644 index 000000000000..d8d6034cd1a2 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types "/> + <title value="Guest customer should be able to advance search Bundle product with product sku that contains hyphen"/> + <description value="Guest customer should be able to advance search Bundle product with product sku that contains hyphen"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20359"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php index 831098cc44c3..4df60d07d98e 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php @@ -6,6 +6,7 @@ namespace Magento\Bundle\Test\Unit\Model\Product\CopyConstructor; use Magento\Bundle\Api\Data\BundleOptionInterface; +use Magento\Bundle\Model\Link; use Magento\Bundle\Model\Product\CopyConstructor\Bundle; use Magento\Catalog\Api\Data\ProductExtensionInterface; use Magento\Catalog\Model\Product; @@ -45,6 +46,7 @@ public function testBuildNegative() */ public function testBuildPositive() { + /** @var Product|\PHPUnit_Framework_MockObject_MockObject $product */ $product = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->getMock(); @@ -60,18 +62,42 @@ public function testBuildPositive() ->method('getExtensionAttributes') ->willReturn($extensionAttributesProduct); + $productLink = $this->getMockBuilder(Link::class) + ->setMethods(['setSelectionId']) + ->disableOriginalConstructor() + ->getMock(); + $productLink->expects($this->exactly(2)) + ->method('setSelectionId') + ->with($this->identicalTo(null)); + $firstOption = $this->getMockBuilder(BundleOptionInterface::class) + ->setMethods(['getProductLinks']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $firstOption->expects($this->once()) + ->method('getProductLinks') + ->willReturn([$productLink]); + $firstOption->expects($this->once()) + ->method('setOptionId') + ->with($this->identicalTo(null)); + $secondOption = $this->getMockBuilder(BundleOptionInterface::class) + ->setMethods(['getProductLinks']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $secondOption->expects($this->once()) + ->method('getProductLinks') + ->willReturn([$productLink]); + $secondOption->expects($this->once()) + ->method('setOptionId') + ->with($this->identicalTo(null)); $bundleOptions = [ - $this->getMockBuilder(BundleOptionInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(), - $this->getMockBuilder(BundleOptionInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass() + $firstOption, + $secondOption ]; $extensionAttributesProduct->expects($this->once()) ->method('getBundleProductOptions') ->willReturn($bundleOptions); + /** @var Product|\PHPUnit_Framework_MockObject_MockObject $duplicate */ $duplicate = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml index 8eafa23cbd0f..dba973243906 100644 --- a/app/code/Magento/Bundle/etc/db_schema.xml +++ b/app/code/Magento/Bundle/etc/db_schema.xml @@ -203,7 +203,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_bundle_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_bundle_tmp" resource="default" engine="innodb" comment="Catalog Product Index Price Bundle Tmp"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -265,7 +265,7 @@ <column name="selection_id"/> </constraint> </table> - <table name="catalog_product_index_price_bundle_sel_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_bundle_sel_tmp" resource="default" engine="innodb" comment="Catalog Product Index Price Bundle Sel Tmp"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -320,7 +320,7 @@ <column name="option_id"/> </constraint> </table> - <table name="catalog_product_index_price_bundle_opt_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_bundle_opt_tmp" resource="default" engine="innodb" comment="Catalog Product Index Price Bundle Opt Tmp"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/Product/Price/Provider.php b/app/code/Magento/BundleGraphQl/Model/Resolver/Product/Price/Provider.php new file mode 100644 index 000000000000..fead6f923d8f --- /dev/null +++ b/app/code/Magento/BundleGraphQl/Model/Resolver/Product/Price/Provider.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\BundleGraphQl\Model\Resolver\Product\Price; + +use Magento\Bundle\Pricing\Price\FinalPrice; +use Magento\Catalog\Pricing\Price\BasePrice; +use Magento\Bundle\Model\Product\Price; +use Magento\Catalog\Pricing\Price\RegularPrice; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface; +use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Framework\Pricing\SaleableInterface; + +/** + * Provides pricing information for Bundle products + */ +class Provider implements ProviderInterface +{ + /** + * @inheritdoc + */ + public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getMinimalPrice(); + } + + /** + * @inheritdoc + */ + public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getMinimalPrice(); + } + + /** + * @inheritdoc + */ + public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getMaximalPrice(); + } + + /** + * @inheritdoc + */ + public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getMaximalPrice(); + } + + /** + * @inheritdoc + */ + public function getRegularPrice(SaleableInterface $product): AmountInterface + { + if ($product->getPriceType() == Price::PRICE_TYPE_FIXED) { + return $product->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getAmount(); + } + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getAmount(); + } +} diff --git a/app/code/Magento/BundleGraphQl/etc/graphql/di.xml b/app/code/Magento/BundleGraphQl/etc/graphql/di.xml index 50a2e32b8c9d..98dbe012c900 100644 --- a/app/code/Magento/BundleGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/BundleGraphQl/etc/graphql/di.xml @@ -40,4 +40,22 @@ </argument> </arguments> </type> + + + <type name="Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="bundle" xsi:type="object">Magento\BundleGraphQl\Model\Resolver\Product\Price\Provider</item> + </argument> + </arguments> + </type> + <type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\AttributeProcessor"> + <arguments> + <argument name="fieldToAttributeMap" xsi:type="array"> + <item name="price_range" xsi:type="array"> + <item name="price_type" xsi:type="string">price_type</item> + </item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php index a829c058d89b..c58ed58370e3 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg.php @@ -26,7 +26,7 @@ class Wysiwyg extends \Magento\Framework\Data\Form\Element\Textarea /** * Catalog data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager = null; @@ -46,7 +46,7 @@ class Wysiwyg extends \Magento\Framework\Data\Form\Element\Textarea * @param \Magento\Framework\Escaper $escaper * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig * @param \Magento\Framework\View\LayoutInterface $layout - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Backend\Helper\Data $backendData * @param array $data */ @@ -56,7 +56,7 @@ public function __construct( \Magento\Framework\Escaper $escaper, \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, \Magento\Framework\View\LayoutInterface $layout, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Backend\Helper\Data $backendData, array $data = [] ) { diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php index e754ab970051..386fe1333a7e 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Price.php @@ -19,7 +19,7 @@ class Price extends Extended /** * Catalog data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -32,14 +32,14 @@ class Price extends Extended * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\ProductAlert\Model\PriceFactory $priceFactory - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\ProductAlert\Model\PriceFactory $priceFactory, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_priceFactory = $priceFactory; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php index 2c6647fd57be..ede478cabe78 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Alerts/Stock.php @@ -19,7 +19,7 @@ class Stock extends Extended /** * Catalog data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -32,14 +32,14 @@ class Stock extends Extended * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper * @param \Magento\ProductAlert\Model\StockFactory $stockFactory - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magento\ProductAlert\Model\StockFactory $stockFactory, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_stockFactory = $stockFactory; diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php index 9278b84362e7..782147e1e8ef 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Inventory.php @@ -18,7 +18,7 @@ class Inventory extends \Magento\Backend\Block\Widget protected $_template = 'Magento_Catalog::catalog/product/tab/inventory.phtml'; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -53,7 +53,7 @@ class Inventory extends \Magento\Backend\Block\Widget * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\CatalogInventory\Model\Source\Backorders $backorders * @param \Magento\CatalogInventory\Model\Source\Stock $stock - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration @@ -63,7 +63,7 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\CatalogInventory\Model\Source\Backorders $backorders, \Magento\CatalogInventory\Model\Source\Stock $stock, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Registry $coreRegistry, \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php index 42990116e933..5ffd3d1dda38 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Price/Group/AbstractGroup.php @@ -41,7 +41,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface /** * Catalog data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -81,7 +81,7 @@ abstract class AbstractGroup extends Widget implements RendererInterface * @param \Magento\Backend\Block\Template\Context $context * @param GroupRepositoryInterface $groupRepository * @param \Magento\Directory\Helper\Data $directoryHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Registry $registry * @param GroupManagementInterface $groupManagement * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder @@ -92,7 +92,7 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, GroupRepositoryInterface $groupRepository, \Magento\Directory\Helper\Data $directoryHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Registry $registry, GroupManagementInterface $groupManagement, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php index 51c326763b09..37ad3f4bea20 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tabs.php @@ -14,7 +14,7 @@ use Magento\Catalog\Helper\Data; use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory; use Magento\Framework\Json\EncoderInterface; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Registry; use Magento\Framework\Translate\InlineInterface; @@ -65,7 +65,7 @@ class Tabs extends WidgetTabs protected $_collectionFactory; /** - * @var ModuleManagerInterface + * @var Manager */ protected $_moduleManager; @@ -78,7 +78,7 @@ class Tabs extends WidgetTabs * @param Context $context * @param EncoderInterface $jsonEncoder * @param Session $authSession - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param CollectionFactory $collectionFactory * @param Catalog $helperCatalog * @param Data $catalogData @@ -91,7 +91,7 @@ public function __construct( Context $context, EncoderInterface $jsonEncoder, Session $authSession, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, CollectionFactory $collectionFactory, Catalog $helperCatalog, Data $catalogData, diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 7e43f2fc064a..01408ade5643 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -16,7 +16,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -59,7 +59,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended * @param \Magento\Catalog\Model\Product\Type $type * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status * @param \Magento\Catalog\Model\Product\Visibility $visibility - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data * * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -73,7 +73,7 @@ public function __construct( \Magento\Catalog\Model\Product\Type $type, \Magento\Catalog\Model\Product\Attribute\Source\Status $status, \Magento\Catalog\Model\Product\Visibility $visibility, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_websiteFactory = $websiteFactory; diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php index 088619511545..24811d61a771 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Related.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Related.php @@ -46,7 +46,7 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct implements protected $_checkoutCart; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -55,7 +55,7 @@ class Related extends \Magento\Catalog\Block\Product\AbstractProduct implements * @param \Magento\Checkout\Model\ResourceModel\Cart $checkoutCart * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( @@ -63,7 +63,7 @@ public function __construct( \Magento\Checkout\Model\ResourceModel\Cart $checkoutCart, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_checkoutCart = $checkoutCart; @@ -141,6 +141,7 @@ public function getIdentities() { $identities = []; foreach ($this->getItems() as $item) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $identities = array_merge($identities, $item->getIdentities()); } return $identities; diff --git a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php index d888f44a6fbf..fa1beaf6e0ea 100644 --- a/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php +++ b/app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php @@ -60,7 +60,7 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct implements protected $_checkoutCart; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -69,7 +69,7 @@ class Upsell extends \Magento\Catalog\Block\Product\AbstractProduct implements * @param \Magento\Checkout\Model\ResourceModel\Cart $checkoutCart * @param \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param array $data */ public function __construct( @@ -77,7 +77,7 @@ public function __construct( \Magento\Checkout\Model\ResourceModel\Cart $checkoutCart, \Magento\Catalog\Model\Product\Visibility $catalogProductVisibility, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, array $data = [] ) { $this->_checkoutCart = $checkoutCart; @@ -264,6 +264,7 @@ public function getIdentities() { $identities = []; foreach ($this->getItems() as $item) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $identities = array_merge($identities, $item->getIdentities()); } return $identities; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php index 1e0cb9f197a5..f45f854be076 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php @@ -7,10 +7,13 @@ namespace Magento\Catalog\Controller\Adminhtml; +use Magento\Framework\App\ObjectManager; use Magento\Store\Model\Store; +use Magento\Framework\Controller\ResultFactory; /** * Catalog category controller + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ abstract class Category extends \Magento\Backend\App\Action { @@ -26,20 +29,61 @@ abstract class Category extends \Magento\Backend\App\Action */ protected $dateFilter; + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + + /** + * @var \Magento\Framework\Registry + */ + private $registry; + + /** + * @var \Magento\Cms\Model\Wysiwyg\Config + */ + private $wysiwigConfig; + + /** + * @var \Magento\Backend\Model\Auth\Session + */ + private $authSession; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Stdlib\DateTime\Filter\Date|null $dateFilter + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Framework\Registry $registry + * @param \Magento\Cms\Model\Wysiwyg\Config $wysiwigConfig + * @param \Magento\Backend\Model\Auth\Session $authSession */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter = null + \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter = null, + \Magento\Store\Model\StoreManagerInterface $storeManager = null, + \Magento\Framework\Registry $registry = null, + \Magento\Cms\Model\Wysiwyg\Config $wysiwigConfig = null, + \Magento\Backend\Model\Auth\Session $authSession = null ) { $this->dateFilter = $dateFilter; + $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get( + \Magento\Store\Model\StoreManagerInterface::class + ); + $this->registry = $registry ?: ObjectManager::getInstance()->get( + \Magento\Framework\Registry::class + ); + $this->wysiwigConfig = $wysiwigConfig ?: ObjectManager::getInstance()->get( + \Magento\Cms\Model\Wysiwyg\Config::class + ); + $this->authSession = $authSession ?: ObjectManager::getInstance()->get( + \Magento\Backend\Model\Auth\Session::class + ); parent::__construct($context); } /** - * Initialize requested category and put it into registry. + * Initialize requested category and put it into registry + * * Root category can be returned, if inappropriate store/category is specified * * @param bool $getRootInstead @@ -55,11 +99,7 @@ protected function _initCategory($getRootInstead = false) if ($categoryId) { $category->load($categoryId); if ($storeId) { - $rootId = $this->_objectManager->get( - \Magento\Store\Model\StoreManagerInterface::class - )->getStore( - $storeId - )->getRootCategoryId(); + $rootId = $this->storeManager->getStore($storeId)->getRootCategoryId(); if (!in_array($rootId, $category->getPathIds())) { // load root category instead wrong one if ($getRootInstead) { @@ -71,10 +111,9 @@ protected function _initCategory($getRootInstead = false) } } - $this->_objectManager->get(\Magento\Framework\Registry::class)->register('category', $category); - $this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_category', $category); - $this->_objectManager->get(\Magento\Cms\Model\Wysiwyg\Config::class) - ->setStoreId($storeId); + $this->registry->register('category', $category); + $this->registry->register('current_category', $category); + $this->wysiwigConfig->setStoreId($storeId); return $category; } @@ -91,9 +130,8 @@ private function resolveCategoryId() : int } /** - * Resolve store id + * Resolve store Id, tries to take store id from store HTTP parameter * - * Tries to take store id from store HTTP parameter * @see Store * * @return int @@ -121,11 +159,7 @@ protected function ajaxRequestResponse($category, $resultPage) $breadcrumbsPath = $category->getPath(); if (empty($breadcrumbsPath)) { // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session - $breadcrumbsPath = $this->_objectManager->get( - \Magento\Backend\Model\Auth\Session::class - )->getDeletedPath( - true - ); + $breadcrumbsPath = $this->authSession->getDeletedPath(true); if (!empty($breadcrumbsPath)) { $breadcrumbsPath = explode('/', $breadcrumbsPath); // no need to get parent breadcrumbs if deleting category level 1 @@ -138,19 +172,21 @@ protected function ajaxRequestResponse($category, $resultPage) } } - $eventResponse = new \Magento\Framework\DataObject([ - 'content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml() - . $resultPage->getLayout()->getBlock('category.tree') - ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), - 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(), - 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml() - ]); + $eventResponse = new \Magento\Framework\DataObject( + [ + 'content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml() + . $resultPage->getLayout()->getBlock('category.tree') + ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'), + 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(), + 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml() + ] + ); $this->_eventManager->dispatch( 'category_prepare_ajax_response', ['response' => $eventResponse, 'controller' => $this] ); /** @var \Magento\Framework\Controller\Result\Json $resultJson */ - $resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\Json::class); + $resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON); $resultJson->setHeader('Content-type', 'application/json', true); $resultJson->setData($eventResponse->getData()); return $resultJson; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php index 752257f5b900..9c3aeba6dc91 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php @@ -1,13 +1,16 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Catalog\Controller\Adminhtml\Category; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +use Magento\Framework\App\ObjectManager; +/** + * Class CategoriesJson + */ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpPostActionInterface { /** @@ -20,19 +23,28 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category impl */ protected $layoutFactory; + /** + * @var \Magento\Backend\Model\Auth\Session + */ + private $authSession; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Backend\Model\Auth\Session $authSession */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, - \Magento\Framework\View\LayoutFactory $layoutFactory + \Magento\Framework\View\LayoutFactory $layoutFactory, + \Magento\Backend\Model\Auth\Session $authSession = null ) { parent::__construct($context); $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; + $this->authSession = $authSession ?: ObjectManager::getInstance() + ->get(\Magento\Backend\Model\Auth\Session::class); } /** @@ -43,9 +55,9 @@ public function __construct( public function execute() { if ($this->getRequest()->getParam('expand_all')) { - $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class)->setIsTreeWasExpanded(true); + $this->authSession->setIsTreeWasExpanded(true); } else { - $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class)->setIsTreeWasExpanded(false); + $this->authSession->setIsTreeWasExpanded(false); } $categoryId = (int)$this->getRequest()->getPost('id'); if ($categoryId) { diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php index 0450ff1607a0..57b5d74e1eaf 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php @@ -1,13 +1,16 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Catalog\Controller\Adminhtml\Category; use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; +use Magento\Framework\App\ObjectManager; +/** + * Class Edit + */ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpGetActionInterface { /** @@ -27,18 +30,23 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category implements Htt /** * Edit constructor. + * * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory + \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager = null ) { parent::__construct($context); $this->resultPageFactory = $resultPageFactory; $this->resultJsonFactory = $resultJsonFactory; + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(\Magento\Store\Model\StoreManagerInterface::class); } /** @@ -51,20 +59,20 @@ public function __construct( public function execute() { $storeId = (int)$this->getRequest()->getParam('store'); - $store = $this->getStoreManager()->getStore($storeId); - $this->getStoreManager()->setCurrentStore($store->getCode()); + $store = $this->storeManager->getStore($storeId); + $this->storeManager->setCurrentStore($store->getCode()); $categoryId = (int)$this->getRequest()->getParam('id'); if (!$categoryId) { if ($storeId) { - $categoryId = (int)$this->getStoreManager()->getStore($storeId)->getRootCategoryId(); + $categoryId = (int)$this->storeManager->getStore($storeId)->getRootCategoryId(); } else { - $defaultStoreView = $this->getStoreManager()->getDefaultStoreView(); + $defaultStoreView = $this->storeManager->getDefaultStoreView(); if ($defaultStoreView) { $categoryId = (int)$defaultStoreView->getRootCategoryId(); } else { - $stores = $this->getStoreManager()->getStores(); + $stores = $this->storeManager->getStores(); if (count($stores)) { $store = reset($stores); $categoryId = (int)$store->getRootCategoryId(); @@ -109,16 +117,4 @@ public function execute() return $resultPage; } - - /** - * @return \Magento\Store\Model\StoreManagerInterface - */ - private function getStoreManager() - { - if (null === $this->storeManager) { - $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Store\Model\StoreManagerInterface::class); - } - return $this->storeManager; - } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 77518fd9bf5c..ee8abfdb7ab4 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -8,6 +8,7 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Catalog\Api\Data\CategoryAttributeInterface; +use Magento\Framework\App\ObjectManager; use Magento\Store\Model\StoreManagerInterface; /** @@ -56,6 +57,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category implements Htt */ private $eavConfig; + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + /** * Constructor * @@ -66,6 +72,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category implements Htt * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter * @param StoreManagerInterface $storeManager * @param \Magento\Eav\Model\Config $eavConfig + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -74,15 +81,18 @@ public function __construct( \Magento\Framework\View\LayoutFactory $layoutFactory, \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter, StoreManagerInterface $storeManager, - \Magento\Eav\Model\Config $eavConfig = null + \Magento\Eav\Model\Config $eavConfig = null, + \Psr\Log\LoggerInterface $logger = null ) { parent::__construct($context, $dateFilter); $this->resultRawFactory = $resultRawFactory; $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; $this->storeManager = $storeManager; - $this->eavConfig = $eavConfig - ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Eav\Model\Config::class); + $this->eavConfig = $eavConfig ?: ObjectManager::getInstance() + ->get(\Magento\Eav\Model\Config::class); + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(\Psr\Log\LoggerInterface::class); } /** @@ -210,7 +220,9 @@ public function execute() __('The "%1" attribute is required. Enter and try again.', $attribute) ); } else { - throw new \Exception($error); + $this->messageManager->addErrorMessage(__('Something went wrong while saving the category.')); + $this->logger->critical('Something went wrong while saving the category.'); + $this->_getSession()->setCategoryData($categoryPostData); } } } @@ -221,11 +233,7 @@ public function execute() $this->messageManager->addSuccessMessage(__('You saved the category.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addExceptionMessage($e); - $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); - $this->_getSession()->setCategoryData($categoryPostData); - } catch (\Exception $e) { - $this->messageManager->addErrorMessage(__('Something went wrong while saving the category.')); - $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); + $this->logger->critical($e); $this->_getSession()->setCategoryData($categoryPostData); } } @@ -332,11 +340,7 @@ protected function getParentCategory($parentId, $storeId) { if (!$parentId) { if ($storeId) { - $parentId = $this->_objectManager->get( - \Magento\Store\Model\StoreManagerInterface::class - )->getStore( - $storeId - )->getRootCategoryId(); + $parentId = $this->storeManager->getStore($storeId)->getRootCategoryId(); } else { $parentId = \Magento\Catalog\Model\Category::TREE_ROOT_ID; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 342bbc388f87..2d10d7148fb7 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -7,8 +7,10 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; use Magento\AsynchronousOperations\Api\Data\OperationInterface; +use Magento\Eav\Model\Config; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Backend\App\Action; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** @@ -47,6 +49,16 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $bulkSize; + /** + * @var TimezoneInterface + */ + private $timezone; + + /** + * @var Config + */ + private $eavConfig; + /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -56,6 +68,9 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param \Magento\Authorization\Model\UserContextInterface $userContext * @param int $bulkSize + * @param TimezoneInterface $timezone + * @param Config $eavConfig + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( Action\Context $context, @@ -65,7 +80,9 @@ public function __construct( \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService, \Magento\Framework\Serialize\SerializerInterface $serializer, \Magento\Authorization\Model\UserContextInterface $userContext, - int $bulkSize = 100 + int $bulkSize = 100, + TimezoneInterface $timezone = null, + Config $eavConfig = null ) { parent::__construct($context, $attributeHelper); $this->bulkManagement = $bulkManagement; @@ -74,6 +91,10 @@ public function __construct( $this->serializer = $serializer; $this->userContext = $userContext; $this->bulkSize = $bulkSize; + $this->timezone = $timezone ?: ObjectManager::getInstance() + ->get(TimezoneInterface::class); + $this->eavConfig = $eavConfig ?: ObjectManager::getInstance() + ->get(Config::class); } /** @@ -122,11 +143,10 @@ public function execute() */ private function sanitizeProductAttributes($attributesData) { - $dateFormat = $this->_objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); - $config = $this->_objectManager->get(\Magento\Eav\Model\Config::class); + $dateFormat = $this->timezone->getDateFormat(\IntlDateFormatter::SHORT); foreach ($attributesData as $attributeCode => $value) { - $attribute = $config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); + $attribute = $this->eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); continue; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php index 30a6629dd1c2..4a3de5f6e6eb 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -9,7 +8,11 @@ use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute as AttributeAction; +use Magento\Framework\App\ObjectManager; +/** + * Class Validate + */ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPostActionInterface { /** @@ -22,21 +25,30 @@ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPo */ protected $layoutFactory; + /** + * @var \Magento\Eav\Model\Config + */ + private $eavConfig; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, - \Magento\Framework\View\LayoutFactory $layoutFactory + \Magento\Framework\View\LayoutFactory $layoutFactory, + \Magento\Eav\Model\Config $eavConfig = null ) { parent::__construct($context, $attributeHelper); $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; + $this->eavConfig = $eavConfig ?: ObjectManager::getInstance() + ->get(\Magento\Eav\Model\Config::class); } /** @@ -54,8 +66,7 @@ public function execute() try { if ($attributesData) { foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) - ->getAttribute('catalog_product', $attributeCode); + $attribute = $this->eavConfig->getAttribute('catalog_product', $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); continue; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php index 09eacbbf0731..a05602403e08 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php @@ -17,16 +17,16 @@ use Magento\Eav\Api\Data\AttributeGroupInterfaceFactory; use Magento\Eav\Api\Data\AttributeInterface; use Magento\Eav\Api\Data\AttributeSetInterface; +use Magento\Framework\Api\ExtensionAttributesFactory; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\Result\Json; use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\App\ObjectManager; -use Psr\Log\LoggerInterface; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Api\ExtensionAttributesFactory; +use Psr\Log\LoggerInterface; /** * Class AddAttributeToTemplate @@ -86,20 +86,49 @@ class AddAttributeToTemplate extends Product implements HttpPostActionInterface * @param Context $context * @param Builder $productBuilder * @param JsonFactory $resultJsonFactory - * @param AttributeGroupInterfaceFactory|null $attributeGroupFactory + * @param AttributeGroupInterfaceFactory $attributeGroupFactory + * @param AttributeRepositoryInterface $attributeRepository + * @param AttributeSetRepositoryInterface $attributeSetRepository + * @param AttributeGroupRepositoryInterface $attributeGroupRepository + * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param AttributeManagementInterface $attributeManagement + * @param LoggerInterface $logger + * @param ExtensionAttributesFactory $extensionAttributesFactory * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function __construct( Context $context, Builder $productBuilder, JsonFactory $resultJsonFactory, - AttributeGroupInterfaceFactory $attributeGroupFactory = null + AttributeGroupInterfaceFactory $attributeGroupFactory = null, + AttributeRepositoryInterface $attributeRepository = null, + AttributeSetRepositoryInterface $attributeSetRepository = null, + AttributeGroupRepositoryInterface $attributeGroupRepository = null, + SearchCriteriaBuilder $searchCriteriaBuilder = null, + AttributeManagementInterface $attributeManagement = null, + LoggerInterface $logger = null, + ExtensionAttributesFactory $extensionAttributesFactory = null ) { parent::__construct($context, $productBuilder); $this->resultJsonFactory = $resultJsonFactory; $this->attributeGroupFactory = $attributeGroupFactory ?: ObjectManager::getInstance() ->get(AttributeGroupInterfaceFactory::class); + $this->attributeRepository = $attributeRepository ?: ObjectManager::getInstance() + ->get(AttributeRepositoryInterface::class); + $this->attributeSetRepository = $attributeSetRepository ?: ObjectManager::getInstance() + ->get(AttributeSetRepositoryInterface::class); + $this->attributeGroupRepository = $attributeGroupRepository ?: ObjectManager::getInstance() + ->get(AttributeGroupRepositoryInterface::class); + $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance() + ->get(SearchCriteriaBuilder::class); + $this->attributeManagement = $attributeManagement ?: ObjectManager::getInstance() + ->get(AttributeManagementInterface::class); + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(LoggerInterface::class); + $this->extensionAttributesFactory = $extensionAttributesFactory ?: ObjectManager::getInstance() + ->get(ExtensionAttributesFactory::class); } /** @@ -115,13 +144,13 @@ public function execute() try { /** @var AttributeSetInterface $attributeSet */ - $attributeSet = $this->getAttributeSetRepository()->get($request->getParam('templateId')); + $attributeSet = $this->attributeSetRepository->get($request->getParam('templateId')); $groupCode = $request->getParam('groupCode'); $groupName = $request->getParam('groupName'); $groupSortOrder = $request->getParam('groupSortOrder'); $attributeSearchCriteria = $this->getBasicAttributeSearchCriteriaBuilder()->create(); - $attributeGroupSearchCriteria = $this->getSearchCriteriaBuilder() + $attributeGroupSearchCriteria = $this->searchCriteriaBuilder ->addFilter('attribute_set_id', $attributeSet->getAttributeSetId()) ->addFilter('attribute_group_code', $groupCode) ->setPageSize(1) @@ -129,22 +158,24 @@ public function execute() try { /** @var AttributeGroupInterface[] $attributeGroupItems */ - $attributeGroupItems = $this->getAttributeGroupRepository()->getList($attributeGroupSearchCriteria) + $attributeGroupItems = $this->attributeGroupRepository + ->getList($attributeGroupSearchCriteria) ->getItems(); - if (!$attributeGroupItems) { - throw new NoSuchEntityException; + if ($attributeGroupItems) { + /** @var AttributeGroupInterface $attributeGroup */ + $attributeGroup = reset($attributeGroupItems); + } else { + /** @var AttributeGroupInterface $attributeGroup */ + $attributeGroup = $this->attributeGroupFactory->create(); } - - /** @var AttributeGroupInterface $attributeGroup */ - $attributeGroup = reset($attributeGroupItems); } catch (NoSuchEntityException $e) { /** @var AttributeGroupInterface $attributeGroup */ $attributeGroup = $this->attributeGroupFactory->create(); } $extensionAttributes = $attributeGroup->getExtensionAttributes() - ?: $this->getExtensionAttributesFactory()->create(AttributeGroupInterface::class); + ?: $this->extensionAttributesFactory->create(AttributeGroupInterface::class); $extensionAttributes->setAttributeGroupCode($groupCode); $extensionAttributes->setSortOrder($groupSortOrder); @@ -152,28 +183,31 @@ public function execute() $attributeGroup->setAttributeSetId($attributeSet->getAttributeSetId()); $attributeGroup->setExtensionAttributes($extensionAttributes); - $this->getAttributeGroupRepository()->save($attributeGroup); + $this->attributeGroupRepository->save($attributeGroup); /** @var AttributeInterface[] $attributesItems */ - $attributesItems = $this->getAttributeRepository()->getList( + $attributesItems = $this->attributeRepository->getList( ProductAttributeInterface::ENTITY_TYPE_CODE, $attributeSearchCriteria )->getItems(); - array_walk($attributesItems, function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) { - $this->getAttributeManagement()->assign( - ProductAttributeInterface::ENTITY_TYPE_CODE, - $attributeSet->getAttributeSetId(), - $attributeGroup->getAttributeGroupId(), - $attribute->getAttributeCode(), - '0' - ); - }); + array_walk( + $attributesItems, + function (AttributeInterface $attribute) use ($attributeSet, $attributeGroup) { + $this->attributeManagement->assign( + ProductAttributeInterface::ENTITY_TYPE_CODE, + $attributeSet->getAttributeSetId(), + $attributeGroup->getAttributeGroupId(), + $attribute->getAttributeCode(), + '0' + ); + } + ); } catch (LocalizedException $e) { $response->setError(true); $response->setMessage($e->getMessage()); } catch (\Exception $e) { - $this->getLogger()->critical($e); + $this->logger->critical($e); $response->setError(true); $response->setMessage(__('Unable to add attribute')); } @@ -195,105 +229,10 @@ private function getBasicAttributeSearchCriteriaBuilder() throw new LocalizedException(__('Attributes were missing and must be specified.')); } - return $this->getSearchCriteriaBuilder() - ->addFilter('attribute_id', [$attributeIds['selected']], 'in'); - } - - /** - * Get AttributeRepositoryInterface - * - * @return AttributeRepositoryInterface - */ - private function getAttributeRepository() - { - if (null === $this->attributeRepository) { - $this->attributeRepository = ObjectManager::getInstance() - ->get(AttributeRepositoryInterface::class); - } - return $this->attributeRepository; - } - - /** - * Get AttributeSetRepositoryInterface - * - * @return AttributeSetRepositoryInterface - */ - private function getAttributeSetRepository() - { - if (null === $this->attributeSetRepository) { - $this->attributeSetRepository = ObjectManager::getInstance() - ->get(AttributeSetRepositoryInterface::class); - } - return $this->attributeSetRepository; - } - - /** - * Get AttributeGroupInterface - * - * @return AttributeGroupRepositoryInterface - */ - private function getAttributeGroupRepository() - { - if (null === $this->attributeGroupRepository) { - $this->attributeGroupRepository = ObjectManager::getInstance() - ->get(AttributeGroupRepositoryInterface::class); - } - return $this->attributeGroupRepository; - } - - /** - * Get SearchCriteriaBuilder - * - * @return SearchCriteriaBuilder - */ - private function getSearchCriteriaBuilder() - { - if (null === $this->searchCriteriaBuilder) { - $this->searchCriteriaBuilder = ObjectManager::getInstance() - ->get(SearchCriteriaBuilder::class); - } - return $this->searchCriteriaBuilder; - } - - /** - * Get AttributeManagementInterface - * - * @return AttributeManagementInterface - */ - private function getAttributeManagement() - { - if (null === $this->attributeManagement) { - $this->attributeManagement = ObjectManager::getInstance() - ->get(AttributeManagementInterface::class); - } - return $this->attributeManagement; - } - - /** - * Get LoggerInterface - * - * @return LoggerInterface - */ - private function getLogger() - { - if (null === $this->logger) { - $this->logger = ObjectManager::getInstance() - ->get(LoggerInterface::class); - } - return $this->logger; - } - - /** - * Get ExtensionAttributesFactory. - * - * @return ExtensionAttributesFactory - */ - private function getExtensionAttributesFactory() - { - if (null === $this->extensionAttributesFactory) { - $this->extensionAttributesFactory = ObjectManager::getInstance() - ->get(ExtensionAttributesFactory::class); - } - return $this->extensionAttributesFactory; + return $this->searchCriteriaBuilder->addFilter( + 'attribute_id', + [$attributeIds['selected']], + 'in' + ); } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index c74a382724a0..ce6668229d65 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -13,6 +12,7 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject; +use Magento\Framework\Escaper; use Magento\Framework\Serialize\Serializer\FormData; /** @@ -49,6 +49,11 @@ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPo */ private $attributeCodeValidator; + /** + * @var Escaper + */ + private $escaper; + /** * Constructor * @@ -61,6 +66,8 @@ class Validate extends AttributeAction implements HttpGetActionInterface, HttpPo * @param array $multipleAttributeList * @param FormData|null $formDataSerializer * @param AttributeCodeValidator|null $attributeCodeValidator + * @param Escaper $escaper + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -71,7 +78,8 @@ public function __construct( \Magento\Framework\View\LayoutFactory $layoutFactory, array $multipleAttributeList = [], FormData $formDataSerializer = null, - AttributeCodeValidator $attributeCodeValidator = null + AttributeCodeValidator $attributeCodeValidator = null, + Escaper $escaper = null ) { parent::__construct($context, $attributeLabelCache, $coreRegistry, $resultPageFactory); $this->resultJsonFactory = $resultJsonFactory; @@ -79,9 +87,10 @@ public function __construct( $this->multipleAttributeList = $multipleAttributeList; $this->formDataSerializer = $formDataSerializer ?: ObjectManager::getInstance() ->get(FormData::class); - $this->attributeCodeValidator = $attributeCodeValidator ?: ObjectManager::getInstance()->get( - AttributeCodeValidator::class - ); + $this->attributeCodeValidator = $attributeCodeValidator ?: ObjectManager::getInstance() + ->get(AttributeCodeValidator::class); + $this->escaper = $escaper ?: ObjectManager::getInstance() + ->get(Escaper::class); } /** @@ -99,8 +108,10 @@ public function execute() $optionsData = $this->formDataSerializer ->unserialize($this->getRequest()->getParam('serialized_options', '[]')); } catch (\InvalidArgumentException $e) { - $message = __("The attribute couldn't be validated due to an error. Verify your information and try again. " - . "If the error persists, please try again later."); + $message = __( + "The attribute couldn't be validated due to an error. Verify your information and try again. " + . "If the error persists, please try again later." + ); $this->setMessageToResponse($response, [$message]); $response->setError(true); } @@ -138,7 +149,7 @@ public function execute() $attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class); $attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name'); if ($attributeSet->getId()) { - $setName = $this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($setName); + $setName = $this->escaper->escapeHtml($setName); $this->messageManager->addErrorMessage(__('An attribute set named \'%1\' already exists.', $setName)); $layout = $this->layoutFactory->create(); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php index 63e52eead064..90b8ee316418 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Duplicate.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -8,25 +7,39 @@ use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Product; +use Magento\Framework\App\ObjectManager; -class Duplicate extends \Magento\Catalog\Controller\Adminhtml\Product +/** + * Class Duplicate + */ +class Duplicate extends \Magento\Catalog\Controller\Adminhtml\Product implements + \Magento\Framework\App\Action\HttpGetActionInterface { /** * @var \Magento\Catalog\Model\Product\Copier */ protected $productCopier; + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + /** * @param Action\Context $context * @param Builder $productBuilder * @param \Magento\Catalog\Model\Product\Copier $productCopier + * @param \Psr\Log\LoggerInterface $logger */ public function __construct( \Magento\Backend\App\Action\Context $context, Product\Builder $productBuilder, - \Magento\Catalog\Model\Product\Copier $productCopier + \Magento\Catalog\Model\Product\Copier $productCopier, + \Psr\Log\LoggerInterface $logger = null ) { $this->productCopier = $productCopier; + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(\Psr\Log\LoggerInterface::class); parent::__construct($context, $productBuilder); } @@ -46,7 +59,7 @@ public function execute() $this->messageManager->addSuccessMessage(__('You duplicated the product.')); $resultRedirect->setPath('catalog/*/edit', ['_current' => true, 'id' => $newProduct->getId()]); } catch (\Exception $e) { - $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); + $this->logger->critical($e); $this->messageManager->addErrorMessage($e->getMessage()); $resultRedirect->setPath('catalog/*/edit', ['_current' => true]); } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php index c31ceabcda65..d6781be1edc0 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Edit.php @@ -1,13 +1,17 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Controller\Adminhtml\Product; use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; +use Magento\Framework\App\ObjectManager; +/** + * Edit product + */ class Edit extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface { /** @@ -22,18 +26,27 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Product implements Http */ protected $resultPageFactory; + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, - \Magento\Framework\View\Result\PageFactory $resultPageFactory + \Magento\Framework\View\Result\PageFactory $resultPageFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager = null ) { parent::__construct($context, $productBuilder); $this->resultPageFactory = $resultPageFactory; + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(\Magento\Store\Model\StoreManagerInterface::class); } /** @@ -43,15 +56,13 @@ public function __construct( */ public function execute() { - /** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ - $storeManager = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); $storeId = (int) $this->getRequest()->getParam('store', 0); - $store = $storeManager->getStore($storeId); - $storeManager->setCurrentStore($store->getCode()); + $store = $this->storeManager->getStore($storeId); + $this->storeManager->setCurrentStore($store->getCode()); $productId = (int) $this->getRequest()->getParam('id'); $product = $this->productBuilder->build($this->getRequest()); - if (($productId && !$product->getEntityId())) { + if ($productId && !$product->getEntityId()) { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $this->messageManager->addErrorMessage(__('This product doesn\'t exist.')); @@ -72,9 +83,8 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Products')); $resultPage->getConfig()->getTitle()->prepend($product->getName()); - if (!$this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->isSingleStoreMode() - && - ($switchBlock = $resultPage->getLayout()->getBlock('store_switcher')) + if (!$this->storeManager->isSingleStoreMode() + && ($switchBlock = $resultPage->getLayout()->getBlock('store_switcher')) ) { $switchBlock->setDefaultStoreName(__('Default Values')) ->setWebsiteIds($product->getWebsiteIds()) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php index ff7311e93175..f4c7891d0084 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -8,7 +7,12 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\LocalizedException; +/** + * Class Upload + */ class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterface { /** @@ -23,19 +27,58 @@ class Upload extends \Magento\Backend\App\Action implements HttpPostActionInterf */ protected $resultRawFactory; + /** + * @var array + */ + private $allowedMimeTypes = [ + 'jpg' => 'image/jpg', + 'jpeg' => 'image/jpeg', + 'gif' => 'image/png', + 'png' => 'image/gif' + ]; + + /** + * @var \Magento\Framework\Image\AdapterFactory + */ + private $adapterFactory; + + /** + * @var \Magento\Framework\Filesystem + */ + private $filesystem; + + /** + * @var \Magento\Catalog\Model\Product\Media\Config + */ + private $productMediaConfig; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory + * @param \Magento\Framework\Image\AdapterFactory $adapterFactory + * @param \Magento\Framework\Filesystem $filesystem + * @param \Magento\Catalog\Model\Product\Media\Config $productMediaConfig */ public function __construct( \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Controller\Result\RawFactory $resultRawFactory + \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, + \Magento\Framework\Image\AdapterFactory $adapterFactory = null, + \Magento\Framework\Filesystem $filesystem = null, + \Magento\Catalog\Model\Product\Media\Config $productMediaConfig = null ) { parent::__construct($context); $this->resultRawFactory = $resultRawFactory; + $this->adapterFactory = $adapterFactory ?: ObjectManager::getInstance() + ->get(\Magento\Framework\Image\AdapterFactory::class); + $this->filesystem = $filesystem ?: ObjectManager::getInstance() + ->get(\Magento\Framework\Filesystem::class); + $this->productMediaConfig = $productMediaConfig ?: ObjectManager::getInstance() + ->get(\Magento\Catalog\Model\Product\Media\Config::class); } /** + * Upload image(s) to the product gallery. + * * @return \Magento\Framework\Controller\Result\Raw */ public function execute() @@ -45,17 +88,20 @@ public function execute() \Magento\MediaStorage\Model\File\Uploader::class, ['fileId' => 'image'] ); - $uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']); - /** @var \Magento\Framework\Image\Adapter\AdapterInterface $imageAdapter */ - $imageAdapter = $this->_objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create(); + $uploader->setAllowedExtensions($this->getAllowedExtensions()); + + if (!$uploader->checkMimeType($this->getAllowedMimeTypes())) { + throw new LocalizedException(__('Disallowed File Type.')); + } + + $imageAdapter = $this->adapterFactory->create(); $uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile'); $uploader->setAllowRenameFiles(true); $uploader->setFilesDispersion(true); - /** @var \Magento\Framework\Filesystem\Directory\Read $mediaDirectory */ - $mediaDirectory = $this->_objectManager->get(\Magento\Framework\Filesystem::class) - ->getDirectoryRead(DirectoryList::MEDIA); - $config = $this->_objectManager->get(\Magento\Catalog\Model\Product\Media\Config::class); - $result = $uploader->save($mediaDirectory->getAbsolutePath($config->getBaseTmpMediaPath())); + $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + $result = $uploader->save( + $mediaDirectory->getAbsolutePath($this->productMediaConfig->getBaseTmpMediaPath()) + ); $this->_eventManager->dispatch( 'catalog_product_gallery_upload_image_after', @@ -65,8 +111,7 @@ public function execute() unset($result['tmp_name']); unset($result['path']); - $result['url'] = $this->_objectManager->get(\Magento\Catalog\Model\Product\Media\Config::class) - ->getTmpMediaUrl($result['file']); + $result['url'] = $this->productMediaConfig->getTmpMediaUrl($result['file']); $result['file'] = $result['file'] . '.tmp'; } catch (\Exception $e) { $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()]; @@ -78,4 +123,24 @@ public function execute() $response->setContents(json_encode($result)); return $response; } + + /** + * Get the set of allowed file extensions. + * + * @return array + */ + private function getAllowedExtensions() + { + return array_keys($this->allowedMimeTypes); + } + + /** + * Get the set of allowed mime types. + * + * @return array + */ + private function getAllowedMimeTypes() + { + return array_values($this->allowedMimeTypes); + } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php index f11d16755ef0..a29d02f5e545 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php @@ -6,17 +6,24 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Initialization; +use DateTime; +use Magento\Backend\Helper\Js; use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory as CustomOptionFactory; use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory as ProductLinkFactory; +use Magento\Catalog\Api\Data\ProductLinkTypeInterface; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Api\ProductRepositoryInterface\Proxy as ProductRepository; -use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeDefaultValueFilter; +use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks; use Magento\Catalog\Model\Product\Link\Resolver as LinkResolver; use Magento\Catalog\Model\Product\LinkTypeProvider; use Magento\Framework\App\ObjectManager; -use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Locale\FormatInterface; +use Magento\Framework\Stdlib\DateTime\Filter\Date; +use Magento\Store\Model\StoreManagerInterface; +use Zend_Filter_Input; /** * Product helper @@ -28,12 +35,12 @@ class Helper { /** - * @var \Magento\Framework\App\RequestInterface + * @var RequestInterface */ protected $request; /** - * @var \Magento\Store\Model\StoreManagerInterface + * @var StoreManagerInterface */ protected $storeManager; @@ -43,12 +50,12 @@ class Helper protected $stockFilter; /** - * @var \Magento\Backend\Helper\Js + * @var Js */ protected $jsHelper; /** - * @var \Magento\Framework\Stdlib\DateTime\Filter\Date + * @var Date * @deprecated 101.0.0 */ protected $dateFilter; @@ -96,34 +103,41 @@ class Helper */ private $attributeFilter; + /** + * @var FormatInterface + */ + private $localeFormat; + /** * Constructor * - * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param RequestInterface $request + * @param StoreManagerInterface $storeManager * @param StockDataFilter $stockFilter * @param ProductLinks $productLinks - * @param \Magento\Backend\Helper\Js $jsHelper - * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter + * @param Js $jsHelper + * @param Date $dateFilter * @param CustomOptionFactory|null $customOptionFactory * @param ProductLinkFactory|null $productLinkFactory * @param ProductRepositoryInterface|null $productRepository * @param LinkTypeProvider|null $linkTypeProvider * @param AttributeFilter|null $attributeFilter + * @param FormatInterface|null $localeFormat * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\App\RequestInterface $request, - \Magento\Store\Model\StoreManagerInterface $storeManager, + RequestInterface $request, + StoreManagerInterface $storeManager, StockDataFilter $stockFilter, - \Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks, - \Magento\Backend\Helper\Js $jsHelper, - \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter, + ProductLinks $productLinks, + Js $jsHelper, + Date $dateFilter, CustomOptionFactory $customOptionFactory = null, ProductLinkFactory $productLinkFactory = null, ProductRepositoryInterface $productRepository = null, LinkTypeProvider $linkTypeProvider = null, - AttributeFilter $attributeFilter = null + AttributeFilter $attributeFilter = null, + FormatInterface $localeFormat = null ) { $this->request = $request; $this->storeManager = $storeManager; @@ -132,26 +146,27 @@ public function __construct( $this->jsHelper = $jsHelper; $this->dateFilter = $dateFilter; - $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $objectManager = ObjectManager::getInstance(); $this->customOptionFactory = $customOptionFactory ?: $objectManager->get(CustomOptionFactory::class); $this->productLinkFactory = $productLinkFactory ?: $objectManager->get(ProductLinkFactory::class); $this->productRepository = $productRepository ?: $objectManager->get(ProductRepositoryInterface::class); $this->linkTypeProvider = $linkTypeProvider ?: $objectManager->get(LinkTypeProvider::class); $this->attributeFilter = $attributeFilter ?: $objectManager->get(AttributeFilter::class); + $this->localeFormat = $localeFormat ?: $objectManager->get(FormatInterface::class); } /** * Initialize product from data * - * @param \Magento\Catalog\Model\Product $product + * @param Product $product * @param array $productData - * @return \Magento\Catalog\Model\Product + * @return Product * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @since 101.0.0 */ - public function initializeFromData(\Magento\Catalog\Model\Product $product, array $productData) + public function initializeFromData(Product $product, array $productData) { unset($productData['custom_attributes'], $productData['extension_attributes']); @@ -190,7 +205,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra } } - $inputFilter = new \Zend_Filter_Input($dateFieldFilters, [], $productData); + $inputFilter = new Zend_Filter_Input($dateFieldFilters, [], $productData); $productData = $inputFilter->getUnescaped(); if (isset($productData['options'])) { @@ -201,7 +216,7 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra } $productData['tier_price'] = isset($productData['tier_price']) ? $productData['tier_price'] : []; - $useDefaults = (array)$this->request->getPost('use_default', []); + $useDefaults = (array) $this->request->getPost('use_default', []); $productData = $this->attributeFilter->prepareProductAttributes($product, $productData, $useDefaults); $product->addData($productData); @@ -222,24 +237,25 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra /** * Initialize product before saving * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\Catalog\Model\Product + * @param Product $product + * @return Product */ - public function initialize(\Magento\Catalog\Model\Product $product) + public function initialize(Product $product) { $productData = $this->request->getPost('product', []); + return $this->initializeFromData($product, $productData); } /** * Setting product links * - * @param \Magento\Catalog\Model\Product $product - * @return \Magento\Catalog\Model\Product + * @param Product $product + * @return Product * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @since 101.0.0 */ - protected function setProductLinks(\Magento\Catalog\Model\Product $product) + protected function setProductLinks(Product $product) { $links = $this->getLinkResolver()->getLinks(); @@ -249,7 +265,7 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product) $productLinks = $product->getProductLinks(); $linkTypes = []; - /** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkTypeObject */ + /** @var ProductLinkTypeInterface $linkTypeObject */ foreach ($this->linkTypeProvider->getItems() as $linkTypeObject) { $linkTypes[$linkTypeObject->getName()] = $product->getData($linkTypeObject->getName() . '_readonly'); } @@ -261,7 +277,7 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product) foreach ($linkTypes as $linkType => $readonly) { if (isset($links[$linkType]) && !$readonly) { - foreach ((array)$links[$linkType] as $linkData) { + foreach ((array) $links[$linkType] as $linkData) { if (empty($linkData['id'])) { continue; } @@ -271,7 +287,7 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product) $link->setSku($product->getSku()) ->setLinkedProductSku($linkProduct->getSku()) ->setLinkType($linkType) - ->setPosition(isset($linkData['position']) ? (int)$linkData['position'] : 0); + ->setPosition(isset($linkData['position']) ? (int) $linkData['position'] : 0); $productLinks[] = $link; } } @@ -377,6 +393,7 @@ private function getLinkResolver() if (!is_object($this->linkResolver)) { $this->linkResolver = ObjectManager::getInstance()->get(LinkResolver::class); } + return $this->linkResolver; } @@ -389,9 +406,10 @@ private function getLinkResolver() private function getDateTimeFilter() { if ($this->dateTimeFilter === null) { - $this->dateTimeFilter = \Magento\Framework\App\ObjectManager::getInstance() + $this->dateTimeFilter = ObjectManager::getInstance() ->get(\Magento\Framework\Stdlib\DateTime\Filter\DateTime::class); } + return $this->dateTimeFilter; } @@ -407,7 +425,7 @@ private function getDateTimeFilter() private function filterWebsiteIds($websiteIds) { if (!$this->storeManager->isSingleStoreMode()) { - $websiteIds = array_filter((array)$websiteIds); + $websiteIds = array_filter((array) $websiteIds); } else { $websiteIds[$this->storeManager->getWebsite(true)->getId()] = 1; } @@ -448,9 +466,17 @@ private function fillProductOptions(Product $product, array $productOptions) } if (isset($customOptionData['values'])) { - $customOptionData['values'] = array_filter($customOptionData['values'], function ($valueData) { - return empty($valueData['is_delete']); - }); + $customOptionData['values'] = array_filter( + $customOptionData['values'], + function ($valueData) { + return empty($valueData['is_delete']); + } + ); + } + + if (isset($customOptionData['price'])) { + // Make sure we're working with a number here and no localized value. + $customOptionData['price'] = $this->localeFormat->getNumber($customOptionData['price']); } $customOption = $this->customOptionFactory->create(['data' => $customOptionData]); @@ -471,7 +497,7 @@ private function convertSpecialFromDateStringToObject($productData) { if (isset($productData['special_from_date']) && $productData['special_from_date'] != '') { $productData['special_from_date'] = $this->getDateTimeFilter()->filter($productData['special_from_date']); - $productData['special_from_date'] = new \DateTime($productData['special_from_date']); + $productData['special_from_date'] = new DateTime($productData['special_from_date']); } return $productData; diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php index 47324c5b7090..f7e69bc72ea1 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/StockDataFilter.php @@ -7,7 +7,6 @@ use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\CatalogInventory\Model\Stock; /** * Class StockDataFilter @@ -61,8 +60,8 @@ public function filter(array $stockData) $stockData['qty'] = self::MAX_QTY_VALUE; } - if (isset($stockData['min_qty'])) { - $stockData['min_qty'] = $this->purifyMinQty($stockData['min_qty'], $stockData['backorders']); + if (isset($stockData['min_qty']) && (int)$stockData['min_qty'] < 0) { + $stockData['min_qty'] = 0; } if (!isset($stockData['is_decimal_divided']) || $stockData['is_qty_decimal'] == 0) { @@ -71,27 +70,4 @@ public function filter(array $stockData) return $stockData; } - - /** - * Purifies min_qty. - * - * @param int $minQty - * @param int $backOrders - * @return float - */ - private function purifyMinQty(int $minQty, int $backOrders): float - { - /** - * As described in the documentation if the Backorders Option is disabled - * it is recommended to set the Out Of Stock Threshold to a positive number. - * That's why to clarify the logic to the end user the code below prevent him to set a negative number so such - * a number will turn to zero. - * @see https://docs.magento.com/m2/ce/user_guide/catalog/inventory-backorders.html - */ - if ($backOrders === Stock::BACKORDERS_NO && $minQty < 0) { - $minQty = 0; - } - - return (float)$minQty; - } } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php index 9d7273fb3f23..b6c4db6c6438 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php @@ -7,8 +7,8 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; -use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Product; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\ResultFactory; use Magento\Ui\Component\MassAction\Filter; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; @@ -37,22 +37,31 @@ class MassStatus extends \Magento\Catalog\Controller\Adminhtml\Product implement protected $collectionFactory; /** - * @param Action\Context $context + * @var \Magento\Catalog\Model\Product\Action + */ + private $productAction; + + /** + * @param \Magento\Backend\App\Action\Context $context * @param Builder $productBuilder * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor * @param Filter $filter * @param CollectionFactory $collectionFactory + * @param \Magento\Catalog\Model\Product\Action $productAction */ public function __construct( \Magento\Backend\App\Action\Context $context, Product\Builder $productBuilder, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, Filter $filter, - CollectionFactory $collectionFactory + CollectionFactory $collectionFactory, + \Magento\Catalog\Model\Product\Action $productAction = null ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; + $this->productAction = $productAction ?: ObjectManager::getInstance() + ->get(\Magento\Catalog\Model\Product\Action::class); parent::__construct($context, $productBuilder); } @@ -94,8 +103,7 @@ public function execute() try { $this->_validateMassStatus($productIds, $status); - $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) - ->updateAttributes($productIds, ['status' => $status], (int) $storeId); + $this->productAction->updateAttributes($productIds, ['status' => $status], (int) $storeId); $this->messageManager->addSuccessMessage( __('A total of %1 record(s) have been updated.', count($productIds)) ); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php index 825d0ee032d6..5c3e27334cb6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -11,6 +10,7 @@ use Magento\Backend\App\Action; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Controller\Adminhtml\Product; +use Magento\Framework\App\ObjectManager; use Magento\Store\Model\StoreManagerInterface; use Magento\Framework\App\Request\DataPersistorInterface; @@ -56,12 +56,12 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product implements Http private $storeManager; /** - * @var \Magento\Framework\Escaper|null + * @var \Magento\Framework\Escaper */ private $escaper; /** - * @var null|\Psr\Log\LoggerInterface + * @var \Psr\Log\LoggerInterface */ private $logger; @@ -74,8 +74,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product implements Http * @param \Magento\Catalog\Model\Product\Copier $productCopier * @param \Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository - * @param \Magento\Framework\Escaper|null $escaper - * @param \Psr\Log\LoggerInterface|null $logger + * @param \Magento\Framework\Escaper $escaper + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement + * @param StoreManagerInterface $storeManager + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -85,15 +88,23 @@ public function __construct( \Magento\Catalog\Model\Product\TypeTransitionManager $productTypeManager, \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Escaper $escaper = null, - \Psr\Log\LoggerInterface $logger = null + \Psr\Log\LoggerInterface $logger = null, + \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement = null, + \Magento\Store\Model\StoreManagerInterface $storeManager = null ) { + parent::__construct($context, $productBuilder); $this->initializationHelper = $initializationHelper; $this->productCopier = $productCopier; $this->productTypeManager = $productTypeManager; $this->productRepository = $productRepository; - parent::__construct($context, $productBuilder); - $this->escaper = $escaper ?? $this->_objectManager->get(\Magento\Framework\Escaper::class); - $this->logger = $logger ?? $this->_objectManager->get(\Psr\Log\LoggerInterface::class); + $this->escaper = $escaper ?: ObjectManager::getInstance() + ->get(\Magento\Framework\Escaper::class); + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(\Psr\Log\LoggerInterface::class); + $this->categoryLinkManagement = $categoryLinkManagement ?: ObjectManager::getInstance() + ->get(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(\Magento\Store\Model\StoreManagerInterface::class); } /** @@ -106,8 +117,8 @@ public function __construct( public function execute() { $storeId = $this->getRequest()->getParam('store', 0); - $store = $this->getStoreManager()->getStore($storeId); - $this->getStoreManager()->setCurrentStore($store->getCode()); + $store = $this->storeManager->getStore($storeId); + $this->storeManager->setCurrentStore($store->getCode()); $redirectBack = $this->getRequest()->getParam('back', false); $productId = $this->getRequest()->getParam('id'); $resultRedirect = $this->resultRedirectFactory->create(); @@ -130,7 +141,7 @@ public function execute() $canSaveCustomOptions = $product->getCanSaveCustomOptions(); $product->save(); $this->handleImageRemoveError($data, $product->getId()); - $this->getCategoryLinkManagement()->assignProductToCategories( + $this->categoryLinkManagement->assignProductToCategories( $product->getSku(), $product->getCategoryIds() ); @@ -236,11 +247,9 @@ private function handleImageRemoveError($postData, $productId) /** * Do copying data to stores * - * If the 'copy_from' field is not specified in the input data, - * the store fallback mechanism will automatically take the admin store's default value. - * * @param array $data * @param int $productId + * * @return void */ protected function copyToStores($data, $productId) @@ -250,19 +259,7 @@ protected function copyToStores($data, $productId) if (isset($data['product']['website_ids'][$websiteId]) && (bool)$data['product']['website_ids'][$websiteId]) { foreach ($group as $store) { - if (isset($store['copy_from'])) { - $copyFrom = $store['copy_from']; - $copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0; - if ($copyTo) { - $this->_objectManager->create(\Magento\Catalog\Model\Product::class) - ->setStoreId($copyFrom) - ->load($productId) - ->setStoreId($copyTo) - ->setCanSaveCustomOptions($data['can_save_custom_options']) - ->setCopyFromView(true) - ->save(); - } - } + $this->copyToStore($data, $productId, $store); } } } @@ -270,32 +267,30 @@ protected function copyToStores($data, $productId) } /** - * Get categoryLinkManagement in a backward compatible way. + * Do copying data to stores * - * @return \Magento\Catalog\Api\CategoryLinkManagementInterface - */ - private function getCategoryLinkManagement() - { - if (null === $this->categoryLinkManagement) { - $this->categoryLinkManagement = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Catalog\Api\CategoryLinkManagementInterface::class); - } - return $this->categoryLinkManagement; - } - - /** - * Get storeManager in a backward compatible way. + * If the 'copy_from' field is not specified in the input data, + * the store fallback mechanism will automatically take the admin store's default value. * - * @return StoreManagerInterface - * @deprecated 101.0.0 + * @param array $data + * @param int $productId + * @param array $store */ - private function getStoreManager() + private function copyToStore($data, $productId, $store) { - if (null === $this->storeManager) { - $this->storeManager = \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Store\Model\StoreManagerInterface::class); + if (isset($store['copy_from'])) { + $copyFrom = $store['copy_from']; + $copyTo = (isset($store['copy_to'])) ? $store['copy_to'] : 0; + if ($copyTo) { + $this->_objectManager->create(\Magento\Catalog\Model\Product::class) + ->setStoreId($copyFrom) + ->load($productId) + ->setStoreId($copyTo) + ->setCanSaveCustomOptions($data['can_save_custom_options']) + ->setCopyFromView(true) + ->save(); + } } - return $this->storeManager; } /** diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php index 6f6870cb0849..89d2c1b8a066 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php @@ -6,45 +6,63 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Set; -use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; +use Magento\Framework\Registry; +use Magento\Backend\App\Action\Context; +use Magento\Framework\App\ObjectManager; +use Magento\Backend\Model\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Eav\Api\AttributeSetRepositoryInterface; +use Magento\Catalog\Controller\Adminhtml\Product\Set; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\App\Action\HttpGetActionInterface; -class Edit extends \Magento\Catalog\Controller\Adminhtml\Product\Set implements HttpGetActionInterface +/** + * Edit attribute set controller. + */ +class Edit extends Set implements HttpGetActionInterface { /** - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; /** - * @param \Magento\Backend\App\Action\Context $context - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory + * @var AttributeSetRepositoryInterface + */ + private $attributeSetRepository; + + /** + * @param Context $context + * @param Registry $coreRegistry + * @param PageFactory $resultPageFactory + * @param AttributeSetRepositoryInterface $attributeSetRepository */ public function __construct( - \Magento\Backend\App\Action\Context $context, - \Magento\Framework\Registry $coreRegistry, - \Magento\Framework\View\Result\PageFactory $resultPageFactory + Context $context, + Registry $coreRegistry, + PageFactory $resultPageFactory, + AttributeSetRepositoryInterface $attributeSetRepository = null ) { parent::__construct($context, $coreRegistry); $this->resultPageFactory = $resultPageFactory; + $this->attributeSetRepository = $attributeSetRepository ?: + ObjectManager::getInstance()->get(AttributeSetRepositoryInterface::class); } /** - * @return \Magento\Backend\Model\View\Result\Page + * @inheritdoc */ public function execute() { $this->_setTypeId(); - $attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class) - ->load($this->getRequest()->getParam('id')); - + $attributeSet = $this->attributeSetRepository->get($this->getRequest()->getParam('id')); if (!$attributeSet->getId()) { return $this->resultRedirectFactory->create()->setPath('catalog/*/index'); } - $this->_coreRegistry->register('current_attribute_set', $attributeSet); - /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ + /** @var Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->setActiveMenu('Magento_Catalog::catalog_attributes_sets'); $resultPage->getConfig()->getTitle()->prepend(__('Attribute Sets')); diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php index c0bb9f60c187..e7d576e5e941 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Wysiwyg.php @@ -1,12 +1,17 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Catalog\Controller\Adminhtml\Product; -class Wysiwyg extends \Magento\Catalog\Controller\Adminhtml\Product +use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\ObjectManager; + +/** + * Class Wysiwyg + */ +class Wysiwyg extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpPostActionInterface { /** * @var \Magento\Framework\Controller\Result\RawFactory @@ -18,21 +23,30 @@ class Wysiwyg extends \Magento\Catalog\Controller\Adminhtml\Product */ protected $layoutFactory; + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Store\Model\StoreManagerInterface $storeManager */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder, \Magento\Framework\Controller\Result\RawFactory $resultRawFactory, - \Magento\Framework\View\LayoutFactory $layoutFactory + \Magento\Framework\View\LayoutFactory $layoutFactory, + \Magento\Store\Model\StoreManagerInterface $storeManager = null ) { parent::__construct($context, $productBuilder); $this->resultRawFactory = $resultRawFactory; $this->layoutFactory = $layoutFactory; + $this->storeManager = $storeManager ?: ObjectManager::getInstance() + ->get(\Magento\Store\Model\StoreManagerInterface::class); } /** @@ -42,10 +56,11 @@ public function __construct( */ public function execute() { + // @codingStandardsIgnoreStart $elementId = $this->getRequest()->getParam('element_id', md5(microtime())); + // @codingStandardsIgnoreEnd $storeId = $this->getRequest()->getParam('store_id', 0); - $storeMediaUrl = $this->_objectManager->get(\Magento\Store\Model\StoreManagerInterface::class) - ->getStore($storeId) + $storeMediaUrl = $this->storeManager->getStore($storeId) ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $content = $this->layoutFactory->create() diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php index da3d99a8d274..770a306431b7 100644 --- a/app/code/Magento/Catalog/Controller/Category/View.php +++ b/app/code/Magento/Catalog/Controller/Category/View.php @@ -7,6 +7,7 @@ namespace Magento\Catalog\Controller\Category; use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Helper\Category as CategoryHelper; use Magento\Catalog\Model\Category; use Magento\Catalog\Model\Design; use Magento\Catalog\Model\Layer\Resolver; @@ -18,6 +19,7 @@ use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\App\ActionInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\Result\ForwardFactory; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\DataObject; @@ -94,6 +96,16 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter */ private $toolbarMemorizer; + /** + * @var CategoryHelper + */ + private $categoryHelper; + + /** + * @var LoggerInterface + */ + private $logger; + /** * Constructor * @@ -107,7 +119,9 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter * @param ForwardFactory $resultForwardFactory * @param Resolver $layerResolver * @param CategoryRepositoryInterface $categoryRepository - * @param ToolbarMemorizer|null $toolbarMemorizer + * @param ToolbarMemorizer $toolbarMemorizer + * @param CategoryHelper $categoryHelper + * @param LoggerInterface $logger * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -121,7 +135,9 @@ public function __construct( ForwardFactory $resultForwardFactory, Resolver $layerResolver, CategoryRepositoryInterface $categoryRepository, - ToolbarMemorizer $toolbarMemorizer = null + ToolbarMemorizer $toolbarMemorizer = null, + CategoryHelper $categoryHelper = null, + LoggerInterface $logger = null ) { parent::__construct($context); $this->_storeManager = $storeManager; @@ -133,7 +149,12 @@ public function __construct( $this->resultForwardFactory = $resultForwardFactory; $this->layerResolver = $layerResolver; $this->categoryRepository = $categoryRepository; - $this->toolbarMemorizer = $toolbarMemorizer ?: $context->getObjectManager()->get(ToolbarMemorizer::class); + $this->toolbarMemorizer = $toolbarMemorizer ?: ObjectManager::getInstance() + ->get(ToolbarMemorizer::class); + $this->categoryHelper = $categoryHelper ?: ObjectManager::getInstance() + ->get(CategoryHelper::class); + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(LoggerInterface::class); } /** @@ -153,7 +174,7 @@ protected function _initCategory() } catch (NoSuchEntityException $e) { return false; } - if (!$this->_objectManager->get(\Magento\Catalog\Helper\Category::class)->canShow($category)) { + if (!$this->categoryHelper->canShow($category)) { return false; } $this->_catalogSession->setLastVisitedCategoryId($category->getId()); @@ -165,7 +186,7 @@ protected function _initCategory() ['category' => $category, 'controller_action' => $this] ); } catch (LocalizedException $e) { - $this->_objectManager->get(LoggerInterface::class)->critical($e); + $this->logger->critical($e); return false; } diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php index f5c3171a3fe9..8b854361fd4e 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Add.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Add.php @@ -6,14 +6,72 @@ */ namespace Magento\Catalog\Controller\Product\Compare; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\ViewModel\Product\Checker\AddToCompareAvailability; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +use Magento\Framework\Data\Form\FormKey\Validator; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\View\Result\PageFactory; /** * Add item to compare list action. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Add extends \Magento\Catalog\Controller\Product\Compare implements HttpPostActionInterface { + /** + * @var AddToCompareAvailability + */ + private $compareAvailability; + + /** + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory + * @param \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Customer\Model\Visitor $customerVisitor + * @param \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList + * @param \Magento\Catalog\Model\Session $catalogSession + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param Validator $formKeyValidator + * @param PageFactory $resultPageFactory + * @param ProductRepositoryInterface $productRepository + * @param AddToCompareAvailability|null $compareAvailability + * @SuppressWarnings(PHPMD.ExcessiveParameterList) + */ + public function __construct( + \Magento\Framework\App\Action\Context $context, + \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory, + \Magento\Catalog\Model\ResourceModel\Product\Compare\Item\CollectionFactory $itemCollectionFactory, + \Magento\Customer\Model\Session $customerSession, + \Magento\Customer\Model\Visitor $customerVisitor, + \Magento\Catalog\Model\Product\Compare\ListCompare $catalogProductCompareList, + \Magento\Catalog\Model\Session $catalogSession, + \Magento\Store\Model\StoreManagerInterface $storeManager, + Validator $formKeyValidator, + PageFactory $resultPageFactory, + ProductRepositoryInterface $productRepository, + AddToCompareAvailability $compareAvailability = null + ) { + parent::__construct( + $context, + $compareItemFactory, + $itemCollectionFactory, + $customerSession, + $customerVisitor, + $catalogProductCompareList, + $catalogSession, + $storeManager, + $formKeyValidator, + $resultPageFactory, + $productRepository + ); + + $this->compareAvailability = $compareAvailability + ?: $this->_objectManager->get(AddToCompareAvailability::class); + } + /** * Add item to compare list. * @@ -36,7 +94,7 @@ public function execute() $product = null; } - if ($product && $product->isSalable()) { + if ($product && $this->compareAvailability->isAvailableForCompare($product)) { $this->_catalogProductCompareList->addProduct($product); $productName = $this->_objectManager->get( \Magento\Framework\Escaper::class diff --git a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php index acf0f1b754c1..f5d56dc9e6b0 100644 --- a/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php +++ b/app/code/Magento/Catalog/Controller/Product/Compare/Remove.php @@ -6,6 +6,7 @@ */ namespace Magento\Catalog\Controller\Product\Compare; +use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Framework\Exception\NoSuchEntityException; @@ -17,12 +18,13 @@ class Remove extends \Magento\Catalog\Controller\Product\Compare implements Http /** * Remove item from compare list. * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @return \Magento\Framework\Controller\ResultInterface */ public function execute() { $productId = (int)$this->getRequest()->getParam('product'); - if ($productId) { + if ($this->_formKeyValidator->validate($this->getRequest()) && $productId) { $storeId = $this->_storeManager->getStore()->getId(); try { /** @var \Magento\Catalog\Model\Product $product */ @@ -31,7 +33,7 @@ public function execute() $product = null; } - if ($product && $product->isSalable()) { + if ($product && (int)$product->getStatus() !== Status::STATUS_DISABLED) { /** @var $item \Magento\Catalog\Model\Product\Compare\Item */ $item = $this->_compareItemFactory->create(); if ($this->_customerSession->isLoggedIn()) { diff --git a/app/code/Magento/Catalog/Controller/Product/View.php b/app/code/Magento/Catalog/Controller/Product/View.php index 024123e15150..570b8f541b76 100644 --- a/app/code/Magento/Catalog/Controller/Product/View.php +++ b/app/code/Magento/Catalog/Controller/Product/View.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -9,11 +8,14 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; use Magento\Framework\App\Action\Context; +use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Result\PageFactory; use Magento\Catalog\Controller\Product as ProductAction; /** - * View a product on storefront. Needs to be accessible by POST because of the store switching. + * View a product on storefront. Needs to be accessible by POST because of the store switching + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class View extends ProductAction implements HttpGetActionInterface, HttpPostActionInterface { @@ -32,6 +34,16 @@ class View extends ProductAction implements HttpGetActionInterface, HttpPostActi */ protected $resultPageFactory; + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + + /** + * @var \Magento\Framework\Json\Helper\Data + */ + private $jsonHelper; + /** * Constructor * @@ -39,17 +51,25 @@ class View extends ProductAction implements HttpGetActionInterface, HttpPostActi * @param \Magento\Catalog\Helper\Product\View $viewHelper * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory * @param PageFactory $resultPageFactory + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Json\Helper\Data $jsonHelper */ public function __construct( Context $context, \Magento\Catalog\Helper\Product\View $viewHelper, \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory, - PageFactory $resultPageFactory + PageFactory $resultPageFactory, + \Psr\Log\LoggerInterface $logger = null, + \Magento\Framework\Json\Helper\Data $jsonHelper = null ) { + parent::__construct($context); $this->viewHelper = $viewHelper; $this->resultForwardFactory = $resultForwardFactory; $this->resultPageFactory = $resultPageFactory; - parent::__construct($context); + $this->logger = $logger ?: ObjectManager::getInstance() + ->get(\Psr\Log\LoggerInterface::class); + $this->jsonHelper = $jsonHelper ?: ObjectManager::getInstance() + ->get(\Magento\Framework\Json\Helper\Data::class); } /** @@ -84,21 +104,23 @@ public function execute() if ($this->getRequest()->isPost() && $this->getRequest()->getParam(self::PARAM_NAME_URL_ENCODED)) { $product = $this->_initProduct(); - + if (!$product) { return $this->noProductRedirect(); } - + if ($specifyOptions) { $notice = $product->getTypeInstance()->getSpecifyOptionMessage(); $this->messageManager->addNoticeMessage($notice); } - + if ($this->getRequest()->isAjax()) { $this->getResponse()->representJson( - $this->_objectManager->get(\Magento\Framework\Json\Helper\Data::class)->jsonEncode([ - 'backUrl' => $this->_redirect->getRedirectUrl() - ]) + $this->jsonHelper->jsonEncode( + [ + 'backUrl' => $this->_redirect->getRedirectUrl() + ] + ) ); return; } @@ -120,7 +142,7 @@ public function execute() } catch (\Magento\Framework\Exception\NoSuchEntityException $e) { return $this->noProductRedirect(); } catch (\Exception $e) { - $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); + $this->logger->critical($e); $resultForward = $this->resultForwardFactory->create(); $resultForward->forward('noroute'); return $resultForward; diff --git a/app/code/Magento/Catalog/Helper/Image.php b/app/code/Magento/Catalog/Helper/Image.php index 9b8d0ad75a8c..110b798df9df 100644 --- a/app/code/Magento/Catalog/Helper/Image.php +++ b/app/code/Magento/Catalog/Helper/Image.php @@ -213,31 +213,29 @@ protected function setImageProperties() // Set 'keep frame' flag $frame = $this->getFrame(); - if (!empty($frame)) { - $this->_getModel()->setKeepFrame($frame); - } + $this->_getModel()->setKeepFrame($frame); // Set 'constrain only' flag $constrain = $this->getAttribute('constrain'); - if (!empty($constrain)) { + if (null !== $constrain) { $this->_getModel()->setConstrainOnly($constrain); } // Set 'keep aspect ratio' flag $aspectRatio = $this->getAttribute('aspect_ratio'); - if (!empty($aspectRatio)) { + if (null !== $aspectRatio) { $this->_getModel()->setKeepAspectRatio($aspectRatio); } // Set 'transparency' flag $transparency = $this->getAttribute('transparency'); - if (!empty($transparency)) { + if (null !== $transparency) { $this->_getModel()->setKeepTransparency($transparency); } // Set background color $background = $this->getAttribute('background'); - if (!empty($background)) { + if (null !== $background) { $this->_getModel()->setBackgroundColor($background); } diff --git a/app/code/Magento/Catalog/Helper/Output.php b/app/code/Magento/Catalog/Helper/Output.php index 33e261dc353b..93b67965e723 100644 --- a/app/code/Magento/Catalog/Helper/Output.php +++ b/app/code/Magento/Catalog/Helper/Output.php @@ -9,9 +9,21 @@ use Magento\Catalog\Model\Category as ModelCategory; use Magento\Catalog\Model\Product as ModelProduct; +use Magento\Eav\Model\Config; +use Magento\Framework\App\Helper\AbstractHelper; +use Magento\Framework\App\Helper\Context; +use Magento\Framework\Escaper; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Filter\Template; +use function is_object; +use function method_exists; +use function preg_match; +use function strtolower; -class Output extends \Magento\Framework\App\Helper\AbstractHelper +/** + * Html output + */ +class Output extends AbstractHelper { /** * Array of existing handlers @@ -37,12 +49,12 @@ class Output extends \Magento\Framework\App\Helper\AbstractHelper /** * Eav config * - * @var \Magento\Eav\Model\Config + * @var Config */ protected $_eavConfig; /** - * @var \Magento\Framework\Escaper + * @var Escaper */ protected $_escaper; @@ -53,27 +65,32 @@ class Output extends \Magento\Framework\App\Helper\AbstractHelper /** * Output constructor. - * @param \Magento\Framework\App\Helper\Context $context - * @param \Magento\Eav\Model\Config $eavConfig + * @param Context $context + * @param Config $eavConfig * @param Data $catalogData - * @param \Magento\Framework\Escaper $escaper + * @param Escaper $escaper * @param array $directivePatterns + * @param array $handlers */ public function __construct( - \Magento\Framework\App\Helper\Context $context, - \Magento\Eav\Model\Config $eavConfig, + Context $context, + Config $eavConfig, Data $catalogData, - \Magento\Framework\Escaper $escaper, - $directivePatterns = [] + Escaper $escaper, + $directivePatterns = [], + array $handlers = [] ) { $this->_eavConfig = $eavConfig; $this->_catalogData = $catalogData; $this->_escaper = $escaper; $this->directivePatterns = $directivePatterns; + $this->_handlers = $handlers; parent::__construct($context); } /** + * Return template processor + * * @return Template */ protected function _getTemplateProcessor() @@ -115,8 +132,7 @@ public function addHandler($method, $handler) */ public function getHandlers($method) { - $method = strtolower($method); - return $this->_handlers[$method] ?? []; + return $this->_handlers[strtolower($method)] ?? []; } /** @@ -145,21 +161,21 @@ public function process($method, $result, $params) * @param string $attributeName * @return string * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function productAttribute($product, $attributeHtml, $attributeName) { $attribute = $this->_eavConfig->getAttribute(ModelProduct::ENTITY, $attributeName); if ($attribute && $attribute->getId() && - $attribute->getFrontendInput() != 'media_image' && + $attribute->getFrontendInput() !== 'media_image' && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled()) ) { - if ($attribute->getFrontendInput() != 'price') { + if ($attribute->getFrontendInput() !== 'price') { $attributeHtml = $this->_escaper->escapeHtml($attributeHtml); } - if ($attribute->getFrontendInput() == 'textarea') { + if ($attribute->getFrontendInput() === 'textarea') { $attributeHtml = nl2br($attributeHtml); } } @@ -187,14 +203,14 @@ public function productAttribute($product, $attributeHtml, $attributeName) * @param string $attributeHtml * @param string $attributeName * @return string - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function categoryAttribute($category, $attributeHtml, $attributeName) { $attribute = $this->_eavConfig->getAttribute(ModelCategory::ENTITY, $attributeName); if ($attribute && - $attribute->getFrontendInput() != 'image' && + $attribute->getFrontendInput() !== 'image' && (!$attribute->getIsHtmlAllowedOnFront() && !$attribute->getIsWysiwygEnabled()) ) { diff --git a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php index 0940ca7a234a..cf194615b1f3 100644 --- a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php +++ b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php @@ -81,7 +81,7 @@ public function containsValue($entityType, $entity, $attributeCode, $storeId) if ((int)$storeId === Store::DEFAULT_STORE_ID) { return false; } - if ($this->attributesValues === null) { + if (!isset($this->attributesValues[$storeId])) { $this->initAttributeValues($entityType, $entity, (int)$storeId); } @@ -110,6 +110,8 @@ public function getDefaultValues($entityType, $entity) } /** + * Init attribute values. + * * @param string $entityType * @param \Magento\Catalog\Model\AbstractModel $entity * @param int $storeId @@ -158,6 +160,8 @@ private function initAttributeValues($entityType, $entity, $storeId) } /** + * Returns entity attributes. + * * @param string $entityType * @return \Magento\Eav\Api\Data\AttributeInterface[] */ diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php index 97bc00bc7dd6..4dda2fe5786e 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/Sortby.php @@ -40,7 +40,7 @@ protected function _getCatalogConfig() } /** - * {@inheritdoc} + * @inheritdoc */ public function getAllOptions() { @@ -49,7 +49,7 @@ public function getAllOptions() foreach ($this->_getCatalogConfig()->getAttributesUsedForSortBy() as $attribute) { $this->_options[] = [ 'label' => __($attribute['frontend_label']), - 'value' => $attribute['attribute_code'], + 'value' => $attribute['attribute_code'] ]; } } diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php index c96b2aae3605..d2e237779e2a 100644 --- a/app/code/Magento/Catalog/Model/Category/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Model\Category; use Magento\Catalog\Api\Data\CategoryInterface; @@ -20,6 +22,7 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Filesystem; use Magento\Framework\Stdlib\ArrayManager; +use Magento\Framework\Stdlib\ArrayUtils; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\Ui\Component\Form\Field; @@ -28,10 +31,9 @@ use Magento\Framework\AuthorizationInterface; /** - * Class DataProvider + * Category form data provider. * * @api - * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) * @since 101.0.0 @@ -52,6 +54,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider /** * EAV attribute properties to fetch from meta storage + * * @var array * @since 101.0.0 */ @@ -143,6 +146,11 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider */ private $arrayManager; + /** + * @var ArrayUtils + */ + private $arrayUtils; + /** * @var Filesystem */ @@ -154,8 +162,6 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider private $auth; /** - * DataProvider constructor - * * @param string $name * @param string $primaryFieldName * @param string $requestFieldName @@ -170,6 +176,8 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @param array $data * @param PoolInterface|null $pool * @param AuthorizationInterface|null $auth + * @param ArrayUtils|null $arrayUtils + * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -186,7 +194,8 @@ public function __construct( array $meta = [], array $data = [], PoolInterface $pool = null, - ?AuthorizationInterface $auth = null + ?AuthorizationInterface $auth = null, + ?ArrayUtils $arrayUtils = null ) { $this->eavValidationRules = $eavValidationRules; $this->collection = $categoryCollectionFactory->create(); @@ -197,6 +206,7 @@ public function __construct( $this->request = $request; $this->categoryFactory = $categoryFactory; $this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class); + $this->arrayUtils = $arrayUtils ?? ObjectManager::getInstance()->get(ArrayUtils::class); parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); } @@ -226,7 +236,7 @@ public function getMeta() * @param array $meta * @return array */ - private function addUseDefaultValueCheckbox(Category $category, array $meta) + private function addUseDefaultValueCheckbox(Category $category, array $meta): array { /** @var EavAttributeInterface $attribute */ foreach ($category->getAttributes() as $attribute) { @@ -290,7 +300,7 @@ public function prepareMeta($meta) * @param array $fieldsMeta * @return array */ - private function prepareFieldsMeta($fieldsMap, $fieldsMeta) + private function prepareFieldsMeta(array $fieldsMap, array $fieldsMeta): array { $canEditDesign = $this->auth->isAllowed('Magento_Catalog::edit_category_design'); @@ -350,6 +360,8 @@ public function getAttributesMeta(Type $entityType) { $meta = []; $attributes = $entityType->getAttributeCollection(); + $fields = $this->getFields(); + $category = $this->getCurrentCategory(); /* @var EavAttribute $attribute */ foreach ($attributes as $attribute) { $code = $attribute->getAttributeCode(); @@ -364,6 +376,9 @@ public function getAttributesMeta(Type $entityType) } if ($attribute->usesSource()) { $meta[$code]['options'] = $attribute->getSource()->getAllOptions(); + foreach ($meta[$code]['options'] as &$option) { + $option['__disableTmpl'] = true; + } } } @@ -374,6 +389,16 @@ public function getAttributesMeta(Type $entityType) $meta[$code]['scopeLabel'] = $this->getScopeLabel($attribute); $meta[$code]['componentType'] = Field::NAME; + + // disable fields + if ($category) { + $attributeIsLocked = $category->isLockedAttribute($code); + $meta[$code]['disabled'] = $attributeIsLocked; + $hasUseConfigField = (bool) array_search('use_config.' . $code, $fields, true); + if ($hasUseConfigField && $meta[$code]['disabled']) { + $meta['use_config.' . $code]['disabled'] = true; + } + } } $result = []; @@ -505,7 +530,7 @@ protected function filterFields($categoryData) * @param array $categoryData * @return array */ - private function convertValues($category, $categoryData) + private function convertValues($category, $categoryData): array { foreach ($category->getAttributes() as $attributeCode => $attribute) { if (!isset($categoryData[$attributeCode])) { @@ -616,13 +641,24 @@ protected function getFieldsMap() ]; } + /** + * Return list of fields names. + * + * @return array + */ + private function getFields(): array + { + $fieldsMap = $this->getFieldsMap(); + return $this->arrayUtils->flatten($fieldsMap); + } + /** * Retrieve scope overridden value * * @return ScopeOverriddenValue * @deprecated 101.1.0 */ - private function getScopeOverriddenValue() + private function getScopeOverriddenValue(): ScopeOverriddenValue { if (null === $this->scopeOverriddenValue) { $this->scopeOverriddenValue = \Magento\Framework\App\ObjectManager::getInstance()->get( @@ -639,7 +675,7 @@ private function getScopeOverriddenValue() * @return ArrayManager * @deprecated 101.1.0 */ - private function getArrayManager() + private function getArrayManager(): ArrayManager { if (null === $this->arrayManager) { $this->arrayManager = \Magento\Framework\App\ObjectManager::getInstance()->get( @@ -657,7 +693,7 @@ private function getArrayManager() * * @deprecated 101.1.0 */ - private function getFileInfo() + private function getFileInfo(): FileInfo { if ($this->fileInfo === null) { $this->fileInfo = ObjectManager::getInstance()->get(FileInfo::class); diff --git a/app/code/Magento/Catalog/Model/CategoryAttributeSearchResults.php b/app/code/Magento/Catalog/Model/CategoryAttributeSearchResults.php new file mode 100644 index 000000000000..db1b84ed2777 --- /dev/null +++ b/app/code/Magento/Catalog/Model/CategoryAttributeSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model; + +use Magento\Catalog\Api\Data\CategoryAttributeSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Category Attribute search results. + */ +class CategoryAttributeSearchResults extends SearchResults implements CategoryAttributeSearchResultsInterface +{ +} diff --git a/app/code/Magento/Catalog/Model/CategorySearchResults.php b/app/code/Magento/Catalog/Model/CategorySearchResults.php new file mode 100644 index 000000000000..7590ee4a23ed --- /dev/null +++ b/app/code/Magento/Catalog/Model/CategorySearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model; + +use Magento\Catalog\Api\Data\CategorySearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Category search results. + */ +class CategorySearchResults extends SearchResults implements CategorySearchResultsInterface +{ +} diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php index cb708695255d..15ba6c8f3758 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php @@ -105,7 +105,7 @@ public function execute(array $entityIds = [], $useTempTable = false) * @throws \Exception if metadataPool doesn't contain metadata for ProductInterface * @throws \DomainException */ - private function getProductIdsWithParents(array $childProductIds) + private function getProductIdsWithParents(array $childProductIds): array { /** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */ $metadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); @@ -123,8 +123,12 @@ private function getProductIdsWithParents(array $childProductIds) ); $parentProductIds = $this->connection->fetchCol($select); + $ids = array_unique(array_merge($childProductIds, $parentProductIds)); + foreach ($ids as $key => $id) { + $ids[$key] = (int) $id; + } - return array_unique(array_merge($childProductIds, $parentProductIds)); + return $ids; } /** @@ -175,7 +179,7 @@ protected function removeEntries() protected function getNonAnchorCategoriesSelect(\Magento\Store\Model\Store $store) { $select = parent::getNonAnchorCategoriesSelect($store); - return $select->where('ccp.product_id IN (?) OR relation.child_id IN (?)', $this->limitationByProducts); + return $select->where('ccp.product_id IN (?)', $this->limitationByProducts); } /** @@ -216,28 +220,28 @@ protected function isRangingNeeded() * Returns a list of category ids which are assigned to product ids in the index * * @param array $productIds - * @return \Magento\Framework\Indexer\CacheContext + * @return array */ - private function getCategoryIdsFromIndex(array $productIds) + private function getCategoryIdsFromIndex(array $productIds): array { $categoryIds = []; foreach ($this->storeManager->getStores() as $store) { - $categoryIds = array_merge( - $categoryIds, - $this->connection->fetchCol( - $this->connection->select() - ->from($this->getIndexTable($store->getId()), ['category_id']) - ->where('product_id IN (?)', $productIds) - ->distinct() - ) + $storeCategories = $this->connection->fetchCol( + $this->connection->select() + ->from($this->getIndexTable($store->getId()), ['category_id']) + ->where('product_id IN (?)', $productIds) + ->distinct() ); + $categoryIds[] = $storeCategories; } - $parentCategories = $categoryIds; + $categoryIds = array_merge(...$categoryIds); + + $parentCategories = [$categoryIds]; foreach ($categoryIds as $categoryId) { $parentIds = explode('/', $this->getPathFromCategoryId($categoryId)); - $parentCategories = array_merge($parentCategories, $parentIds); + $parentCategories[] = $parentIds; } - $categoryIds = array_unique($parentCategories); + $categoryIds = array_unique(array_merge(...$parentCategories)); return $categoryIds; } diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php index ebad10e19762..a0acacd4dfd2 100644 --- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php +++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/AbstractAction.php @@ -254,10 +254,12 @@ protected function _updateRelationProducts($storeId, $productIds = null) * * @param int $storeId * @return \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _cleanRelationProducts($storeId) { - if (!$this->_productIndexerHelper->isAddChildData()) { + if (!$this->_productIndexerHelper->isAddChildData() || !$this->_isFlatTableExists($storeId)) { return $this; } diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 1b7552c82276..8092ff3eb9d4 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -177,7 +177,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements protected $_catalogProduct = null; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -381,7 +381,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements * @param Product\Attribute\Source\Status $catalogProductStatus * @param Product\Media\Config $catalogProductMediaConfig * @param Product\Type $catalogProductType - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Helper\Product $catalogProduct * @param ResourceModel\Product $resource * @param ResourceModel\Product\Collection $resourceCollection @@ -422,7 +422,7 @@ public function __construct( \Magento\Catalog\Model\Product\Attribute\Source\Status $catalogProductStatus, \Magento\Catalog\Model\Product\Media\Config $catalogProductMediaConfig, Product\Type $catalogProductType, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Catalog\Model\ResourceModel\Product $resource, \Magento\Catalog\Model\ResourceModel\Product\Collection $resourceCollection, diff --git a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php index d0c710385149..57d08916bcd4 100644 --- a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php +++ b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php @@ -5,10 +5,13 @@ */ namespace Magento\Catalog\Model\Product\AttributeSet; +/** + * Attribute Set Options + */ class Options implements \Magento\Framework\Data\OptionSourceInterface { /** - * @var null|array + * @var array */ protected $options; @@ -25,7 +28,7 @@ public function __construct( } /** - * @return array|null + * @inheritDoc */ public function toOptionArray() { @@ -33,7 +36,15 @@ public function toOptionArray() $this->options = $this->collectionFactory->create() ->setEntityTypeFilter($this->product->getTypeId()) ->toOptionArray(); + + array_walk( + $this->options, + function (&$option) { + $option['__disableTmpl'] = true; + } + ); } + return $this->options; } } diff --git a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php index 12dbaf0c29f4..9ccb86441812 100644 --- a/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php +++ b/app/code/Magento/Catalog/Model/Product/Compare/ListCompare.php @@ -5,13 +5,17 @@ */ namespace Magento\Catalog\Model\Product\Compare; +use Magento\Catalog\Model\ProductRepository; use Magento\Catalog\Model\ResourceModel\Product\Compare\Item\Collection; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\NoSuchEntityException; /** * Product Compare List Model * * @api * @SuppressWarnings(PHPMD.LongVariable) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) * @since 100.0.2 */ class ListCompare extends \Magento\Framework\DataObject @@ -51,6 +55,11 @@ class ListCompare extends \Magento\Framework\DataObject */ protected $_compareItemFactory; + /** + * @var ProductRepository + */ + private $productRepository; + /** * Constructor * @@ -60,6 +69,7 @@ class ListCompare extends \Magento\Framework\DataObject * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Visitor $customerVisitor * @param array $data + * @param ProductRepository|null $productRepository */ public function __construct( \Magento\Catalog\Model\Product\Compare\ItemFactory $compareItemFactory, @@ -67,13 +77,15 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Visitor $customerVisitor, - array $data = [] + array $data = [], + ProductRepository $productRepository = null ) { $this->_compareItemFactory = $compareItemFactory; $this->_itemCollectionFactory = $itemCollectionFactory; $this->_catalogProductCompareItem = $catalogProductCompareItem; $this->_customerSession = $customerSession; $this->_customerVisitor = $customerVisitor; + $this->productRepository = $productRepository ?: ObjectManager::getInstance()->create(ProductRepository::class); parent::__construct($data); } @@ -82,6 +94,7 @@ public function __construct( * * @param int|\Magento\Catalog\Model\Product $product * @return $this + * @throws \Exception */ public function addProduct($product) { @@ -90,7 +103,7 @@ public function addProduct($product) $this->_addVisitorToItem($item); $item->loadByProduct($product); - if (!$item->getId()) { + if (!$item->getId() && $this->productExists($product)) { $item->addProductData($product); $item->save(); } @@ -98,6 +111,25 @@ public function addProduct($product) return $this; } + /** + * Check product exists. + * + * @param int|\Magento\Catalog\Model\Product $product + * @return bool + */ + private function productExists($product) + { + if ($product instanceof \Magento\Catalog\Model\Product && $product->getId()) { + return true; + } + try { + $product = $this->productRepository->getById((int)$product); + return !empty($product->getId()); + } catch (NoSuchEntityException $e) { + return false; + } + } + /** * Add products to compare list * diff --git a/app/code/Magento/Catalog/Model/Product/Copier.php b/app/code/Magento/Catalog/Model/Product/Copier.php index 44ebdf0f1f28..a7f7bad1a516 100644 --- a/app/code/Magento/Catalog/Model/Product/Copier.php +++ b/app/code/Magento/Catalog/Model/Product/Copier.php @@ -6,7 +6,9 @@ namespace Magento\Catalog\Model\Product; use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Model\Attribute\ScopeOverriddenValue; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ProductFactory; /** * Catalog product copier. @@ -28,7 +30,7 @@ class Copier protected $copyConstructor; /** - * @var \Magento\Catalog\Model\ProductFactory + * @var ProductFactory */ protected $productFactory; @@ -36,17 +38,24 @@ class Copier * @var \Magento\Framework\EntityManager\MetadataPool */ protected $metadataPool; + /** + * @var ScopeOverriddenValue + */ + private $scopeOverriddenValue; /** * @param CopyConstructorInterface $copyConstructor - * @param \Magento\Catalog\Model\ProductFactory $productFactory + * @param ProductFactory $productFactory + * @param ScopeOverriddenValue $scopeOverriddenValue */ public function __construct( CopyConstructorInterface $copyConstructor, - \Magento\Catalog\Model\ProductFactory $productFactory + ProductFactory $productFactory, + ScopeOverriddenValue $scopeOverriddenValue ) { $this->productFactory = $productFactory; $this->copyConstructor = $copyConstructor; + $this->scopeOverriddenValue = $scopeOverriddenValue; } /** @@ -121,19 +130,20 @@ private function setStoresUrl(Product $product, Product $duplicate) : void $storeIds = $duplicate->getStoreIds(); $productId = $product->getId(); $productResource = $product->getResource(); - $defaultUrlKey = $productResource->getAttributeRawValue( - $productId, - 'url_key', - \Magento\Store\Model\Store::DEFAULT_STORE_ID - ); $duplicate->setData('save_rewrites_history', false); foreach ($storeIds as $storeId) { + $useDefault = !$this->scopeOverriddenValue->containsValue( + ProductInterface::class, + $product, + 'url_key', + $storeId + ); + if ($useDefault) { + continue; + } $isDuplicateSaved = false; $duplicate->setStoreId($storeId); $urlKey = $productResource->getAttributeRawValue($productId, 'url_key', $storeId); - if ($urlKey === $defaultUrlKey) { - continue; - } do { $urlKey = $this->modifyUrl($urlKey); $duplicate->setUrlKey($urlKey); diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php index e06e85e90a2d..b374b754d7de 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php @@ -3,11 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Model\Product\Gallery; +use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\ObjectManager; use Magento\Framework\EntityManager\Operation\ExtensionInterface; use Magento\MediaStorage\Model\File\Uploader as FileUploader; +use Magento\Store\Model\StoreManagerInterface; /** * Create handler for catalog product gallery @@ -74,6 +79,16 @@ class CreateHandler implements ExtensionInterface */ private $mediaAttributeCodes; + /** + * @var array + */ + private $imagesGallery; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + /** * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository @@ -82,6 +97,8 @@ class CreateHandler implements ExtensionInterface * @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb + * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager + * @throws \Magento\Framework\Exception\FileSystemException */ public function __construct( \Magento\Framework\EntityManager\MetadataPool $metadataPool, @@ -90,7 +107,8 @@ public function __construct( \Magento\Framework\Json\Helper\Data $jsonHelper, \Magento\Catalog\Model\Product\Media\Config $mediaConfig, \Magento\Framework\Filesystem $filesystem, - \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb + \Magento\MediaStorage\Helper\File\Storage\Database $fileStorageDb, + \Magento\Store\Model\StoreManagerInterface $storeManager = null ) { $this->metadata = $metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); $this->attributeRepository = $attributeRepository; @@ -99,6 +117,7 @@ public function __construct( $this->mediaConfig = $mediaConfig; $this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); $this->fileStorageDb = $fileStorageDb; + $this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class); } /** @@ -137,6 +156,10 @@ public function execute($product, $arguments = []) if ($product->getIsDuplicate() != true) { foreach ($value['images'] as &$image) { + if (!empty($image['removed']) && !$this->canRemoveImage($product, $image['file'])) { + $image['removed'] = ''; + } + if (!empty($image['removed'])) { $clearImages[] = $image['file']; } elseif (empty($image['value_id'])) { @@ -152,6 +175,10 @@ public function execute($product, $arguments = []) // For duplicating we need copy original images. $duplicate = []; foreach ($value['images'] as &$image) { + if (!empty($image['removed']) && !$this->canRemoveImage($product, $image['file'])) { + $image['removed'] = ''; + } + if (empty($image['value_id']) || !empty($image['removed'])) { continue; } @@ -538,4 +565,46 @@ private function processMediaAttributeLabel( ); } } + + /** + * Get product images for all stores + * + * @param ProductInterface $product + * @return array + */ + private function getImagesForAllStores(ProductInterface $product) + { + if ($this->imagesGallery === null) { + $storeIds = array_keys($this->storeManager->getStores()); + $storeIds[] = 0; + + $this->imagesGallery = $this->resourceModel->getProductImages($product, $storeIds); + } + + return $this->imagesGallery; + } + + /** + * Check possibility to remove image + * + * @param ProductInterface $product + * @param string $imageFile + * @return bool + */ + private function canRemoveImage(ProductInterface $product, string $imageFile) :bool + { + $canRemoveImage = true; + $gallery = $this->getImagesForAllStores($product); + $storeId = $product->getStoreId(); + + if (!empty($gallery)) { + foreach ($gallery as $image) { + if ($image['filepath'] === $imageFile && (int) $image['store_id'] !== $storeId) { + $canRemoveImage = false; + } + } + } + + return $canRemoveImage; + } } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php index e1b788bc3941..f1d27c38e945 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php @@ -167,10 +167,10 @@ public function addImage( } $fileName = \Magento\MediaStorage\Model\File\Uploader::getCorrectFileName($pathinfo['basename']); - $dispretionPath = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName); - $fileName = $dispretionPath . '/' . $fileName; + $dispersionPath = \Magento\MediaStorage\Model\File\Uploader::getDispersionPath($fileName); + $fileName = $dispersionPath . '/' . $fileName; - $fileName = $this->getNotDuplicatedFilename($fileName, $dispretionPath); + $fileName = $this->getNotDuplicatedFilename($fileName, $dispersionPath); $destinationFile = $this->mediaConfig->getTmpMediaPath($fileName); @@ -465,27 +465,27 @@ protected function getUniqueFileName($file, $forTmp = false) * Get filename which is not duplicated with other files in media temporary and media directories * * @param string $fileName - * @param string $dispretionPath + * @param string $dispersionPath * @return string * @since 101.0.0 */ - protected function getNotDuplicatedFilename($fileName, $dispretionPath) + protected function getNotDuplicatedFilename($fileName, $dispersionPath) { - $fileMediaName = $dispretionPath . '/' + $fileMediaName = $dispersionPath . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName($this->mediaConfig->getMediaPath($fileName)); - $fileTmpMediaName = $dispretionPath . '/' + $fileTmpMediaName = $dispersionPath . '/' . \Magento\MediaStorage\Model\File\Uploader::getNewFileName($this->mediaConfig->getTmpMediaPath($fileName)); if ($fileMediaName != $fileTmpMediaName) { if ($fileMediaName != $fileName) { return $this->getNotDuplicatedFilename( $fileMediaName, - $dispretionPath + $dispersionPath ); } elseif ($fileTmpMediaName != $fileName) { return $this->getNotDuplicatedFilename( $fileTmpMediaName, - $dispretionPath + $dispersionPath ); } } diff --git a/app/code/Magento/Catalog/Model/Product/Hydrator.php b/app/code/Magento/Catalog/Model/Product/Hydrator.php new file mode 100644 index 000000000000..dcdce7202b21 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Product/Hydrator.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Product; + +use Magento\Framework\EntityManager\HydratorInterface; + +/** + * Class is used to extract data and populate entity with data + */ +class Hydrator implements HydratorInterface +{ + /** + * @inheritdoc + */ + public function extract($entity) + { + return $entity->getData(); + } + + /** + * @inheritdoc + */ + public function hydrate($entity, array $data) + { + $lockedAttributes = $entity->getLockedAttributes(); + $entity->unlockAttributes(); + $entity->setData(array_merge($entity->getData(), $data)); + foreach ($lockedAttributes as $attribute) { + $entity->lockAttribute($attribute); + } + + return $entity; + } +} diff --git a/app/code/Magento/Catalog/Model/ProductAttributeSearchResults.php b/app/code/Magento/Catalog/Model/ProductAttributeSearchResults.php new file mode 100644 index 000000000000..776009089b9a --- /dev/null +++ b/app/code/Magento/Catalog/Model/ProductAttributeSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model; + +use Magento\Catalog\Api\Data\ProductAttributeSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Product Attribute search results. + */ +class ProductAttributeSearchResults extends SearchResults implements ProductAttributeSearchResultsInterface +{ +} diff --git a/app/code/Magento/Catalog/Model/ProductLink/Search.php b/app/code/Magento/Catalog/Model/ProductLink/Search.php index 8750345aa222..ad7f3370ab3f 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/Search.php +++ b/app/code/Magento/Catalog/Model/ProductLink/Search.php @@ -10,7 +10,9 @@ use Magento\Catalog\Api\Data\ProductInterface; -/** Returns collection of product visible in catalog by search key */ +/** + * Returns collection of product visible in catalog by search key + */ class Search { /** @@ -58,7 +60,6 @@ public function prepareCollection( ): \Magento\Catalog\Model\ResourceModel\Product\Collection { $productCollection = $this->productCollectionFactory->create(); $productCollection->addAttributeToSelect(ProductInterface::NAME); - $productCollection->setVisibility($this->catalogVisibility->getVisibleInCatalogIds()); $productCollection->setPage($pageNum, $limit); $this->filter->addFilter($productCollection, 'fulltext', ['fulltext' => $searchKey]); $productCollection->setPage($pageNum, $limit); diff --git a/app/code/Magento/Catalog/Model/ProductSearchResults.php b/app/code/Magento/Catalog/Model/ProductSearchResults.php new file mode 100644 index 000000000000..7aa3b4d961c2 --- /dev/null +++ b/app/code/Magento/Catalog/Model/ProductSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model; + +use Magento\Catalog\Api\Data\ProductSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Product search results. + */ +class ProductSearchResults extends SearchResults implements ProductSearchResultsInterface +{ +} diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php index 797ce72ae9b7..9e0d174a4ccc 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php @@ -18,6 +18,8 @@ use Magento\Framework\DataObject; use Magento\Framework\EntityManager\EntityManager; use Magento\Catalog\Setup\CategorySetup; +use Magento\Framework\EntityManager\MetadataPool; +use Magento\Catalog\Api\Data\ProductInterface; /** * Resource model for category entity @@ -95,6 +97,11 @@ class Category extends AbstractResource */ private $indexerProcessor; + /** + * @var MetadataPool + */ + private $metadataPool; + /** * Category constructor. * @param \Magento\Eav\Model\Entity\Context $context @@ -106,6 +113,7 @@ class Category extends AbstractResource * @param Processor $indexerProcessor * @param array $data * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer + * @param MetadataPool|null $metadataPool * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -117,7 +125,8 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $categoryCollectionFactory, Processor $indexerProcessor, $data = [], - \Magento\Framework\Serialize\Serializer\Json $serializer = null + \Magento\Framework\Serialize\Serializer\Json $serializer = null, + MetadataPool $metadataPool = null ) { parent::__construct( $context, @@ -132,6 +141,7 @@ public function __construct( $this->indexerProcessor = $indexerProcessor; $this->serializer = $serializer ?: ObjectManager::getInstance() ->get(\Magento\Framework\Serialize\Serializer\Json::class); + $this->metadataPool = $metadataPool ?: ObjectManager::getInstance()->get(MetadataPool::class); } /** @@ -1160,13 +1170,14 @@ public function getCategoryWithChildren(int $categoryId): array return []; } + $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); $select = $connection->select() ->from( ['cce' => $this->getTable('catalog_category_entity')], - ['entity_id', 'parent_id', 'path'] + [$linkField, 'parent_id', 'path'] )->join( ['cce_int' => $this->getTable('catalog_category_entity_int')], - 'cce.entity_id = cce_int.entity_id', + 'cce.' . $linkField . ' = cce_int.' . $linkField, ['is_anchor' => 'cce_int.value'] )->where( 'cce_int.attribute_id = ?', diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php index 42d55892b6ec..442499f2da7e 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php @@ -193,7 +193,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac /** * Catalog data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager = null; @@ -322,7 +322,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Collection\Abstrac * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -352,7 +352,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, @@ -1595,6 +1595,8 @@ public function addAttributeToFilter($attribute, $condition = null, $joinType = } else { return parent::addAttributeToFilter($attribute, $condition, $joinType); } + + return $this; } /** @@ -2113,13 +2115,14 @@ private function getChildrenCategories(int $categoryId): array $firstCategory = array_shift($categories); if ($firstCategory['is_anchor'] == 1) { - $anchorCategory[] = (int)$firstCategory['entity_id']; + $linkField = $this->getProductEntityMetadata()->getLinkField(); + $anchorCategory[] = (int)$firstCategory[$linkField]; foreach ($categories as $category) { if (in_array($category['parent_id'], $categoryIds) && in_array($category['parent_id'], $anchorCategory)) { - $categoryIds[] = (int)$category['entity_id']; + $categoryIds[] = (int)$category[$linkField]; if ($category['is_anchor'] == 1) { - $anchorCategory[] = (int)$category['entity_id']; + $anchorCategory[] = (int)$category[$linkField]; } } } diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php index dc3411743a06..92741cf9ba88 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Compare/Item/Collection.php @@ -64,7 +64,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -76,6 +76,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Product\Compare\Item $catalogProductCompareItem * @param \Magento\Catalog\Helper\Product\Compare $catalogProductCompare * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -89,7 +90,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php index 7730d7cc9a7f..e625e38b59f3 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php @@ -8,6 +8,8 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Framework\DB\Select; +use Magento\Framework\DB\Sql\UnionExpression; /** * Catalog Product Eav Select and Multiply Select Attributes Indexer resource model @@ -199,13 +201,52 @@ protected function _prepareSelectIndex($entityIds = null, $attributeId = null) 'dd.attribute_id', 's.store_id', 'value' => new \Zend_Db_Expr('COALESCE(ds.value, dd.value)'), - 'cpe.entity_id', + 'cpe.entity_id AS source_id', ] ); if ($entityIds !== null) { $ids = implode(',', array_map('intval', $entityIds)); + $selectWithoutDefaultStore = $connection->select()->from( + ['wd' => $this->getTable('catalog_product_entity_int')], + [ + 'cpe.entity_id', + 'attribute_id', + 'store_id', + 'value', + 'cpe.entity_id', + ] + )->joinLeft( + ['cpe' => $this->getTable('catalog_product_entity')], + "cpe.{$productIdField} = wd.{$productIdField}", + [] + )->joinLeft( + ['d2d' => $this->getTable('catalog_product_entity_int')], + sprintf( + "d2d.store_id = 0 AND d2d.{$productIdField} = wd.{$productIdField} AND d2d.attribute_id = %s", + $this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId() + ), + [] + )->joinLeft( + ['d2s' => $this->getTable('catalog_product_entity_int')], + "d2s.store_id != 0 AND d2s.attribute_id = d2d.attribute_id AND " . + "d2s.{$productIdField} = d2d.{$productIdField}", + [] + ) + ->where((new \Zend_Db_Expr('COALESCE(d2s.value, d2d.value)')) . ' = ' . ProductStatus::STATUS_ENABLED) + ->where("wd.attribute_id IN({$attrIdsFlat})") + ->where('wd.value IS NOT NULL') + ->where('wd.store_id != 0') + ->where("cpe.entity_id IN({$ids})"); $select->where("cpe.entity_id IN({$ids})"); + $selects = new UnionExpression( + [$select, $selectWithoutDefaultStore], + Select::SQL_UNION, + '( %s )' + ); + + $select = $connection->select(); + $select->from(['u' => $selects]); } /** @@ -342,7 +383,7 @@ private function getMultiSelectAttributeWithSourceModels($attrIds) ProductAttributeInterface::ENTITY_TYPE_CODE, $criteria )->getItems(); - + $options = []; foreach ($attributes as $attribute) { $sourceModelOptions = $attribute->getOptions(); diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php index 9643f4c3a718..b64cca4ff1b2 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/DefaultPrice.php @@ -40,7 +40,7 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface /** * Core data * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -73,7 +73,7 @@ class DefaultPrice extends AbstractIndexer implements PriceInterface * @param \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy * @param \Magento\Eav\Model\Config $eavConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param string|null $connectionName * @param IndexTableStructureFactory $indexTableStructureFactory * @param PriceModifierInterface[] $priceModifiers @@ -83,7 +83,7 @@ public function __construct( \Magento\Framework\Indexer\Table\StrategyInterface $tableStrategy, \Magento\Eav\Model\Config $eavConfig, \Magento\Framework\Event\ManagerInterface $eventManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, $connectionName = null, IndexTableStructureFactory $indexTableStructureFactory = null, array $priceModifiers = [] diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php index a3f463d53e7a..77407ed699fb 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/Query/BaseFinalPrice.php @@ -37,7 +37,7 @@ class BaseFinalPrice private $joinAttributeProcessor; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManager; @@ -69,7 +69,7 @@ class BaseFinalPrice /** * @param \Magento\Framework\App\ResourceConnection $resource * @param JoinAttributeProcessor $joinAttributeProcessor - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool * @param string $connectionName @@ -77,7 +77,7 @@ class BaseFinalPrice public function __construct( \Magento\Framework\App\ResourceConnection $resource, JoinAttributeProcessor $joinAttributeProcessor, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\EntityManager\MetadataPool $metadataPool, $connectionName = 'indexer' diff --git a/app/code/Magento/Catalog/Model/View/Asset/Image.php b/app/code/Magento/Catalog/Model/View/Asset/Image.php index dfae9f4b0da9..c547ec612bb9 100644 --- a/app/code/Magento/Catalog/Model/View/Asset/Image.php +++ b/app/code/Magento/Catalog/Model/View/Asset/Image.php @@ -88,7 +88,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getUrl() { @@ -96,7 +96,7 @@ public function getUrl() } /** - * {@inheritdoc} + * @inheritdoc */ public function getContentType() { @@ -104,7 +104,7 @@ public function getContentType() } /** - * {@inheritdoc} + * @inheritdoc */ public function getPath() { @@ -112,7 +112,7 @@ public function getPath() } /** - * {@inheritdoc} + * @inheritdoc */ public function getSourceFile() { @@ -131,7 +131,7 @@ public function getSourceContentType() } /** - * {@inheritdoc} + * @inheritdoc */ public function getContent() { @@ -139,7 +139,7 @@ public function getContent() } /** - * {@inheritdoc} + * @inheritdoc */ public function getFilePath() { @@ -147,7 +147,8 @@ public function getFilePath() } /** - * {@inheritdoc} + * @inheritdoc + * * @return ContextInterface */ public function getContext() @@ -156,7 +157,7 @@ public function getContext() } /** - * {@inheritdoc} + * @inheritdoc */ public function getModule() { @@ -191,20 +192,21 @@ private function getImageInfo() /** * Converting bool into a string representation - * @param $miscParams + * + * @param array $miscParams * @return array */ - private function convertToReadableFormat($miscParams) + private function convertToReadableFormat(array $miscParams) { $miscParams['image_height'] = 'h:' . ($miscParams['image_height'] ?? 'empty'); $miscParams['image_width'] = 'w:' . ($miscParams['image_width'] ?? 'empty'); $miscParams['quality'] = 'q:' . ($miscParams['quality'] ?? 'empty'); $miscParams['angle'] = 'r:' . ($miscParams['angle'] ?? 'empty'); - $miscParams['keep_aspect_ratio'] = (isset($miscParams['keep_aspect_ratio']) ? '' : 'non') . 'proportional'; - $miscParams['keep_frame'] = (isset($miscParams['keep_frame']) ? '' : 'no') . 'frame'; - $miscParams['keep_transparency'] = (isset($miscParams['keep_transparency']) ? '' : 'no') . 'transparency'; - $miscParams['constrain_only'] = (isset($miscParams['constrain_only']) ? 'do' : 'not') . 'constrainonly'; - $miscParams['background'] = isset($miscParams['background']) + $miscParams['keep_aspect_ratio'] = (!empty($miscParams['keep_aspect_ratio']) ? '' : 'non') . 'proportional'; + $miscParams['keep_frame'] = (!empty($miscParams['keep_frame']) ? '' : 'no') . 'frame'; + $miscParams['keep_transparency'] = (!empty($miscParams['keep_transparency']) ? '' : 'no') . 'transparency'; + $miscParams['constrain_only'] = (!empty($miscParams['constrain_only']) ? 'do' : 'not') . 'constrainonly'; + $miscParams['background'] = !empty($miscParams['background']) ? 'rgb' . implode(',', $miscParams['background']) : 'nobackground'; return $miscParams; diff --git a/app/code/Magento/Catalog/Observer/FlushCategoryPagesCache.php b/app/code/Magento/Catalog/Observer/FlushCategoryPagesCache.php new file mode 100644 index 000000000000..751fa3fdfad8 --- /dev/null +++ b/app/code/Magento/Catalog/Observer/FlushCategoryPagesCache.php @@ -0,0 +1,60 @@ +<?php declare(strict_types=1); +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Observer; + +use Magento\Catalog\Model\Category; +use Magento\Framework\Event\Observer as Event; +use Magento\Framework\Event\ObserverInterface; +use Magento\PageCache\Model\Cache\Type as PageCache; +use Magento\PageCache\Model\Config as CacheConfig; + +/** + * Flush the built in page cache when a category is moved + */ +class FlushCategoryPagesCache implements ObserverInterface +{ + + /** + * @var CacheConfig + */ + private $cacheConfig; + + /** + * + * @var PageCache + */ + private $pageCache; + + /** + * FlushCategoryPagesCache constructor. + * + * @param CacheConfig $cacheConfig + * @param PageCache $pageCache + */ + public function __construct(CacheConfig $cacheConfig, PageCache $pageCache) + { + $this->cacheConfig = $cacheConfig; + $this->pageCache = $pageCache; + } + + /** + * Clean the category page cache if built in cache page cache is used. + * + * The built in cache requires cleaning all pages that contain the top category navigation menu when a + * category is moved. This is because the built in cache does not support ESI blocks. + * + * @param Event $event + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function execute(Event $event) + { + if ($this->cacheConfig->getType() == CacheConfig::BUILT_IN && $this->cacheConfig->isEnabled()) { + $this->pageCache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, [Category::CACHE_TAG]); + } + } +} diff --git a/app/code/Magento/Catalog/Setup/Patch/Schema/ChangeTmpTablesEngine.php b/app/code/Magento/Catalog/Setup/Patch/Schema/ChangeTmpTablesEngine.php deleted file mode 100644 index c39247f9b30d..000000000000 --- a/app/code/Magento/Catalog/Setup/Patch/Schema/ChangeTmpTablesEngine.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Catalog\Setup\Patch\Schema; - -use Magento\Framework\Setup\Patch\SchemaPatchInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Change engine for temporary tables to InnoDB. - */ -class ChangeTmpTablesEngine implements SchemaPatchInterface -{ - /** - * @var SchemaSetupInterface - */ - private $schemaSetup; - - /** - * @param SchemaSetupInterface $schemaSetup - */ - public function __construct(SchemaSetupInterface $schemaSetup) - { - $this->schemaSetup = $schemaSetup; - } - - /** - * @inheritdoc - */ - public function apply() - { - $this->schemaSetup->startSetup(); - - $tables = [ - 'catalog_product_index_price_cfg_opt_agr_tmp', - 'catalog_product_index_price_cfg_opt_tmp', - 'catalog_product_index_price_final_tmp', - 'catalog_product_index_price_opt_tmp', - 'catalog_product_index_price_opt_agr_tmp', - 'catalog_product_index_eav_tmp', - 'catalog_product_index_eav_decimal_tmp', - 'catalog_product_index_price_tmp', - 'catalog_category_product_index_tmp', - ]; - foreach ($tables as $table) { - $tableName = $this->schemaSetup->getTable($table); - if ($this->schemaSetup->getConnection()->isTableExists($tableName)) { - $this->schemaSetup->getConnection()->changeTableEngine($tableName, 'InnoDB'); - } - } - - $this->schemaSetup->endSetup(); - } - - /** - * @inheritdoc - */ - public static function getDependencies() - { - return []; - } - - /** - * @inheritdoc - */ - public function getAliases() - { - return []; - } -} diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertProductEditPageCreateAttributeSaveInAttributeSetPopUpShownActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertProductEditPageCreateAttributeSaveInAttributeSetPopUpShownActionGroup.xml new file mode 100644 index 000000000000..602bd494d599 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertProductEditPageCreateAttributeSaveInAttributeSetPopUpShownActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + + <actionGroup name="AdminAssertProductEditPageCreateAttributeSaveInAttributeSetPopUpShownActionGroup"> + <annotations> + <description>Asserts that after click on "Save In New Attribute Set" poup shown .</description> + </annotations> + <see userInput="Enter Name for New Attribute Set" stepKey="seeContent"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml index c6492754515f..e5cefda0aca9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml @@ -15,8 +15,8 @@ <arguments> <argument name="image"/> </arguments> - - <conditionalClick selector="{{AdminProductImagesSection.productImagesToggleState('closed')}}" dependentSelector="{{AdminProductImagesSection.productImagesToggleState('open')}}" visible="false" stepKey="clickSectionImage"/> + <conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageFile(image.fileName)}}" visible="false" stepKey="expandImages"/> + <waitForElementVisible selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="seeProductImageName"/> <click selector="{{AdminProductImagesSection.imageFile(image.fileName)}}" stepKey="clickProductImage"/> <waitForElementVisible selector="{{AdminProductImagesSection.altText}}" stepKey="seeAltTextSection"/> <checkOption selector="{{AdminProductImagesSection.roleBase}}" stepKey="checkRoleBase"/> @@ -25,4 +25,14 @@ <checkOption selector="{{AdminProductImagesSection.roleSwatch}}" stepKey="checkRoleSwatch"/> <click selector="{{AdminSlideOutDialogSection.closeButton}}" stepKey="clickCloseButton"/> </actionGroup> + <actionGroup name="AdminAssignImageRolesIfUnassignedActionGroup" extends="AdminAssignImageRolesActionGroup"> + <annotations> + <description>Requires the navigation to the Product Creation page. Assign the Base, Small, Thumbnail, and Swatch Roles to image.</description> + </annotations> + + <conditionalClick selector="{{AdminProductImagesSection.roleBase}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Base')}}" visible="false" stepKey="checkRoleBase"/> + <conditionalClick selector="{{AdminProductImagesSection.roleSmall}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Small')}}" visible="false" stepKey="checkRoleSmall"/> + <conditionalClick selector="{{AdminProductImagesSection.roleThumbnail}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Thumbnail')}}" visible="false" stepKey="checkRoleThumbnail"/> + <conditionalClick selector="{{AdminProductImagesSection.roleSwatch}}" dependentSelector="{{AdminProductImagesSection.isRoleChecked('Swatch')}}" visible="false" stepKey="checkRoleSwatch"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index b9b31b780c8f..afc332cc2837 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -191,6 +191,18 @@ <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/> <dontSee selector="{{AdminCategorySidebarTreeSection.categoryInTree(categoryEntity.name)}}" stepKey="dontSeeCategoryInTree"/> </actionGroup> + <actionGroup name="AdminDeleteCategoryByName" extends="DeleteCategory"> + <arguments> + <argument name="categoryName" type="string" defaultValue="category1"/> + </arguments> + <remove keyForRemoval="clickCategoryLink"/> + <remove keyForRemoval="dontSeeCategoryInTree"/> + <remove keyForRemoval="expandToSeeAllCategories"/> + <conditionalClick selector="{{AdminCategorySidebarTreeSection.expandAll}}" dependentSelector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" visible="false" stepKey="expandCategories" after="waitForCategoryPageLoad"/> + <click selector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" stepKey="clickCategory" after="expandCategories"/> + <conditionalClick selector="{{AdminCategorySidebarTreeSection.expandAll}}" dependentSelector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" visible="false" stepKey="expandCategoriesToSeeAll" after="seeDeleteSuccess"/> + <dontSee selector="{{AdminCategorySidebarTreeSection.categoryByName(categoryName)}}" stepKey="dontSeeCategory" after="expandCategoriesToSeeAll"/> + </actionGroup> <!-- Actions to fill out a new category from the product page--> <!-- The action assumes that you are already on an admin product configuration page --> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickAddAttributeOnProductEditPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickAddAttributeOnProductEditPageActionGroup.xml new file mode 100644 index 000000000000..488d905a8dc4 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickAddAttributeOnProductEditPageActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + + <actionGroup name="AdminClickAddAttributeOnProductEditPageActionGroup"> + <annotations> + <description>Clicks on 'Add Attribute'. Admin Product creation/edit page .</description> + </annotations> + <click selector="{{AdminProductFormSection.addAttributeBtn}}" stepKey="clickAddAttributeBtn"/> + <waitForPageLoad stepKey="waitForSidePanel"/> + <see userInput="Select Attribute" stepKey="checkNewAttributePopUpAppeared"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickCreateNewAttributeFromProductEditPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickCreateNewAttributeFromProductEditPageActionGroup.xml new file mode 100644 index 000000000000..658c76ebabee --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickCreateNewAttributeFromProductEditPageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + + <actionGroup name="AdminClickCreateNewAttributeFromProductEditPageActionGroup"> + <annotations> + <description>Clicks on 'Create New Attribute'. Admin Product creation/edit page .</description> + </annotations> + <click selector="{{AdminProductFormAttributeSection.createNewAttribute}}" stepKey="clickCreateNewAttribute"/> + <waitForPageLoad stepKey="waitForSidePanel"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillAttributeDataProductFormNewAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillAttributeDataProductFormNewAttributeActionGroup.xml new file mode 100644 index 000000000000..560b3a7e9ace --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminFillAttributeDataProductFormNewAttributeActionGroup.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + + <actionGroup name="AdminFillAttributeDataProductFormNewAttributeActionGroup"> + <arguments> + <argument name="attributeName" type="string" defaultValue="TestAttributeName"/> + <argument name="attributeType" type="string" defaultValue="Text Field"/> + </arguments> + <annotations> + <description>Fill attribute data on 'Create New Attribute' page Admin Product creation/edit page .</description> + </annotations> + <fillField selector="{{AdminProductFormNewAttributeSection.attributeLabel}}" userInput="{{attributeName}}" + stepKey="fillAttributeLabel"/> + <selectOption selector="{{AdminProductFormNewAttributeSection.attributeType}}" userInput="{{attributeType}}" + stepKey="selectAttributeType"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index 5c5ee0f9cb32..428b3828901c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -24,7 +24,7 @@ <seeInCurrentUrl url="{{AdminProductCreatePage.url(AddToDefaultSet.attributeSetId, product.type_id)}}" stepKey="seeNewProductUrl"/> <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Product" stepKey="seeNewProductTitle"/> </actionGroup> - + <!--Navigate to create product page directly via ID--> <actionGroup name="goToProductPageViaID"> <annotations> @@ -108,6 +108,12 @@ <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{product.name}}" stepKey="fillProductName"/> <fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="fillProductSku"/> </actionGroup> + <actionGroup name="AdminFillProductCountryOfManufactureActionGroup"> + <arguments> + <argument name="countryId" type="string" defaultValue="US"/> + </arguments> + <selectOption selector="{{AdminProductFormBundleSection.countryOfManufactureDropDown}}" userInput="{{countryId}}" stepKey="countryOfManufactureDropDown"/> + </actionGroup> <!--Check that required fields are actually required--> <actionGroup name="checkRequiredFieldsInProductForm"> @@ -184,6 +190,18 @@ <click selector="{{AdminProductImagesSection.removeImageButton}}" stepKey="clickRemoveImage"/> </actionGroup> + <!--Remove Product image by name--> + <actionGroup name="RemoveProductImageByName" extends="removeProductImage"> + <annotations> + <description>Removes a Product Image on the Admin Products creation/edit page by name.</description> + </annotations> + + <arguments> + <argument name="image" defaultValue="ProductImage"/> + </arguments> + <click selector="{{AdminProductImagesSection.removeImageButtonForExactImage(image.fileName)}}" stepKey="clickRemoveImage"/> + </actionGroup> + <!-- Assert product image in Admin Product page --> <actionGroup name="assertProductImageAdminProductPage"> <annotations> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml index aef79e651b58..320a322fc5f8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml @@ -389,7 +389,7 @@ <waitForPageLoad stepKey="waitForGridLoad"/> </actionGroup> - <!--Filter and select the the product --> + <!--Filter and select the product --> <actionGroup name="filterAndSelectProduct"> <annotations> <description>Goes to the Admin Products grid. Filters the Product grid by the provided Product SKU.</description> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DisableProductLabelActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DisableProductLabelActionGroup.xml new file mode 100644 index 000000000000..a416957dabc2 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DisableProductLabelActionGroup.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="DisableProductLabelActionGroup"> + <annotations> + <description>Disable Product Label and Change Attribute Set.</description> + </annotations> + <arguments> + <argument name="createAttributeSet"/> + </arguments> + + <checkOption selector="{{AdminProductFormSection.enableProductLabel}}" stepKey="disableProduct"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/> + <waitForPageLoad time="30" stepKey="waitForChangeAttrSet"/> + <click selector="{{AdminProductFormSection.attributeSet}}" stepKey="startEditAttrSet"/> + <fillField selector="{{AdminProductFormSection.attributeSetFilter}}" userInput="{{createAttributeSet.attribute_set_name}}" stepKey="searchForAttrSet"/> + <click selector="{{AdminProductFormSection.attributeSetFilterResult}}" stepKey="selectAttrSet"/> + <dontSeeCheckboxIsChecked selector="{{AdminProductFormSection.productStatus}}" stepKey="dontSeeCheckboxEnableProductIsChecked"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml index 899603aa27d7..e0229906ad55 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml @@ -18,4 +18,15 @@ <amOnPage url="{{StorefrontProductPage.url(productUrl)}}" stepKey="openProductPage"/> <waitForPageLoad stepKey="waitForProductPageLoaded"/> </actionGroup> + <actionGroup name="StorefrontOpenProductPageOnSecondStore"> + <annotations> + <description>Goes to the Storefront Product page for the provided store code and Product URL.</description> + </annotations> + <arguments> + <argument name="storeCode" type="string"/> + <argument name="productUrl" type="string"/> + </arguments> + + <amOnPage url="{{StorefrontStoreViewProductPage.url(storeCode,productUrl)}}" stepKey="openProductPage"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/CatalogConfigurationData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogConfigurationData.xml new file mode 100644 index 000000000000..cb2bacfd2f2d --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogConfigurationData.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <!-- Catalog > Price --> + <entity name="GlobalCatalogPriceScopeConfigData"> + <!-- Default configuration --> + <data key="path">catalog/price/scope</data> + <data key="scope_id">0</data> + <data key="label">Global</data> + <data key="value">0</data> + </entity> + <entity name="WebsiteCatalogPriceScopeConfigData"> + <data key="path">catalog/price/scope</data> + <data key="scope_id">0</data> + <data key="label">Website</data> + <data key="value">1</data> + </entity> +</entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/CatalogPriceConfigData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogPriceConfigData.xml new file mode 100644 index 000000000000..50ce7f2da18c --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogPriceConfigData.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="CatalogPriceScopeWebsiteConfigData"> + <data key="path">catalog/price/scope</data> + <data key="value">1</data> + </entity> + <entity name="CatalogPriceScopeGlobalConfigData"> + <data key="path">catalog/price/scope</data> + <data key="value">0</data> + </entity> +</entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/CustomAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/CustomAttributeData.xml index 7bd392f0aa74..1effb4ed0664 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/CustomAttributeData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/CustomAttributeData.xml @@ -55,4 +55,20 @@ <data key="attribute_code">is_anchor</data> <data key="value">0</data> </entity> + <entity name="ProductDescriptionAdvancedSearchABC" type="custom_attribute"> + <data key="attribute_code">description</data> + <data key="value"><p>adc_Full</p></data> + </entity> + <entity name="ProductShortDescriptionAdvancedSearch" type="custom_attribute"> + <data key="attribute_code">short_description</data> + <data key="value"><p>abc_short</p></data> + </entity> + <entity name="ProductDescriptionAdvancedSearchADC123" type="custom_attribute"> + <data key="attribute_code">description</data> + <data key="value"><p>dfj_full</p></data> + </entity> + <entity name="ProductShortDescriptionAdvancedSearchADC123" type="custom_attribute"> + <data key="attribute_code">short_description</data> + <data key="value"><p>dfj_short</p></data> + </entity> </entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index e122615eb8aa..aad43bb7011c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -438,6 +438,34 @@ <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> </entity> + <entity name="ApiProductNameWithNoSpaces" type="product"> + <data key="sku" unique="suffix">api-simple-product</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">ApiSimpleProduct</data> + <data key="price">123.00</data> + <data key="urlKey" unique="suffix">api-simple-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + </entity> + <entity name="ApiProductWithDescriptionAndUnderscoredSku" type="product"> + <data key="sku" unique="suffix">api_simple_product</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">Api Simple Product</data> + <data key="price">123.00</data> + <data key="urlKey" unique="suffix">api-simple-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + </entity> <entity name="_newDefaultProduct" type="product"> <data key="sku" unique="suffix">testSku</data> <data key="type_id">simple</data> @@ -531,6 +559,20 @@ <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> </entity> + <entity name="ApiVirtualProductWithDescriptionAndUnderscoredSku" type="product"> + <data key="sku" unique="suffix">api_virtual_product</data> + <data key="type_id">virtual</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">Api Virtual Product</data> + <data key="price">123.00</data> + <data key="urlKey" unique="suffix">api-virtual-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + </entity> <entity name="SimpleProductWithNewFromDate" type="product"> <data key="sku" unique="suffix">SimpleProduct</data> <data key="type_id">simple</data> @@ -1224,4 +1266,41 @@ <requiredEntity type="product_extension_attribute">EavStock1</requiredEntity> <requiredEntity type="custom_attribute">CustomAttributeProductAttribute</requiredEntity> </entity> + <entity name="ABC_dfj_SimpleProduct" type="product"> + <data key="name" unique="suffix">abc_dfj_</data> + <data key="sku" unique="suffix">abc_dfj</data> + <data key="price">50.00</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">100</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ProductDescriptionAdvancedSearchABC</requiredEntity> + <requiredEntity type="custom_attribute_array">ProductShortDescriptionAdvancedSearch</requiredEntity> + </entity> + <entity name="ABC_123_SimpleProduct" type="product"> + <data key="name" unique="suffix">adc_123_</data> + <data key="sku" unique="suffix">adc_123</data> + <data key="price">100.00</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">100</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ProductDescriptionAdvancedSearchADC123</requiredEntity> + <requiredEntity type="custom_attribute_array">ProductShortDescriptionAdvancedSearchADC123</requiredEntity> + </entity> + <entity name="SimpleProductUpdatePrice11" type="product2"> + <data key="price">11.00</data> + </entity> + <entity name="SimpleProductUpdatePrice14" type="product2"> + <data key="price">14.00</data> + </entity> + <entity name="SimpleProductUpdatePrice16" type="product2"> + <data key="price">16.00</data> + </entity> </entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductFormData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductFormData.xml new file mode 100644 index 000000000000..933276edd834 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductFormData.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="ProductFormMessages" type="message"> + <data key="remove_image_notice">The image cannot be removed as it has been assigned to the other image role</data> + <data key="save_success">You saved the product.</data> + </entity> +</entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontStoreViewProductPage.xml b/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontStoreViewProductPage.xml new file mode 100644 index 000000000000..046323bb368d --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontStoreViewProductPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <!-- It is created to open product page with store code setting--> + <page name="StorefrontStoreViewProductPage" url="/{{storeCode}}/{{productUrlKey}}.html" area="storefront" module="Magento_Catalog" parameterized="true"> + </page> +</pages> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMainActionsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMainActionsSection.xml index e8adede5b2de..4aca4a09602b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMainActionsSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMainActionsSection.xml @@ -13,6 +13,7 @@ <element name="DeleteButton" type="button" selector=".page-actions-inner #delete" timeout="30"/> <element name="CategoryStoreViewDropdownToggle" type="button" selector="#store-change-button"/> <element name="CategoryStoreViewOption" type="button" selector="//div[contains(@class, 'store-switcher')]//a[normalize-space()='{{store}}']" parameterized="true"/> + <element name="CategoryStoreViewOptionSelected" type="button" selector="//div[contains(@class, 'store-switcher')]//div[contains(@class,'actions')]//button[contains(text(),'{{store}}')]" parameterized="true"/> <element name="CategoryStoreViewModalAccept" type="button" selector=".modal-popup.confirm._show .action-accept"/> <element name="allStoreViews" type="button" selector=".store-switcher .store-switcher-all" timeout="30"/> <element name="storeSwitcher" type="text" selector=".store-switcher"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryProductsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryProductsSection.xml index e9ff40f98bb1..8a993a74a58d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryProductsSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryProductsSection.xml @@ -11,5 +11,6 @@ <section name="AdminCategoryProductsSection"> <element name="sectionHeader" type="button" selector="div[data-index='assign_products']" timeout="30"/> <element name="addProducts" type="button" selector="#catalog_category_add_product_tabs" timeout="30"/> + <element name="addProductsDisabled" type="button" selector="#catalog_category_add_product_tabs[disabled]" timeout="30"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml index bc552721e6ab..af7e2786f6e8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml @@ -19,5 +19,6 @@ <element name="lastCreatedCategory" type="block" selector=".x-tree-root-ct li li:last-child" /> <element name="treeContainer" type="block" selector=".tree-holder" /> <element name="expandRootCategory" type="text" selector="img.x-tree-elbow-end-plus"/> + <element name="categoryByName" type="text" selector="//div[contains(@class, 'categories-side-col')]//a/span[contains(text(), '{{categoryName}}')]" parameterized="true" timeout="30"/> </section> </sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml index 98b23a4669b7..7388ebc8408d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml @@ -8,6 +8,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminProductFormSection"> + <element name="datepickerNewAttribute" type="input" selector="[data-index='{{attrName}}'] input" timeout="30" parameterized="true"/> <element name="attributeSet" type="select" selector="div[data-index='attribute_set_id'] .admin__field-control"/> <element name="attributeSetFilter" type="input" selector="div[data-index='attribute_set_id'] .admin__field-control input" timeout="30"/> <element name="attributeSetFilterResult" type="input" selector="div[data-index='attribute_set_id'] .action-menu-item._last" timeout="30"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml index 89eb1ed678cc..f20e9b3a11e5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml @@ -14,6 +14,7 @@ <element name="imageUploadButton" type="button" selector="div.image div.fileinput-button"/> <element name="imageFile" type="text" selector="//*[@id='media_gallery_content']//img[contains(@src, '{{url}}')]" parameterized="true"/> <element name="removeImageButton" type="button" selector=".action-remove"/> + <element name="removeImageButtonForExactImage" type="button" selector="[id='media_gallery_content'] img[src*='{{imageName}}'] + div[class='actions'] button[class='action-remove']" parameterized="true"/> <element name="modalOkBtn" type="button" selector="button.action-primary.action-accept"/> <element name="uploadProgressBar" type="text" selector=".uploader .file-row"/> <element name="productImagesToggleState" type="button" selector="[data-index='gallery'] > [data-state-collapsible='{{status}}']" parameterized="true"/> @@ -27,6 +28,7 @@ <element name="roleSmall" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li/label[normalize-space(.) = 'Small']"/> <element name="roleThumbnail" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li/label[normalize-space(.) = 'Thumbnail']"/> <element name="roleSwatch" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li/label[normalize-space(.) = 'Swatch']"/> + <element name="isRoleChecked" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li/label[normalize-space(.) = '{{role}}']/parent::li[contains(@class,'selected')]" parameterized="true"/> <element name="isBaseSelected" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li[contains(@class, 'selected')]/label[normalize-space(.) = 'Base']"/> <element name="isSmallSelected" type="button" selector="//div[contains(@class, 'field-image-role')]//ul/li[contains(@class, 'selected')]/label[normalize-space(.) = 'Small']"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml index 1b7bbd58eea9..136a8ceadb89 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml @@ -12,6 +12,8 @@ <element name="filterOptions" type="text" selector=".filter-options-content .items"/> <element name="filterOption" type="text" selector=".filter-options-content .item"/> <element name="optionQty" type="text" selector=".filter-options-content .item .count"/> + <element name="filterOptionByLabel" type="button" selector=" div.filter-options-item div[option-label='{{optionLabel}}']" parameterized="true"/> + <element name="removeFilter" type="button" selector="div.filter-current .remove"/> </section> <section name="StorefrontCategorySidebarMobileSection"> <element name="shopByButton" type="button" selector="//div[contains(@class, 'filter-title')]/strong[contains(text(), 'Shop By')]"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml index 31204c7b4b0b..9a0f5ad00272 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml @@ -18,13 +18,10 @@ <testCaseId value="MAGETWO-98644"/> <useCaseId value="MAGETWO-98522"/> <group value="Catalog"/> - <skip> - <issueId value="MC-15930"/> - </skip> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - <magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="displayOutOfStockNo"/> + <magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockDisable.path}} {{CatalogInventoryOptionsShowOutOfStockDisable.value}}" stepKey="setConfigShowOutOfStockFalse"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> <createData entity="SimpleSubCategory" stepKey="category"/> <createData entity="SimpleProduct4" stepKey="product"> @@ -32,7 +29,7 @@ </createData> </before> <after> - <magentoCLI command="config:set cataloginventory/options/show_out_of_stock 0" stepKey="displayOutOfStockNo2"/> + <magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockDisable.path}} {{CatalogInventoryOptionsShowOutOfStockDisable.value}}" stepKey="setConfigShowOutOfStockFalse"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> <deleteData createDataKey="product" stepKey="deleteProduct"/> <deleteData createDataKey="category" stepKey="deleteCategory"/> @@ -40,23 +37,24 @@ </after> <!--Open product page--> <comment userInput="Open product page" stepKey="openProdPage"/> - <amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage"/> + <amOnPage url="{{StorefrontProductPage.url($$product.custom_attributes[url_key]$$)}}" stepKey="goToSimpleProductPage"/> <waitForPageLoad stepKey="waitForSimpleProductPage"/> <!--'Add to compare' link is not available--> <comment userInput="'Add to compare' link is not available" stepKey="addToCompareLinkAvailability"/> <dontSeeElement selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="dontSeeAddToCompareLink"/> <!--Turn on 'out on stock' config--> <comment userInput="Turn on 'out of stock' config" stepKey="onOutOfStockConfig"/> - <magentoCLI command="config:set cataloginventory/options/show_out_of_stock 1" stepKey="displayOutOfStockYes"/> + <magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockEnable.path}} {{CatalogInventoryOptionsShowOutOfStockEnable.value}}" stepKey="setConfigShowOutOfStockTrue"/> <!--Clear cache and reindex--> <comment userInput="Clear cache and reindex" stepKey="cleanCache"/> <magentoCLI command="indexer:reindex" stepKey="reindex"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> <!--Open product page--> <comment userInput="Open product page" stepKey="openProductPage"/> - <amOnPage url="{{StorefrontProductPage.url($$product.name$$)}}" stepKey="goToSimpleProductPage2"/> + <amOnPage url="{{StorefrontProductPage.url($$product.custom_attributes[url_key]$$)}}" stepKey="goToSimpleProductPage2"/> <waitForPageLoad stepKey="waitForSimpleProductPage2"/> <!--Click on 'Add to Compare' link--> + <waitForElementVisible selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="seeAddToCompareLink"/> <comment userInput="Click on 'Add to Compare' link" stepKey="clickOnAddToCompareLink"/> <click selector="{{StorefrontProductInfoMainSection.productAddToCompare}}" stepKey="clickOnAddToCompare"/> <waitForPageLoad stepKey="waitForProdAddToCmpList"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml index feb4fffd12f5..51ef7fb77d74 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml @@ -60,6 +60,9 @@ <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/> <waitForLoadingMaskToDisappear stepKey="waitForLoading"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/> + <!--Clear cache and reindex--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> <!--Verify product is visible in category front page --> <amOnPage url="$$createCategory.name$$.html" stepKey="openCategoryStoreFrontPage"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml index 679cab4159eb..88c524eff387 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml @@ -23,11 +23,13 @@ <createData entity="SimpleProductInStockQuantityZero" stepKey="createProduct"/> <!-- Configure Magento to show out of stock products and to allow backorders --> + <magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockEnable.path}} {{CatalogInventoryOptionsShowOutOfStockEnable.value}}" stepKey="setConfigShowOutOfStockTrue"/> <magentoCLI command="config:set {{CatalogInventoryItemOptionsBackordersEnable.path}} {{CatalogInventoryItemOptionsBackordersEnable.value}}" stepKey="setConfigAllowBackordersTrue"/> </before> <after> <!-- Set Magento back to default configuration --> + <magentoCLI command="config:set {{CatalogInventoryOptionsShowOutOfStockDisable.path}} {{CatalogInventoryOptionsShowOutOfStockDisable.value}}" stepKey="setConfigShowOutOfStockFalse"/> <magentoCLI command="config:set {{CatalogInventoryItemOptionsBackordersDisable.path}} {{CatalogInventoryItemOptionsBackordersDisable.value}}" stepKey="setConfigAllowBackordersFalse"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> </after> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckOutOfStockProductIsVisibleInCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckOutOfStockProductIsVisibleInCategoryTest.xml index e1cb45be22b4..a863de2716c9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckOutOfStockProductIsVisibleInCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckOutOfStockProductIsVisibleInCategoryTest.xml @@ -63,6 +63,10 @@ <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/> <waitForLoadingMaskToDisappear stepKey="waitForLoading"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/> + + <!--Run re-index task --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Verify product is visible in category front page --> <amOnPage url="$$createCategory.name$$.html" stepKey="openCategoryStoreFrontPage"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml index 1b7245874706..47e206768527 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml @@ -16,6 +16,9 @@ <severity value="CRITICAL"/> <group value="mtf_migrated"/> <group value="Catalog"/> + <skip> + <issueId value="MC-21962"/> + </skip> </annotations> <before> <magentoCLI stepKey="setFlatCatalogCategory" command="config:set catalog/frontend/flat_catalog_category 1 "/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml index 15171fe3713c..784b5d3fd182 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest.xml @@ -19,7 +19,7 @@ <group value="category"/> </annotations> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml index 9115004ad958..a6890c2ad490 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml @@ -64,6 +64,9 @@ <waitForPageLoad stepKey="waitForPageTitleToBeSaved"/> <!--Verify the Category Title--> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> + <!--Clear cache and reindex--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> <!--Verify Product in store front page--> <amOnPage url="{{StorefrontCategoryPage.url(_defaultCategory.name_lwr)}}" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForPageToBeLoaded"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateNewAttributeFromProductPageTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateNewAttributeFromProductPageTest.xml new file mode 100644 index 000000000000..2706d00038e4 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateNewAttributeFromProductPageTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateNewAttributeFromProductPageTest"> + <annotations> + <features value="Catalog"/> + <stories value="We should validate the form when the user click Save in New Attribute Set"/> + <title value="We should validate the form when the user click Save in New Attribute Set"/> + <description + value="Admin should be able to create product attribute and validate the form when the user click Save in New Attribute Set"/> + <testCaseId value="https://github.com/magento/magento2/pull/25132"/> + <severity value="CRITICAL"/> + <group value="Catalog"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <actionGroup ref="GoToProductCatalogPage" stepKey="goToProductCatalogPage"/> + <actionGroup ref="goToCreateProductPage" stepKey="goToCreateProduct"> + <argument name="product" value="SimpleProduct"/> + </actionGroup> + <actionGroup ref="AdminClickAddAttributeOnProductEditPageActionGroup" stepKey="clickAddAttribute"/> + <actionGroup ref="AdminClickCreateNewAttributeFromProductEditPageActionGroup" stepKey="clickCreateNewAttribute1" /> + <actionGroup ref="AdminFillAttributeDataProductFormNewAttributeActionGroup" stepKey="fillAttributeData" /> + + <click selector="{{AdminProductFormNewAttributeSection.saveInNewSet}}" stepKey="saveAttributeInSet"/> + <actionGroup ref="AdminAssertProductEditPageCreateAttributeSaveInAttributeSetPopUpShownActionGroup" stepKey="assertPopUp"/> + <click selector="{{ModalConfirmationSection.CancelButton}}" stepKey="cancelButton"/> + + <actionGroup ref="AdminFillAttributeDataProductFormNewAttributeActionGroup" stepKey="emptyAttributeData" > + <argument name="attributeName" value=" "/> + <argument name="attributeType" value=" "/> + </actionGroup> + + <click selector="{{AdminProductFormNewAttributeSection.saveInNewSet}}" stepKey="clickSaveInSet"/> + <see userInput="This is a required field." stepKey="seeThisIsRequiredField"/> + <dontSee userInput="Enter Name for New Attribute Set" stepKey="dontSeePopUp" /> + + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeFromProductPageTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeFromProductPageTest.xml index 5c798db29b97..63a964f4b5e9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeFromProductPageTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductAttributeFromProductPageTest.xml @@ -90,6 +90,9 @@ <waitForPageLoad stepKey="waitForProductToSave"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/> + <!--Run Re-Index task --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Verify product attribute added in product form --> <scrollTo selector="{{AdminProductFormSection.contentTab}}" stepKey="scrollToContentTab"/> <waitForElementVisible selector="{{AdminProductFormSection.attributeTab}}" stepKey="waitForAttributeToVisible"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductDuplicateUrlkeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductDuplicateUrlkeyTest.xml index 6658ad36d715..291b6985bd3e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductDuplicateUrlkeyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductDuplicateUrlkeyTest.xml @@ -23,7 +23,7 @@ </createData> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="simpleProduct" stepKey="deleteProduct"/> </after> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductTest.xml index 6096ee1fa399..a7587a5ed31f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductTest.xml @@ -22,7 +22,6 @@ <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> </after> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithUnicodeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithUnicodeTest.xml index 896a28d0298e..94d488f216b4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithUnicodeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithUnicodeTest.xml @@ -22,7 +22,7 @@ <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> </after> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml index 58737dd50974..23f772a395a7 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml @@ -117,6 +117,8 @@ <!-- Verify we see success message --> <see selector="{{AdminProductFormSection.successMessage}}" userInput="You saved the product." stepKey="seeAssertVirtualProductSuccessMessage"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> <!-- Verify customer see created virtual product with custom options suite and import options(from above step) on storefront page and is searchable by sku --> <amOnPage url="{{StorefrontProductPage.url(virtualProductCustomImportOptions.urlKey)}}" stepKey="goToProductPage"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml index 78247f494359..9055e961f889 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml @@ -24,6 +24,9 @@ <createData entity="Simple_US_CA_Customer" stepKey="customer" /> </before> <after> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteVirtualProduct"> + <argument name="product" value="virtualProductGeneralGroup"/> + </actionGroup> <deleteData stepKey="deleteSimpleSubCategory" createDataKey="categoryEntity"/> <deleteData stepKey="deleteCustomer" createDataKey="customer"/> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml index 6ef2569945fa..40f26761e7b6 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceTest.xml @@ -97,6 +97,10 @@ <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> <see selector="{{StorefrontCategoryMainSection.productLink}}" userInput="{{virtualProductBigQty.name}}" stepKey="seeVirtualProductNameOnCategoryPage"/> + <!--Run full reindex and clear caches --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!-- Verify customer see created virtual product with tier price(from above step) on storefront page and is searchable by sku --> <amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStorefront"/> <waitForPageLoad stepKey="waitForStoreFrontProductPageLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteProductsImageInCaseOfMultipleStoresTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteProductsImageInCaseOfMultipleStoresTest.xml new file mode 100644 index 000000000000..f334cbc218b7 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteProductsImageInCaseOfMultipleStoresTest.xml @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminDeleteProductsImageInCaseOfMultipleStoresTest"> + <annotations> + <stories value="MultipleStores"/> + <features value="Catalog"/> + <title value="Delete products image in case of multiple stores"/> + <description value="Delete products image in case of multiple stores"/> + <severity value="MAJOR"/> + <testCaseId value="MC-11466"/> + <useCaseId value="MC-15391"/> + <group value="Catalog"/> + </annotations> + <before> + <!--Login as admin--> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create new website, store and store view--> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> + <argument name="newWebsiteName" value="{{NewWebSiteData.name}}"/> + <argument name="websiteCode" value="{{NewWebSiteData.code}}"/> + </actionGroup> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStore"> + <argument name="website" value="{{NewWebSiteData.name}}"/> + <argument name="storeGroupName" value="{{NewStoreData.name}}"/> + <argument name="storeGroupCode" value="{{NewStoreData.code}}"/> + </actionGroup> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createCustomStoreView"> + <argument name="StoreGroup" value="NewStoreData"/> + <argument name="customStore" value="NewStoreViewData"/> + </actionGroup> + <!--Create Product--> + <createData entity="SimpleProduct2" stepKey="createProduct"/> + <createData entity="SubCategory" stepKey="createSubCategory"/> + <createData entity="NewRootCategory" stepKey="createRootCategory"/> + <amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="visitAdminProductPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad0"/> + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="['Default Category', $$createRootCategory.name$$, $$createSubCategory.name$$]" stepKey="fillCategory"/> + <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + <!--Add images to the product--> + <amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="visitAdminProductPage2"/> + <waitForPageLoad stepKey="waitForProductPageLoad1"/> + <actionGroup ref="addProductImage" stepKey="addImageToProduct"> + <argument name="image" value="ProductImage"/> + </actionGroup> + <actionGroup ref="addProductImage" stepKey="addImage1ToProduct"> + <argument name="image" value="TestImageNew"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct1"/> + <!--Enable config to view created store view on store front--> + <createData entity="EnableWebUrlOptionsConfig" stepKey="enableWebUrlOptionsConfig"/> + </before> + <after> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"> + <argument name="websiteName" value="{{NewWebSiteData.name}}"/> + </actionGroup> + <magentoCLI stepKey="reindex" command="indexer:reindex"/> + <magentoCLI stepKey="flushCache" command="cache:flush"/> + <deleteData createDataKey="createSubCategory" stepKey="deleteSubCategory"/> + <deleteData createDataKey="createRootCategory" stepKey="deleteRootCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <createData entity="DefaultWebUrlOptionsConfig" stepKey="defaultWebUrlOptionsConfig"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Grab new store view code--> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="navigateToNewWebsitePage"/> + <waitForPageLoad stepKey="waitForStoresPageLoad"/> + <fillField userInput="{{NewWebSiteData.name}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillSearchWebsiteField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <click selector="{{AdminStoresGridSection.storeNameInFirstRow}}" stepKey="clickFirstRow"/> + <grabValueFrom selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="grabStoreViewCode"/> + <click selector="{{AdminNewStoreViewActionsSection.backButton}}" stepKey="clickBack"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="clickResetButton"/> + <waitForPageLoad stepKey="waitForStorePageLoad"/> + <!--Open product page on admin--> + <amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="openProductEditPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad2"/> + <!--Enable the newly created website and save the product--> + <actionGroup ref="SelectProductInWebsitesActionGroup" stepKey="selectWebsiteInProduct2"> + <argument name="website" value="{{NewWebSiteData.name}}"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct2"/> + <!--Reindex and flush cache--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!--Switch to 'Default Store View' scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchDefaultStoreView"> + <argument name="storeViewName" value="'Default Store View'"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad3"/> + <!--Assign all roles to first image on default store view--> + <actionGroup ref="AdminAssignImageRolesIfUnassignedActionGroup" stepKey="assignAllRolesToFirstImage"> + <argument name="image" value="ProductImage"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct3"/> + <!--Switch to newly created Store View scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchNewStoreView"> + <argument name="storeViewName" value="{{NewStoreViewData.name}}"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad4"/> + <!--Assign all roles to first image on new store view--> + <actionGroup ref="AdminAssignImageRolesIfUnassignedActionGroup" stepKey="assignAllRolesToFirstImage2"> + <argument name="image" value="ProductImage"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct4"/> + <!--Switch to 'All Store Views' scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchAllStoreView"> + <argument name="storeViewName" value="'All Store Views'"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad5"/> + <!--Remove product image and save--> + <actionGroup ref="RemoveProductImageByName" stepKey="removeProductImage"> + <argument name="image" value="ProductImage"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct5"/> + <!--Assert notification and success messages--> + <see selector="{{StorefrontMessagesSection.success}}" userInput="{{ProductFormMessages.save_success}}" stepKey="seeSuccessMessage"/> + <see selector="{{StorefrontMessagesSection.noticeMessage}}" userInput="{{ProductFormMessages.remove_image_notice}}" stepKey="seeNotification"/> + <!--Reopen image tab and see the image is not deleted--> + <conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesTab"/> + <waitForPageLoad stepKey="waitForImagesLoad"/> + <seeElement selector="{{AdminProductImagesSection.imageFile(ProductImage.fileName)}}" stepKey="seeImageIsNotDeleted"/> + <!--Switch to newly created Store View scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchNewStoreView2"> + <argument name="storeViewName" value="{{NewStoreViewData.name}}"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad6"/> + <!--Assign all roles to second image on default store view--> + <actionGroup ref="AdminAssignImageRolesIfUnassignedActionGroup" stepKey="assignAllRolesToSecondImage"> + <argument name="image" value="TestImageNew"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct6"/> + <!--Switch to 'All Store Views' scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchAllStoreView2"> + <argument name="storeViewName" value="'All Store Views'"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad7"/> + <!--Remove product image and save--> + <actionGroup ref="RemoveProductImageByName" stepKey="removeProductFirstImage"> + <argument name="image" value="ProductImage"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct7"/> + <!--Assert notification and success messages--> + <see selector="{{StorefrontMessagesSection.success}}" userInput="{{ProductFormMessages.save_success}}" stepKey="seeSuccessMessage2"/> + <see selector="{{StorefrontMessagesSection.noticeMessage}}" userInput="{{ProductFormMessages.remove_image_notice}}" stepKey="seeNotification2"/> + <!--Reopen image tab and see the image is not deleted--> + <conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesTab2"/> + <waitForPageLoad stepKey="waitForImagesLoad2"/> + <seeElement selector="{{AdminProductImagesSection.imageFile(ProductImage.fileName)}}" stepKey="seeImageIsNotDeleted2"/> + <!--Switch to newly created Store View scope and open product page--> + <actionGroup ref="SwitchToTheNewStoreView" stepKey="SwitchNewStoreView3"> + <argument name="storeViewName" value="{{NewStoreViewData.name}}"/> + </actionGroup> + <waitForPageLoad stepKey="waitForProductPageLoad8"/> + <!--Remove second image and save--> + <actionGroup ref="RemoveProductImageByName" stepKey="removeProductSecondImage"> + <argument name="image" value="TestImageNew"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct8"/> + <!--Assert success messages--> + <see selector="{{StorefrontMessagesSection.success}}" userInput="{{ProductFormMessages.save_success}}" stepKey="seeSuccessMessage3"/> + <!--Reopen image tab and see the image is deleted--> + <conditionalClick selector="{{AdminProductImagesSection.productImagesToggle}}" dependentSelector="{{AdminProductImagesSection.imageUploadButton}}" visible="false" stepKey="openProductImagesTab3"/> + <waitForPageLoad stepKey="waitForImagesLoad3"/> + <dontSeeElement selector="{{AdminProductImagesSection.imageFile(TestImageNew.fileName)}}" stepKey="seeImageIsDeleted"/> + <!--Open Storefront on Default store view and assert image existence--> + <amOnPage url="{{StorefrontCategoryPage.url($$createSubCategory.name$$)}}" stepKey="navigateToCategoryPage"/> + <waitForPageLoad stepKey="waitForCategoryPageLoad0"/> + <grabAttributeFrom userInput="src" selector="{{StorefrontCategoryMainSection.mediaDescription($$createProduct.name$$)}}" stepKey="grabAttributeFromImage"/> + <assertContains expectedType="string" expected="{{ProductImage.filename}}" actual="$grabAttributeFromImage" stepKey="assertProductImageAbsence"/> + <!--Open Storefront on newly created store view and assert image absence--> + <amOnPage url="$grabStoreViewCode" stepKey="navigateToHomePageOfSpecificStore"/> + <waitForPageLoad stepKey="waitForHomePageLoad"/> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createSubCategory.name$$)}}" stepKey="clickCategory"/> + <waitForPageLoad stepKey="waitForCategoryPageLoad1"/> + <grabAttributeFrom userInput="src" selector="{{StorefrontCategoryMainSection.mediaDescription($$createProduct.name$$)}}" stepKey="grabAttributeFromImage2"/> + <assertContains expectedType="string" expected="small_image" actual="$grabAttributeFromImage2" stepKey="assertProductImageAbsence2"/> + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDisableProductOnChangingAttributeSetTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDisableProductOnChangingAttributeSetTest.xml new file mode 100644 index 000000000000..dab1704d50bf --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDisableProductOnChangingAttributeSetTest.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminDisableProductOnChangingAttributeSetTest"> + <annotations> + <features value="Catalog"/> + <stories value="Disabled product is enabled when change attribute set"/> + <title value="Verify product status while changing attribute set"/> + <description value="Value set for enabled product has to be shown when attribute set is changed"/> + <severity value="MAJOR"/> + <testCaseId value="MC-19716"/> + <group value="catalog"/> + </annotations> + <before> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/> + </before> + <after> + <deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + <amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$$createAttributeSet.attribute_set_id$$/" stepKey="onAttributeSetEdit"/> + <actionGroup ref="SaveAttributeSet" stepKey="SaveAttributeSet"/> + <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct"> + <argument name="product" value="$$createSimpleProduct$$"/> + </actionGroup> + + <actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1"> + <argument name="product" value="$$createSimpleProduct$$"/> + </actionGroup> + <actionGroup ref="DisableProductLabelActionGroup" stepKey="disableWhileChangingAttributeSet" > + <argument name="createAttributeSet" value="$$createAttributeSet$$"/> + </actionGroup> + + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminGridPageNumberAfterSaveAndCloseActionTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminGridPageNumberAfterSaveAndCloseActionTest.xml index df6ddfa16902..eb4a56176007 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminGridPageNumberAfterSaveAndCloseActionTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminGridPageNumberAfterSaveAndCloseActionTest.xml @@ -25,9 +25,7 @@ <comment userInput="Clear product grid" stepKey="commentClearProductGrid"/> <amOnPage url="{{ProductCatalogPage.url}}" stepKey="goToProductCatalog"/> <waitForPageLoad stepKey="waitForProductIndexPage"/> - <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" - dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/> - <waitForLoadingMaskToDisappear stepKey="waitForGridLoad"/> + <actionGroup ref="resetProductGridToDefaultView" stepKey="resetProductGridToDefaultView"/> <actionGroup ref="deleteProductsIfTheyExist" stepKey="deleteProductIfTheyExist"/> <createData stepKey="category1" entity="SimpleSubCategory"/> <createData stepKey="product1" entity="SimpleProduct"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml index bee13bec370d..18d4b9e341cc 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml @@ -18,6 +18,85 @@ <testCaseId value="MC-128"/> <group value="Catalog"/> <group value="Product Attributes"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView" /> + <createData entity="ApiProductWithDescription" stepKey="createProductOne"/> + <createData entity="ApiProductWithDescription" stepKey="createProductTwo"/> + <createData entity="ApiProductNameWithNoSpaces" stepKey="createProductThree"/> + </before> + <after> + <deleteData createDataKey="createProductOne" stepKey="deleteProductOne"/> + <deleteData createDataKey="createProductTwo" stepKey="deleteProductTwo"/> + <deleteData createDataKey="createProductThree" stepKey="deleteProductThree"/> + <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="AdminDeleteStoreViewActionGroup"/> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> + </after> + + <!-- Search and select products --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/> + <waitForPageLoad stepKey="waitForProductIndexPageLoad"/> + <actionGroup ref="searchProductGridByKeyword2" stepKey="searchByKeyword"> + <argument name="keyword" value="api-simple-product"/> + </actionGroup> + <actionGroup ref="sortProductsByIdDescending" stepKey="sortProductsByIdDescending"/> + <click selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="clickCheckbox1"/> + <click selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckbox2"/> + <!-- Mass update attributes --> + <click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickDropdown"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Update attributes')}}" stepKey="clickOption"/> + <waitForPageLoad stepKey="waitForBulkUpdatePage"/> + <seeInCurrentUrl stepKey="seeInUrl" url="catalog/product_action_attribute/edit/"/> + <!-- Switch store view --> + <actionGroup ref="AdminSwitchStoreViewActionGroup" stepKey="AdminSwitchStoreViewActionGroup"/> + <!-- Update attribute --> + <click selector="{{AdminEditProductAttributesSection.ChangeAttributeDescriptionToggle}}" stepKey="toggleToChangeDescription"/> + <fillField selector="{{AdminEditProductAttributesSection.AttributeDescription}}" userInput="Updated $$createProductOne.custom_attributes[description]$$" stepKey="fillAttributeDescriptionField"/> + <click selector="{{AdminEditProductAttributesSection.Save}}" stepKey="save"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> + + + <!-- Assert on storefront default view with partial word of product name --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault"> + <argument name="name" value="$$createProductOne.name$$"/> + <argument name="description" value="$$createProductOne.custom_attributes[description]$$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault"/> + <see userInput="2 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInDefault"/> + + <!-- Assert on storefront custom view with partial word of product name --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupCustom"/> + <actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="StorefrontSwitchStoreViewActionGroup"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameCustom"> + <argument name="name" value="$$createProductOne.name$$"/> + <argument name="description" value="Updated $$createProductOne.custom_attributes[description]$$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultCustom"/> + <see userInput="2 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInCustom"/> + + <!-- Assert Storefront default view with exact product name --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault1"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault1"> + <argument name="name" value="$$createProductThree.name$$"/> + <argument name="description" value="$$createProductThree.custom_attributes[description]$$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault1"/> + <see userInput="1 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInDefault1"/> + </test> + <test name="AdminMassUpdateProductAttributesStoreViewScopeMysqlTest"> + <annotations> + <features value="Catalog"/> + <stories value="Mass update product attributes"/> + <title value="Admin should be able to mass update product attributes in store view scope using the Mysql search engine"/> + <description value="Admin should be able to mass update product attributes in store view scope using the Mysql search engine"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-20467"/> + <group value="Catalog"/> + <group value="Product Attributes"/> + <group value="SearchEngineMysql"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductStatusStoreViewScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductStatusStoreViewScopeTest.xml index e9b54e3f1a3d..02e8157282de 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductStatusStoreViewScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductStatusStoreViewScopeTest.xml @@ -18,6 +18,157 @@ <testCaseId value="MAGETWO-59361"/> <group value="Catalog"/> <group value="Product Attributes"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/> + + <!--Create Website --> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createAdditionalWebsite"> + <argument name="newWebsiteName" value="Second Website"/> + <argument name="websiteCode" value="second_website"/> + </actionGroup> + + <!--Create Store --> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStore"> + <argument name="website" value="Second Website"/> + <argument name="storeGroupName" value="Second Store"/> + <argument name="storeGroupCode" value="second_store"/> + </actionGroup> + + <!--Create Store view --> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForPageLoad stepKey="waitForSystemStorePage"/> + <click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <waitForElementVisible selector="//legend[contains(., 'Store View Information')]" stepKey="waitForNewStorePageToOpen"/> + <selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/> + <fillField userInput="Second Store View" selector="{{AdminNewStoreSection.storeNameTextField}}" stepKey="fillStoreViewName"/> + <fillField userInput="second_store_view" selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="fillStoreViewCode"/> + <selectOption selector="{{AdminNewStoreSection.statusDropdown}}" userInput="1" stepKey="enableStoreViewStatus"/> + <click selector="{{AdminNewStoreViewActionsSection.saveButton}}" stepKey="clickSaveStoreView" /> + <waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal" /> + <see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarning" /> + <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="dismissModal" /> + <waitForPageLoad stepKey="waitForPageLoad2" time="180" /> + <waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" time="150" stepKey="waitForPageReolad"/> + <see userInput="You saved the store view." stepKey="seeSavedMessage" /> + + <!--Create a Simple Product 1 --> + <actionGroup ref="createSimpleProductAndAddToWebsite" stepKey="createSimpleProduct1"> + <argument name="product" value="simpleProductForMassUpdate"/> + <argument name="website" value="Second Website"/> + </actionGroup> + + <!--Create a Simple Product 2 --> + <actionGroup ref="createSimpleProductAndAddToWebsite" stepKey="createSimpleProduct2"> + <argument name="product" value="simpleProductForMassUpdate2"/> + <argument name="website" value="Second Website"/> + </actionGroup> + </before> + <after> + <!--Delete website --> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite"> + <argument name="websiteName" value="Second Website"/> + </actionGroup> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/> + + <!--Delete Products --> + <actionGroup ref="DeleteProductActionGroup" stepKey="deleteProduct1"> + <argument name="productName" value="simpleProductForMassUpdate.name"/> + </actionGroup> + <actionGroup ref="DeleteProductActionGroup" stepKey="deleteProduct2"> + <argument name="productName" value="simpleProductForMassUpdate2.name"/> + </actionGroup> + <actionGroup ref="logout" stepKey="amOnLogoutPage"/> + </after> + + <!-- Search and select products --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/> + <waitForPageLoad stepKey="waitForProductIndexPageLoad"/> + <actionGroup ref="searchProductGridByKeyword2" stepKey="searchByKeyword"> + <argument name="keyword" value="{{simpleProductForMassUpdate.keyword}}"/> + </actionGroup> + <actionGroup ref="sortProductsByIdDescending" stepKey="sortProductsByIdDescending"/> + + <!-- Filter to Second Store View --> + <actionGroup ref="AdminFilterStoreViewActionGroup" stepKey="filterStoreView" > + <argument name="customStore" value="'Second Store View'" /> + </actionGroup> + + <!-- Select Product 2 --> + <click selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckbox2"/> + + <!-- Mass update attributes --> + <click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickDropdown"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickOption"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Disable')}}" stepKey="clickDisabled"/> + <waitForPageLoad stepKey="waitForBulkUpdatePage"/> + + <!-- Verify Product Statuses --> + <see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Enabled" stepKey="checkIfProduct1IsEnabled"/> + <see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="Disabled" stepKey="checkIfProduct2IsDisabled"/> + + <!-- Filter to Default Store View --> + <actionGroup ref="AdminFilterStoreViewActionGroup" stepKey="filterDefaultStoreView"> + <argument name="customStore" value="'Default'" /> + </actionGroup> + + <!-- Verify Product Statuses --> + <see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Enabled" stepKey="checkIfDefaultViewProduct1IsEnabled"/> + <see selector="{{AdminProductGridSection.productGridContentsOnRow('2')}}" userInput="Enabled" stepKey="checkIfDefaultViewProduct2IsEnabled"/> + + <!-- Assert on storefront default view with first product --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault"> + <argument name="name" value="{{simpleProductForMassUpdate.name}}"/> + <argument name="description" value=""/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault"/> + <see userInput="1 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInDefault"/> + + <!-- Assert on storefront default view with second product --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefaultToSearchSecondProduct"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefaultWithSecondProduct"> + <argument name="name" value="{{simpleProductForMassUpdate2.name}}"/> + <argument name="description" value=""/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefaultForSecondProduct"/> + <see userInput="1 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="seeInDefaultSecondProductResults"/> + + <!--Enable the product in Default store view--> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex2"/> + <waitForPageLoad stepKey="waitForProductIndexPageLoad2"/> + <click selector="{{AdminProductGridSection.productGridCheckboxOnRow('1')}}" stepKey="clickCheckboxDefaultStoreView"/> + <click selector="{{AdminProductGridSection.productGridCheckboxOnRow('2')}}" stepKey="clickCheckboxDefaultStoreView2"/> + + <!-- Mass update attributes --> + <click selector="{{AdminProductGridSection.bulkActionDropdown}}" stepKey="clickDropdownDefaultStoreView"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Change status')}}" stepKey="clickOptionDefaultStoreView"/> + <click selector="{{AdminProductGridSection.bulkActionOption('Disable')}}" stepKey="clickDisabledDefaultStoreView"/> + <waitForPageLoad stepKey="waitForBulkUpdatePageDefaultStoreView"/> + <see selector="{{AdminProductGridSection.productGridContentsOnRow('1')}}" userInput="Disabled" stepKey="checkIfProduct2IsDisabledDefaultStoreView"/> + + <!-- Assert on storefront default view --> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault2"/> + <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault2"> + <argument name="name" value="{{simpleProductForMassUpdate.name}}"/> + <argument name="description" value=""/> + </actionGroup> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault2"/> + <see userInput="We can't find any items matching these search criteria." selector="{{StorefrontCatalogSearchAdvancedResultMainSection.message}}" stepKey="seeInDefault2"/> + </test> + <test name="AdminMassUpdateProductStatusStoreViewScopeMysqlTest"> + <annotations> + <features value="Catalog"/> + <stories value="Mass update product status"/> + <title value="Admin should be able to mass update product statuses in store view scope using the Mysql search engine"/> + <description value="Admin should be able to mass update product statuses in store view scope using the Mysql search engine"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-20471"/> + <group value="Catalog"/> + <group value="Product Attributes"/> + <group value="SearchEngineMysql"/> </annotations> <before> <actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/> @@ -147,5 +298,5 @@ </actionGroup> <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResultDefault2"/> <see userInput="We can't find any items matching these search criteria." selector="{{StorefrontCatalogSearchAdvancedResultMainSection.message}}" stepKey="seeInDefault2"/> - </test> -</tests> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml index d17078d794b4..b613068893b0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml @@ -59,6 +59,9 @@ <waitForPageLoad stepKey="waitForSecondCategoryToSave"/> <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSuccessMessage"/> + <!--Run re-index task --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Verify category displayed in store front page--> <amOnPage url="/$$createDefaultCategory.name$$/{{SimpleSubCategory.name}}.html" stepKey="seeTheCategoryInStoreFrontPage"/> <waitForPageLoad stepKey="waitForStoreFrontPageLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMultipleWebsitesUseDefaultValuesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMultipleWebsitesUseDefaultValuesTest.xml index 264615ff6736..f7fd81f28199 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMultipleWebsitesUseDefaultValuesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMultipleWebsitesUseDefaultValuesTest.xml @@ -22,7 +22,7 @@ <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite"> <argument name="websiteName" value="Second Website"/> </actionGroup> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createAdditionalWebsite"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml index ec0d86ac066f..41d3ca3020c9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCategoryIndexerInUpdateOnScheduleModeTest.xml @@ -18,6 +18,9 @@ <testCaseId value="MC-11146"/> <group value="catalog"/> <group value="indexer"/> + <skip> + <issueId value="MC-20392"/> + </skip> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml index a11646cc4687..de065d2d930c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml @@ -20,12 +20,16 @@ <group value="catalog"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <!--Create product--> <comment userInput="Create product" stepKey="commentCreateProduct"/> <createData entity="VirtualProduct" stepKey="createProduct"/> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <!--Delete product--> <comment userInput="Delete product" stepKey="commentDeleteProduct"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml index 240a5492355c..ebae27a1f718 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml @@ -18,7 +18,7 @@ <group value="Catalog"/> </annotations> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest.xml index 1cd0e15780c1..df50edd20410 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest.xml @@ -34,7 +34,7 @@ <deleteData createDataKey="category" stepKey="deletePreReqCategory"/> <deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/> <deleteData createDataKey="secondProduct" stepKey="deleteSecondProduct"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Go to the first product edit page --> @@ -144,6 +144,8 @@ <!-- Save the second product --> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct2"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> <!-- Go to the admin grid and see the uploaded image --> <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductIndex3"/> @@ -186,7 +188,7 @@ <after> <deleteData createDataKey="category" stepKey="deletePreReqCategory"/> <deleteData createDataKey="product" stepKey="deleteProduct"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Go to the product edit page --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml index 2ff83afa15e5..0f63a7284445 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml @@ -22,7 +22,7 @@ <actionGroup ref="DeleteCategory" stepKey="deleteCategory"> <argument name="categoryEntity" value="_defaultCategory"/> </actionGroup> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create category, change store view to default --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml index 1cb01ac11cb8..ad110ceee32d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml @@ -64,6 +64,10 @@ <!--Verify Category Title--> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!--Verify Category in store front page--> <amOnPage url="{{StorefrontCategoryPage.url(_defaultCategory.name)}}" stepKey="seeDefaultProductPage"/> <waitForPageLoad stepKey="waitForPageToBeLoaded"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml index 637ae790c16c..82395e5d6e0e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml @@ -94,6 +94,9 @@ <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="clickAdminProductSEOSection1"/> <seeInField selector="{{AdminProductSEOSection.urlKeyInput}}" userInput="{{simpleProductRegularPrice245InStock.urlKey}}" stepKey="seeUrlKey"/> + <!--Run re-index task --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Verify customer see updated simple product link on category page --> <amOnPage url="{{StorefrontCategoryPage.url($$categoryEntity.name$$)}}" stepKey="openCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml index 045b3f3420ff..4817b3497c97 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml @@ -94,6 +94,9 @@ <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="clickAdminProductSEOSection1"/> <seeInField selector="{{AdminProductSEOSection.urlKeyInput}}" userInput="{{simpleProductRegularPrice32501InStock.urlKey}}" stepKey="seeUrlKey"/> + <!--Run re-index task --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Verify customer see updated simple product link on category page --> <amOnPage url="{{StorefrontCategoryPage.url($$categoryEntity.name$$)}}" stepKey="openCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml index 8ac56d09e5b4..9fa0e155a4fe 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml @@ -28,6 +28,9 @@ <createData entity="SimpleSubCategory" stepKey="categoryEntity"/> </before> <after> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteVirtualProduct"> + <argument name="product" value="updateVirtualProductRegularPrice"/> + </actionGroup> <deleteData stepKey="deleteSimpleSubCategory" createDataKey="initialCategoryEntity"/> <deleteData stepKey="deleteSimpleSubCategory2" createDataKey="categoryEntity"/> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml index d28e9ddbb127..e0e836085098 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml @@ -28,6 +28,9 @@ <createData entity="SimpleSubCategory" stepKey="categoryEntity"/> </before> <after> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteVirtualProduct"> + <argument name="product" value="updateVirtualProductTierPriceInStock"/> + </actionGroup> <deleteData stepKey="deleteSimpleSubCategory" createDataKey="initialCategoryEntity"/> <deleteData stepKey="deleteSimpleSubCategory2" createDataKey="categoryEntity"/> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml index 22dd2b0054db..677cc4c65ce8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml @@ -28,6 +28,9 @@ <createData entity="SimpleSubCategory" stepKey="categoryEntity"/> </before> <after> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteVirtualProduct"> + <argument name="product" value="updateVirtualProductWithTierPriceInStock"/> + </actionGroup> <deleteData stepKey="deleteSimpleSubCategory" createDataKey="initialCategoryEntity"/> <deleteData stepKey="deleteSimpleSubCategory2" createDataKey="categoryEntity"/> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml index 29c7536d2162..f0148f3d384c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml @@ -28,6 +28,9 @@ <createData entity="SimpleSubCategory" stepKey="categoryEntity"/> </before> <after> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteVirtualProduct"> + <argument name="product" value="updateVirtualTierPriceOutOfStock"/> + </actionGroup> <deleteData stepKey="deleteSimpleSubCategory" createDataKey="initialCategoryEntity"/> <deleteData stepKey="deleteSimpleSubCategory2" createDataKey="categoryEntity"/> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml index a4c8b492d9d8..867f097042a1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml @@ -36,7 +36,7 @@ <group value="Catalog"/> </annotations> <before> - <createData entity="ApiProductWithDescription" stepKey="product"/> + <createData entity="ApiProductWithDescriptionAndUnderscoredSku" stepKey="product"/> </before> <after> <deleteData createDataKey="product" stepKey="delete"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml index 84c3f81ef6db..07b802637b2e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml @@ -33,7 +33,7 @@ <group value="Catalog"/> </annotations> <before> - <createData entity="ApiVirtualProductWithDescription" stepKey="product"/> + <createData entity="ApiVirtualProductWithDescriptionAndUnderscoredSku" stepKey="product"/> </before> </test> <test name="AdvanceCatalogSearchVirtualProductByDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml index 5cae81b36a32..674d46b9c18b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml @@ -36,7 +36,7 @@ <createData entity="NewRootCategory" stepKey="createNewRootCategoryA"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createProduct1" stepKey="deleteProduct1"/> <deleteData createDataKey="createProduct2" stepKey="deleteProduct2"/> <deleteData createDataKey="createProduct3" stepKey="deleteProduct3"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml index 7c0de6da18ca..ad66214e902f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml @@ -17,6 +17,203 @@ <description value="User browses catalog, searches for product, adds product to cart, adds product to wishlist, compares products, uses coupon code and checks out."/> <severity value="CRITICAL"/> <testCaseId value="MAGETWO-87435"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/> + + <createData entity="ApiCategory" stepKey="createCategory"/> + + <createData entity="ApiSimpleProduct" stepKey="createSimpleProduct1"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createSimpleProduct1Image"> + <requiredEntity createDataKey="createSimpleProduct1"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryMagentoLogo" stepKey="createSimpleProduct1Image1"> + <requiredEntity createDataKey="createSimpleProduct1"/> + </createData> + <updateData entity="ApiSimpleProductUpdateDescription" stepKey="updateSimpleProduct1" createDataKey="createSimpleProduct1"/> + + <createData entity="ApiSimpleProduct" stepKey="createSimpleProduct2"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createSimpleProduct2Image"> + <requiredEntity createDataKey="createSimpleProduct2"/> + </createData> + <updateData entity="ApiSimpleProductUpdateDescription" stepKey="updateSimpleProduct2" createDataKey="createSimpleProduct2"/> + </before> + <after> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createSimpleProduct1Image" stepKey="deleteSimpleProduct1Image"/>--> + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createSimpleProduct1Image1" stepKey="deleteSimpleProduct1Image1"/>--> + <deleteData createDataKey="createSimpleProduct1" stepKey="deleteSimpleProduct1"/> + + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createSimpleProduct2Image" stepKey="deleteSimpleProduct2Image"/>--> + <deleteData createDataKey="createSimpleProduct2" stepKey="deleteSimpleProduct2"/> + </after> + + <!--Re-index--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + + <!-- Step 1: User browses catalog --> + <comment userInput="Start of browsing catalog" stepKey="startOfBrowsingCatalog" /> + <amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnHomePage"/> + <waitForPageLoad stepKey="homeWaitForPageLoad"/> + <waitForElementVisible selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeWaitForWelcomeMessage"/> + <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeCheckWelcome"/> + + <!-- Open Category --> + <comment userInput="Open category" stepKey="commentOpenCategory" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="browseClickCategory"/> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="browseAssertCategory"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <!-- Check simple product 1 in category --> + <comment userInput="Check simple product 1 in category" stepKey="commentCheckSimpleProductInCategory" /> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="browseAssertCategoryProduct1"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="browseGrabSimpleProduct1ImageSrc"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$browseGrabSimpleProduct1ImageSrc" stepKey="browseAssertSimpleProduct1ImageNotDefault"/> + <!-- Check simple product 2 in category --> + <comment userInput="Check simple product 2 in category" stepKey="commentCheckSimpleProduct2InCategory" /> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="browseAssertCategoryProduct2"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="browseGrabSimpleProduct2ImageSrc"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$browseGrabSimpleProduct2ImageSrc" stepKey="browseAssertSimpleProduct2ImageNotDefault"/> + + <!-- View Simple Product 1 --> + <comment userInput="View simple product 1" stepKey="commentViewSimpleProduct1" after="browseAssertSimpleProduct2ImageNotDefault"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct1.name$$)}}" stepKey="browseClickCategorySimpleProduct1View" after="commentViewSimpleProduct1"/> + <waitForLoadingMaskToDisappear stepKey="waitForSimpleProduct1Viewloaded" /> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="browseAssertProduct1Page"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="browseGrabSimpleProduct1PageImageSrc"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$browseGrabSimpleProduct1PageImageSrc" stepKey="browseAssertSimpleProduct1PageImageNotDefault"/> + + <!-- View Simple Product 2 --> + <comment userInput="View simple product 2" stepKey="commentViewSimpleProduct2" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="clickCategory1"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct2.name$$)}}" stepKey="browseClickCategorySimpleProduct2View"/> + <waitForLoadingMaskToDisappear stepKey="waitForSimpleProduct2ViewLoaded" /> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="browseAssertProduct2Page"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="browseGrabSimpleProduct2PageImageSrc"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$browseGrabSimpleProduct2PageImageSrc" stepKey="browseAssertSimpleProduct2PageImageNotDefault"/> + <comment userInput="End of browsing catalog" stepKey="endOfBrowsingCatalog" after="browseAssertSimpleProduct2PageImageNotDefault"/> + + <!-- Step 4: User compares products --> + <comment userInput="Start of comparing products" stepKey="startOfComparingProducts" after="endOfBrowsingCatalog"/> + <!-- Add Simple Product 1 to comparison --> + <comment userInput="Add simple product 1 to comparison" stepKey="commentAddSimpleProduct1ToComparison" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="compareClickCategory" /> + <waitForLoadingMaskToDisappear stepKey="waitForCategoryloaded" /> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="compareAssertCategory"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="compareAssertSimpleProduct1"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="compareGrabSimpleProduct1ImageSrc"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabSimpleProduct1ImageSrc" stepKey="compareAssertSimpleProduct1ImageNotDefault"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct1.name$$)}}" stepKey="compareClickSimpleProduct1"/> + <waitForLoadingMaskToDisappear stepKey="waitForCompareSimpleProduct1loaded" /> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="compareAssertProduct1Page"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="compareGrabSimpleProduct1PageImageSrc"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$compareGrabSimpleProduct1PageImageSrc" stepKey="compareAssertSimpleProduct2PageImageNotDefault"/> + <actionGroup ref="StorefrontAddProductToCompareActionGroup" stepKey="compareAddSimpleProduct1ToCompare"> + <argument name="productVar" value="$$createSimpleProduct1$$"/> + </actionGroup> + + <!-- Add Simple Product 2 to comparison --> + <comment userInput="Add simple product 2 to comparison" stepKey="commentAddSimpleProduct2ToComparison" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="compareClickCategory1"/> + <waitForLoadingMaskToDisappear stepKey="waitForCompareCategory1loaded" /> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="compareAssertCategory1"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="compareAssertSimpleProduct2"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="compareGrabSimpleProduct2ImageSrc"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabSimpleProduct2ImageSrc" stepKey="compareAssertSimpleProduct2ImageNotDefault"/> + <actionGroup ref="StorefrontAddCategoryProductToCompareActionGroup" stepKey="compareAddSimpleProduct2ToCompare"> + <argument name="productVar" value="$$createSimpleProduct2$$"/> + </actionGroup> + + <!-- Check products in comparison sidebar --> + <!-- Check simple product 1 in comparison sidebar --> + <comment userInput="Check simple product 1 in comparison sidebar" stepKey="commentCheckSimpleProduct1InComparisonSidebar" after="compareAddSimpleProduct2ToCompare"/> + <actionGroup ref="StorefrontCheckCompareSidebarProductActionGroup" stepKey="compareSimpleProduct1InSidebar" after="commentCheckSimpleProduct1InComparisonSidebar"> + <argument name="productVar" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- Check simple product 2 in comparison sidebar --> + <comment userInput="Check simple product 2 in comparison sidebar" stepKey="commentCheckSimpleProduct2InComparisonSidebar" /> + <actionGroup ref="StorefrontCheckCompareSidebarProductActionGroup" stepKey="compareSimpleProduct2InSidebar"> + <argument name="productVar" value="$$createSimpleProduct2$$"/> + </actionGroup> + + <!-- Check products on comparison page --> + <!-- Check simple product 1 on comparison page --> + <comment userInput="Check simple product 1 on comparison page" stepKey="commentCheckSimpleProduct1OnComparisonPage" after="compareSimpleProduct2InSidebar"/> + <actionGroup ref="StorefrontOpenAndCheckComparisionActionGroup" stepKey="compareOpenComparePage" after="commentCheckSimpleProduct1OnComparisonPage"/> + <actionGroup ref="StorefrontCheckCompareSimpleProductActionGroup" stepKey="compareAssertSimpleProduct1InComparison"> + <argument name="productVar" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductCompareMainSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="compareGrabSimpleProduct1ImageSrcInComparison"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabSimpleProduct1ImageSrcInComparison" stepKey="compareAssertSimpleProduct1ImageNotDefaultInComparison"/> + <!-- Check simple product2 on comparison page --> + <comment userInput="Check simple product 2 on comparison page" stepKey="commentCheckSimpleProduct2OnComparisonPage" /> + <actionGroup ref="StorefrontCheckCompareSimpleProductActionGroup" stepKey="compareAssertSimpleProduct2InComparison"> + <argument name="productVar" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductCompareMainSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="compareGrabSimpleProduct2ImageSrcInComparison"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabSimpleProduct2ImageSrcInComparison" stepKey="compareAssertSimpleProduct2ImageNotDefaultInComparison"/> + + <!-- Clear comparison sidebar --> + <comment userInput="Clear comparison sidebar" stepKey="commentClearComparisonSidebar" after="compareAssertSimpleProduct2ImageNotDefaultInComparison"/> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="compareClickCategoryBeforeClear" after="commentClearComparisonSidebar"/> + + + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="compareAssertCategory2"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontClearCompareActionGroup" stepKey="compareClearCompare"/> + <comment userInput="End of Comparing Products" stepKey="endOfComparingProducts" /> + </test> + <test name="EndToEndB2CGuestUserMysqlTest"> + <annotations> + <features value="End to End scenarios"/> + <stories value="B2C guest user - MAGETWO-75411"/> + <group value="e2e"/> + <title value="You should be able to pass End to End B2C Guest User scenario using the Mysql search engine"/> + <description value="User browses catalog, searches for product, adds product to cart, adds product to wishlist, compares products, uses coupon code and checks out using the Mysql search engine."/> + <severity value="CRITICAL"/> + <testCaseId value="MC-20476"/> + <group value="SearchEngineMysql"/> </annotations> <before> <resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml index 461ebde29fca..c8a7cdee66b5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml @@ -49,6 +49,10 @@ <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/> <waitForPageLoad stepKey="waitForCategorySaved"/> <see userInput="You saved the category." stepKey="seeSuccessMessage"/> + + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <amOnPage url="$$createCategory.name$$.html" stepKey="goToCategoryStorefront"/> <waitForPageLoad stepKey="waitForCategoryStorefrontPage"/> <seeElement selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct.name$$)}}" stepKey="seeCreatedProduct"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml index e9e9eb015878..8092b03c53cb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml @@ -53,7 +53,7 @@ <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteTestWebsite"> <argument name="websiteName" value="Second Website"/> </actionGroup> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchSimpleProductBySkuWithHyphenTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchSimpleProductBySkuWithHyphenTest.xml new file mode 100644 index 000000000000..3b1cd7ff02e6 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchSimpleProductBySkuWithHyphenTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchSimpleProductBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="Catalog"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search simple product with product sku that contains hyphen"/> + <description value="Guest customer should be able to advance search simple product with product sku that contains hyphen"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20361"/> + <group value="Catalog"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="product"/> + </before> + <after> + <deleteData createDataKey="product" stepKey="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchVirtualProductBySkuWithHyphenTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchVirtualProductBySkuWithHyphenTest.xml new file mode 100644 index 000000000000..d6b3a060ffd3 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontAdvanceCatalogSearchVirtualProductBySkuWithHyphenTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchVirtualProductBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="Catalog"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search virtual product with product sku that contains hyphen"/> + <description value="Guest customer should be able to advance search virtual product with product sku that contains hyphen"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20385"/> + <group value="Catalog"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiVirtualProductWithDescription" stepKey="product"/> + </before> + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml index ac2605ff5f3e..4eef6a2c0680 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml @@ -186,6 +186,11 @@ <waitForElementVisible selector="{{AdminCatalogStorefrontConfigSection.productsPerPageAllowedValues}}" stepKey="waitForSectionOpen"/> <seeInField selector="{{AdminCatalogStorefrontConfigSection.productsPerPageAllowedValues}}" userInput="12,24,36" stepKey="seeDefaultValueAllowedNumberProductsPerPage"/> <seeInField selector="{{AdminCatalogStorefrontConfigSection.productsPerPageDefaultValue}}" userInput="12" stepKey="seeDefaultValueProductPerPage"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!-- Open storefront on the category page --> <comment userInput="Open storefront on the category page" stepKey="commentOpenStorefront"/> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToStorefrontCreatedCategoryPage"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuote.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuote.xml index 386633f0e947..21f8e2e070e3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuote.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuote.xml @@ -41,6 +41,9 @@ </actionGroup> <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Check product in category listing--> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="goToCategoryPage"/> <seeElement selector="{{StorefrontCategoryProductSection.ProductImageByNameAndSrc(SimpleProductNameWithDoubleQuote.name, ProductImage.fileName)}}" stepKey="seeCorrectImageCategoryPage"/> @@ -88,6 +91,9 @@ <deleteData createDataKey="createCategoryOne" stepKey="deleteCategory"/> </after> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Check product in category listing--> <amOnPage url="{{StorefrontCategoryPage.url($$createCategoryOne.name$$)}}" stepKey="navigateToCategoryPage"/> <waitForPageLoad stepKey="waitforCategoryPageToLoad"/> @@ -111,11 +117,10 @@ <waitForPageLoad stepKey="waitforCategoryPageToLoad2"/> <!--Open product display page--> - <click selector="{{StorefrontCategoryProductSection.ProductTitleByNumber('1')}}" stepKey="goToProduct2DisplayPage"/> - <!--<click selector="{{StorefrontCategoryProductSection.ProductTitleByName(productWithHTMLEntityOne.name)}}" stepKey="clickProductToGoProductPage"/>--> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName(productWithHTMLEntityTwo.name)}}" stepKey="clickProductToGoSecondProductPage"/> <waitForPageLoad stepKey="waitForProductDisplayPageLoad3"/> - <!--Veriy the breadcrumbs on Product Display page--> + <!--Verify the breadcrumbs on Product Display page--> <see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="Home" stepKey="seeHomePageInBreadcrumbs2"/> <see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$$createCategoryOne.name$$" stepKey="seeCorrectBreadCrumbCategory2"/> <see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$$productTwo.name$$" stepKey="seeCorrectBreadCrumbProduct2"/> diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php index 2008d0b9414c..19c578e976cd 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Edit/Tab/InventoryTest.php @@ -85,7 +85,7 @@ protected function setUp() $this->backordersMock = $this->createMock(\Magento\CatalogInventory\Model\Source\Backorders::class); $this->stockMock = $this->createMock(\Magento\CatalogInventory\Model\Source\Stock::class); $this->coreRegistryMock = $this->createMock(\Magento\Framework\Registry::class); - $this->moduleManager = $this->createMock(\Magento\Framework\Module\ModuleManagerInterface::class); + $this->moduleManager = $this->createMock(\Magento\Framework\Module\Manager::class); $this->storeManagerMock = $this->getMockForAbstractClass( \Magento\Store\Model\StoreManagerInterface::class, [], diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php index cd8d57a51d60..7d4fa86cd690 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/EditTest.php @@ -96,7 +96,9 @@ protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->categoryMock = $this->createPartialMock(\Magento\Catalog\Model\Category::class, [ + $this->categoryMock = $this->createPartialMock( + \Magento\Catalog\Model\Category::class, + [ 'getPath', 'addData', 'getId', @@ -104,9 +106,12 @@ protected function setUp() 'getResource', 'setStoreId', 'toArray' - ]); + ] + ); - $this->contextMock = $this->createPartialMock(\Magento\Backend\App\Action\Context::class, [ + $this->contextMock = $this->createPartialMock( + \Magento\Backend\App\Action\Context::class, + [ 'getTitle', 'getRequest', 'getObjectManager', @@ -115,7 +120,9 @@ protected function setUp() 'getMessageManager', 'getResultRedirectFactory', 'getSession' - ]); + ] + ); + $this->resultRedirectFactoryMock = $this->createPartialMock( \Magento\Backend\Model\View\Result\RedirectFactory::class, ['create'] @@ -285,44 +292,8 @@ public function dataProviderExecute() */ private function mockInitCategoryCall() { - /** - * @var \Magento\Framework\Registry - * |\PHPUnit_Framework_MockObject_MockObject $registryMock - */ - $registryMock = $this->createPartialMock(\Magento\Framework\Registry::class, ['register']); - /** - * @var \Magento\Cms\Model\Wysiwyg\Config - * |\PHPUnit_Framework_MockObject_MockObject $wysiwygConfigMock - */ - $wysiwygConfigMock = $this->createPartialMock(\Magento\Cms\Model\Wysiwyg\Config::class, ['setStoreId']); - /** - * @var \Magento\Store\Model\StoreManagerInterface - * |\PHPUnit_Framework_MockObject_MockObject $storeManagerMock - */ - $storeManagerMock = $this->getMockForAbstractClass( - \Magento\Store\Model\StoreManagerInterface::class, - [], - '', - false, - true, - true, - ['getStore', 'getRootCategoryId'] - ); - $this->objectManagerMock->expects($this->atLeastOnce()) ->method('create') ->will($this->returnValue($this->categoryMock)); - - $this->objectManagerMock->expects($this->atLeastOnce()) - ->method('get') - ->will( - $this->returnValueMap( - [ - [\Magento\Framework\Registry::class, $registryMock], - [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfigMock], - [\Magento\Store\Model\StoreManagerInterface::class, $storeManagerMock], - ] - ) - ); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php index c889c58e3df3..134c6f9edeaf 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization; use Magento\Catalog\Api\ProductRepositoryInterface as ProductRepository; @@ -11,6 +12,8 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Option; use Magento\Framework\App\RequestInterface; +use Magento\Framework\Locale\Format; +use Magento\Framework\Locale\FormatInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Api\Data\WebsiteInterface; use Magento\Store\Model\StoreManagerInterface; @@ -100,6 +103,11 @@ class HelperTest extends \PHPUnit\Framework\TestCase */ private $dateTimeFilterMock; + /** + * @var FormatInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $localeFormatMock; + /** * @inheritdoc */ @@ -152,6 +160,10 @@ protected function setUp() ->setMethods(['prepareProductAttributes']) ->disableOriginalConstructor() ->getMock(); + $this->localeFormatMock = $this->getMockBuilder(Format::class) + ->setMethods(['getNumber']) + ->disableOriginalConstructor() + ->getMock(); $this->helper = $this->objectManager->getObject( Helper::class, @@ -164,7 +176,8 @@ protected function setUp() 'productLinkFactory' => $this->productLinkFactoryMock, 'productRepository' => $this->productRepositoryMock, 'linkTypeProvider' => $this->linkTypeProviderMock, - 'attributeFilter' => $this->attributeFilterMock + 'attributeFilter' => $this->attributeFilterMock, + 'localeFormat' => $this->localeFormatMock, ] ); @@ -207,9 +220,9 @@ public function testInitialize( ->willReturn($this->assembleLinkTypes($linkTypes)); $optionsData = [ - 'option1' => ['is_delete' => true, 'name' => 'name1', 'price' => 'price1', 'option_id' => ''], - 'option2' => ['is_delete' => false, 'name' => 'name1', 'price' => 'price1', 'option_id' => '13'], - 'option3' => ['is_delete' => false, 'name' => 'name1', 'price' => 'price1', 'option_id' => '14'] + 'option1' => ['is_delete' => true, 'name' => 'name1', 'price' => '1', 'option_id' => ''], + 'option2' => ['is_delete' => false, 'name' => 'name2', 'price' => '2', 'option_id' => '13'], + 'option3' => ['is_delete' => false, 'name' => 'name3', 'price' => '3', 'option_id' => '14'], ]; $specialFromDate = '2018-03-03 19:30:00'; $productData = [ @@ -252,7 +265,7 @@ public function testInitialize( $this->requestMock->expects($this->any())->method('getPost')->willReturnMap( [ ['product', [], $productData], - ['use_default', null, $useDefaults] + ['use_default', null, $useDefaults], ] ); $this->linkResolverMock->expects($this->once())->method('getLinks')->willReturn($links); @@ -276,30 +289,38 @@ public function testInitialize( $secondExpectedCustomOption->setData($optionsData['option3']); $this->customOptionFactoryMock->expects($this->any()) ->method('create') - ->willReturnMap([ + ->willReturnMap( [ - ['data' => $optionsData['option2']], - $firstExpectedCustomOption - ], [ - ['data' => $optionsData['option3']], - $secondExpectedCustomOption + [ + ['data' => $optionsData['option2']], + $firstExpectedCustomOption, + ], + [ + ['data' => $optionsData['option3']], + $secondExpectedCustomOption, + ], ] - ]); + ); $website = $this->getMockBuilder(WebsiteInterface::class)->getMockForAbstractClass(); $website->expects($this->any())->method('getId')->willReturn(1); $this->storeManagerMock->expects($this->once())->method('isSingleStoreMode')->willReturn($isSingleStore); $this->storeManagerMock->expects($this->any())->method('getWebsite')->willReturn($website); + $this->localeFormatMock->expects($this->any()) + ->method('getNumber') + ->willReturnArgument(0); $this->assembleProductRepositoryMock($links); $this->productLinkFactoryMock->expects($this->any()) ->method('create') - ->willReturnCallback(function () { - return $this->getMockBuilder(ProductLink::class) - ->setMethods(null) - ->disableOriginalConstructor() - ->getMock(); - }); + ->willReturnCallback( + function () { + return $this->getMockBuilder(ProductLink::class) + ->setMethods(null) + ->disableOriginalConstructor() + ->getMock(); + } + ); $this->attributeFilterMock->expects($this->any())->method('prepareProductAttributes')->willReturnArgument(1); @@ -388,8 +409,8 @@ public function initializeDataProvider() 'price' => 1.00, 'position' => 1, 'record_id' => 1, - ] - ] + ], + ], ], 'linkTypes' => ['related', 'upsell', 'crosssell'], 'expected_links' => [ @@ -533,16 +554,16 @@ public function mergeProductOptionsDataProvider() [ 'option_type_id' => '2', 'key1' => 'val1', - 'default_key1' => 'val2' - ] - ] - ] + 'default_key1' => 'val2', + ], + ], + ], ], [ 4 => [ 'key1' => '1', - 'values' => [3 => ['key1' => 1]] - ] + 'values' => [3 => ['key1' => 1]], + ], ], [ [ @@ -553,11 +574,11 @@ public function mergeProductOptionsDataProvider() [ 'option_type_id' => '2', 'key1' => 'val1', - 'default_key1' => 'val2' - ] - ] - ] - ] + 'default_key1' => 'val2', + ], + ], + ], + ], ], 'key2 is replaced, key1 is not (checkbox is not checked)' => [ [ @@ -573,17 +594,17 @@ public function mergeProductOptionsDataProvider() 'key1' => 'val1', 'key2' => 'val2', 'default_key1' => 'val11', - 'default_key2' => 'val22' - ] - ] - ] + 'default_key2' => 'val22', + ], + ], + ], ], [ 5 => [ 'key1' => '0', 'title' => '1', - 'values' => [2 => ['key1' => 1]] - ] + 'values' => [2 => ['key1' => 1]], + ], ], [ [ @@ -599,11 +620,11 @@ public function mergeProductOptionsDataProvider() 'key1' => 'val11', 'key2' => 'val2', 'default_key1' => 'val11', - 'default_key2' => 'val22' - ] - ] - ] - ] + 'default_key2' => 'val22', + ], + ], + ], + ], ], 'key1 is replaced, key2 has no default value' => [ [ @@ -618,17 +639,17 @@ public function mergeProductOptionsDataProvider() 'key1' => 'val1', 'title' => 'val2', 'default_key1' => 'val11', - 'default_title' => 'val22' - ] - ] - ] + 'default_title' => 'val22', + ], + ], + ], ], [ 7 => [ 'key1' => '1', 'key2' => '1', - 'values' => [2 => ['key1' => 0, 'title' => 1]] - ] + 'values' => [2 => ['key1' => 0, 'title' => 1]], + ], ], [ [ @@ -643,10 +664,10 @@ public function mergeProductOptionsDataProvider() 'title' => 'val22', 'default_key1' => 'val11', 'default_title' => 'val22', - 'is_delete_store_title' => 1 - ] - ] - ] + 'is_delete_store_title' => 1, + ], + ], + ], ], ], ]; diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php index cb23d0c0a9a2..0214de8120ba 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/StockDataFilterTest.php @@ -6,15 +6,11 @@ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Initialization; use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter; -use Magento\CatalogInventory\Model\Stock; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\CatalogInventory\Model\Configuration; -use PHPUnit\Framework\TestCase; /** - * StockDataFilter test. + * Class StockDataFilterTest */ -class StockDataFilterTest extends TestCase +class StockDataFilterTest extends \PHPUnit\Framework\TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject @@ -31,23 +27,17 @@ class StockDataFilterTest extends TestCase */ protected $stockDataFilter; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ + /** @var \PHPUnit_Framework_MockObject_MockObject */ protected $stockConfiguration; - /** - * @inheritdoc - */ protected function setUp() { - $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->scopeConfigMock->method('getValue') - ->will($this->returnValue(1)); + $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue(1)); $this->stockConfiguration = $this->createPartialMock( - Configuration::class, + \Magento\CatalogInventory\Model\Configuration::class, ['getManageStock'] ); @@ -55,11 +45,8 @@ protected function setUp() } /** - * Tests filter method. - * * @param array $inputStockData * @param array $outputStockData - * @return void * * @covers \Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter::filter * @dataProvider filterDataProvider @@ -67,7 +54,8 @@ protected function setUp() public function testFilter(array $inputStockData, array $outputStockData) { if (isset($inputStockData['use_config_manage_stock']) && $inputStockData['use_config_manage_stock'] === 1) { - $this->stockConfiguration->method('getManageStock') + $this->stockConfiguration->expects($this->once()) + ->method('getManageStock') ->will($this->returnValue($outputStockData['manage_stock'])); } @@ -105,13 +93,8 @@ public function filterDataProvider() ], ], 'case4' => [ - 'inputStockData' => ['min_qty' => -1, 'backorders' => Stock::BACKORDERS_NO], - 'outputStockData' => [ - 'min_qty' => 0, - 'is_decimal_divided' => 0, - 'use_config_manage_stock' => 0, - 'backorders' => Stock::BACKORDERS_NO, - ], + 'inputStockData' => ['min_qty' => -1], + 'outputStockData' => ['min_qty' => 0, 'is_decimal_divided' => 0, 'use_config_manage_stock' => 0], ], 'case5' => [ 'inputStockData' => ['is_qty_decimal' => 0], @@ -120,25 +103,7 @@ public function filterDataProvider() 'is_decimal_divided' => 0, 'use_config_manage_stock' => 0, ], - ], - 'case6' => [ - 'inputStockData' => ['min_qty' => -1, 'backorders' => Stock::BACKORDERS_YES_NONOTIFY], - 'outputStockData' => [ - 'min_qty' => -1, - 'is_decimal_divided' => 0, - 'use_config_manage_stock' => 0, - 'backorders' => Stock::BACKORDERS_YES_NONOTIFY, - ], - ], - 'case7' => [ - 'inputStockData' => ['min_qty' => -1, 'backorders' => Stock::BACKORDERS_YES_NOTIFY], - 'outputStockData' => [ - 'min_qty' => -1, - 'is_decimal_divided' => 0, - 'use_config_manage_stock' => 0, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - ], - ], + ] ]; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php index 359e43070ba7..df96eff852d4 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -110,14 +109,15 @@ protected function setUp() 'resultFactory' => $resultFactory ]; /** @var \Magento\Backend\App\Action\Context $context */ - $context = $this->initContext($additionalParams, [[Action::class, $this->actionMock]]); + $context = $this->initContext($additionalParams); $this->action = new \Magento\Catalog\Controller\Adminhtml\Product\MassStatus( $context, $this->productBuilderMock, $this->priceProcessorMock, $this->filterMock, - $collectionFactoryMock + $collectionFactoryMock, + $this->actionMock ); } @@ -137,11 +137,13 @@ public function testMassStatusAction() ->willReturn([3]); $this->request->expects($this->exactly(3)) ->method('getParam') - ->willReturnMap([ - ['store', null, $storeId], - ['status', null, $status], - ['filters', [], $filters] - ]); + ->willReturnMap( + [ + ['store', null, $storeId], + ['status', null, $status], + ['filters', [], $filters] + ] + ); $this->actionMock->expects($this->once()) ->method('updateAttributes') ->with([3], ['status' => $status], 2); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php index 60c6f2f1bd82..b826f25d7c59 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Category/ViewTest.php @@ -25,7 +25,7 @@ class ViewTest extends \PHPUnit\Framework\TestCase protected $response; /** - * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Helper\Category|\PHPUnit_Framework_MockObject_MockObject */ protected $categoryHelper; @@ -165,13 +165,17 @@ protected function setUp() ->method('create') ->will($this->returnValue($this->page)); - $this->action = (new ObjectManager($this))->getObject(\Magento\Catalog\Controller\Category\View::class, [ - 'context' => $this->context, - 'catalogDesign' => $this->catalogDesign, - 'categoryRepository' => $this->categoryRepository, - 'storeManager' => $this->storeManager, - 'resultPageFactory' => $resultPageFactory - ]); + $this->action = (new ObjectManager($this))->getObject( + \Magento\Catalog\Controller\Category\View::class, + [ + 'context' => $this->context, + 'catalogDesign' => $this->catalogDesign, + 'categoryRepository' => $this->categoryRepository, + 'storeManager' => $this->storeManager, + 'resultPageFactory' => $resultPageFactory, + 'categoryHelper' => $this->categoryHelper + ] + ); } public function testApplyCustomLayoutUpdate() @@ -179,19 +183,17 @@ public function testApplyCustomLayoutUpdate() $categoryId = 123; $pageLayout = 'page_layout'; - $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - [\Magento\Catalog\Helper\Category::class, $this->categoryHelper], - ])); - - $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([ - [Action::PARAM_NAME_URL_ENCODED], - ['id', false, $categoryId], - ])); + $this->request->expects($this->any())->method('getParam')->willReturnMap( + [ + [Action::PARAM_NAME_URL_ENCODED], + ['id', false, $categoryId] + ] + ); $this->categoryRepository->expects($this->any())->method('get')->with($categoryId) ->will($this->returnValue($this->category)); - $this->categoryHelper->expects($this->any())->method('canShow')->will($this->returnValue(true)); + $this->categoryHelper->expects($this->once())->method('canShow')->with($this->category)->willReturn(true); $settings = $this->createPartialMock( \Magento\Framework\DataObject::class, diff --git a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php index 2759371dc96e..f37192538655 100644 --- a/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Helper/ImageTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Catalog\Test\Unit\Helper; use Magento\Catalog\Helper\Image; @@ -29,6 +30,11 @@ class ImageTest extends \PHPUnit\Framework\TestCase */ protected $assetRepository; + /** + * @var \Magento\Framework\Config\View|\PHPUnit\Framework\MockObject\MockObject + */ + protected $configView; + /** * @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -58,6 +64,10 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); + $this->configView = $this->getMockBuilder(\Magento\Framework\Config\View::class) + ->disableOriginalConstructor() + ->getMock(); + $this->viewConfig = $this->getMockBuilder(\Magento\Framework\View\ConfigInterface::class) ->getMockForAbstractClass(); @@ -151,23 +161,89 @@ public function initDataProvider() ]; } + /** + * @param array $data - optional 'frame' key + * @param bool $whiteBorders view config + * @param bool $expectedKeepFrame + * @dataProvider initKeepFrameDataProvider + */ + public function testInitKeepFrame($data, $whiteBorders, $expectedKeepFrame) + { + $imageId = 'test_image_id'; + $attributes = []; + + $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->prepareAttributes($data, $imageId); + + $this->configView->expects(isset($data['frame']) ? $this->never() : $this->once()) + ->method('getVarValue') + ->with('Magento_Catalog', 'product_image_white_borders') + ->willReturn($whiteBorders); + + $this->viewConfig->expects($this->once()) + ->method('getViewConfig') + ->willReturn($this->configView); + + $this->image->expects($this->once()) + ->method('setKeepFrame') + ->with($expectedKeepFrame) + ->willReturnSelf(); + + $this->helper->init($productMock, $imageId, $attributes); + } + + /** + * @return array + */ + public function initKeepFrameDataProvider() + { + return [ + // when frame defined explicitly, it wins + [ + 'mediaImage' => [ + 'frame' => 1, + ], + 'whiteBorders' => true, + 'expected' => true, + ], + [ + 'mediaImage' => [ + 'frame' => 0, + ], + 'whiteBorders' => true, + 'expected' => false, + ], + // when frame is not defined, var is used + [ + 'mediaImage' => [], + 'whiteBorders' => true, + 'expected' => true, + ], + [ + 'mediaImage' => [], + 'whiteBorders' => false, + 'expected' => false, + ], + ]; + } + /** * @param $data * @param $imageId */ protected function prepareAttributes($data, $imageId) { - $configViewMock = $this->getMockBuilder(\Magento\Framework\Config\View::class) - ->disableOriginalConstructor() - ->getMock(); - $configViewMock->expects($this->once()) + $this->configView->expects($this->once()) ->method('getMediaAttributes') ->with('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId) ->willReturn($data); $this->viewConfig->expects($this->once()) ->method('getViewConfig') - ->willReturn($configViewMock); + ->willReturn($this->configView); } /** @@ -220,32 +296,34 @@ protected function prepareWatermarkProperties($data) { $this->scopeConfig->expects($this->any()) ->method('getValue') - ->willReturnMap([ + ->willReturnMap( [ - 'design/watermark/' . $data['type'] . '_image', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $data['watermark'] - ], - [ - 'design/watermark/' . $data['type'] . '_imageOpacity', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $data['watermark_opacity'] - ], - [ - 'design/watermark/' . $data['type'] . '_position', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $data['watermark_position'] - ], - [ - 'design/watermark/' . $data['type'] . '_size', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - null, - $data['watermark_size'] - ], - ]); + [ + 'design/watermark/' . $data['type'] . '_image', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + $data['watermark'] + ], + [ + 'design/watermark/' . $data['type'] . '_imageOpacity', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + $data['watermark_opacity'] + ], + [ + 'design/watermark/' . $data['type'] . '_position', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + $data['watermark_position'] + ], + [ + 'design/watermark/' . $data['type'] . '_size', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + null, + $data['watermark_size'] + ], + ] + ); $this->image->expects($this->any()) ->method('setWatermarkFile') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php index 8f3aa66e57c5..4c3450d555f1 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/DataProviderTest.php @@ -17,6 +17,7 @@ use Magento\Store\Model\StoreManagerInterface; use Magento\Ui\DataProvider\EavValidationRules; use Magento\Ui\DataProvider\Modifier\PoolInterface; +use Magento\Framework\Stdlib\ArrayUtils; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -78,6 +79,14 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase */ private $modifierPool; + /** + * @var ArrayUtils|\PHPUnit_Framework_MockObject_MockObject + */ + private $arrayUtils; + + /** + * @inheritDoc + */ protected function setUp() { $this->eavValidationRules = $this->getMockBuilder(EavValidationRules::class) @@ -128,6 +137,10 @@ protected function setUp() ->getMock(); $this->modifierPool = $this->getMockBuilder(PoolInterface::class)->getMockForAbstractClass(); + + $this->arrayUtils = $this->getMockBuilder(ArrayUtils::class) + ->setMethods(['flatten']) + ->disableOriginalConstructor()->getMock(); } /** @@ -157,7 +170,8 @@ private function getModel() 'eavConfig' => $this->eavConfig, 'request' => $this->request, 'categoryFactory' => $this->categoryFactory, - 'pool' => $this->modifierPool + 'pool' => $this->modifierPool, + 'arrayUtils' => $this->arrayUtils ] ); @@ -206,10 +220,12 @@ public function testGetDataNoFileExists() ->getMock(); $categoryMock->expects($this->exactly(2)) ->method('getData') - ->willReturnMap([ - ['', null, $categoryData], - ['image', null, $categoryData['image']], - ]); + ->willReturnMap( + [ + ['', null, $categoryData], + ['image', null, $categoryData['image']], + ] + ); $categoryMock->expects($this->any()) ->method('getExistsStoreValueFlag') ->with('url_key') @@ -280,10 +296,12 @@ public function testGetData() ->getMock(); $categoryMock->expects($this->exactly(2)) ->method('getData') - ->willReturnMap([ - ['', null, $categoryData], - ['image', null, $categoryData['image']], - ]); + ->willReturnMap( + [ + ['', null, $categoryData], + ['image', null, $categoryData['image']], + ] + ); $categoryMock->expects($this->any()) ->method('getExistsStoreValueFlag') ->with('url_key') @@ -331,10 +349,12 @@ public function testGetData() public function testGetMetaWithoutParentInheritanceResolving() { + $this->arrayUtils->expects($this->atLeastOnce())->method('flatten')->willReturn([1,3,3]); + $categoryMock = $this->getMockBuilder(\Magento\Catalog\Model\Category::class) ->disableOriginalConstructor() ->getMock(); - $this->registry->expects($this->once()) + $this->registry->expects($this->atLeastOnce()) ->method('registry') ->with('category') ->willReturn($categoryMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php index 71f5ca33d130..6977a9ad1c7c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/FileInfoTest.php @@ -191,6 +191,9 @@ public function testIsExist($fileName, $fileMediaPath) $this->assertTrue($this->model->isExist($fileName)); } + /** + * @return array + */ public function isExistProvider() { return [ @@ -213,6 +216,9 @@ public function testIsBeginsWithMediaDirectoryPath($fileName, $expected) $this->assertEquals($expected, $this->model->isBeginsWithMediaDirectoryPath($fileName)); } + /** + * @return array + */ public function isBeginsWithMediaDirectoryPathProvider() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php index 80b6db2a516b..809fa0225278 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php @@ -6,6 +6,7 @@ namespace Magento\Catalog\Test\Unit\Model\Product; use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Model\Attribute\ScopeOverriddenValue; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Copier; @@ -46,6 +47,11 @@ class CopierTest extends \PHPUnit\Framework\TestCase */ protected $metadata; + /** + * @var ScopeOverriddenValue|\PHPUnit_Framework_MockObject_MockObject + */ + private $scopeOverriddenValue; + protected function setUp() { $this->copyConstructorMock = $this->createMock(\Magento\Catalog\Model\Product\CopyConstructorInterface::class); @@ -59,6 +65,7 @@ protected function setUp() $this->optionRepositoryMock; $this->productMock = $this->createMock(Product::class); $this->productMock->expects($this->any())->method('getEntityId')->willReturn(1); + $this->scopeOverriddenValue = $this->createMock(ScopeOverriddenValue::class); $this->metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class) ->disableOriginalConstructor() @@ -67,15 +74,20 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $metadataPool->expects($this->any())->method('getMetadata')->willReturn($this->metadata); + $this->_model = new Copier( $this->copyConstructorMock, - $this->productFactoryMock + $this->productFactoryMock, + $this->scopeOverriddenValue ); - $this->setProperties($this->_model, [ - 'optionRepository' => $this->optionRepositoryMock, - 'metadataPool' => $metadataPool, - ]); + $this->setProperties( + $this->_model, + [ + 'optionRepository' => $this->optionRepositoryMock, + 'metadataPool' => $metadataPool, + ] + ); } /** @@ -103,10 +115,12 @@ public function testCopy() ]; $this->productMock->expects($this->atLeastOnce())->method('getWebsiteIds'); $this->productMock->expects($this->atLeastOnce())->method('getCategoryIds'); - $this->productMock->expects($this->any())->method('getData')->willReturnMap([ - ['', null, $productData], - ['linkField', null, '1'], - ]); + $this->productMock->expects($this->any())->method('getData')->willReturnMap( + [ + ['', null, $productData], + ['linkField', null, '1'], + ] + ); $entityMock = $this->getMockForAbstractClass( \Magento\Eav\Model\Entity\AbstractEntity::class, @@ -191,9 +205,11 @@ public function testCopy() $this->metadata->expects($this->any())->method('getLinkField')->willReturn('linkField'); - $duplicateMock->expects($this->any())->method('getData')->willReturnMap([ - ['linkField', null, '2'], - ]); + $duplicateMock->expects($this->any())->method('getData')->willReturnMap( + [ + ['linkField', null, '2'], + ] + ); $this->optionRepositoryMock->expects($this->once()) ->method('duplicate') ->with($this->productMock, $duplicateMock); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 5eaf2422e95a..028c7ea83e1c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -41,7 +41,7 @@ class ProductTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; @@ -221,7 +221,7 @@ protected function setUp() $this->categoryIndexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class); $this->moduleManager = $this->createPartialMock( - \Magento\Framework\Module\ModuleManagerInterface::class, + \Magento\Framework\Module\Manager::class, ['isEnabled'] ); $this->extensionAttributes = $this->getMockBuilder(\Magento\Framework\Api\ExtensionAttributesInterface::class) @@ -486,6 +486,9 @@ public function testGetStoreSingleSiteModelIds( $this->assertEquals($websiteIDs, $this->model->getStoreIds()); } + /** + * @return array + */ public function getSingleStoreIds() { return [ diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php index 6370a4a7a27e..0316b2e374d2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php @@ -98,7 +98,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getStore', 'getId', 'getWebsiteId']) ->getMockForAbstractClass(); - $moduleManager = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $moduleManager = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); $catalogProductFlatState = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Flat\State::class) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php index eb7b70c8a171..6832d5b3399d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/View/Asset/ImageTest.php @@ -7,6 +7,7 @@ use Magento\Catalog\Model\Product\Media\ConfigInterface; use Magento\Catalog\Model\View\Asset\Image; +use Magento\Framework\Encryption\Encryptor; use Magento\Framework\Encryption\EncryptorInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Asset\ContextInterface; @@ -103,9 +104,10 @@ public function testGetContext() /** * @param string $filePath * @param array $miscParams + * @param string $readableParams * @dataProvider getPathDataProvider */ - public function testGetPath($filePath, $miscParams) + public function testGetPath($filePath, $miscParams, $readableParams) { $imageModel = $this->objectManager->getObject( Image::class, @@ -118,11 +120,13 @@ public function testGetPath($filePath, $miscParams) 'miscParams' => $miscParams ] ); - $miscParams['background'] = isset($miscParams['background']) ? implode(',', $miscParams['background']) : ''; $absolutePath = '/var/www/html/magento2ce/pub/media/catalog/product'; - $hashPath = md5(implode('_', $miscParams)); + $hashPath = 'somehash'; $this->context->method('getPath')->willReturn($absolutePath); - $this->encryptor->method('hash')->willReturn($hashPath); + $this->encryptor->expects(static::once()) + ->method('hash') + ->with($readableParams, $this->anything()) + ->willReturn($hashPath); static::assertEquals( $absolutePath . '/cache/'. $hashPath . $filePath, $imageModel->getPath() @@ -132,9 +136,10 @@ public function testGetPath($filePath, $miscParams) /** * @param string $filePath * @param array $miscParams + * @param string $readableParams * @dataProvider getPathDataProvider */ - public function testGetUrl($filePath, $miscParams) + public function testGetUrl($filePath, $miscParams, $readableParams) { $imageModel = $this->objectManager->getObject( Image::class, @@ -147,11 +152,13 @@ public function testGetUrl($filePath, $miscParams) 'miscParams' => $miscParams ] ); - $miscParams['background'] = isset($miscParams['background']) ? implode(',', $miscParams['background']) : ''; $absolutePath = 'http://localhost/pub/media/catalog/product'; - $hashPath = md5(implode('_', $miscParams)); + $hashPath = 'somehash'; $this->context->expects(static::once())->method('getBaseUrl')->willReturn($absolutePath); - $this->encryptor->expects(static::once())->method('hash')->willReturn($hashPath); + $this->encryptor->expects(static::once()) + ->method('hash') + ->with($readableParams, $this->anything()) + ->willReturn($hashPath); static::assertEquals( $absolutePath . '/cache/' . $hashPath . $filePath, $imageModel->getUrl() @@ -166,7 +173,8 @@ public function getPathDataProvider() return [ [ '/some_file.png', - [], //default value for miscParams + [], //default value for miscParams, + 'h:empty_w:empty_q:empty_r:empty_nonproportional_noframe_notransparency_notconstrainonly_nobackground', ], [ '/some_file_2.png', @@ -174,15 +182,32 @@ public function getPathDataProvider() 'image_type' => 'thumbnail', 'image_height' => 75, 'image_width' => 75, - 'keep_aspect_ratio' => 'proportional', - 'keep_frame' => 'frame', - 'keep_transparency' => 'transparency', - 'constrain_only' => 'doconstrainonly', + 'keep_aspect_ratio' => true, + 'keep_frame' => true, + 'keep_transparency' => true, + 'constrain_only' => true, 'background' => [233,1,0], 'angle' => null, 'quality' => 80, ], - ] + 'h:75_w:75_proportional_frame_transparency_doconstrainonly_rgb233,1,0_r:empty_q:80', + ], + [ + '/some_file_3.png', + [ + 'image_type' => 'thumbnail', + 'image_height' => 75, + 'image_width' => 75, + 'keep_aspect_ratio' => false, + 'keep_frame' => false, + 'keep_transparency' => false, + 'constrain_only' => false, + 'background' => [233,1,0], + 'angle' => 90, + 'quality' => 80, + ], + 'h:75_w:75_nonproportional_noframe_notransparency_notconstrainonly_rgb233,1,0_r:90_q:80', + ], ]; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php index 774edcfeb6b6..55acfff6d87d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -67,9 +67,10 @@ protected function setUp(): void $this->uiComponentFactory->method('create') ->willReturn($this->column); - $this->columnFactory = $this->objectManager->getObject(ColumnFactory::class, [ - 'componentFactory' => $this->uiComponentFactory - ]); + $this->columnFactory = $this->objectManager->getObject( + ColumnFactory::class, + ['componentFactory' => $this->uiComponentFactory] + ); } /** @@ -111,6 +112,7 @@ public function testCreateWithNotFilterableInGridAttribute(array $filterModifier 'visible' => null, 'filter' => $filter, 'component' => 'Magento_Ui/js/grid/columns/column', + '__disableTmpl' => ['label' => true] ], ], 'context' => $this->context, diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php index dcd50d4739d7..c704d9f89581 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php @@ -12,6 +12,9 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; +/** + * MassAction test + */ class MassActionTest extends \PHPUnit\Framework\TestCase { /** @@ -103,7 +106,8 @@ public function getPrepareDataProvider() : array [ 'type' => 'first_action', 'label' => 'First Action', - 'url' => '/module/controller/firstAction' + 'url' => '/module/controller/firstAction', + '__disableTmpl' => true ], ], [ @@ -122,7 +126,8 @@ public function getPrepareDataProvider() : array 'label' => 'Second Sub Action 2', 'url' => '/module/controller/secondSubAction2' ], - ] + ], + '__disableTmpl' => true ], ], [ @@ -141,7 +146,8 @@ public function getPrepareDataProvider() : array 'label' => 'Second Sub Action 2', 'url' => '/module/controller/disable' ], - ] + ], + '__disableTmpl' => true ], ], [ @@ -160,7 +166,8 @@ public function getPrepareDataProvider() : array 'label' => 'Second Sub Action 2', 'url' => '/module/controller/disable' ], - ] + ], + '__disableTmpl' => true ], false, false @@ -170,7 +177,8 @@ public function getPrepareDataProvider() : array [ 'type' => 'delete', 'label' => 'First Action', - 'url' => '/module/controller/delete' + 'url' => '/module/controller/delete', + '__disableTmpl' => true ], ], [ @@ -178,7 +186,8 @@ public function getPrepareDataProvider() : array [ 'type' => 'delete', 'label' => 'First Action', - 'url' => '/module/controller/delete' + 'url' => '/module/controller/delete', + '__disableTmpl' => true ], false, false @@ -188,7 +197,8 @@ public function getPrepareDataProvider() : array [ 'type' => 'delete', 'label' => 'First Action', - 'url' => '/module/controller/attributes' + 'url' => '/module/controller/attributes', + '__disableTmpl' => true ], ], [ @@ -196,7 +206,8 @@ public function getPrepareDataProvider() : array [ 'type' => 'delete', 'label' => 'First Action', - 'url' => '/module/controller/attributes' + 'url' => '/module/controller/attributes', + '__disableTmpl' => true ], false, false diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php index e9f9349100f1..e455ad47ee62 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/AdvancedPricingTest.php @@ -11,7 +11,7 @@ use Magento\Customer\Api\GroupManagementInterface; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Directory\Helper\Data as DirectoryHelper; use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php index 932b09f7df9c..bceafee0f82a 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/CategoriesTest.php @@ -10,7 +10,6 @@ use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Categories; use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory; use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection; -use Magento\Framework\App\CacheInterface; use Magento\Framework\DB\Helper as DbHelper; use Magento\Framework\UrlInterface; use Magento\Store\Model\Store; @@ -161,7 +160,14 @@ public function testModifyMetaLocked($locked) ->willReturnArgument(2); $modifyMeta = $this->createModel()->modifyMeta($meta); - $this->assertEquals($locked, $modifyMeta['arguments']['data']['config']['disabled']); + $this->assertEquals( + $locked, + $modifyMeta['children']['category_ids']['arguments']['data']['config']['disabled'] + ); + $this->assertEquals( + $locked, + $modifyMeta['children']['create_category_button']['arguments']['data']['config']['disabled'] + ); } /** diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 88075b13f143..e4c8414ce07b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -562,6 +562,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_not_new_locked_and_required' => [ @@ -581,6 +582,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -601,6 +603,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_and_not_required' => [ @@ -620,6 +623,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_locked_and_not_required' => [ @@ -639,6 +643,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -659,6 +664,7 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, + '__disableTmpl' => ['label' => true, 'code' => true] ], ] ]; diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php index a9d717db7b7f..9d0e7fc57ffc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php @@ -33,7 +33,7 @@ protected function setUp() parent::setUp(); $this->attributeRepositoryMock = $this->getMockBuilder(AttributeRepositoryInterface::class) - ->getMockForAbstractClass(); + ->getMockForAbstractClass(); $arrayManager = $this->objectManager->getObject(ArrayManager::class); @@ -52,10 +52,13 @@ protected function setUp() */ protected function createModel() { - return $this->objectManager->getObject(General::class, [ + return $this->objectManager->getObject( + General::class, + [ 'locator' => $this->locatorMock, 'arrayManager' => $this->arrayManagerMock, - ]); + ] + ); } public function testModifyMeta() @@ -63,8 +66,10 @@ public function testModifyMeta() $this->arrayManagerMock->expects($this->any()) ->method('merge') ->willReturnArgument(2); - $this->assertNotEmpty($this->getModel()->modifyMeta([ - 'first_panel_code' => [ + $this->assertNotEmpty( + $this->getModel()->modifyMeta( + [ + 'first_panel_code' => [ 'arguments' => [ 'data' => [ 'config' => [ @@ -72,15 +77,17 @@ public function testModifyMeta() ] ], ] - ] - ])); + ] + ] + ) + ); } /** - * @param array $data - * @param int $defaultStatusValue - * @param array $expectedResult - * @throws \Magento\Framework\Exception\NoSuchEntityException + * @param array $data + * @param int $defaultStatusValue + * @param array $expectedResult + * @throws \Magento\Framework\Exception\NoSuchEntityException * @dataProvider modifyDataDataProvider */ public function testModifyDataNewProduct(array $data, int $defaultStatusValue, array $expectedResult) @@ -100,6 +107,97 @@ public function testModifyDataNewProduct(array $data, int $defaultStatusValue, a $this->assertSame($expectedResult, $this->generalModifier->modifyData($data)); } + /** + * Verify the product attribute status set owhen editing existing product + * + * @param array $data + * @param string $modelId + * @param int $defaultStatus + * @param int $statusAttributeValue + * @param array $expectedResult + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @dataProvider modifyDataOfExistingProductDataProvider + */ + public function testModifyDataOfExistingProduct( + array $data, + string $modelId, + int $defaultStatus, + int $statusAttributeValue, + array $expectedResult + ) { + $attributeMock = $this->getMockForAbstractClass(AttributeInterface::class); + $attributeMock->expects($this->any()) + ->method('getDefaultValue') + ->willReturn($defaultStatus); + $this->attributeRepositoryMock->expects($this->any()) + ->method('get') + ->with( + ProductAttributeInterface::ENTITY_TYPE_CODE, + ProductAttributeInterface::CODE_STATUS + ) + ->willReturn($attributeMock); + $this->productMock->expects($this->any()) + ->method('getId') + ->willReturn($modelId); + $this->productMock->expects($this->any()) + ->method('getStatus') + ->willReturn($statusAttributeValue); + $this->assertSame($expectedResult, current($this->generalModifier->modifyData($data))); + } + + /** + * @return array + */ + public function modifyDataOfExistingProductDataProvider(): array + { + return [ + 'With enable status value' => [ + 'data' => [], + 'modelId' => '1', + 'defaultStatus' => 1, + 'statusAttributeValue' => 1, + 'expectedResult' => [ + General::DATA_SOURCE_DEFAULT => [ + ProductAttributeInterface::CODE_STATUS => 1, + ], + ], + ], + 'Without disable status value' => [ + 'data' => [], + 'modelId' => '1', + 'defaultStatus' => 1, + 'statusAttributeValue' => 2, + 'expectedResult' => [ + General::DATA_SOURCE_DEFAULT => [ + ProductAttributeInterface::CODE_STATUS => 2, + ], + ], + ], + 'With enable status value with empty modelId' => [ + 'data' => [], + 'modelId' => '', + 'defaultStatus' => 1, + 'statusAttributeValue' => 1, + 'expectedResult' => [ + General::DATA_SOURCE_DEFAULT => [ + ProductAttributeInterface::CODE_STATUS => 1, + ], + ], + ], + 'Without disable status value with empty modelId' => [ + 'data' => [], + 'modelId' => '', + 'defaultStatus' => 2, + 'statusAttributeValue' => 2, + 'expectedResult' => [ + General::DATA_SOURCE_DEFAULT => [ + ProductAttributeInterface::CODE_STATUS => 2, + ], + ], + ], + ]; + } + /** * @return array */ diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php index 9a6a22fcb098..638f225ca1b8 100644 --- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php @@ -74,6 +74,7 @@ public function create($attribute, $context, array $config = []) 'filter' => ($attribute->getIsFilterableInGrid() || array_key_exists($columnName, $filterModifiers)) ? $this->getFilterType($attribute->getFrontendInput()) : null, + '__disableTmpl' => ['label' => true], ], $config ); diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php index 0c4efa87c1a3..596b0f411859 100644 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php +++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php @@ -60,6 +60,7 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, + '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php index 894e2b701b5a..f770f6b9c497 100644 --- a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php +++ b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php @@ -12,6 +12,9 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Ui\Component\AbstractComponent; +/** + * Class MassAction + */ class MassAction extends AbstractComponent { const NAME = 'massaction'; @@ -40,7 +43,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function prepare() : void { @@ -49,7 +52,8 @@ public function prepare() : void foreach ($this->getChildComponents() as $actionComponent) { $actionType = $actionComponent->getConfiguration()['type']; if ($this->isActionAllowed($actionType)) { - $config['actions'][] = $actionComponent->getConfiguration(); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge + $config['actions'][] = array_merge($actionComponent->getConfiguration(), ['__disableTmpl' => true]); } } $origConfig = $this->getConfiguration(); @@ -64,7 +68,7 @@ public function prepare() : void } /** - * {@inheritdoc} + * @inheritdoc */ public function getComponentName() : string { diff --git a/app/code/Magento/Catalog/Ui/Component/UrlInput/Product.php b/app/code/Magento/Catalog/Ui/Component/UrlInput/Product.php index be73940237db..932fe4ef33d8 100644 --- a/app/code/Magento/Catalog/Ui/Component/UrlInput/Product.php +++ b/app/code/Magento/Catalog/Ui/Component/UrlInput/Product.php @@ -10,6 +10,9 @@ use Magento\Framework\UrlInterface; +/** + * Returns configuration for product Url Input type + */ class Product implements \Magento\Ui\Model\UrlInput\ConfigInterface { /** @@ -27,7 +30,7 @@ public function __construct(UrlInterface $urlBuilder) } /** - * {@inheritdoc} + * @inheritdoc */ public function getConfig(): array { @@ -46,6 +49,7 @@ public function getConfig(): array 'template' => 'ui/grid/filters/elements/ui-select', 'searchUrl' => $this->urlBuilder->getUrl('catalog/product/search'), 'filterPlaceholder' => __('Product Name or SKU'), + 'filterRateLimitMethod' => 'notifyWhenChangesStop', 'isDisplayEmptyPlaceholder' => true, 'emptyOptionsHtml' => __('Start typing to find products'), 'missingValuePlaceholder' => __('Product with ID: %s doesn\'t exist'), diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index 9ad75b5fda92..00132c6ad89e 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -14,7 +14,7 @@ use Magento\Customer\Api\GroupManagementInterface; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Ui\Component\Container; use Magento\Ui\Component\Form\Element\DataType\Number; use Magento\Ui\Component\Form\Element\DataType\Price; diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php index 0733d21bf47d..53c9595b59e7 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php @@ -78,11 +78,20 @@ public function getOptions() \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection::SORT_ORDER_ASC ); - return $collection->getData(); + $collectionData = $collection->getData() ?? []; + + array_walk( + $collectionData, + function (&$attribute) { + $attribute['__disableTmpl'] = true; + } + ); + + return $collectionData; } /** - * {@inheritdoc} + * @inheritdoc * @since 101.0.0 */ public function modifyMeta(array $meta) @@ -116,17 +125,20 @@ public function modifyMeta(array $meta) } /** - * {@inheritdoc} + * @inheritdoc * @since 101.0.0 */ public function modifyData(array $data) { - return array_replace_recursive($data, [ - $this->locator->getProduct()->getId() => [ - self::DATA_SOURCE_DEFAULT => [ - 'attribute_set_id' => $this->locator->getProduct()->getAttributeSetId() - ], + return array_replace_recursive( + $data, + [ + $this->locator->getProduct()->getId() => [ + self::DATA_SOURCE_DEFAULT => [ + 'attribute_set_id' => $this->locator->getProduct()->getAttributeSetId() + ], + ] ] - ]); + ); } } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php index 5f1907344ce8..c4ca5eca8e88 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php @@ -23,7 +23,6 @@ * Data provider for categories field of product page * * @api - * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 101.0.0 */ @@ -120,7 +119,7 @@ public function __construct( * @return CacheInterface * @deprecated 101.0.3 */ - private function getCacheManager() + private function getCacheManager(): CacheInterface { if (!$this->cacheManager) { $this->cacheManager = ObjectManager::getInstance() @@ -148,9 +147,9 @@ public function modifyMeta(array $meta) * * @return bool */ - private function isAllowed() + private function isAllowed(): bool { - return $this->authorization->isAllowed('Magento_Catalog::categories'); + return (bool) $this->authorization->isAllowed('Magento_Catalog::categories'); } /** @@ -234,6 +233,7 @@ protected function customizeCategoriesField(array $meta) $fieldCode = 'category_ids'; $elementPath = $this->arrayManager->findPath($fieldCode, $meta, null, 'children'); $containerPath = $this->arrayManager->findPath(static::CONTAINER_PREFIX . $fieldCode, $meta, null, 'children'); + $fieldIsDisabled = $this->locator->getProduct()->isLockedAttribute($fieldCode); if (!$elementPath) { return $meta; @@ -250,7 +250,6 @@ protected function customizeCategoriesField(array $meta) 'componentType' => 'container', 'component' => 'Magento_Ui/js/form/components/group', 'scopeLabel' => __('[GLOBAL]'), - 'disabled' => $this->locator->getProduct()->isLockedAttribute($fieldCode), ], ], ], @@ -266,6 +265,7 @@ protected function customizeCategoriesField(array $meta) 'chipsEnabled' => true, 'disableLabel' => true, 'levelsVisibility' => '1', + 'disabled' => $fieldIsDisabled, 'elementTmpl' => 'ui/grid/filters/elements/ui-select', 'options' => $this->getCategoriesTree(), 'listens' => [ @@ -291,6 +291,7 @@ protected function customizeCategoriesField(array $meta) 'formElement' => 'container', 'additionalClasses' => 'admin__field-small', 'componentType' => 'container', + 'disabled' => $fieldIsDisabled, 'component' => 'Magento_Ui/js/form/components/button', 'template' => 'ui/form/components/button/container', 'actions' => [ @@ -320,11 +321,7 @@ protected function customizeCategoriesField(array $meta) ] ]; } - $meta = $this->arrayManager->merge( - $containerPath, - $meta, - $value - ); + $meta = $this->arrayManager->merge($containerPath, $meta, $value); return $meta; } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index 5d1e853cef3d..acebe66f6f5a 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -46,6 +46,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * @SuppressWarnings(PHPMD.ExcessiveClassLength) * @since 101.0.0 */ class Eav extends AbstractModifier @@ -684,6 +685,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC 'scopeLabel' => $this->getScopeLabel($attribute), 'globalScope' => $this->isScopeGlobal($attribute), 'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER, + '__disableTmpl' => ['label' => true, 'code' => true] ] ); @@ -725,7 +727,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC // TODO: getAttributeModel() should not be used when MAGETWO-48284 is complete $childData = $this->arrayManager->get($configPath, $meta, []); - if (($rules = $this->catalogEavValidationRules->build($this->getAttributeModel($attribute), $childData))) { + if ($rules = $this->catalogEavValidationRules->build($this->getAttributeModel($attribute), $childData)) { $meta = $this->arrayManager->merge($configPath, $meta, ['validation' => $rules]); } @@ -850,6 +852,7 @@ public function setupAttributeContainerMeta(ProductAttributeInterface $attribute 'breakLine' => false, 'label' => $attribute->getDefaultFrontendLabel(), 'required' => $attribute->getIsRequired(), + '__disableTmpl' => ['label' => true] ] ); @@ -1048,6 +1051,10 @@ private function isScopeGlobal($attribute) */ private function getAttributeModel($attribute) { + // The statement below solves performance issue related to loading same attribute options on different models + if ($attribute instanceof EavAttribute) { + return $attribute; + } $attributeId = $attribute->getAttributeId(); if (!array_key_exists($attributeId, $this->attributesCache)) { diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php index 91c74a2da504..7c42b881bad3 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php @@ -21,13 +21,13 @@ class General extends AbstractModifier { /** - * @var LocatorInterface + * @var LocatorInterface * @since 101.0.0 */ protected $locator; /** - * @var ArrayManager + * @var ArrayManager * @since 101.0.0 */ protected $arrayManager; @@ -43,8 +43,8 @@ class General extends AbstractModifier private $attributeRepository; /** - * @param LocatorInterface $locator - * @param ArrayManager $arrayManager + * @param LocatorInterface $locator + * @param ArrayManager $arrayManager * @param AttributeRepositoryInterface|null $attributeRepository */ public function __construct( @@ -61,10 +61,10 @@ public function __construct( /** * Customize number fields for advanced price and weight fields. * - * @param array $data + * @param array $data * @return array * @throws \Magento\Framework\Exception\NoSuchEntityException - * @since 101.0.0 + * @since 101.0.0 */ public function modifyData(array $data) { @@ -72,7 +72,10 @@ public function modifyData(array $data) $data = $this->customizeAdvancedPriceFormat($data); $modelId = $this->locator->getProduct()->getId(); - if (!isset($data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS])) { + $productStatus = $this->locator->getProduct()->getStatus(); + if (!empty($productStatus) && !empty($modelId)) { + $data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS] = $productStatus; + } elseif (!isset($data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS])) { $attributeStatus = $this->attributeRepository->get( ProductAttributeInterface::ENTITY_TYPE_CODE, ProductAttributeInterface::CODE_STATUS @@ -87,9 +90,9 @@ public function modifyData(array $data) /** * Customizing weight fields * - * @param array $data + * @param array $data * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeWeightFormat(array $data) { @@ -112,9 +115,9 @@ protected function customizeWeightFormat(array $data) /** * Customizing number fields for advanced price * - * @param array $data + * @param array $data * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeAdvancedPriceFormat(array $data) { @@ -136,9 +139,9 @@ protected function customizeAdvancedPriceFormat(array $data) /** * Customize product form fields. * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ public function modifyMeta(array $meta) { @@ -154,9 +157,9 @@ public function modifyMeta(array $meta) /** * Disable collapsible and set empty label * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function prepareFirstPanel(array $meta) { @@ -177,9 +180,9 @@ protected function prepareFirstPanel(array $meta) /** * Customize Status field * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeStatusField(array $meta) { @@ -203,9 +206,9 @@ protected function customizeStatusField(array $meta) /** * Customize Weight filed * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeWeightField(array $meta) { @@ -277,9 +280,9 @@ protected function customizeWeightField(array $meta) /** * Customize "Set Product as New" date fields * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeNewDateRangeField(array $meta) { @@ -335,9 +338,9 @@ protected function customizeNewDateRangeField(array $meta) /** * Add links for fields depends of product name * - * @param array $meta + * @param array $meta * @return array - * @since 101.0.0 + * @since 101.0.0 */ protected function customizeNameListeners(array $meta) { @@ -409,9 +412,9 @@ private function getLocaleCurrency() /** * Format price according to the locale of the currency * - * @param mixed $value + * @param mixed $value * @return string - * @since 101.0.0 + * @since 101.0.0 */ protected function formatPrice($value) { @@ -429,9 +432,9 @@ protected function formatPrice($value) /** * Format number according to the locale of the currency and precision of input * - * @param mixed $value + * @param mixed $value * @return string - * @since 101.0.0 + * @since 101.0.0 */ protected function formatNumber($value) { diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php index 4fcb87ab1396..d8f76c40e8fa 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Listing/Collector/Image.php @@ -98,8 +98,6 @@ public function __construct( } /** - * In order to allow to use image generation using Services, we need to emulate area code and store code - * * @inheritdoc */ public function collect(ProductInterface $product, ProductRenderInterface $productRender) @@ -107,6 +105,7 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ $images = []; /** @var ThemeInterface $currentTheme */ $currentTheme = $this->design->getDesignTheme(); + $this->design->setDesignTheme($currentTheme); foreach ($this->imageCodes as $imageCode) { /** @var ImageInterface $image */ @@ -135,7 +134,6 @@ public function collect(ProductInterface $product, ProductRenderInterface $produ $images[] = $image; } - $this->design->setDesignTheme($currentTheme); $productRender->setImages($images); } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Modifier/Attributes.php new file mode 100644 index 000000000000..01aaa6f8e062 --- /dev/null +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Modifier/Attributes.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Ui\DataProvider\Product\Modifier; + +use Magento\Framework\Escaper; +use Magento\Ui\DataProvider\Modifier\ModifierInterface; + +/** + * Modify product listing attributes + */ +class Attributes implements ModifierInterface +{ + /** + * @var Escaper + */ + private $escaper; + + /** + * @var array + */ + private $escapeAttributes; + + /** + * @param Escaper $escaper + * @param array $escapeAttributes + */ + public function __construct( + Escaper $escaper, + array $escapeAttributes = [] + ) { + $this->escaper = $escaper; + $this->escapeAttributes = $escapeAttributes; + } + + /** + * @inheritdoc + */ + public function modifyData(array $data) + { + if (!empty($data) && !empty($this->escapeAttributes)) { + foreach ($data['items'] as &$item) { + foreach ($this->escapeAttributes as $escapeAttribute) { + if (isset($item[$escapeAttribute])) { + $item[$escapeAttribute] = $this->escaper->escapeHtml($item[$escapeAttribute]); + } + } + } + } + return $data; + } + + /** + * @inheritdoc + */ + public function modifyMeta(array $meta) + { + return $meta; + } +} diff --git a/app/code/Magento/Catalog/ViewModel/Product/Checker/AddToCompareAvailability.php b/app/code/Magento/Catalog/ViewModel/Product/Checker/AddToCompareAvailability.php index 27829155af29..00bac7e61b5b 100644 --- a/app/code/Magento/Catalog/ViewModel/Product/Checker/AddToCompareAvailability.php +++ b/app/code/Magento/Catalog/ViewModel/Product/Checker/AddToCompareAvailability.php @@ -10,6 +10,7 @@ use Magento\Framework\View\Element\Block\ArgumentInterface; use Magento\Catalog\Api\Data\ProductInterface; use Magento\CatalogInventory\Api\StockConfigurationInterface; +use Magento\Catalog\Model\Product\Attribute\Source\Status; /** * Check is available add to compare. @@ -37,7 +38,11 @@ public function __construct(StockConfigurationInterface $stockConfiguration) */ public function isAvailableForCompare(ProductInterface $product): bool { - return $this->isInStock($product) || $this->stockConfiguration->isShowOutOfStock(); + if ((int)$product->getStatus() !== Status::STATUS_DISABLED) { + return $this->isInStock($product) || $this->stockConfiguration->isShowOutOfStock(); + } + + return false; } /** @@ -53,6 +58,6 @@ private function isInStock(ProductInterface $product): bool return $product->isSalable(); } - return isset($quantityAndStockStatus['is_in_stock']) && $quantityAndStockStatus['is_in_stock']; + return $quantityAndStockStatus['is_in_stock'] ?? false; } } diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml index c04cfb2dce00..b3c9230b3cfc 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/di.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml @@ -166,7 +166,24 @@ <argument name="pool" xsi:type="object">Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool</argument> </arguments> </type> - <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool"/> + <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Listing\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool"> + <arguments> + <argument name="modifiers" xsi:type="array"> + <item name="attributes" xsi:type="array"> + <item name="class" xsi:type="string">Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes</item> + <item name="sortOrder" xsi:type="number">10</item> + </item> + </argument> + </arguments> + </virtualType> + <type name="Magento\Catalog\Ui\DataProvider\Product\Modifier\Attributes"> + <arguments> + <argument name="escapeAttributes" xsi:type="array"> + <item name="name" xsi:type="string">name</item> + <item name="sku" xsi:type="string">sku</item> + </argument> + </arguments> + </type> <type name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\CustomOptions"> <arguments> <argument name="scopeName" xsi:type="string">product_form.product_form</argument> diff --git a/app/code/Magento/Catalog/etc/adminhtml/events.xml b/app/code/Magento/Catalog/etc/adminhtml/events.xml index ad83f5898237..ab1a8348d290 100644 --- a/app/code/Magento/Catalog/etc/adminhtml/events.xml +++ b/app/code/Magento/Catalog/etc/adminhtml/events.xml @@ -12,4 +12,7 @@ <event name="catalog_category_change_products"> <observer name="category_product_indexer" instance="Magento\Catalog\Observer\CategoryProductIndexer"/> </event> + <event name="category_move"> + <observer name="clean_cagegory_page_cache" instance="Magento\Catalog\Observer\FlushCategoryPagesCache" /> + </event> </config> diff --git a/app/code/Magento/Catalog/etc/db_schema.xml b/app/code/Magento/Catalog/etc/db_schema.xml index 3d17db7a6666..d5b318f67172 100644 --- a/app/code/Magento/Catalog/etc/db_schema.xml +++ b/app/code/Magento/Catalog/etc/db_schema.xml @@ -1238,7 +1238,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_cfg_opt_agr_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_cfg_opt_agr_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Config Option Aggregate Temp Table"> <column xsi:type="int" name="parent_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Parent ID"/> @@ -1279,7 +1279,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_cfg_opt_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_cfg_opt_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Config Option Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1327,7 +1327,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_final_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_final_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Final Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1375,7 +1375,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_opt_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_opt_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Option Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1418,7 +1418,7 @@ <column name="option_id"/> </constraint> </table> - <table name="catalog_product_index_price_opt_agr_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_opt_agr_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Option Aggregate Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1470,7 +1470,7 @@ <column name="value"/> </index> </table> - <table name="catalog_product_index_eav_tmp" resource="default" engine="memory" + <table name="catalog_product_index_eav_tmp" resource="default" engine="innodb" comment="Catalog Product EAV Indexer Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1489,13 +1489,13 @@ <column name="value"/> <column name="source_id"/> </constraint> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_ATTRIBUTE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_STORE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_VALUE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_TMP_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1528,7 +1528,7 @@ <column name="value"/> </index> </table> - <table name="catalog_product_index_eav_decimal_tmp" resource="default" engine="memory" + <table name="catalog_product_index_eav_decimal_tmp" resource="default" engine="innodb" comment="Catalog Product EAV Decimal Indexer Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1547,13 +1547,13 @@ <column name="value"/> <column name="source_id"/> </constraint> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_ATTRIBUTE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_ATTRIBUTE_ID" indexType="btree"> <column name="attribute_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_STORE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_STORE_ID" indexType="btree"> <column name="store_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_VALUE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_EAV_DECIMAL_TMP_VALUE" indexType="btree"> <column name="value"/> </index> </table> @@ -1592,7 +1592,7 @@ <column name="min_price"/> </index> </table> - <table name="catalog_product_index_price_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_tmp" resource="default" engine="innodb" comment="Catalog Product Price Indexer Temp Table"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> @@ -1617,17 +1617,17 @@ <column name="customer_group_id"/> <column name="website_id"/> </constraint> - <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_CUSTOMER_GROUP_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_CUSTOMER_GROUP_ID" indexType="btree"> <column name="customer_group_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_WEBSITE_ID" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> - <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_MIN_PRICE" indexType="hash"> + <index referenceId="CATALOG_PRODUCT_INDEX_PRICE_TMP_MIN_PRICE" indexType="btree"> <column name="min_price"/> </index> </table> - <table name="catalog_category_product_index_tmp" resource="default" engine="memory" + <table name="catalog_category_product_index_tmp" resource="default" engine="innodb" comment="Catalog Category Product Indexer temporary table"> <column xsi:type="int" name="category_id" padding="10" unsigned="true" nullable="false" identity="false" default="0" comment="Category ID"/> @@ -1646,7 +1646,7 @@ <column name="product_id"/> <column name="store_id"/> </constraint> - <index referenceId="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="hash"> + <index referenceId="CAT_CTGR_PRD_IDX_TMP_PRD_ID_CTGR_ID_STORE_ID" indexType="btree"> <column name="product_id"/> <column name="category_id"/> <column name="store_id"/> diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index d4d20995a48b..ff2fab73e037 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -36,16 +36,16 @@ <preference for="Magento\Catalog\Api\ProductAttributeGroupRepositoryInterface" type="Magento\Catalog\Model\ProductAttributeGroupRepository" /> <preference for="Magento\Catalog\Api\ProductAttributeOptionManagementInterface" type="Magento\Catalog\Model\Product\Attribute\OptionManagement" /> <preference for="Magento\Catalog\Api\ProductLinkRepositoryInterface" type="Magento\Catalog\Model\ProductLink\Repository" /> - <preference for="Magento\Catalog\Api\Data\ProductAttributeSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> - <preference for="Magento\Catalog\Api\Data\CategoryAttributeSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> - <preference for="Magento\Catalog\Api\Data\ProductSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Catalog\Api\Data\ProductAttributeSearchResultsInterface" type="Magento\Catalog\Model\ProductAttributeSearchResults" /> + <preference for="Magento\Catalog\Api\Data\CategoryAttributeSearchResultsInterface" type="Magento\Catalog\Model\CategoryAttributeSearchResults" /> + <preference for="Magento\Catalog\Api\Data\ProductSearchResultsInterface" type="Magento\Catalog\Model\ProductSearchResults" /> <preference for="Magento\Catalog\Api\ProductAttributeManagementInterface" type="Magento\Catalog\Model\Product\Attribute\Management" /> <preference for="Magento\Catalog\Api\AttributeSetManagementInterface" type="Magento\Catalog\Model\Product\Attribute\SetManagement" /> <preference for="Magento\Catalog\Api\AttributeSetRepositoryInterface" type="Magento\Catalog\Model\Product\Attribute\SetRepository" /> <preference for="Magento\Catalog\Api\ProductManagementInterface" type="Magento\Catalog\Model\ProductManagement" /> <preference for="Magento\Catalog\Api\AttributeSetFinderInterface" type="Magento\Catalog\Model\Product\Attribute\AttributeSetFinder" /> <preference for="Magento\Catalog\Api\CategoryListInterface" type="Magento\Catalog\Model\CategoryList" /> - <preference for="Magento\Catalog\Api\Data\CategorySearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Catalog\Api\Data\CategorySearchResultsInterface" type="Magento\Catalog\Model\CategorySearchResults" /> <preference for="Magento\Catalog\Model\Config\Source\ProductPriceOptionsInterface" type="Magento\Catalog\Model\Config\Source\Product\Options\Price"/> <preference for="Magento\Catalog\Model\Indexer\Product\Flat\Table\BuilderInterface" type="Magento\Catalog\Model\Indexer\Product\Flat\Table\Builder"/> <preference for="Magento\Catalog\Api\ProductRenderListInterface" type="Magento\Catalog\Model\ProductRenderList"/> @@ -867,7 +867,7 @@ <argument name="hydrators" xsi:type="array"> <item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item> <item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item> - <item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Framework\EntityManager\AbstractModelHydrator</item> + <item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="string">Magento\Catalog\Model\Product\Hydrator</item> </argument> </arguments> </type> diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml index 6b63a20134df..d6340330df8e 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml @@ -507,8 +507,13 @@ })(jQuery); this.closeModal(); } - }] - + }], + keyEventHandlers: { + enterKey: function (event) { + this.buttons[1].click(); + event.preventDefault(); + } + } }).trigger('openModal'); } diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/components/new-attribute-form.js b/app/code/Magento/Catalog/view/adminhtml/web/js/components/new-attribute-form.js index 6702b94b119d..a879b85bab25 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/components/new-attribute-form.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/components/new-attribute-form.js @@ -42,41 +42,47 @@ define([ var self = this; - prompt({ - content: this.newSetPromptMessage, - actions: { + this.validate(); - /** - * @param {String} val - * @this {actions} - */ - confirm: function (val) { - var rules = ['required-entry', 'validate-no-html-tags'], - editForm = self, - newAttributeSetName = val, - i, - params = {}; + if (!this.additionalInvalid && !this.source.get('params.invalid')) { + prompt({ + content: this.newSetPromptMessage, + actions: { - if (!newAttributeSetName) { - return; - } - - for (i = 0; i < rules.length; i++) { - if (!$.validator.methods[rules[i]](newAttributeSetName)) { - alert({ - content: $.validator.messages[rules[i]] - }); + /** + * @param {String} val + * @this {actions} + */ + confirm: function (val) { + var rules = ['required-entry', 'validate-no-html-tags'], + editForm = self, + newAttributeSetName = val, + i, + params = {}; + if (!newAttributeSetName) { return; } - } - params['new_attribute_set_name'] = newAttributeSetName; - editForm.setAdditionalData(params); - editForm.save(); + for (i = 0; i < rules.length; i++) { + if (!$.validator.methods[rules[i]](newAttributeSetName)) { + alert({ + content: $.validator.messages[rules[i]] + }); + + return; + } + } + + params['new_attribute_set_name'] = newAttributeSetName; + editForm.setAdditionalData(params); + editForm.save(); + } } - } - }); + }); + } else { + this.focusInvalid(); + } } }); }); diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml index ce44884a575b..8c32302cf7c2 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml @@ -72,7 +72,9 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class); </strong> <?= $block->getReviewsSummaryHtml($_product, $templateType) ?> <?= /* @noEscape */ $block->getProductPrice($_product) ?> - <?= $block->getProductDetailsHtml($_product) ?> + <?php if ($_product->isAvailable()) :?> + <?= $block->getProductDetailsHtml($_product) ?> + <?php endif; ?> <div class="product-item-inner"> <div class="product actions product-item-actions"<?= strpos($pos, $viewMode . '-actions') ? $block->escapeHtmlAttr($position) : '' ?>> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml index c6d351b2a957..25257f4bcea8 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/form.phtml @@ -22,7 +22,7 @@ <input type="hidden" name="product" value="<?= (int)$_product->getId() ?>" /> <input type="hidden" name="selected_configurable_option" value="" /> <input type="hidden" name="related_product" id="related-products-field" value="" /> - <input type="hidden" name="item" value="<?= $block->escapeHtmlAttr($block->getRequest()->getParam('id')) ?>" /> + <input type="hidden" name="item" value="<?= (int)$block->getRequest()->getParam('id') ?>" /> <?= $block->getBlockHtml('formkey') ?> <?= $block->getChildHtml('form_top') ?> <?php if (!$block->hasOptions()) :?> diff --git a/app/code/Magento/Catalog/view/frontend/web/js/gallery.js b/app/code/Magento/Catalog/view/frontend/web/js/gallery.js index f6be6fd58ca2..2b3349c25c91 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/gallery.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/gallery.js @@ -3,18 +3,10 @@ * See COPYING.txt for license details. */ -(function (factory) { - 'use strict'; - - if (typeof define === 'function' && define.amd) { - define([ - 'jquery', - 'jquery-ui-modules/widget' - ], factory); - } else { - factory(jQuery); - } -}(function ($) { +define([ + 'jquery', + 'jquery-ui-modules/widget' +], function ($) { 'use strict'; $.widget('mage.gallery', { @@ -49,4 +41,4 @@ }); return $.mage.gallery; -})); +}); diff --git a/app/code/Magento/Catalog/view/frontend/web/js/related-products.js b/app/code/Magento/Catalog/view/frontend/web/js/related-products.js index 822dd5b9a7b1..c875dd8f5d2c 100644 --- a/app/code/Magento/Catalog/view/frontend/web/js/related-products.js +++ b/app/code/Magento/Catalog/view/frontend/web/js/related-products.js @@ -26,8 +26,8 @@ define([ * @private */ _create: function () { - $(this.options.selectAllLink).on('click', $.proxy(this._selectAllRelated, this)); - $(this.options.relatedCheckbox).on('click', $.proxy(this._addRelatedToProduct, this)); + $(this.options.selectAllLink, this.element).on('click', $.proxy(this._selectAllRelated, this)); + $(this.options.relatedCheckbox, this.element).on('click', $.proxy(this._addRelatedToProduct, this)); this._showRelatedProducts( this.element.find(this.options.elementsSelector), this.element.data('limit'), diff --git a/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js b/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js index ab1753e7b9ed..3205e58297b6 100644 --- a/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js +++ b/app/code/Magento/Catalog/view/frontend/web/product/view/validation.js @@ -3,19 +3,11 @@ * See COPYING.txt for license details. */ -(function (factory) { - 'use strict'; - - if (typeof define === 'function' && define.amd) { - define([ - 'jquery', - 'jquery-ui-modules/widget', - 'mage/validation/validation' - ], factory); - } else { - factory(jQuery); - } -}(function ($) { +define([ + 'jquery', + 'jquery-ui-modules/widget', + 'mage/validation/validation' +], function ($) { 'use strict'; $.widget('mage.validation', $.mage.validation, { @@ -97,4 +89,4 @@ }); return $.mage.validation; -})); +}); diff --git a/app/code/Magento/CatalogCmsGraphQl/Model/Resolver/Category/Block.php b/app/code/Magento/CatalogCmsGraphQl/Model/Resolver/Category/Block.php new file mode 100644 index 000000000000..110d03cac773 --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/Model/Resolver/Category/Block.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogCmsGraphQl\Model\Resolver\Category; + +use Magento\Catalog\Model\Category; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\CmsGraphQl\Model\Resolver\DataProvider\Block as BlockProvider; + +/** + * Resolver category cms content + */ +class Block implements ResolverInterface +{ + /** + * @var BlockProvider + */ + private $blockProvider; + + /** + * @param BlockProvider $blockProvider + */ + public function __construct(BlockProvider $blockProvider) + { + $this->blockProvider = $blockProvider; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + /** @var Category $category */ + $category = $value['model']; + $blockId = $category->getLandingPage(); + + if (empty($blockId)) { + return null; + } + + try { + $block = $this->blockProvider->getData($blockId); + } catch (NoSuchEntityException $e) { + return null; + } + + return $block; + } +} diff --git a/app/code/Magento/CatalogCmsGraphQl/README.md b/app/code/Magento/CatalogCmsGraphQl/README.md new file mode 100644 index 000000000000..f3b36e515ac6 --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/README.md @@ -0,0 +1,3 @@ +# CatalogCmsGraphQl + +**CatalogCmsGraphQl** provides type and resolver information for GraphQL attributes that have dependencies on the Catalog and Cms modules. \ No newline at end of file diff --git a/app/code/Magento/CatalogCmsGraphQl/composer.json b/app/code/Magento/CatalogCmsGraphQl/composer.json new file mode 100644 index 000000000000..a9d6ee4d9f2f --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/composer.json @@ -0,0 +1,28 @@ +{ + "name": "magento/module-catalog-cms-graph-ql", + "description": "N/A", + "type": "magento2-module", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/framework": "*", + "magento/module-catalog": "*", + "magento/module-cms-graph-ql": "*" + }, + "suggest": { + "magento/module-graph-ql": "*", + "magento/module-cms": "*", + "magento/module-catalog-graph-ql": "*" + }, + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\CatalogCmsGraphQl\\": "" + } + } +} diff --git a/app/code/Magento/CatalogCmsGraphQl/etc/graphql/di.xml b/app/code/Magento/CatalogCmsGraphQl/etc/graphql/di.xml new file mode 100644 index 000000000000..cc8d8f9845c5 --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/etc/graphql/di.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> + <type name="Magento\CatalogGraphQl\Model\AttributesJoiner"> + <arguments> + <argument name="fieldToAttributeMap" xsi:type="array"> + <item name="cms_block" xsi:type="array"> + <item name="landing_page" xsi:type="string">landing_page</item> + </item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/CatalogCmsGraphQl/etc/module.xml b/app/code/Magento/CatalogCmsGraphQl/etc/module.xml new file mode 100644 index 000000000000..40cc556bbf71 --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/etc/module.xml @@ -0,0 +1,15 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> + <module name="Magento_CatalogCmsGraphQl" > + <sequence> + <module name="Magento_CmsGraphQl"/> + <module name="Magento_CatalogGraphQl"/> + </sequence> + </module> +</config> diff --git a/app/code/Magento/CatalogCmsGraphQl/etc/schema.graphqls b/app/code/Magento/CatalogCmsGraphQl/etc/schema.graphqls new file mode 100644 index 000000000000..0fc5f69a009a --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/etc/schema.graphqls @@ -0,0 +1,6 @@ +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +interface CategoryInterface { + cms_block: CmsBlock @doc(description: "Category CMS Block.") @resolver(class: "Magento\\CatalogCmsGraphQl\\Model\\Resolver\\Category\\Block") +} \ No newline at end of file diff --git a/app/code/Magento/CatalogCmsGraphQl/registration.php b/app/code/Magento/CatalogCmsGraphQl/registration.php new file mode 100644 index 000000000000..c2b95cd9a4c5 --- /dev/null +++ b/app/code/Magento/CatalogCmsGraphQl/registration.php @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_CatalogCmsGraphQl', __DIR__); diff --git a/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Customer/GetCustomerGroup.php b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Customer/GetCustomerGroup.php new file mode 100644 index 000000000000..65ab2940a7a5 --- /dev/null +++ b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Customer/GetCustomerGroup.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogCustomerGraphQl\Model\Resolver\Customer; + +use Magento\Customer\Api\GroupManagementInterface; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Model\GroupManagement; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; + +/** + * Get customer group + */ +class GetCustomerGroup +{ + /** + * @var GroupManagementInterface + */ + private $groupManagement; + + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + + /** + * @param GroupManagementInterface $groupManagement + * @param CustomerRepositoryInterface $customerRepository + */ + public function __construct( + GroupManagementInterface $groupManagement, + CustomerRepositoryInterface $customerRepository + ) { + $this->groupManagement = $groupManagement; + $this->customerRepository = $customerRepository; + } + + /** + * Get customer group by id + * + * @param int|null $customerId + * @return int + * @throws GraphQlNoSuchEntityException + */ + public function execute(?int $customerId): int + { + if (!$customerId) { + $customerGroupId = GroupManagement::NOT_LOGGED_IN_ID; + } else { + try { + $customer = $this->customerRepository->getById($customerId); + } catch (NoSuchEntityException $e) { + throw new GraphQlNoSuchEntityException( + __('Customer with id "%customer_id" does not exist.', ['customer_id' => $customerId]), + $e + ); + } + $customerGroupId = $customer->getGroupId(); + } + return (int)$customerGroupId; + } +} diff --git a/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php new file mode 100644 index 000000000000..4e75139c1a88 --- /dev/null +++ b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php @@ -0,0 +1,151 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogCustomerGraphQl\Model\Resolver; + +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\Tiers; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\TiersFactory; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Customer\GetCustomerGroup; +use Magento\Store\Api\Data\StoreInterface; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\Discount; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool as PriceProviderPool; +use Magento\Catalog\Api\Data\ProductTierPriceInterface; + +/** + * Resolver for price_tiers + */ +class PriceTiers implements ResolverInterface +{ + /** + * @var TiersFactory + */ + private $tiersFactory; + + /** + * @var ValueFactory + */ + private $valueFactory; + + /** + * @var GetCustomerGroup + */ + private $getCustomerGroup; + + /** + * @var int + */ + private $customerGroupId; + + /** + * @var Tiers + */ + private $tiers; + + /** + * @var Discount + */ + private $discount; + + /** + * @var PriceProviderPool + */ + private $priceProviderPool; + + /** + * @param ValueFactory $valueFactory + * @param TiersFactory $tiersFactory + * @param GetCustomerGroup $getCustomerGroup + * @param Discount $discount + * @param PriceProviderPool $priceProviderPool + */ + public function __construct( + ValueFactory $valueFactory, + TiersFactory $tiersFactory, + GetCustomerGroup $getCustomerGroup, + Discount $discount, + PriceProviderPool $priceProviderPool + ) { + $this->valueFactory = $valueFactory; + $this->tiersFactory = $tiersFactory; + $this->getCustomerGroup = $getCustomerGroup; + $this->discount = $discount; + $this->priceProviderPool = $priceProviderPool; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + + if (empty($this->tiers)) { + $this->customerGroupId = $this->getCustomerGroup->execute($context->getUserId()); + $this->tiers = $this->tiersFactory->create(['customerGroupId' => $this->customerGroupId]); + } + + $product = $value['model']; + $productId = $product->getId(); + $this->tiers->addProductFilter($productId); + + return $this->valueFactory->create( + function () use ($productId, $context) { + /** @var StoreInterface $store */ + $store = $context->getExtensionAttributes()->getStore(); + + $productPrice = $this->tiers->getProductRegularPrice($productId) ?? 0.0; + $tierPrices = $this->tiers->getProductTierPrices($productId) ?? []; + + return $this->formatProductTierPrices($tierPrices, $productPrice, $store); + } + ); + } + + /** + * Format tier prices for output + * + * @param ProductTierPriceInterface[] $tierPrices + * @param float $productPrice + * @param StoreInterface $store + * @return array + */ + private function formatProductTierPrices(array $tierPrices, float $productPrice, StoreInterface $store): array + { + $tiers = []; + + foreach ($tierPrices as $tierPrice) { + $percentValue = $tierPrice->getExtensionAttributes()->getPercentageValue(); + if ($percentValue && is_numeric($percentValue)) { + $discount = $this->discount->getDiscountByPercent($productPrice, (float)$percentValue); + } else { + $discount = $this->discount->getDiscountByDifference($productPrice, (float)$tierPrice->getValue()); + } + + $tiers[] = [ + "discount" => $discount, + "quantity" => $tierPrice->getQty(), + "final_price" => [ + "value" => $tierPrice->getValue(), + "currency" => $store->getCurrentCurrencyCode() + ] + ]; + } + return $tiers; + } +} diff --git a/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price/Tiers.php b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price/Tiers.php new file mode 100644 index 000000000000..73a2ba83d509 --- /dev/null +++ b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/Product/Price/Tiers.php @@ -0,0 +1,176 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price; + +use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; +use Magento\Catalog\Model\ResourceModel\Product\Collection; +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; +use Magento\Customer\Model\GroupManagement; +use Magento\Catalog\Api\Data\ProductTierPriceInterface; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool as PriceProviderPool; + +/** + * Get product tier price information + */ +class Tiers +{ + /** + * @var CollectionFactory + */ + private $collectionFactory; + + /** + * @var ProductResource + */ + private $productResource; + + /** + * @var PriceProviderPool + */ + private $priceProviderPool; + + /** + * @var bool + */ + private $loaded = false; + + /** + * @var int + */ + private $customerGroupId = GroupManagement::CUST_GROUP_ALL; + + /** + * @var array + */ + private $filterProductIds = []; + + /** + * @var array + */ + private $products = []; + + /** + * @param CollectionFactory $collectionFactory + * @param ProductResource $productResource + * @param PriceProviderPool $priceProviderPool + * @param int $customerGroupId + */ + public function __construct( + CollectionFactory $collectionFactory, + ProductResource $productResource, + PriceProviderPool $priceProviderPool, + $customerGroupId + ) { + $this->collectionFactory = $collectionFactory; + $this->productResource = $productResource; + $this->priceProviderPool = $priceProviderPool; + $this->customerGroupId = $customerGroupId; + } + + /** + * Add product ID to collection filter + * + * @param int $productId + */ + public function addProductFilter($productId): void + { + $this->filterProductIds[] = $productId; + } + + /** + * Get tier prices for product by ID + * + * @param int $productId + * @return ProductTierPriceInterface[]|null + */ + public function getProductTierPrices($productId): ?array + { + if (!$this->isLoaded()) { + $this->load(); + } + + if (empty($this->products[$productId])) { + return null; + } + return $this->products[$productId]->getTierPrices(); + } + + /** + * Get product regular price by ID + * + * @param int $productId + * @return float|null + */ + public function getProductRegularPrice($productId): ?float + { + if (!$this->isLoaded()) { + $this->load(); + } + + if (empty($this->products[$productId])) { + return null; + } + $product = $this->products[$productId]; + $priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId()); + return $priceProvider->getRegularPrice($product)->getValue(); + } + + /** + * Check if collection has been loaded + * + * @return bool + */ + public function isLoaded(): bool + { + $numFilterProductIds = count(array_unique($this->filterProductIds)); + if ($numFilterProductIds > count($this->products)) { + //New products were added to the filter after load, so we should reload + return false; + } + return $this->loaded; + } + + /** + * Load product collection + */ + private function load(): void + { + $this->loaded = false; + + $productIdField = $this->productResource->getEntityIdField(); + /** @var Collection $productCollection */ + $productCollection = $this->collectionFactory->create(); + $productCollection->addFieldToFilter($productIdField, ['in' => $this->filterProductIds]); + $productCollection->addAttributeToSelect('price'); + $productCollection->addAttributeToSelect('price_type'); + $productCollection->load(); + $productCollection->addTierPriceDataByGroupId($this->customerGroupId); + + $this->setProducts($productCollection); + $this->loaded = true; + } + + /** + * Set products from collection + * + * @param Collection $productCollection + */ + private function setProducts(Collection $productCollection): void + { + $this->products = []; + + foreach ($productCollection as $product) { + $this->products[$product->getId()] = $product; + } + + $missingProducts = array_diff($this->filterProductIds, array_keys($this->products)); + foreach (array_unique($missingProducts) as $missingProductId) { + $this->products[$missingProductId] = null; + } + } +} diff --git a/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/TierPrices.php b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/TierPrices.php index ed657ca9a998..c449d0a2ba30 100644 --- a/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/TierPrices.php +++ b/app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/TierPrices.php @@ -8,17 +8,14 @@ namespace Magento\CatalogCustomerGraphQl\Model\Resolver; use Magento\Catalog\Model\Product; -use Magento\Catalog\Model\ResourceModel\Product\Collection; -use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; -use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Model\GroupManagement; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Customer\GetCustomerGroup; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\Tiers; +use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\TiersFactory; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; -use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; -use Magento\Framework\Exception\NoSuchEntityException; /** * @inheritdoc @@ -26,43 +23,43 @@ class TierPrices implements ResolverInterface { /** - * @var Collection + * @var ValueFactory */ - private $collection; + private $valueFactory; /** - * @var CustomerRepositoryInterface + * @var int */ - private $customerRepository; + private $customerGroupId = null; /** - * @var ValueFactory + * @var Tiers */ - private $valueFactory; + private $tiers; /** - * @var int + * @var TiersFactory */ - private $customerGroupId = null; + private $tiersFactory; /** - * @var array + * @var GetCustomerGroup */ - private $productIds = []; + private $getCustomerGroup; /** - * @param CollectionFactory $collectionFactory * @param ValueFactory $valueFactory - * @param CustomerRepositoryInterface $customerRepository + * @param TiersFactory $tiersFactory + * @param GetCustomerGroup $getCustomerGroup */ public function __construct( - CollectionFactory $collectionFactory, ValueFactory $valueFactory, - CustomerRepositoryInterface $customerRepository + TiersFactory $tiersFactory, + GetCustomerGroup $getCustomerGroup ) { - $this->collection = $collectionFactory->create(); $this->valueFactory = $valueFactory; - $this->customerRepository = $customerRepository; + $this->tiersFactory = $tiersFactory; + $this->getCustomerGroup = $getCustomerGroup; } /** @@ -80,62 +77,21 @@ public function resolve( } if (null === $this->customerGroupId) { - $this->customerGroupId = $this->getCustomerGroupId($context); + $this->customerGroupId = $this->getCustomerGroup->execute($context->getUserId()); + $this->tiers = $this->tiersFactory->create(['customerGroupId' => $this->customerGroupId]); } /** @var Product $product */ $product = $value['model']; $productId = $product->getId(); - $this->productIds[] = $productId; - $that = $this; + $this->tiers->addProductFilter($productId); return $this->valueFactory->create( - function () use ($that, $productId, $context) { - $tierPrices = []; - if (empty($that->productIds)) { - return []; - } - if (!$that->collection->isLoaded()) { - $that->collection->addIdFilter($that->productIds); - $that->collection->addTierPriceDataByGroupId($that->customerGroupId); - } - /** @var \Magento\Catalog\Model\Product $item */ - foreach ($that->collection as $item) { - if ($item->getId() === $productId) { - // Try to extract all requested fields from the loaded collection data - foreach ($item->getTierPrices() as $tierPrice) { - $tierPrices[] = $tierPrice->getData(); - } - } - } - return $tierPrices; - } - ); - } + function () use ($productId, $context) { + $tierPrices = $this->tiers->getProductTierPrices($productId); - /** - * Get the customer group Id. - * - * @param \Magento\GraphQl\Model\Query\ContextInterface $context - * - * @return int - */ - private function getCustomerGroupId(\Magento\GraphQl\Model\Query\ContextInterface $context) - { - $currentUserId = $context->getUserId(); - if (!$currentUserId) { - $customerGroupId = GroupManagement::NOT_LOGGED_IN_ID; - } else { - try { - $customer = $this->customerRepository->getById($currentUserId); - } catch (NoSuchEntityException $e) { - throw new GraphQlNoSuchEntityException( - __('Customer with id "%customer_id" does not exist.', ['customer_id' => $currentUserId]), - $e - ); + return $tierPrices ?? []; } - $customerGroupId = $customer->getGroupId(); - } - return $customerGroupId; + ); } } diff --git a/app/code/Magento/CatalogCustomerGraphQl/composer.json b/app/code/Magento/CatalogCustomerGraphQl/composer.json index 30bb86a7523e..859a5c623569 100644 --- a/app/code/Magento/CatalogCustomerGraphQl/composer.json +++ b/app/code/Magento/CatalogCustomerGraphQl/composer.json @@ -4,10 +4,11 @@ "type": "magento2-module", "require": { "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/framework": "*", "magento/module-catalog": "*", "magento/module-customer": "*", - "magento/framework": "*", - "magento/module-graph-ql": "*" + "magento/module-catalog-graph-ql": "*", + "magento/module-store": "*" }, "license": [ "OSL-3.0", diff --git a/app/code/Magento/CatalogCustomerGraphQl/etc/module.xml b/app/code/Magento/CatalogCustomerGraphQl/etc/module.xml index a1b2e2957972..6131435258b5 100644 --- a/app/code/Magento/CatalogCustomerGraphQl/etc/module.xml +++ b/app/code/Magento/CatalogCustomerGraphQl/etc/module.xml @@ -10,7 +10,7 @@ <sequence> <module name="Magento_Catalog"/> <module name="Magento_Customer"/> - <module name="Magento_GraphQl"/> + <module name="Magento_CatalogGraphQl"/> </sequence> </module> </config> diff --git a/app/code/Magento/CatalogCustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CatalogCustomerGraphQl/etc/schema.graphqls index 8cf6c6f874cf..17880584bf16 100644 --- a/app/code/Magento/CatalogCustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CatalogCustomerGraphQl/etc/schema.graphqls @@ -2,13 +2,21 @@ # See COPYING.txt for license details. interface ProductInterface { - tier_prices: [ProductTierPrices] @doc(description: "An array of ProductTierPrices objects.") @resolver(class: "Magento\\CatalogCustomerGraphQl\\Model\\Resolver\\TierPrices") + tier_prices: [ProductTierPrices] @deprecated(reason: "Use price_tiers for product tier price information.") @doc(description: "An array of ProductTierPrices objects.") @resolver(class: "Magento\\CatalogCustomerGraphQl\\Model\\Resolver\\TierPrices") + price_tiers: [TierPrice] @doc(description: "An array of TierPrice objects.") @resolver(class: "Magento\\CatalogCustomerGraphQl\\Model\\Resolver\\PriceTiers") } -type ProductTierPrices @doc(description: "The ProductTierPrices object defines a tier price, which is a quantity discount offered to a specific customer group.") { - customer_group_id: String @doc(description: "The ID of the customer group.") - qty: Float @doc(description: "The number of items that must be purchased to qualify for tier pricing.") - value: Float @doc(description: "The price of the fixed price item.") - percentage_value: Float @doc(description: "The percentage discount of the item.") - website_id: Float @doc(description: "The ID assigned to the website.") +type ProductTierPrices @doc(description: "ProductTierPrices is deprecated and has been replaced by TierPrice. The ProductTierPrices object defines a tier price, which is a quantity discount offered to a specific customer group.") { + customer_group_id: String @deprecated(reason: "customer_group_id is not relevant for storefront.") @doc(description: "The ID of the customer group.") + qty: Float @deprecated(reason: "ProductTierPrices is deprecated, use TierPrice.quantity.") @doc(description: "The number of items that must be purchased to qualify for tier pricing.") + value: Float @deprecated(reason: "ProductTierPrices is deprecated. Use TierPrice.final_price") @doc(description: "The price of the fixed price item.") + percentage_value: Float @deprecated(reason: "ProductTierPrices is deprecated. Use TierPrice.discount.") @doc(description: "The percentage discount of the item.") + website_id: Float @deprecated(reason: "website_id is not relevant for storefront.") @doc(description: "The ID assigned to the website.") +} + + +type TierPrice @doc(description: "A price based on the quantity purchased.") { + final_price: Money @doc(desription: "The price of the product at this tier.") + quantity: Float @doc(description: "The minimum number of items that must be purchased to qualify for this price tier.") + discount: ProductDiscount @doc(description: "The price discount that this tier represents.") } diff --git a/app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php b/app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php index d57154c42992..b3a9672a4701 100644 --- a/app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php +++ b/app/code/Magento/CatalogGraphQl/Model/AttributesJoiner.php @@ -20,6 +20,24 @@ class AttributesJoiner */ private $queryFields = []; + /** + * Field to attribute mapping + * + * For fields that are not named the same as their attribute, or require extra attributes to resolve + * e.g. ['field' => ['attr1', 'attr2'], 'other_field' => ['other_attr']] + * + * @var array + */ + private $fieldToAttributeMap = []; + + /** + * @param array $fieldToAttributeMap + */ + public function __construct(array $fieldToAttributeMap = []) + { + $this->fieldToAttributeMap = $fieldToAttributeMap; + } + /** * Join fields attached to field node to collection's select. * @@ -30,9 +48,7 @@ class AttributesJoiner public function join(FieldNode $fieldNode, AbstractCollection $collection) : void { foreach ($this->getQueryFields($fieldNode) as $field) { - if (!$collection->isAttributeAdded($field)) { - $collection->addAttributeToSelect($field); - } + $this->addFieldToCollection($collection, $field); } } @@ -42,7 +58,7 @@ public function join(FieldNode $fieldNode, AbstractCollection $collection) : voi * @param FieldNode $fieldNode * @return string[] */ - public function getQueryFields(FieldNode $fieldNode) + public function getQueryFields(FieldNode $fieldNode): array { if (!isset($this->queryFields[$fieldNode->name->value])) { $this->queryFields[$fieldNode->name->value] = []; @@ -58,4 +74,29 @@ public function getQueryFields(FieldNode $fieldNode) return $this->queryFields[$fieldNode->name->value]; } + + /** + * Add field to collection select + * + * Add a query field to the collection, using mapped attribute names if they are set + * + * @param AbstractCollection $collection + * @param string $field + */ + private function addFieldToCollection(AbstractCollection $collection, string $field) + { + $attribute = isset($this->fieldToAttributeMap[$field]) ? $this->fieldToAttributeMap[$field] : $field; + + if (is_array($attribute)) { + foreach ($attribute as $attributeName) { + if (!$collection->isAttributeAdded($attributeName)) { + $collection->addAttributeToSelect($attributeName); + } + } + } else { + if (!$collection->isAttributeAdded($attribute)) { + $collection->addAttributeToSelect($attribute); + } + } + } } diff --git a/app/code/Magento/CatalogGraphQl/Model/Category/CategoryFilter.php b/app/code/Magento/CatalogGraphQl/Model/Category/CategoryFilter.php new file mode 100644 index 000000000000..2c03550404ae --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Category/CategoryFilter.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Category; + +use Magento\Catalog\Api\Data\CategoryInterface; +use Magento\Catalog\Model\ResourceModel\Category\Collection; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\InputException; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\ScopeInterface; +use Magento\Search\Model\Query; + +/** + * Category filter allows to filter collection using 'id, url_key, name' from search criteria. + */ +class CategoryFilter +{ + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @param ScopeConfigInterface $scopeConfig + */ + public function __construct( + ScopeConfigInterface $scopeConfig + ) { + $this->scopeConfig = $scopeConfig; + } + + /** + * Filter for filtering the requested categories id's based on url_key, ids, name in the result. + * + * @param array $args + * @param Collection $categoryCollection + * @param StoreInterface $store + * @throws InputException + */ + public function applyFilters(array $args, Collection $categoryCollection, StoreInterface $store) + { + $categoryCollection->addAttributeToFilter(CategoryInterface::KEY_IS_ACTIVE, ['eq' => 1]); + foreach ($args['filters'] as $field => $cond) { + foreach ($cond as $condType => $value) { + if ($field === 'ids') { + $categoryCollection->addIdFilter($value); + } else { + $this->addAttributeFilter($categoryCollection, $field, $condType, $value, $store); + } + } + } + } + + /** + * Add filter to category collection + * + * @param Collection $categoryCollection + * @param string $field + * @param string $condType + * @param string|array $value + * @param StoreInterface $store + * @throws InputException + */ + private function addAttributeFilter($categoryCollection, $field, $condType, $value, $store) + { + if ($condType === 'match') { + $this->addMatchFilter($categoryCollection, $field, $value, $store); + return; + } + $categoryCollection->addAttributeToFilter($field, [$condType => $value]); + } + + /** + * Add match filter to collection + * + * @param Collection $categoryCollection + * @param string $field + * @param string $value + * @param StoreInterface $store + * @throws InputException + */ + private function addMatchFilter($categoryCollection, $field, $value, $store) + { + $minQueryLength = $this->scopeConfig->getValue( + Query::XML_PATH_MIN_QUERY_LENGTH, + ScopeInterface::SCOPE_STORE, + $store + ); + $searchValue = str_replace('%', '', $value); + $matchLength = strlen($searchValue); + if ($matchLength < $minQueryLength) { + throw new InputException(__('Invalid match filter')); + } + + $categoryCollection->addAttributeToFilter($field, ['like' => "%{$searchValue}%"]); + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Config/CategoryAttributeReader.php b/app/code/Magento/CatalogGraphQl/Model/Config/CategoryAttributeReader.php index 0ca72d9ff951..cd11c3c68f79 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Config/CategoryAttributeReader.php +++ b/app/code/Magento/CatalogGraphQl/Model/Config/CategoryAttributeReader.php @@ -51,16 +51,24 @@ class CategoryAttributeReader implements ReaderInterface */ private $collectionFactory; + /** + * @var array + */ + private $categoryAttributeResolvers; + /** * @param Type $typeLocator * @param CollectionFactory $collectionFactory + * @param array $categoryAttributeResolvers */ public function __construct( Type $typeLocator, - CollectionFactory $collectionFactory + CollectionFactory $collectionFactory, + array $categoryAttributeResolvers = [] ) { $this->typeLocator = $typeLocator; $this->collectionFactory = $collectionFactory; + $this->categoryAttributeResolvers = $categoryAttributeResolvers; } /** @@ -93,6 +101,9 @@ public function read($scope = null) : array $data['fields'][$attributeCode]['name'] = $attributeCode; $data['fields'][$attributeCode]['type'] = $locatedType; $data['fields'][$attributeCode]['arguments'] = []; + if (isset($this->categoryAttributeResolvers[$attributeCode])) { + $data['fields'][$attributeCode]['resolver'] = $this->categoryAttributeResolvers[$attributeCode]; + } } $config['CategoryInterface'] = $data; diff --git a/app/code/Magento/CatalogGraphQl/Model/Product/Option/DateType.php b/app/code/Magento/CatalogGraphQl/Model/Product/Option/DateType.php index e1106a3f696e..cd582ffda924 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Product/Option/DateType.php +++ b/app/code/Magento/CatalogGraphQl/Model/Product/Option/DateType.php @@ -10,9 +10,12 @@ use Magento\Catalog\Model\Product\Option\Type\Date as ProductDateOptionType; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Stdlib\DateTime; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; /** - * @inheritdoc + * CatalogGraphQl product option date type + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class DateType extends ProductDateOptionType { @@ -43,6 +46,13 @@ private function formatValues($values) if (isset($values[$this->getOption()->getId()])) { $value = $values[$this->getOption()->getId()]; $dateTime = \DateTime::createFromFormat(DateTime::DATETIME_PHP_FORMAT, $value); + + if ($dateTime === false) { + throw new GraphQlInputException( + __('Invalid format provided. Please use \'Y-m-d H:i:s\' format.') + ); + } + $values[$this->getOption()->getId()] = [ 'date' => $value, 'year' => $dateTime->format('Y'), diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider/Breadcrumbs.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider/Breadcrumbs.php index 9e23c4f1e973..863e621bd8df 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider/Breadcrumbs.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider/Breadcrumbs.php @@ -29,8 +29,11 @@ public function __construct( } /** + * Get breadcrumbs data + * * @param string $categoryPath * @return array + * @throws \Magento\Framework\Exception\LocalizedException */ public function getData(string $categoryPath): array { @@ -41,7 +44,7 @@ public function getData(string $categoryPath): array if (count($parentCategoryIds)) { $collection = $this->collectionFactory->create(); - $collection->addAttributeToSelect(['name', 'url_key']); + $collection->addAttributeToSelect(['name', 'url_key', 'url_path']); $collection->addAttributeToFilter('entity_id', $parentCategoryIds); foreach ($collection as $category) { @@ -50,6 +53,7 @@ public function getData(string $categoryPath): array 'category_name' => $category->getName(), 'category_level' => $category->getLevel(), 'category_url_key' => $category->getUrlKey(), + 'category_url_path' => $category->getUrlPath(), ]; } } diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/Image.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/Image.php new file mode 100644 index 000000000000..a06a8252d5a5 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/Image.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Category; + +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Framework\Exception\LocalizedException; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Framework\Filesystem\DirectoryList; + +/** + * Resolve category image to a fully qualified URL + */ +class Image implements ResolverInterface +{ + /** @var DirectoryList */ + private $directoryList; + + /** + * @param DirectoryList $directoryList + */ + public function __construct(DirectoryList $directoryList) + { + $this->directoryList = $directoryList; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + /** @var \Magento\Catalog\Model\Category $category */ + $category = $value['model']; + $imagePath = $category->getImage(); + if (empty($imagePath)) { + return null; + } + /** @var StoreInterface $store */ + $store = $context->getExtensionAttributes()->getStore(); + $baseUrl = $store->getBaseUrl('media'); + + $mediaPath = $this->directoryList->getUrlPath('media'); + $pos = strpos($imagePath, $mediaPath); + if ($pos !== false) { + $imagePath = substr($imagePath, $pos + strlen($mediaPath), strlen($baseUrl)); + } + $imageUrl = rtrim($baseUrl, '/') . '/' . ltrim($imagePath, '/'); + + return $imageUrl; + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/CategoryList.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/CategoryList.php new file mode 100644 index 000000000000..6b8949d61282 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/CategoryList.php @@ -0,0 +1,114 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver; + +use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\ExtractDataFromCategoryTree; +use Magento\Framework\Exception\InputException; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\CategoryTree; +use Magento\CatalogGraphQl\Model\Category\CategoryFilter; +use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory; + +/** + * Category List resolver, used for GraphQL category data request processing. + */ +class CategoryList implements ResolverInterface +{ + /** + * @var CategoryTree + */ + private $categoryTree; + + /** + * @var CollectionFactory + */ + private $collectionFactory; + + /** + * @var CategoryFilter + */ + private $categoryFilter; + + /** + * @var ExtractDataFromCategoryTree + */ + private $extractDataFromCategoryTree; + + /** + * @param CategoryTree $categoryTree + * @param ExtractDataFromCategoryTree $extractDataFromCategoryTree + * @param CategoryFilter $categoryFilter + * @param CollectionFactory $collectionFactory + */ + public function __construct( + CategoryTree $categoryTree, + ExtractDataFromCategoryTree $extractDataFromCategoryTree, + CategoryFilter $categoryFilter, + CollectionFactory $collectionFactory + ) { + $this->categoryTree = $categoryTree; + $this->extractDataFromCategoryTree = $extractDataFromCategoryTree; + $this->categoryFilter = $categoryFilter; + $this->collectionFactory = $collectionFactory; + } + + /** + * @inheritdoc + */ + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) + { + if (isset($value[$field->getName()])) { + return $value[$field->getName()]; + } + $store = $context->getExtensionAttributes()->getStore(); + + $rootCategoryIds = []; + if (!isset($args['filters'])) { + $rootCategoryIds[] = (int)$store->getRootCategoryId(); + } else { + $categoryCollection = $this->collectionFactory->create(); + try { + $this->categoryFilter->applyFilters($args, $categoryCollection, $store); + } catch (InputException $e) { + return []; + } + + foreach ($categoryCollection as $category) { + $rootCategoryIds[] = (int)$category->getId(); + } + } + + $result = $this->fetchCategories($rootCategoryIds, $info); + return $result; + } + + /** + * Fetch category tree data + * + * @param array $categoryIds + * @param ResolveInfo $info + * @return array + * @throws GraphQlNoSuchEntityException + */ + private function fetchCategories(array $categoryIds, ResolveInfo $info) + { + $fetchedCategories = []; + foreach ($categoryIds as $categoryId) { + $categoryTree = $this->categoryTree->getTree($info, $categoryId); + if (empty($categoryTree)) { + continue; + } + $fetchedCategories[] = current($this->extractDataFromCategoryTree->execute($categoryTree)); + } + + return $fetchedCategories; + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Discount.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Discount.php new file mode 100644 index 000000000000..c56e05bf267a --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Discount.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Product\Price; + +/** + * Calculate price discount as value and percent + */ +class Discount +{ + /** + * @var float + */ + private $zeroThreshold = 0.0001; + + /** + * Get formatted discount between two prices + * + * @param float $regularPrice + * @param float $finalPrice + * @return array + */ + public function getDiscountByDifference(float $regularPrice, float $finalPrice): array + { + return [ + 'amount_off' => $this->getPriceDifferenceAsValue($regularPrice, $finalPrice), + 'percent_off' => $this->getPriceDifferenceAsPercent($regularPrice, $finalPrice) + ]; + } + + /** + * Get formatted discount based on percent off + * + * @param float $regularPrice + * @param float $percentOff + * @return array + */ + public function getDiscountByPercent(float $regularPrice, float $percentOff): array + { + return [ + 'amount_off' => $this->getPercentDiscountAsValue($regularPrice, $percentOff), + 'percent_off' => $percentOff + ]; + } + + /** + * Get value difference between two prices + * + * @param float $regularPrice + * @param float $finalPrice + * @return float + */ + private function getPriceDifferenceAsValue(float $regularPrice, float $finalPrice): float + { + $difference = $regularPrice - $finalPrice; + if ($difference <= $this->zeroThreshold) { + return 0; + } + return round($difference, 2); + } + + /** + * Get percent difference between two prices + * + * @param float $regularPrice + * @param float $finalPrice + * @return float + */ + private function getPriceDifferenceAsPercent(float $regularPrice, float $finalPrice): float + { + $difference = $this->getPriceDifferenceAsValue($regularPrice, $finalPrice); + + if ($difference <= $this->zeroThreshold || $regularPrice <= $this->zeroThreshold) { + return 0; + } + + return round(($difference / $regularPrice) * 100, 2); + } + + /** + * Get amount difference that percentOff represents + * + * @param float $regularPrice + * @param float $percentOff + * @return float + */ + private function getPercentDiscountAsValue(float $regularPrice, float $percentOff): float + { + $percentDecimal = $percentOff / 100; + $valueDiscount = $regularPrice * $percentDecimal; + + return round($valueDiscount, 2); + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Provider.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Provider.php new file mode 100644 index 000000000000..67dbcf861170 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Provider.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Product\Price; + +use Magento\Catalog\Pricing\Price\FinalPrice; +use Magento\Catalog\Pricing\Price\RegularPrice; +use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Framework\Pricing\SaleableInterface; + +/** + * Provides product prices + */ +class Provider implements ProviderInterface +{ + /** + * @inheritdoc + */ + public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface + { + /** @var FinalPrice $finalPrice */ + $finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE); + return $finalPrice->getMinimalPrice(); + } + + /** + * @inheritdoc + */ + public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface + { + return $this->getRegularPrice($product); + } + + /** + * @inheritdoc + */ + public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface + { + /** @var FinalPrice $finalPrice */ + $finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE); + return $finalPrice->getMaximalPrice(); + } + + /** + * @inheritdoc + */ + public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface + { + return $this->getRegularPrice($product); + } + + /** + * @inheritdoc + */ + public function getRegularPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getAmount(); + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderInterface.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderInterface.php new file mode 100644 index 000000000000..99459daf045a --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderInterface.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Product\Price; + +use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Framework\Pricing\SaleableInterface; + +/** + * Provides product prices + */ +interface ProviderInterface +{ + /** + * Get the product minimal final price + * + * @param SaleableInterface $product + * @return AmountInterface + */ + public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface; + + /** + * Get the product minimal regular price + * + * @param SaleableInterface $product + * @return AmountInterface + */ + public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface; + + /** + * Get the product maximum final price + * + * @param SaleableInterface $product + * @return AmountInterface + */ + public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface; + + /** + * Get the product maximum final price + * + * @param SaleableInterface $product + * @return AmountInterface + */ + public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface; + + /** + * Get the product regular price + * + * @param SaleableInterface $product + * @return AmountInterface + */ + public function getRegularPrice(SaleableInterface $product): AmountInterface; +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderPool.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderPool.php new file mode 100644 index 000000000000..a23c28a868b6 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/ProviderPool.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Product\Price; + +/** + * Pool of price providers for different product types + */ +class ProviderPool +{ + private const DEFAULT = 'default'; + + /** + * @var ProviderInterface[] + */ + private $providers; + + /** + * @param ProviderInterface[] $providers + */ + public function __construct(array $providers) + { + $this->providers = $providers; + } + + /** + * Get price provider by product type + * + * @param string $productType + * @return ProviderInterface + */ + public function getProviderByProductType(string $productType): ProviderInterface + { + if (isset($this->providers[$productType])) { + return $this->providers[$productType]; + } + return $this->providers[self::DEFAULT]; + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/PriceRange.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/PriceRange.php new file mode 100644 index 000000000000..9396b1f02b97 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/PriceRange.php @@ -0,0 +1,133 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Model\Resolver\Product; + +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\Discount; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool as PriceProviderPool; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Catalog\Model\Product; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Pricing\SaleableInterface; +use Magento\Store\Api\Data\StoreInterface; + +/** + * Format product's pricing information for price_range field + */ +class PriceRange implements ResolverInterface +{ + /** + * @var Discount + */ + private $discount; + + /** + * @var PriceProviderPool + */ + private $priceProviderPool; + + /** + * @param PriceProviderPool $priceProviderPool + * @param Discount $discount + */ + public function __construct(PriceProviderPool $priceProviderPool, Discount $discount) + { + $this->priceProviderPool = $priceProviderPool; + $this->discount = $discount; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + /** @var StoreInterface $store */ + $store = $context->getExtensionAttributes()->getStore(); + + /** @var Product $product */ + $product = $value['model']; + $product->unsetData('minimal_price'); + + $requestedFields = $info->getFieldSelection(10); + $returnArray = []; + + if (isset($requestedFields['minimum_price'])) { + $returnArray['minimum_price'] = $this->getMinimumProductPrice($product, $store); + } + if (isset($requestedFields['maximum_price'])) { + $returnArray['maximum_price'] = $this->getMaximumProductPrice($product, $store); + } + return $returnArray; + } + + /** + * Get formatted minimum product price + * + * @param SaleableInterface $product + * @param StoreInterface $store + * @return array + */ + private function getMinimumProductPrice(SaleableInterface $product, StoreInterface $store): array + { + $priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId()); + $regularPrice = $priceProvider->getMinimalRegularPrice($product)->getValue(); + $finalPrice = $priceProvider->getMinimalFinalPrice($product)->getValue(); + $minPriceArray = $this->formatPrice($regularPrice, $finalPrice, $store); + $minPriceArray['model'] = $product; + return $minPriceArray; + } + + /** + * Get formatted maximum product price + * + * @param SaleableInterface $product + * @param StoreInterface $store + * @return array + */ + private function getMaximumProductPrice(SaleableInterface $product, StoreInterface $store): array + { + $priceProvider = $this->priceProviderPool->getProviderByProductType($product->getTypeId()); + $regularPrice = $priceProvider->getMaximalRegularPrice($product)->getValue(); + $finalPrice = $priceProvider->getMaximalFinalPrice($product)->getValue(); + $maxPriceArray = $this->formatPrice($regularPrice, $finalPrice, $store); + $maxPriceArray['model'] = $product; + return $maxPriceArray; + } + + /** + * Format price for GraphQl output + * + * @param float $regularPrice + * @param float $finalPrice + * @param StoreInterface $store + * @return array + */ + private function formatPrice(float $regularPrice, float $finalPrice, StoreInterface $store): array + { + return [ + 'regular_price' => [ + 'value' => $regularPrice, + 'currency' => $store->getCurrentCurrencyCode() + ], + 'final_price' => [ + 'value' => $finalPrice, + 'currency' => $store->getCurrentCurrencyCode() + ], + 'discount' => $this->discount->getDiscountByDifference($regularPrice, $finalPrice), + ]; + } +} diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/AttributeProcessor.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/AttributeProcessor.php index f4cefeb3f363..2ad05fbfa1e0 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/AttributeProcessor.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/AttributeProcessor.php @@ -19,7 +19,22 @@ class AttributeProcessor implements CollectionProcessorInterface { /** - * {@inheritdoc} + * Map GraphQl input fields to product attributes + * + * @var array + */ + private $fieldToAttributeMap = []; + + /** + * @param array $fieldToAttributeMap + */ + public function __construct($fieldToAttributeMap = []) + { + $this->fieldToAttributeMap = array_merge($this->fieldToAttributeMap, $fieldToAttributeMap); + } + + /** + * @inheritdoc */ public function process( Collection $collection, @@ -27,9 +42,32 @@ public function process( array $attributeNames ): Collection { foreach ($attributeNames as $name) { - $collection->addAttributeToSelect($name); + $this->addAttribute($collection, $name); } return $collection; } + + /** + * Add attribute to collection select + * + * @param Collection $collection + * @param string $attribute + */ + private function addAttribute(Collection $collection, string $attribute): void + { + if (isset($this->fieldToAttributeMap[$attribute])) { + $attributeMap = $this->fieldToAttributeMap[$attribute]; + if (is_array($attributeMap)) { + foreach ($attributeMap as $attributeName) { + $collection->addAttributeToSelect($attributeName); + } + } else { + $collection->addAttributeToSelect($attributeMap); + } + + } else { + $collection->addAttributeToSelect($attribute); + } + } } diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/FieldSelection.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/FieldSelection.php index 3912bab05ebb..ae4f2e911a5b 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/FieldSelection.php +++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Products/Query/FieldSelection.php @@ -60,9 +60,9 @@ private function getProductFields(ResolveInfo $info): array $fieldNames[] = $this->collectProductFieldNames($selection, $fieldNames); } } - - $fieldNames = array_merge(...$fieldNames); - + if (!empty($fieldNames)) { + $fieldNames = array_merge(...$fieldNames); + } return $fieldNames; } diff --git a/app/code/Magento/CatalogGraphQl/Plugin/DesignLoader.php b/app/code/Magento/CatalogGraphQl/Plugin/DesignLoader.php new file mode 100644 index 000000000000..cfb99ce270c2 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Plugin/DesignLoader.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Plugin; + +use Magento\Catalog\Model\Product; +use Magento\Framework\Message\MessageInterface; +use Magento\Framework\View\DesignLoader as ViewDesignLoader; +use Magento\Framework\Message\ManagerInterface; +use Magento\Catalog\Block\Product\ImageFactory; + +/** + * Load necessary design files for GraphQL + */ +class DesignLoader +{ + /** + * @var DesignLoader + */ + private $designLoader; + + /** + * @var ManagerInterface + */ + private $messageManager; + + /** + * @param ViewDesignLoader $designLoader + * @param ManagerInterface $messageManager + */ + public function __construct( + ViewDesignLoader $designLoader, + ManagerInterface $messageManager + ) { + $this->designLoader = $designLoader; + $this->messageManager = $messageManager; + } + + /** + * Before create load the design files + * + * @param ImageFactory $subject + * @param Product $product + * @param string $imageId + * @param array|null $attributes + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeCreate( + ImageFactory $subject, + Product $product, + string $imageId, + array $attributes = null + ) { + try { + $this->designLoader->load(); + } catch (\Magento\Framework\Exception\LocalizedException $e) { + if ($e->getPrevious() instanceof \Magento\Framework\Config\Dom\ValidationException) { + /** @var MessageInterface $message */ + $message = $this->messageManager + ->createMessage(MessageInterface::TYPE_ERROR) + ->setText($e->getMessage()); + $this->messageManager->addUniqueMessages([$message]); + } + } + } +} diff --git a/app/code/Magento/CatalogGraphQl/Test/Unit/Model/Resolver/Product/Price/DiscountTest.php b/app/code/Magento/CatalogGraphQl/Test/Unit/Model/Resolver/Product/Price/DiscountTest.php new file mode 100644 index 000000000000..5ebb48f761c0 --- /dev/null +++ b/app/code/Magento/CatalogGraphQl/Test/Unit/Model/Resolver/Product/Price/DiscountTest.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogGraphQl\Test\Unit\Model\Resolver\Product\Price; + +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\Discount; +use PHPUnit\Framework\TestCase; + +class DiscountTest extends TestCase +{ + /** + * @var Discount + */ + private $discount; + + protected function setUp() + { + $this->discount = new Discount(); + } + + /** + * @dataProvider priceDataProvider + * @param $regularPrice + * @param $finalPrice + * @param $expectedAmountOff + * @param $expectedPercentOff + */ + public function testGetPriceDiscount($regularPrice, $finalPrice, $expectedAmountOff, $expectedPercentOff) + { + $discountResult = $this->discount->getDiscountByDifference($regularPrice, $finalPrice); + + $this->assertEquals($expectedAmountOff, $discountResult['amount_off']); + $this->assertEquals($expectedPercentOff, $discountResult['percent_off']); + } + + /** + * Price data provider + * + * [regularPrice, finalPrice, expectedAmountOff, expectedPercentOff] + * + * @return array + */ + public function priceDataProvider() + { + return [ + [100, 50, 50, 50], + [.1, .05, .05, 50], + [12.50, 10, 2.5, 20], + [99.99, 84.99, 15.0, 15], + [9999999999.01, 8999999999.11, 999999999.9, 10], + [0, 0, 0, 0], + [0, 10, 0, 0], + [9.95, 9.95, 0, 0], + [21.05, 0, 21.05, 100] + ]; + } +} diff --git a/app/code/Magento/CatalogGraphQl/etc/di.xml b/app/code/Magento/CatalogGraphQl/etc/di.xml index 485ae792193e..1fe62fc442ec 100644 --- a/app/code/Magento/CatalogGraphQl/etc/di.xml +++ b/app/code/Magento/CatalogGraphQl/etc/di.xml @@ -69,4 +69,6 @@ <type name="Magento\Framework\Search\Request\Config\FilesystemReader"> <plugin name="productAttributesDynamicFields" type="Magento\CatalogGraphQl\Plugin\Search\Request\ConfigReader" /> </type> + + <preference type="\Magento\CatalogGraphQl\Model\Resolver\Product\Price\Provider" for="\Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface"/> </config> diff --git a/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml b/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml index fe3413dc3b21..76456166ded3 100644 --- a/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/CatalogGraphQl/etc/graphql/di.xml @@ -118,4 +118,35 @@ </argument> </arguments> </type> + + + <type name="Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="default" xsi:type="object">Magento\CatalogGraphQl\Model\Resolver\Product\Price\Provider</item> + </argument> + </arguments> + </type> + + <type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\AttributeProcessor"> + <arguments> + <argument name="fieldToAttributeMap" xsi:type="array"> + <item name="price_range" xsi:type="array"> + <item name="price" xsi:type="string">price</item> + </item> + </argument> + </arguments> + </type> + + <type name="Magento\Catalog\Block\Product\ImageFactory"> + <plugin name="designLoader" type="Magento\CatalogGraphQl\Plugin\DesignLoader" /> + </type> + + <type name="Magento\CatalogGraphQl\Model\Config\CategoryAttributeReader"> + <arguments> + <argument name="categoryAttributeResolvers" xsi:type="array"> + <item name="image" xsi:type="string">Magento\CatalogGraphQl\Model\Resolver\Category\Image</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/CatalogGraphQl/etc/schema.graphqls b/app/code/Magento/CatalogGraphQl/etc/schema.graphqls index 140aab37c9ce..536992d3fca8 100644 --- a/app/code/Magento/CatalogGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CatalogGraphQl/etc/schema.graphqls @@ -11,26 +11,29 @@ type Query { ): Products @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Products") @doc(description: "The products query searches for products that match the criteria specified in the search and filter attributes.") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Identity") category ( - id: Int @doc(description: "Id of the category.") + id: Int @doc(description: "Id of the category.") ): CategoryTree - @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree") @doc(description: "The category query searches for categories that match the criteria specified in the search and filter attributes.") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoryTreeIdentity") + @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryTree") @doc(description: "The category query searches for categories that match the criteria specified in the search and filter attributes.") @deprecated(reason: "Use 'categoryList' query instead of 'category' query") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoryTreeIdentity") + categoryList( + filters: CategoryFilterInput @doc(description: "Identifies which Category filter inputs to search for and return.") + ): [CategoryTree] @doc(description: "Returns an array of categories based on the specified filters.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\CategoryList") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoriesIdentity") } -type Price @doc(description: "The Price object defines the price of a product as well as any tax-related adjustments.") { - amount: Money @doc(description: "The price of a product plus a three-letter currency code.") - adjustments: [PriceAdjustment] @doc(description: "An array that provides information about tax, weee, or weee_tax adjustments.") +type Price @doc(description: "Price is deprecated, replaced by ProductPrice. The Price object defines the price of a product as well as any tax-related adjustments.") { + amount: Money @deprecated(reason: "Price is deprecated, use ProductPrice.") @doc(description: "The price of a product plus a three-letter currency code.") + adjustments: [PriceAdjustment] @deprecated(reason: "Price is deprecated, use ProductPrice.") @doc(description: "An array that provides information about tax, weee, or weee_tax adjustments.") } -type PriceAdjustment @doc(description: "The PricedAdjustment object defines the amount of money to apply as an adjustment, the type of adjustment to apply, and whether the item is included or excluded from the adjustment.") { +type PriceAdjustment @doc(description: "PriceAdjustment is deprecated. Taxes will be included or excluded in the price. The PricedAdjustment object defines the amount of money to apply as an adjustment, the type of adjustment to apply, and whether the item is included or excluded from the adjustment.") { amount: Money @doc(description: "The amount of the price adjustment and its currency code.") - code: PriceAdjustmentCodesEnum @doc(description: "Indicates whether the adjustment involves tax, weee, or weee_tax.") - description: PriceAdjustmentDescriptionEnum @doc(description: "Indicates whether the entity described by the code attribute is included or excluded from the adjustment.") + code: PriceAdjustmentCodesEnum @deprecated(reason: "PriceAdjustment is deprecated.") @doc(description: "Indicates whether the adjustment involves tax, weee, or weee_tax.") + description: PriceAdjustmentDescriptionEnum @deprecated(reason: "PriceAdjustment is deprecated.") @doc(description: "Indicates whether the entity described by the code attribute is included or excluded from the adjustment.") } -enum PriceAdjustmentCodesEnum @doc(description: "Note: This enumeration contains values defined in modules other than the Catalog module.") { +enum PriceAdjustmentCodesEnum @doc(description: "PriceAdjustment.code is deprecated. This enumeration contains values defined in modules other than the Catalog module.") { } -enum PriceAdjustmentDescriptionEnum @doc(description: "This enumeration states whether a price adjustment is included or excluded.") { +enum PriceAdjustmentDescriptionEnum @doc(description: "PriceAdjustmentDescriptionEnum is deprecated. This enumeration states whether a price adjustment is included or excluded.") { INCLUDED EXCLUDED } @@ -41,10 +44,26 @@ enum PriceTypeEnum @doc(description: "This enumeration the price type.") { DYNAMIC } -type ProductPrices @doc(description: "The ProductPrices object contains the regular price of an item, as well as its minimum and maximum prices. Only composite products, which include bundle, configurable, and grouped products, can contain a minimum and maximum price.") { - minimalPrice: Price @doc(description: "The lowest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the from value.") - maximalPrice: Price @doc(description: "The highest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the to value.") - regularPrice: Price @doc(description: "The base price of a product.") +type ProductPrices @doc(description: "ProductPrices is deprecated, replaced by PriceRange. The ProductPrices object contains the regular price of an item, as well as its minimum and maximum prices. Only composite products, which include bundle, configurable, and grouped products, can contain a minimum and maximum price.") { + minimalPrice: Price @deprecated(reason: "Use PriceRange.minimum_price.") @doc(description: "The lowest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the from value.") + maximalPrice: Price @deprecated(reason: "Use PriceRange.maximum_price.") @doc(description: "The highest possible final price for all the options defined within a composite product. If you are specifying a price range, this would be the to value.") + regularPrice: Price @deprecated(reason: "Use regular_price from PriceRange.minimum_price or PriceRange.maximum_price.") @doc(description: "The base price of a product.") +} + +type PriceRange @doc(description: "Price range for a product. If the product has a single price, the minimum and maximum price will be the same."){ + minimum_price: ProductPrice! @doc(description: "The lowest possible price for the product.") + maximum_price: ProductPrice @doc(description: "The highest possible price for the product.") +} + +type ProductPrice @doc(description: "Represents a product price.") { + regular_price: Money! @doc(description: "The regular price of the product.") + final_price: Money! @doc(description: "The final price of the product after discounts applied.") + discount: ProductDiscount @doc(description: "The price discount. Represents the difference between the regular and final price.") +} + +type ProductDiscount @doc(description: "A discount applied to a product price.") { + percent_off: Float @doc(description: "The discount expressed a percentage.") + amount_off: Float @doc(description: "The actual value of the discount.") } type ProductLinks implements ProductLinksInterface @doc(description: "ProductLinks is an implementation of ProductLinksInterface.") { @@ -58,7 +77,6 @@ interface ProductLinksInterface @typeResolver(class: "Magento\\CatalogGraphQl\\M position: Int @doc(description: "The position within the list of product links.") } - interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\ProductInterfaceTypeResolverComposite") @doc(description: "The ProductInterface contains attributes that are common to all types of products. Note that descriptions may not be available for custom and EAV attributes.") { id: Int @doc(description: "The ID number assigned to the product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\EntityIdToId") name: String @doc(description: "The product name. Customers use this name to identify the product.") @@ -77,7 +95,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\ thumbnail: ProductImage @doc(description: "The relative path to the product's thumbnail image.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage") new_from_date: String @doc(description: "The beginning date for new product listings, and determines if the product is featured as a new product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo") new_to_date: String @doc(description: "The end date for new product listings.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo") - tier_price: Float @doc(description: "The price when tier pricing is in effect and the items purchased threshold has been reached.") + tier_price: Float @deprecated(reason: "Use price_tiers for product tier price information.") @doc(description: "The price when tier pricing is in effect and the items purchased threshold has been reached.") options_container: String @doc(description: "If the product has multiple options, determines where they appear on the product page.") created_at: String @doc(description: "Timestamp indicating when the product was created.") updated_at: String @doc(description: "Timestamp indicating when the product was updated.") @@ -86,7 +104,8 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\ websites: [Website] @doc(description: "An array of websites in which the product is available.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Websites") product_links: [ProductLinksInterface] @doc(description: "An array of ProductLinks objects.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductLinks") media_gallery_entries: [MediaGalleryEntry] @deprecated(reason: "Use product's `media_gallery` instead") @doc(description: "An array of MediaGalleryEntry objects.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\MediaGalleryEntries") - price: ProductPrices @doc(description: "A ProductPrices object, indicating the price of an item.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Price") + price: ProductPrices @deprecated(reason: "Use price_range for product price information.") @doc(description: "A ProductPrices object, indicating the price of an item.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Price") + price_range: PriceRange! @doc(description: "A PriceRange object, indicating the range of prices for the product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\PriceRange") gift_message_available: String @doc(description: "Indicates whether a gift message is available.") manufacturer: Int @doc(description: "A number representing the product's manufacturer.") categories: [CategoryInterface] @doc(description: "The categories assigned to a product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoriesIdentity") @@ -223,6 +242,7 @@ type Breadcrumb @doc(description: "Breadcrumb item."){ category_name: String @doc(description: "Category name.") category_level: Int @doc(description: "Category level.") category_url_key: String @doc(description: "Category URL key.") + category_url_path: String @doc(description: "Category URL path.") } type CustomizableRadioOption implements CustomizableOptionInterface @doc(description: "CustomizableRadioOption contains information about a set of radio buttons that are defined as part of a customizable option.") { @@ -277,6 +297,13 @@ input ProductAttributeFilterInput @doc(description: "ProductAttributeFilterInput category_id: FilterEqualTypeInput @doc(description: "Filter product by category id") } +input CategoryFilterInput @doc(description: "CategoryFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.") +{ + ids: FilterEqualTypeInput @doc(description: "Filter by category ID that uniquely identifies the category.") + url_key: FilterEqualTypeInput @doc(description: "Filter by the part of the URL that identifies the category") + name: FilterMatchTypeInput @doc(description: "Filter by the display name of the category.") +} + input ProductFilterInput @doc(description: "ProductFilterInput is deprecated, use @ProductAttributeFilterInput instead. ProductFilterInput defines the filters to be used in the search. A filter contains at least one attribute, a comparison operator, and the value that is being searched for.") { name: FilterTypeInput @doc(description: "The product name. Customers use this name to identify the product.") sku: FilterTypeInput @doc(description: "A number or code assigned to a product to identify the product, options, price, and manufacturer.") diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index 1ae993ed9906..9ff2edaf2708 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -302,6 +302,9 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity ValidatorInterface::ERROR_DUPLICATE_URL_KEY => 'Url key: \'%s\' was already generated for an item with the SKU: \'%s\'. You need to specify the unique URL key manually', ValidatorInterface::ERROR_DUPLICATE_MULTISELECT_VALUES => 'Value for multiselect attribute %s contains duplicated values', 'invalidNewToDateValue' => 'Make sure new_to_date is later than or the same as new_from_date', + // Can't add new translated strings in patch release + 'invalidLayoutUpdate' => 'Invalid format.', + 'insufficientPermissions' => 'Invalid format.', ]; //@codingStandardsIgnoreEnd @@ -1511,7 +1514,7 @@ public function getImagesFromRow(array $rowData) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.UnusedLocalVariable) * @throws LocalizedException - * phpcs:disable Generic.Metrics.NestingLevel + * phpcs:disable Generic.Metrics.NestingLevel.TooHigh */ protected function _saveProducts() { diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php index 4d8088a23540..502ad70d405a 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php @@ -1695,7 +1695,7 @@ protected function _parseRequiredData(array $rowData) $this->_rowIsMain = false; } - return [$this->_rowProductId, $this->_rowStoreId, $this->_rowType, $this->_rowIsMain]; + return true; } /** diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdate.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdate.php new file mode 100644 index 000000000000..99919628518c --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdate.php @@ -0,0 +1,85 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\CatalogImportExport\Model\Import\Product\Validator; + +use Magento\Framework\Config\ValidationStateInterface; +use Magento\Framework\View\Model\Layout\Update\ValidatorFactory; + +/** + * Validates layout and custom layout update fields + */ +class LayoutUpdate extends AbstractImportValidator +{ + private const ERROR_INVALID_LAYOUT_UPDATE = 'invalidLayoutUpdate'; + + /** + * @var ValidatorFactory + */ + private $layoutValidatorFactory; + + /** + * @var ValidationStateInterface + */ + private $validationState; + + /** + * @param ValidatorFactory $layoutValidatorFactory + * @param ValidationStateInterface $validationState + */ + public function __construct( + ValidatorFactory $layoutValidatorFactory, + ValidationStateInterface $validationState + ) { + $this->layoutValidatorFactory = $layoutValidatorFactory; + $this->validationState = $validationState; + } + + /** + * @inheritdoc + */ + public function isValid($value): bool + { + if (!empty($value['custom_layout_update']) && !$this->validateXml($value['custom_layout_update'])) { + $this->_addMessages( + [ + $this->context->retrieveMessageTemplate(self::ERROR_INVALID_LAYOUT_UPDATE) + ] + ); + return false; + } + + return true; + } + + /** + * Validate XML layout update + * + * @param string $xml + * @return bool + */ + private function validateXml(string $xml): bool + { + /** @var $layoutXmlValidator \Magento\Framework\View\Model\Layout\Update\Validator */ + $layoutXmlValidator = $this->layoutValidatorFactory->create( + [ + 'validationState' => $this->validationState, + ] + ); + + try { + if (!$layoutXmlValidator->isValid($xml)) { + return false; + } + } catch (\Exception $e) { + return false; + } + + return true; + } +} diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdatePermissions.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdatePermissions.php new file mode 100644 index 000000000000..50d38cedfb75 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Validator/LayoutUpdatePermissions.php @@ -0,0 +1,78 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\CatalogImportExport\Model\Import\Product\Validator; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\AuthorizationInterface; +use Magento\CatalogImportExport\Model\Import\Product\Validator\AbstractImportValidator; + +/** + * Validator to assert that the current user is allowed to make design updates if a layout is provided in the import + */ +class LayoutUpdatePermissions extends AbstractImportValidator +{ + private const ERROR_INSUFFICIENT_PERMISSIONS = 'insufficientPermissions'; + + /** + * @var UserContextInterface + */ + private $userContext; + + /** + * @var AuthorizationInterface + */ + private $authorization; + + /** + * @var array + */ + private $allowedUserTypes = [ + UserContextInterface::USER_TYPE_ADMIN, + UserContextInterface::USER_TYPE_INTEGRATION + ]; + + /** + * @param UserContextInterface $userContext + * @param AuthorizationInterface $authorization + */ + public function __construct( + UserContextInterface $userContext, + AuthorizationInterface $authorization + ) { + $this->userContext = $userContext; + $this->authorization = $authorization; + } + + /** + * Validate that the current user is allowed to make design updates + * + * @param array $data + * @return boolean + */ + public function isValid($data): bool + { + if (empty($data['custom_layout_update'])) { + return true; + } + + $userType = $this->userContext->getUserType(); + $isValid = in_array($userType, $this->allowedUserTypes) + && $this->authorization->isAllowed('Magento_Catalog::edit_product_design'); + + if (!$isValid) { + $this->_addMessages( + [ + $this->context->retrieveMessageTemplate(self::ERROR_INSUFFICIENT_PERMISSIONS), + ] + ); + } + + return $isValid; + } +} diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php index 4ce1c0e39d6d..09c3cc4daf1d 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Uploader.php @@ -7,6 +7,8 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\ValidatorException; +use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\DriverPool; /** @@ -111,13 +113,18 @@ class Uploader extends \Magento\MediaStorage\Model\File\Uploader */ private $random; + /** + * @var Filesystem + */ + private $fileSystem; + /** * @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDb * @param \Magento\MediaStorage\Helper\File\Storage $coreFileStorage * @param \Magento\Framework\Image\AdapterFactory $imageFactory * @param \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension $validator - * @param \Magento\Framework\Filesystem $filesystem - * @param \Magento\Framework\Filesystem\File\ReadFactory $readFactory + * @param Filesystem $filesystem + * @param Filesystem\File\ReadFactory $readFactory * @param string|null $filePath * @param \Magento\Framework\Math\Random|null $random * @throws \Magento\Framework\Exception\FileSystemException @@ -128,8 +135,8 @@ public function __construct( \Magento\MediaStorage\Helper\File\Storage $coreFileStorage, \Magento\Framework\Image\AdapterFactory $imageFactory, \Magento\MediaStorage\Model\File\Validator\NotProtectedExtension $validator, - \Magento\Framework\Filesystem $filesystem, - \Magento\Framework\Filesystem\File\ReadFactory $readFactory, + Filesystem $filesystem, + Filesystem\File\ReadFactory $readFactory, $filePath = null, \Magento\Framework\Math\Random $random = null ) { @@ -137,6 +144,7 @@ public function __construct( $this->_coreFileStorageDb = $coreFileStorageDb; $this->_coreFileStorage = $coreFileStorage; $this->_validator = $validator; + $this->fileSystem = $filesystem; $this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $this->_readFactory = $readFactory; if ($filePath !== null) { @@ -236,7 +244,20 @@ private function downloadFileFromUrl($url, $driver) */ protected function _setUploadFile($filePath) { - if (!$this->_directory->isReadable($filePath)) { + try { + $fullPath = $this->_directory->getAbsolutePath($filePath); + if ($this->getTmpDir()) { + $tmpDir = $this->fileSystem->getDirectoryReadByPath( + $this->_directory->getAbsolutePath($this->getTmpDir()) + ); + } else { + $tmpDir = $this->_directory; + } + $readable = $tmpDir->isReadable($fullPath); + } catch (ValidatorException $exception) { + $readable = false; + } + if (!$readable) { throw new \Magento\Framework\Exception\LocalizedException( __('File \'%1\' was not found or has read restriction.', $filePath) ); diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportImportConfigurableProductWithImagesTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportImportConfigurableProductWithImagesTest.xml index 88f6e6c9f903..f0ec7dbd0706 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportImportConfigurableProductWithImagesTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportImportConfigurableProductWithImagesTest.xml @@ -19,6 +19,9 @@ <group value="configurable_product"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + <!-- Create sample data: 1. Create simple products --> <createData entity="ApiCategory" stepKey="createCategory"/> @@ -128,6 +131,9 @@ <actionGroup ref="deleteAllExportedFiles" stepKey="clearExportedFilesList"/> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + <!-- Delete created data --> <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFisrtSimpleProduct"/> <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdatePermissionsTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdatePermissionsTest.php new file mode 100644 index 000000000000..e018fc0cf5cc --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdatePermissionsTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product\Validator; + +use Magento\CatalogImportExport\Model\Import\Product; +use Magento\Authorization\Model\UserContextInterface; +use Magento\CatalogImportExport\Model\Import\Product\Validator\LayoutUpdatePermissions; +use Magento\Framework\AuthorizationInterface; +use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject as MockObject; + +/** + * Test validation for layout update permissions + */ +class LayoutUpdatePermissionsTest extends TestCase +{ + /** + * @var LayoutUpdatePermissions|MockObject + */ + private $validator; + + /** + * @var UserContextInterface|MockObject + */ + private $userContext; + + /** + * @var AuthorizationInterface|MockObject + */ + private $authorization; + + /** + * @var Product + */ + private $context; + + protected function setUp() + { + $this->userContext = $this->createMock(UserContextInterface::class); + $this->authorization = $this->createMock(AuthorizationInterface::class); + $this->context = $this->createMock(Product::class); + $this->context + ->method('retrieveMessageTemplate') + ->with('insufficientPermissions') + ->willReturn('oh no'); + $this->validator = new LayoutUpdatePermissions( + $this->userContext, + $this->authorization + ); + $this->validator->init($this->context); + } + + /** + * @param $value + * @param $userContext + * @param $isAllowed + * @param $isValid + * @dataProvider configurationsProvider + */ + public function testValidationConfiguration($value, $userContext, $isAllowed, $isValid) + { + $this->userContext + ->method('getUserType') + ->willReturn($userContext); + + $this->authorization + ->method('isAllowed') + ->with('Magento_Catalog::edit_product_design') + ->willReturn($isAllowed); + + $result = $this->validator->isValid(['custom_layout_update' => $value]); + $messages = $this->validator->getMessages(); + + self::assertSame($isValid, $result); + + if ($isValid) { + self::assertSame([], $messages); + } else { + self::assertSame(['oh no'], $messages); + } + } + + public function configurationsProvider() + { + return [ + ['', null, null, true], + [null, null, null, true], + ['foo', UserContextInterface::USER_TYPE_ADMIN, true, true], + ['foo', UserContextInterface::USER_TYPE_INTEGRATION, true, true], + ['foo', UserContextInterface::USER_TYPE_ADMIN, false, false], + ['foo', UserContextInterface::USER_TYPE_INTEGRATION, false, false], + ['foo', 'something', null, false], + ]; + } +} diff --git a/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php new file mode 100644 index 000000000000..d1e8b879f6a0 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Validator/LayoutUpdateTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\CatalogImportExport\Test\Unit\Model\Import\Product\Validator; + +use Magento\CatalogImportExport\Model\Import\Product; +use Magento\CatalogImportExport\Model\Import\Product\Validator\LayoutUpdate; +use Magento\Framework\Config\ValidationStateInterface; +use Magento\Framework\View\Model\Layout\Update\Validator; +use Magento\Framework\View\Model\Layout\Update\ValidatorFactory; +use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject as MockObject; + +/** + * Test validation for layout update + */ +class LayoutUpdateTest extends TestCase +{ + /** + * @var LayoutUpdate|MockObject + */ + private $validator; + + /** + * @var Validator|MockObject + */ + private $layoutValidator; + + protected function setUp() + { + $validatorFactory = $this->createMock(ValidatorFactory::class); + $validationState = $this->createMock(ValidationStateInterface::class); + $this->layoutValidator = $this->createMock(Validator::class); + $validatorFactory->method('create') + ->with(['validationState' => $validationState]) + ->willReturn($this->layoutValidator); + + $this->validator = new LayoutUpdate( + $validatorFactory, + $validationState + ); + } + + public function testValidationIsSkippedWithDataNotPresent() + { + $this->layoutValidator + ->expects($this->never()) + ->method('isValid'); + + $result = $this->validator->isValid([]); + self::assertTrue($result); + } + + public function testValidationFailsProperly() + { + $this->layoutValidator + ->method('isValid') + ->with('foo') + ->willReturn(false); + + $contextMock = $this->createMock(Product::class); + $contextMock + ->method('retrieveMessageTemplate') + ->with('invalidLayoutUpdate') + ->willReturn('oh no'); + $this->validator->init($contextMock); + + $result = $this->validator->isValid(['custom_layout_update' => 'foo']); + $messages = $this->validator->getMessages(); + self::assertFalse($result); + self::assertSame(['oh no'], $messages); + } + + public function testInvalidDataException() + { + $this->layoutValidator + ->method('isValid') + ->willThrowException(new \Exception('foo')); + + $contextMock = $this->createMock(Product::class); + $contextMock + ->method('retrieveMessageTemplate') + ->with('invalidLayoutUpdate') + ->willReturn('oh no'); + $this->validator->init($contextMock); + + $result = $this->validator->isValid(['custom_layout_update' => 'foo']); + $messages = $this->validator->getMessages(); + self::assertFalse($result); + self::assertSame(['oh no'], $messages); + } +} diff --git a/app/code/Magento/CatalogImportExport/composer.json b/app/code/Magento/CatalogImportExport/composer.json index 6af2bbaf45e3..25d9c1bde0d6 100644 --- a/app/code/Magento/CatalogImportExport/composer.json +++ b/app/code/Magento/CatalogImportExport/composer.json @@ -16,7 +16,8 @@ "magento/module-import-export": "*", "magento/module-media-storage": "*", "magento/module-store": "*", - "magento/module-tax": "*" + "magento/module-tax": "*", + "magento/module-authorization": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/CatalogImportExport/etc/di.xml b/app/code/Magento/CatalogImportExport/etc/di.xml index 6906272b11d6..4e2fe390e0b1 100644 --- a/app/code/Magento/CatalogImportExport/etc/di.xml +++ b/app/code/Magento/CatalogImportExport/etc/di.xml @@ -25,7 +25,14 @@ <item name="website" xsi:type="object">Magento\CatalogImportExport\Model\Import\Product\Validator\Website</item> <item name="weight" xsi:type="object">Magento\CatalogImportExport\Model\Import\Product\Validator\Weight</item> <item name="quantity" xsi:type="object">Magento\CatalogImportExport\Model\Import\Product\Validator\Quantity</item> + <item name="layout_update" xsi:type="object">Magento\CatalogImportExport\Model\Import\Product\Validator\LayoutUpdate</item> + <item name="layout_update_permissions" xsi:type="object">Magento\CatalogImportExport\Model\Import\Product\Validator\LayoutUpdatePermissions</item> </argument> </arguments> </type> + <type name="Magento\CatalogImportExport\Model\Import\Product\Validator\LayoutUpdate"> + <arguments> + <argument name="validationState" xsi:type="object">Magento\Framework\Config\ValidationState\Required</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php index f9a49d4f8d12..35231b8460b1 100644 --- a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php +++ b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php @@ -104,6 +104,10 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = $select->where('stock_item.use_config_manage_stock = 0 AND stock_item.manage_stock = 1'); } + if (!empty($entityIds)) { + $select->where('stock_item.product_id in (?)', $entityIds); + } + $select->group('stock_item.product_id'); $select->having('max_is_in_stock = 0'); diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php index 3670b93b8cb4..519466c50553 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Indexer/Stock/DefaultStock.php @@ -230,6 +230,8 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f { $connection = $this->getConnection(); $qtyExpr = $connection->getCheckSql('cisi.qty > 0', 'cisi.qty', 0); + $metadata = $this->getMetadataPool()->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + $linkField = $metadata->getLinkField(); $select = $connection->select()->from( ['e' => $this->getTable('catalog_product_entity')], @@ -243,6 +245,12 @@ protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = f ['cisi' => $this->getTable('cataloginventory_stock_item')], 'cisi.stock_id = cis.stock_id AND cisi.product_id = e.entity_id', [] + )->joinInner( + ['mcpei' => $this->getTable('catalog_product_entity_int')], + 'e.' . $linkField . ' = mcpei.' . $linkField + . ' AND mcpei.attribute_id = ' . $this->_getAttribute('status')->getId() + . ' AND mcpei.value = ' . ProductStatus::STATUS_ENABLED, + [] )->columns( ['qty' => $qtyExpr] )->where( @@ -284,7 +292,6 @@ protected function _prepareIndexTable($entityIds = null) */ protected function _updateIndex($entityIds) { - $this->deleteOldRecords($entityIds); $connection = $this->getConnection(); $select = $this->_getStockStatusSelect($entityIds, true); $select = $this->getQueryProcessorComposite()->processQuery($select, $entityIds, true); @@ -307,6 +314,7 @@ protected function _updateIndex($entityIds) } } + $this->deleteOldRecords($entityIds); $this->_updateIndexTable($data); return $this; diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item.php index 3a214bd8cd7c..edccad60231e 100644 --- a/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/Stock/Item.php @@ -14,7 +14,6 @@ use Magento\Framework\DB\Select; use Magento\Framework\App\ObjectManager; use Magento\Framework\Stdlib\DateTime\DateTime; -use Zend_Db_Expr; /** * Stock item resource model @@ -184,12 +183,16 @@ public function updateSetOutOfStock(int $websiteId) 'is_in_stock = ' . Stock::STOCK_IN_STOCK, '(use_config_manage_stock = 1 AND 1 = ' . $this->stockConfiguration->getManageStock() . ')' . ' OR (use_config_manage_stock = 0 AND manage_stock = 1)', - '(' . $this->getBackordersExpr() .' = 0 AND qty <= ' . $this->getMinQtyExpr() . ')' - . ' OR (' . $this->getBackordersExpr() .' != 0 AND ' - . $this->getMinQtyExpr() . ' != 0 AND qty <= ' . $this->getMinQtyExpr() . ')', + '(use_config_min_qty = 1 AND qty <= ' . $this->stockConfiguration->getMinQty() . ')' + . ' OR (use_config_min_qty = 0 AND qty <= min_qty)', 'product_id IN (' . $select->assemble() . ')', ]; - + $backordersWhere = '(use_config_backorders = 0 AND backorders = ' . Stock::BACKORDERS_NO . ')'; + if (Stock::BACKORDERS_NO == $this->stockConfiguration->getBackorders()) { + $where[] = $backordersWhere . ' OR use_config_backorders = 1'; + } else { + $where[] = $backordersWhere; + } $connection->update($this->getMainTable(), $values, $where); $this->stockIndexerProcessor->markIndexerAsInvalid(); @@ -212,8 +215,8 @@ public function updateSetInStock(int $websiteId) $where = [ 'website_id = ' . $websiteId, 'stock_status_changed_auto = 1', - '(qty > ' . $this->getMinQtyExpr() . ')' - . ' OR (' . $this->getBackordersExpr() . ' != 0 AND ' . $this->getMinQtyExpr() . ' = 0)', // If infinite + '(use_config_min_qty = 1 AND qty > ' . $this->stockConfiguration->getMinQty() . ')' + . ' OR (use_config_min_qty = 0 AND qty > min_qty)', 'product_id IN (' . $select->assemble() . ')', ]; $manageStockWhere = '(use_config_manage_stock = 0 AND manage_stock = 1)'; @@ -301,12 +304,12 @@ public function getBackordersExpr(string $tableAlias = ''): \Zend_Db_Expr } /** - * Get Minimum Sale Quantity Expression. + * Get Minimum Sale Quantity Expression * * @param string $tableAlias - * @return Zend_Db_Expr + * @return \Zend_Db_Expr */ - public function getMinSaleQtyExpr(string $tableAlias = ''): Zend_Db_Expr + public function getMinSaleQtyExpr(string $tableAlias = ''): \Zend_Db_Expr { if ($tableAlias) { $tableAlias .= '.'; @@ -320,26 +323,6 @@ public function getMinSaleQtyExpr(string $tableAlias = ''): Zend_Db_Expr return $itemMinSaleQty; } - /** - * Get Min Qty Expression - * - * @param string $tableAlias - * @return Zend_Db_Expr - */ - public function getMinQtyExpr(string $tableAlias = ''): Zend_Db_Expr - { - if ($tableAlias) { - $tableAlias .= '.'; - } - $itemBackorders = $this->getConnection()->getCheckSql( - $tableAlias . 'use_config_min_qty = 1', - $this->stockConfiguration->getMinQty(), - $tableAlias . 'min_qty' - ); - - return $itemBackorders; - } - /** * Build select for products with types from config * diff --git a/app/code/Magento/CatalogInventory/Model/StockStateProvider.php b/app/code/Magento/CatalogInventory/Model/StockStateProvider.php index 74271cdd97bf..6851b05aa56a 100644 --- a/app/code/Magento/CatalogInventory/Model/StockStateProvider.php +++ b/app/code/Magento/CatalogInventory/Model/StockStateProvider.php @@ -72,31 +72,14 @@ public function __construct( */ public function verifyStock(StockItemInterface $stockItem) { - // Manage stock, but qty is null if ($stockItem->getQty() === null && $stockItem->getManageStock()) { return false; } - - // Backorders are not allowed and qty reached min qty if ($stockItem->getBackorders() == StockItemInterface::BACKORDERS_NO && $stockItem->getQty() <= $stockItem->getMinQty() ) { return false; } - - $backordersAllowed = [Stock::BACKORDERS_YES_NONOTIFY, Stock::BACKORDERS_YES_NOTIFY]; - if (in_array($stockItem->getBackorders(), $backordersAllowed)) { - // Infinite - let it be In stock - if ($stockItem->getMinQty() == 0) { - return true; - } - - // qty reached min qty - let it stand Out Of Stock - if ($stockItem->getQty() <= $stockItem->getMinQty()) { - return false; - } - } - return true; } @@ -262,17 +245,15 @@ public function checkQty(StockItemInterface $stockItem, $qty) if (!$stockItem->getManageStock()) { return true; } - - $backordersAllowed = [Stock::BACKORDERS_YES_NONOTIFY, Stock::BACKORDERS_YES_NOTIFY]; - // Infinite check - if ($stockItem->getMinQty() == 0 && in_array($stockItem->getBackorders(), $backordersAllowed)) { - return true; - } - if ($stockItem->getQty() - $stockItem->getMinQty() - $qty < 0) { - return false; + switch ($stockItem->getBackorders()) { + case \Magento\CatalogInventory\Model\Stock::BACKORDERS_YES_NONOTIFY: + case \Magento\CatalogInventory\Model\Stock::BACKORDERS_YES_NOTIFY: + break; + default: + return false; + } } - return true; } diff --git a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php index 268f1846161d..f49d41b5dd65 100644 --- a/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php +++ b/app/code/Magento/CatalogInventory/Model/System/Config/Backend/Minqty.php @@ -6,36 +6,21 @@ namespace Magento\CatalogInventory\Model\System\Config\Backend; -use Magento\CatalogInventory\Model\Stock; - /** - * Minimum product qty backend model. + * Minimum product qty backend model */ class Minqty extends \Magento\Framework\App\Config\Value { /** - * Validate minimum product qty value. + * Validate minimum product qty value * * @return $this */ public function beforeSave() { parent::beforeSave(); - $minQty = (float)$this->getValue(); - - /** - * As described in the documentation if the Backorders Option is disabled - * it is recommended to set the Out Of Stock Threshold to a positive number. - * That's why to clarify the logic to the end user the code below prevent him to set a negative number so such - * a number will turn to zero. - * @see https://docs.magento.com/m2/ce/user_guide/catalog/inventory-backorders.html - */ - if ($this->getFieldsetDataValue("backorders") == Stock::BACKORDERS_NO && $minQty < 0) { - $minQty = 0; - } - + $minQty = (int) $this->getValue() >= 0 ? (int) $this->getValue() : (int) $this->getOldValue(); $this->setValue((string) $minQty); - return $this; } } diff --git a/app/code/Magento/CatalogInventory/Setup/Patch/Schema/ChangeTmpTablesEngine.php b/app/code/Magento/CatalogInventory/Setup/Patch/Schema/ChangeTmpTablesEngine.php deleted file mode 100644 index 7f43cd279d4e..000000000000 --- a/app/code/Magento/CatalogInventory/Setup/Patch/Schema/ChangeTmpTablesEngine.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\CatalogInventory\Setup\Patch\Schema; - -use Magento\Framework\Setup\Patch\SchemaPatchInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Change engine for temporary tables to InnoDB. - */ -class ChangeTmpTablesEngine implements SchemaPatchInterface -{ - /** - * @var SchemaSetupInterface - */ - private $schemaSetup; - - /** - * @param SchemaSetupInterface $schemaSetup - */ - public function __construct(SchemaSetupInterface $schemaSetup) - { - $this->schemaSetup = $schemaSetup; - } - - /** - * @inheritdoc - */ - public function apply() - { - $this->schemaSetup->startSetup(); - - $tableName = $this->schemaSetup->getTable('cataloginventory_stock_status_tmp'); - if ($this->schemaSetup->getConnection()->isTableExists($tableName)) { - $this->schemaSetup->getConnection()->changeTableEngine($tableName, 'InnoDB'); - } - - $this->schemaSetup->endSetup(); - } - - /** - * @inheritdoc - */ - public static function getDependencies() - { - return []; - } - - /** - * @inheritdoc - */ - public function getAliases() - { - return []; - } -} diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml b/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml new file mode 100644 index 000000000000..27c4a93577a0 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAssertDisabledQtyActionGroup"> + <annotations> + <description>Goes to the 'Quantity' field and assert disabled attribute.</description> + </annotations> + + <seeElement selector="{{AdminProductFormSection.productQuantity}}" stepKey="assertProductQty"/> + <assertElementContainsAttribute selector="{{AdminProductFormSection.productQuantity}}" attribute="disabled" expectedValue="true" stepKey="checkIfQtyIsDisabled" /> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php new file mode 100644 index 000000000000..46f4e0f26f37 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php @@ -0,0 +1,121 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\CatalogInventory\Test\Unit\Model\Indexer; + +use Magento\CatalogInventory\Api\StockConfigurationInterface; +use Magento\CatalogInventory\Model\Indexer\ProductPriceIndexFilter; +use Magento\CatalogInventory\Model\ResourceModel\Stock\Item; +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Query\Generator; +use PHPUnit\Framework\MockObject\MockObject; +use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure; + +/** + * Product Price filter test, to ensure that product id's filtered. + */ +class ProductPriceIndexFilterTest extends \PHPUnit\Framework\TestCase +{ + + /** + * @var MockObject|StockConfigurationInterface $stockConfiguration + */ + private $stockConfiguration; + + /** + * @var MockObject|Item $item + */ + private $item; + + /** + * @var MockObject|ResourceConnection $resourceCnnection + */ + private $resourceCnnection; + + /** + * @var MockObject|Generator $generator + */ + private $generator; + + /** + * @var ProductPriceIndexFilter $productPriceIndexFilter + */ + private $productPriceIndexFilter; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->stockConfiguration = $this->createMock(StockConfigurationInterface::class); + $this->item = $this->createMock(Item::class); + $this->resourceCnnection = $this->createMock(ResourceConnection::class); + $this->generator = $this->createMock(Generator::class); + + $this->productPriceIndexFilter = new ProductPriceIndexFilter( + $this->stockConfiguration, + $this->item, + $this->resourceCnnection, + 'indexer', + $this->generator, + 100 + ); + } + + /** + * Test to ensure that Modify Price method uses entityIds, + */ + public function testModifyPrice() + { + $entityIds = [1, 2, 3]; + $indexTableStructure = $this->createMock(IndexTableStructure::class); + $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); + $this->resourceCnnection->expects($this->once())->method('getConnection')->willReturn($connectionMock); + $selectMock = $this->createMock(\Magento\Framework\DB\Select::class); + $connectionMock->expects($this->once())->method('select')->willReturn($selectMock); + $selectMock->expects($this->at(2)) + ->method('where') + ->with('stock_item.product_id in (?)', $entityIds) + ->willReturn($selectMock); + $this->generator->expects($this->once()) + ->method('generate') + ->will( + $this->returnCallback( + $this->getBatchIteratorCallback($selectMock, 5) + ) + ); + + $fetchStmtMock = $this->createPartialMock(\Zend_Db_Statement_Pdo::class, ['fetchAll']); + $fetchStmtMock->expects($this->any()) + ->method('fetchAll') + ->will($this->returnValue([['product_id' => 1]])); + $connectionMock->expects($this->any())->method('query')->will($this->returnValue($fetchStmtMock)); + $this->productPriceIndexFilter->modifyPrice($indexTableStructure, $entityIds); + } + + /** + * Returns batches. + * + * @param MockObject $selectMock + * @param int $batchCount + * @return \Closure + */ + private function getBatchIteratorCallback(MockObject $selectMock, int $batchCount): \Closure + { + $iteratorCallback = function () use ($batchCount, $selectMock): array { + $result = []; + $count = $batchCount; + while ($count) { + $count--; + $result[$count] = $selectMock; + } + + return $result; + }; + + return $iteratorCallback; + } +} diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockStateProviderTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockStateProviderTest.php deleted file mode 100644 index 942d77063a8e..000000000000 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockStateProviderTest.php +++ /dev/null @@ -1,223 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\CatalogInventory\Test\Unit\Model; - -use PHPUnit\Framework\TestCase; -use Magento\CatalogInventory\Model\StockStateProvider; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\CatalogInventory\Api\Data\StockItemInterface; -use Magento\CatalogInventory\Model\Stock; - -/** - * StockRegistry test. - */ -class StockStateProviderTest extends TestCase -{ - /** - * @var ObjectManager - */ - private $objectManager; - - /** - * @var StockStateProvider - */ - private $model; - - /** - * @var StockItemInterface|\PHPUnit\Framework\MockObject\MockObject - */ - private $stockItem; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = new ObjectManager($this); - - $this->stockItem = $this->getMockBuilder(StockItemInterface::class) - ->getMock(); - - $this->model = $this->objectManager->getObject(StockStateProvider::class); - } - - /** - * Tests verifyStock method. - * - * @param int $qty - * @param int $backOrders - * @param int $minQty - * @param int $manageStock - * @param int $expected - * - * @return void - * - * @dataProvider stockItemDataProvider - * @covers \Magento\CatalogInventory\Model\StockStateProvider::verifyStock - */ - public function testVerifyStock( - ?int $qty, - ?int $backOrders, - ?int $minQty, - ?int $manageStock, - bool $expected - ): void { - $this->stockItem->method('getQty') - ->willReturn($qty); - $this->stockItem->method('getBackOrders') - ->willReturn($backOrders); - $this->stockItem->method('getMinQty') - ->willReturn($minQty); - $this->stockItem->method('getManageStock') - ->willReturn($manageStock); - - $result = $this->model->verifyStock($this->stockItem); - - self::assertEquals($expected, $result); - } - - /** - * StockItem data provider. - * - * @return array - */ - public function stockItemDataProvider(): array - { - return [ - 'qty_is_null_manage_stock_on' => [ - 'qty' => null, - 'backorders' => null, - 'min_qty' => null, - 'manage_stock' => 1, - 'expected' => false, - ], - 'qty_reached_threshold_without_backorders' => [ - 'qty' => 3, - 'backorders' => Stock::BACKORDERS_NO, - 'min_qty' => 3, - 'manage_stock' => 1, - 'expected' => false, - ], - 'backorders_are_ininite' => [ - 'qty' => -100, - 'backorders' => Stock::BACKORDERS_YES_NONOTIFY, - 'min_qty' => 0, - 'manage_stock' => 1, - 'expected' => true, - ], - 'limited_backorders_and_qty_reached_threshold' => [ - 'qty' => -100, - 'backorders' => Stock::BACKORDERS_YES_NONOTIFY, - 'min_qty' => -100, - 'manage_stock' => 1, - 'expected' => false, - ], - 'qty_not_yet_reached_threshold_1' => [ - 'qty' => -99, - 'backorders' => Stock::BACKORDERS_YES_NONOTIFY, - 'min_qty' => -100, - 'manage_stock' => 1, - 'expected' => true, - ], - 'qty_not_yet_reached_threshold_2' => [ - 'qty' => 1, - 'backorders' => Stock::BACKORDERS_NO, - 'min_qty' => 0, - 'manage_stock' => 1, - 'expected' => true, - ], - ]; - } - - /** - * Tests checkQty method. - * - * @return void - * - * @dataProvider stockItemAndQtyDataProvider - * @covers \Magento\CatalogInventory\Model\StockStateProvider::verifyStock - */ - public function testCheckQty( - bool $manageStock, - int $qty, - int $minQty, - int $backOrders, - int $orderQty, - bool $expected - ): void { - $this->stockItem->method('getManageStock') - ->willReturn($manageStock); - $this->stockItem->method('getQty') - ->willReturn($qty); - $this->stockItem->method('getMinQty') - ->willReturn($minQty); - $this->stockItem->method('getBackOrders') - ->willReturn($backOrders); - - $result = $this->model->checkQty($this->stockItem, $orderQty); - - self::assertEquals($expected, $result); - } - - /** - * StockItem and qty data provider. - * - * @return array - */ - public function stockItemAndQtyDataProvider(): array - { - return [ - 'disabled_manage_stock' => [ - 'manage_stock' => false, - 'qty' => 0, - 'min_qty' => 0, - 'backorders' => 0, - 'order_qty' => 0, - 'expected' => true, - ], - 'infinite_backorders' => [ - 'manage_stock' => true, - 'qty' => -100, - 'min_qty' => 0, - 'backorders' => Stock::BACKORDERS_YES_NONOTIFY, - 'order_qty' => 100, - 'expected' => true, - ], - 'qty_reached_threshold' => [ - 'manage_stock' => true, - 'qty' => -100, - 'min_qty' => -100, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - 'order_qty' => 1, - 'expected' => false, - ], - 'qty_yet_not_reached_threshold' => [ - 'manage_stock' => true, - 'qty' => -100, - 'min_qty' => -100, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - 'order_qty' => 1, - 'expected' => false, - ] - ]; - } - - /** - * Tests checkQty method when check is not applicable. - * - * @return void - */ - public function testCheckQtyWhenCheckIsNotApplicable(): void - { - $model = $this->objectManager->getObject(StockStateProvider::class, ['qtyCheckApplicable' => false]); - - $result = $model->checkQty($this->stockItem, 3); - - self::assertTrue($result); - } -} diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index da465f5bdd3d..789befcfec8b 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -1,11 +1,10 @@ <?php - -declare(strict_types=1); - /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\CatalogInventory\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter; @@ -238,7 +237,7 @@ private function prepareMeta() $this->meta = $this->arrayManager->merge( $fieldsetPath . '/children', $this->meta, - ['container_quantity_and_stock_status_qty' => $container] + ['quantity_and_stock_status_qty' => $container] ); } } diff --git a/app/code/Magento/CatalogInventory/etc/db_schema.xml b/app/code/Magento/CatalogInventory/etc/db_schema.xml index d903d09dd1f8..b5c4a96f24a9 100644 --- a/app/code/Magento/CatalogInventory/etc/db_schema.xml +++ b/app/code/Magento/CatalogInventory/etc/db_schema.xml @@ -142,7 +142,7 @@ <column name="website_id"/> </index> </table> - <table name="cataloginventory_stock_status_tmp" resource="default" engine="memory" + <table name="cataloginventory_stock_status_tmp" resource="default" engine="innodb" comment="Cataloginventory Stock Status Indexer Tmp"> <column xsi:type="int" name="product_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Product ID"/> @@ -159,10 +159,10 @@ <column name="website_id"/> <column name="stock_id"/> </constraint> - <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_STOCK_ID" indexType="hash"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_STOCK_ID" indexType="btree"> <column name="stock_id"/> </index> - <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_WEBSITE_ID" indexType="hash"> + <index referenceId="CATALOGINVENTORY_STOCK_STATUS_TMP_WEBSITE_ID" indexType="btree"> <column name="website_id"/> </index> </table> diff --git a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php index 6d499b93e411..4f58293d5335 100644 --- a/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php +++ b/app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/Save.php @@ -12,7 +12,6 @@ use Magento\Framework\Registry; use Magento\Framework\Stdlib\DateTime\Filter\Date; use Magento\Framework\App\Request\DataPersistorInterface; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** * Save action for catalog rule @@ -26,27 +25,19 @@ class Save extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog imple */ protected $dataPersistor; - /** - * @var TimezoneInterface - */ - private $localeDate; - /** * @param Context $context * @param Registry $coreRegistry * @param Date $dateFilter * @param DataPersistorInterface $dataPersistor - * @param TimezoneInterface $localeDate */ public function __construct( Context $context, Registry $coreRegistry, Date $dateFilter, - DataPersistorInterface $dataPersistor, - TimezoneInterface $localeDate + DataPersistorInterface $dataPersistor ) { $this->dataPersistor = $dataPersistor; - $this->localeDate = $localeDate; parent::__construct($context, $coreRegistry, $dateFilter); } @@ -55,15 +46,16 @@ public function __construct( * * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) */ public function execute() { if ($this->getRequest()->getPostValue()) { + /** @var \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface $ruleRepository */ $ruleRepository = $this->_objectManager->get( \Magento\CatalogRule\Api\CatalogRuleRepositoryInterface::class ); + /** @var \Magento\CatalogRule\Model\Rule $model */ $model = $this->_objectManager->create(\Magento\CatalogRule\Model\Rule::class); @@ -73,9 +65,7 @@ public function execute() ['request' => $this->getRequest()] ); $data = $this->getRequest()->getPostValue(); - if (!$this->getRequest()->getParam('from_date')) { - $data['from_date'] = $this->localeDate->formatDate(); - } + $filterValues = ['from_date' => $this->_dateFilter]; if ($this->getRequest()->getParam('to_date')) { $filterValues['to_date'] = $this->_dateFilter; diff --git a/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php b/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php index 944710773123..e589c8595ce2 100644 --- a/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php +++ b/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProduct.php @@ -101,9 +101,7 @@ public function execute(Rule $rule, $batchCount, $useAdditionalTable = false) $scopeTz = new \DateTimeZone( $this->localeDate->getConfigTimezone(ScopeInterface::SCOPE_WEBSITE, $websiteId) ); - $fromTime = $rule->getFromDate() - ? (new \DateTime($rule->getFromDate(), $scopeTz))->getTimestamp() - : 0; + $fromTime = (new \DateTime($rule->getFromDate(), $scopeTz))->getTimestamp(); $toTime = $rule->getToDate() ? (new \DateTime($rule->getToDate(), $scopeTz))->getTimestamp() + IndexBuilder::SECONDS_IN_DAY - 1 : 0; diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AdminCreateNewCatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AdminCreateNewCatalogPriceRuleActionGroup.xml index 00dcb68089b7..209095e0b019 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AdminCreateNewCatalogPriceRuleActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AdminCreateNewCatalogPriceRuleActionGroup.xml @@ -21,7 +21,6 @@ <waitForPageLoad stepKey="waitForPageToLoad"/> <fillField stepKey="fillName" selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}"/> <fillField stepKey="fillDescription" selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}"/> - <selectOption selector="{{AdminNewCatalogPriceRule.status}}" userInput="{{catalogRule.is_active}}" stepKey="selectStatus"/> <selectOption stepKey="selectWebSite" selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{catalogRule.website_ids[0]}}"/> <selectOption selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="{{customerGroup}}" stepKey="selectCustomerGroup"/> <scrollTo selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="scrollToActionTab"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AssertCatalogPriceRuleFormActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AssertCatalogPriceRuleFormActionGroup.xml index 77fe0f50653c..0a4b6366d11a 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AssertCatalogPriceRuleFormActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/AssertCatalogPriceRuleFormActionGroup.xml @@ -13,7 +13,7 @@ <description>Validates that the provided Catalog Rule, Status, Websites and Customer Group details are present and correct on a Admin Catalog Price Rule creation/edit page.</description> </annotations> <arguments> - <argument name="catalogRule" defaultValue="inactiveCatalogRule"/> + <argument name="catalogRule" defaultValue="inactiveCatalogRule" /> <argument name="status" type="string" defaultValue=""/> <argument name="websites" type="string"/> <argument name="customerGroup" type="string"/> @@ -21,7 +21,6 @@ <seeInField stepKey="fillName" selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}"/> <seeInField stepKey="fillDescription" selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}"/> - <seeOptionIsSelected selector="{{AdminNewCatalogPriceRule.status}}" userInput="{{status}}" stepKey="selectStatus"/> <see stepKey="seeWebSite" selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{websites}}"/> <seeOptionIsSelected selector="{{AdminNewCatalogPriceRule.customerGroups}}" userInput="{{customerGroup}}" stepKey="selectCustomerGroup"/> <scrollTo selector="{{AdminNewCatalogPriceRule.actionsTab}}" stepKey="scrollToActionTab"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml index a7500858fc94..09053b5ad14a 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml @@ -25,6 +25,7 @@ <!-- Fill the form according the attributes of the entity --> <fillField stepKey="fillName" selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}"/> <fillField stepKey="fillDescription" selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}"/> + <click stepKey="selectActive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/> <selectOption stepKey="selectSite" selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{catalogRule.website_ids[0]}}"/> <click stepKey="clickFromCalender" selector="{{AdminNewCatalogPriceRule.fromDateButton}}"/> <click stepKey="clickFromToday" selector="{{AdminNewCatalogPriceRule.todayDate}}"/> @@ -47,17 +48,39 @@ <arguments> <argument name="catalogRule" defaultValue="_defaultCatalogRule"/> </arguments> - <click stepKey="addNewRule" selector="{{AdminGridMainControls.add}}"/> - <fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName"/> - <fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}" stepKey="fillDescription"/> - <selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="{{catalogRule.website_ids}}" stepKey="selectSite"/> + <fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{catalogRule.name}}" stepKey="fillName" /> + <click stepKey="selectActive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/> + <fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{catalogRule.description}}" stepKey="fillDescription" /> + <selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="{{catalogRule.website_ids}}" stepKey="selectSite" /> <click stepKey="openActionDropdown" selector="{{AdminNewCatalogPriceRule.actionsTab}}"/> <fillField stepKey="fillDiscountValue" selector="{{AdminNewCatalogPriceRuleActions.discountAmount}}" userInput="{{catalogRule.discount_amount}}"/> <scrollToTopOfPage stepKey="scrollToTop"/> + <click selector="{{AdminNewCatalogPriceRule.save}}" stepKey="clickSave"/> <waitForPageLoad stepKey="waitForApplied"/> </actionGroup> + <actionGroup name="AdminCreateCatalogPriceRuleWithConditionActionGroup" extends="createCatalogPriceRule"> + <arguments> + <argument name="catalogRuleType" type="entity" defaultValue="PriceRuleWithCondition"/> + </arguments> + <waitForPageLoad stepKey="waitForPageLoad" after="addNewRule"/> + <click selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="expandConditions" before="openActionDropdown"/> + <scrollTo selector="{{AdminNewCatalogPriceRule.conditionsTab}}" stepKey="scrollToConditionsTab" after="expandConditions"/> + <waitForElementVisible selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="waitForNewRule" after="scrollToConditionsTab"/> + <click selector="{{PriceRuleConditionsSection.createNewRule}}" stepKey="clickNewRule" after="waitForNewRule"/> + <selectOption selector="{{AdminNewCatalogPriceRuleConditions.conditionsDropdown}}" userInput="{{ProductAttributeFrontendLabel.label}}" stepKey="selectProductAttribute" after="clickNewRule"/> + <waitForPageLoad stepKey="waitForAttributeLoad" after="selectProductAttribute"/> + <!--Assert that attribute contains today date without time--> + <comment userInput="Assert that attribute contains today date without time" stepKey="assertDate" after="waitForAttributeLoad"/> + <generateDate date="now" format="Y-m-d" stepKey="today" after="assertDate"/> + <grabTextFrom selector="{{PriceRuleConditionsSection.firstProductAttributeSelected}}" stepKey="grabTextFromSelectedAttribute" after="today"/> + <assertEquals expected="$today" actual="$grabTextFromSelectedAttribute" stepKey="assertTodayDate" after="grabTextFromSelectedAttribute"/> + </actionGroup> + <actionGroup name="AdminCreateMultipleWebsiteCatalogPriceRule" extends="createCatalogPriceRule"> + <remove keyForRemoval="selectSite"/> + <selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="['FirstWebsite', 'SecondWebsite']" stepKey="selectWebsite"/> + </actionGroup> <actionGroup name="CreateCatalogPriceRuleViaTheUi"> <arguments> <argument name="catalogRule" defaultValue="_defaultCatalogRule"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminCatalogPriceRuleStagingSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminCatalogPriceRuleStagingSection.xml index bab9842caaa4..7a92829e2371 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminCatalogPriceRuleStagingSection.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminCatalogPriceRuleStagingSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminCatalogPriceRuleStagingSection"> <element name="status" type="select" selector=".modal-component [data-index='is_active'] select"/> + <element name="isActive" type="select" selector=".modals-wrapper input[name='is_active']+label"/> </section> </sections> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml index ba0493d8e995..c736dd8dde2c 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml @@ -20,8 +20,12 @@ <element name="ruleNameNew" type="input" selector="[name='staging[name]']"/> <element name="description" type="textarea" selector="[name='description']"/> <element name="status" type="select" selector="[name='is_active']"/> + <element name="isActive" type="select" selector="input[name='is_active']+label"/> <element name="websites" type="select" selector="[name='website_ids']"/> + <element name="active" type="checkbox" selector="//div[contains(@class, 'admin__actions-switch')]/input[@name='is_active']/../label"/> + <element name="activeIsEnabled" type="checkbox" selector="(//div[contains(@class, 'admin__actions-switch')])[1]/input[@value='1']"/> + <element name="activePosition" type="checkbox" selector="fieldset[class='admin__fieldset'] div[class*='_required']:nth-of-type(4)"/> <element name="websitesOptions" type="select" selector="[name='website_ids'] option"/> <element name="customerGroups" type="select" selector="[name='customer_group_ids']"/> <element name="customerGroupsOptions" type="select" selector="[name='customer_group_ids'] option"/> @@ -43,6 +47,7 @@ <section name="AdminNewCatalogPriceRuleConditions"> <element name="newCondition" type="button" selector=".rule-param.rule-param-new-child"/> + <element name="conditionsDropdown" type="select" selector="select[data-form-part='catalog_rule_form'][data-ui-id='newchild-0-select-rule-conditions-1-new-child']"/> <element name="conditionSelect" type="select" selector="select#conditions__{{var}}__new_child" parameterized="true"/> <element name="targetEllipsis" type="button" selector="//li[{{var}}]//a[@class='label'][text() = '...']" parameterized="true"/> <element name="targetEllipsisValue" type="button" selector="//ul[@id='conditions__{{var}}__children']//a[contains(text(), '{{var1}}')]" parameterized="true" timeout="30"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml index 741da96179b8..ca534ec7f537 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml @@ -52,6 +52,7 @@ <waitForPageLoad stepKey="waitForIndividualRulePage"/> <fillField selector="{{AdminNewCatalogPriceRule.ruleName}}" userInput="{{_defaultCatalogRule.name}}" stepKey="fillName"/> <fillField selector="{{AdminNewCatalogPriceRule.description}}" userInput="{{_defaultCatalogRule.description}}" stepKey="fillDescription"/> + <click stepKey="selectActive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/> <selectOption selector="{{AdminNewCatalogPriceRule.websites}}" userInput="{{_defaultCatalogRule.website_ids[0]}}" stepKey="selectSite"/> <click selector="{{AdminNewCatalogPriceRule.fromDateButton}}" stepKey="clickFromCalender"/> <click selector="{{AdminNewCatalogPriceRule.todayDate}}" stepKey="clickFromToday"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml index befe0b0ce7f9..09b924603c54 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml @@ -25,6 +25,10 @@ <requiredEntity createDataKey="createCategory"/> </createData> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!-- log in and create the price rule --> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <actionGroup stepKey="createNewPriceRule" ref="newCatalogPriceRuleByUI"/> @@ -150,6 +154,7 @@ <createData entity="ApiSimpleProduct" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> </createData> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> </before> <after> @@ -172,6 +177,10 @@ <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApply"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="assertSuccess"/> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!-- As a NOT LOGGED IN user, go to the storefront category page and should see the discount --> <amOnPage url="$$createCategory.name$$.html" stepKey="goToCategory1"/> <see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$$createProduct.name$$" stepKey="seeProduct1"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateInactiveCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateInactiveCatalogPriceRuleTest.xml index 5223b18df4e4..83dff1ecdcab 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateInactiveCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateInactiveCatalogPriceRuleTest.xml @@ -58,6 +58,7 @@ <argument name="websites" value="Main Website"/> <argument name="customerGroup" value="General"/> </actionGroup> + <dontSeeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="verifyInactiveRule"/> <!-- Search Catalog Rule in Grid --> <actionGroup ref="AdminSearchCatalogRuleInGridActionGroup" stepKey="searchCreatedCatalogRule"> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml index 06392764290a..ea5c2c33a0a3 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml @@ -154,6 +154,10 @@ <requiredEntity createDataKey="createConfigChildProduct2"/> </createData> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> <amOnPage url="{{AdminNewCatalogPriceRulePage.url}}" stepKey="openNewCatalogPriceRulePage"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml index b7a231df5045..dd54c0767e8e 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml @@ -195,6 +195,7 @@ Websites: Main Website Customer Groups: NOT LOGGED IN --> <fillField userInput="{{SimpleCatalogPriceRule.name}}" selector="{{AdminCartPriceRulesFormSection.ruleName}}" stepKey="fillRuleName"/> + <click stepKey="selectActive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/> <selectOption userInput="{{SimpleCatalogPriceRule.websites}}" selector="{{AdminCartPriceRulesFormSection.websites}}" stepKey="selectWebsite"/> <selectOption userInput="{{SimpleCatalogPriceRule.customerGroups}}" selector="{{AdminCartPriceRulesFormSection.customerGroups}}" stepKey="selectCustomerGroups"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductWithCustomOptionsTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductWithCustomOptionsTest.xml index 5b7e722c92a0..a251ee1e235d 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductWithCustomOptionsTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductWithCustomOptionsTest.xml @@ -77,63 +77,27 @@ <actionGroup ref="SaveAndApplyCatalogPriceRuleActionGroup" stepKey="saveAndApplyCatalogPriceRule"/> <magentoCLI command="indexer:reindex" stepKey="reindex"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> - + <!-- Navigate to category on store front --> <amOnPage url="{{StorefrontProductPage.url($createCategory.name$)}}" stepKey="goToCategoryPage"/> - - <!-- Check product 1 name on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct1Name"> - <argument name="productInfo" value="$createProduct1.name$"/> - <argument name="productNumber" value="3"/> - </actionGroup> <!-- Check product 1 price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct1Price"> - <argument name="productInfo" value="$51.10"/> - <argument name="productNumber" value="3"/> - </actionGroup> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct1.name$)}}" userInput="$51.10" stepKey="storefrontProduct1Price"/> <!-- Check product 1 regular price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct1RegularPrice"> - <argument name="productInfo" value="$56.78"/> - <argument name="productNumber" value="3"/> - </actionGroup> - - <!-- Check product 2 name on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct2Name"> - <argument name="productInfo" value="$createProduct2.name$"/> - <argument name="productNumber" value="2"/> - </actionGroup> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct1.name$)}}" userInput="$56.78" stepKey="storefrontProduct1RegularPrice"/> <!-- Check product 2 price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct2Price"> - <argument name="productInfo" value="$51.10"/> - <argument name="productNumber" value="2"/> - </actionGroup> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct2.name$)}}" userInput="$51.10" stepKey="storefrontProduct2Price"/> - <!-- Check product 2 price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct2RegularPrice"> - <argument name="productInfo" value="$56.78"/> - <argument name="productNumber" value="2"/> - </actionGroup> - - <!-- Check product 3 name on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct3Name"> - <argument name="productInfo" value="$createProduct3.name$"/> - <argument name="productNumber" value="1"/> - </actionGroup> + <!-- Check product 2 regular price on store front category page --> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct2.name$)}}" userInput="$56.78" stepKey="storefrontProduct2RegularPrice"/> <!-- Check product 3 price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct3Price"> - <argument name="productInfo" value="$51.10"/> - <argument name="productNumber" value="1"/> - </actionGroup> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct3.name$)}}" userInput="$51.10" stepKey="storefrontProduct3Price"/> <!-- Check product 3 regular price on store front category page --> - <actionGroup ref="AssertProductDetailsOnStorefrontActionGroup" stepKey="storefrontProduct3RegularPrice"> - <argument name="productInfo" value="$56.78"/> - <argument name="productNumber" value="1"/> - </actionGroup> + <see selector="{{StorefrontCategoryProductSection.ProductInfoByName($createProduct3.name$)}}" userInput="$56.78" stepKey="storefrontProduct3RegularPrice"/> <!-- Navigate to product 1 on store front --> <amOnPage url="{{StorefrontProductPage.url($createProduct1.name$)}}" stepKey="goToProductPage1"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml index b486654fe9ac..08e59c631641 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml @@ -26,9 +26,14 @@ </createData> <actionGroup stepKey="createNewPriceRule" ref="newCatalogPriceRuleByUI"/> <actionGroup stepKey="selectLoggedInCustomers" ref="selectNotLoggedInCustomerGroup"/> - <selectOption selector="{{AdminNewCatalogPriceRule.status}}" userInput="Inactive" stepKey="setInactive"/> + <scrollToTopOfPage stepKey="scrollToTop"/> + <click stepKey="setInactive" selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}"/> <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApply"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="seeSuccess"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData createDataKey="createProduct" stepKey="deleteSimpleProduct"/> diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml index c114f6b1d77c..2af8bb0770b2 100644 --- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml +++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml @@ -95,33 +95,30 @@ <dataScope>description</dataScope> </settings> </field> - <field name="is_active" formElement="select"> + <field name="is_active" formElement="checkbox"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="source" xsi:type="string">catalog_rule</item> + <item name="default" xsi:type="number">0</item> </item> </argument> <settings> - <dataType>number</dataType> - <label translate="true">Status</label> - <visible>true</visible> - <dataScope>is_active</dataScope> + <validation> + <rule name="required-entry" xsi:type="boolean">true</rule> + </validation> + <dataType>boolean</dataType> + <label translate="true">Active</label> </settings> <formElements> - <select> + <checkbox> <settings> - <options> - <option name="0" xsi:type="array"> - <item name="value" xsi:type="number">1</item> - <item name="label" xsi:type="string" translate="true">Active</item> - </option> - <option name="1" xsi:type="array"> - <item name="value" xsi:type="number">0</item> - <item name="label" xsi:type="string" translate="true">Inactive</item> - </option> - </options> + <valueMap> + <map name="false" xsi:type="number">0</map> + <map name="true" xsi:type="number">1</map> + </valueMap> + <prefer>toggle</prefer> </settings> - </select> + </checkbox> </formElements> </field> <field name="website_ids" formElement="multiselect"> diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php index 09d4f0068459..cd2529a8fd72 100644 --- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProvider.php @@ -7,14 +7,9 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; -use Magento\CatalogInventory\Api\Data\StockStatusInterface; -use Magento\CatalogInventory\Api\StockConfigurationInterface; -use Magento\CatalogInventory\Api\StockStatusCriteriaInterface; -use Magento\CatalogInventory\Api\StockStatusRepositoryInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Select; use Magento\Store\Model\Store; -use Magento\Framework\App\ObjectManager; /** * Catalog search full test search data provider. @@ -129,16 +124,6 @@ class DataProvider */ private $antiGapMultiplier; - /** - * @var StockConfigurationInterface - */ - private $stockConfiguration; - - /** - * @var StockStatusRepositoryInterface - */ - private $stockStatusRepository; - /** * @param ResourceConnection $resource * @param \Magento\Catalog\Model\Product\Type $catalogProductType @@ -563,8 +548,6 @@ public function prepareProductIndex($indexData, $productData, $storeId) { $index = []; - $indexData = $this->filterOutOfStockProducts($indexData, $storeId); - foreach ($this->getSearchableAttributes('static') as $attribute) { $attributeCode = $attribute->getAttributeCode(); @@ -689,68 +672,4 @@ private function filterAttributeValue($value) { return preg_replace('/\s+/iu', ' ', trim(strip_tags($value))); } - - /** - * Filter out of stock products for products. - * - * @param array $indexData - * @param int $storeId - * @return array - */ - private function filterOutOfStockProducts($indexData, $storeId): array - { - if (!$this->getStockConfiguration()->isShowOutOfStock($storeId)) { - $productIds = array_keys($indexData); - $stockStatusCriteria = $this->createStockStatusCriteria(); - $stockStatusCriteria->setProductsFilter($productIds); - $stockStatusCollection = $this->getStockStatusRepository()->getList($stockStatusCriteria); - $stockStatuses = $stockStatusCollection->getItems(); - $stockStatuses = array_filter( - $stockStatuses, - function (StockStatusInterface $stockStatus) { - return StockStatusInterface::STATUS_IN_STOCK == $stockStatus->getStockStatus(); - } - ); - $indexData = array_intersect_key($indexData, $stockStatuses); - } - return $indexData; - } - - /** - * Get stock configuration. - * - * @return StockConfigurationInterface - */ - private function getStockConfiguration() - { - if (null === $this->stockConfiguration) { - $this->stockConfiguration = ObjectManager::getInstance()->get(StockConfigurationInterface::class); - } - return $this->stockConfiguration; - } - - /** - * Create stock status criteria. - * - * Substitution of autogenerated factory in backward compatibility reasons. - * - * @return StockStatusCriteriaInterface - */ - private function createStockStatusCriteria() - { - return ObjectManager::getInstance()->create(StockStatusCriteriaInterface::class); - } - - /** - * Get stock status repository. - * - * @return StockStatusRepositoryInterface - */ - private function getStockStatusRepository() - { - if (null === $this->stockStatusRepository) { - $this->stockStatusRepository = ObjectManager::getInstance()->get(StockStatusRepositoryInterface::class); - } - return $this->stockStatusRepository; - } } diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php b/app/code/Magento/CatalogSearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php new file mode 100644 index 000000000000..02e48c5d8a1c --- /dev/null +++ b/app/code/Magento/CatalogSearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php @@ -0,0 +1,91 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogSearch\Model\Indexer\Plugin; + +use Magento\CatalogInventory\Api\StockConfigurationInterface; +use Magento\CatalogInventory\Api\StockStatusRepositoryInterface; +use Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory; +use Magento\CatalogInventory\Api\Data\StockStatusInterface; +use Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider; + +/** + * Plugin for filtering child products that are out of stock for preventing their saving to catalog search index. + * + * This plugin reverts changes introduced in commit 9ab466d8569ea556cb01393989579c3aac53d9a3 which break extensions + * relying on stocks. Plugin location is changed for consistency purposes. + */ +class StockedProductsFilterPlugin +{ + /** + * @var StockConfigurationInterface + */ + private $stockConfiguration; + + /** + * @var StockStatusRepositoryInterface + */ + private $stockStatusRepository; + + /** + * @var StockStatusCriteriaInterfaceFactory + */ + private $stockStatusCriteriaFactory; + + /** + * @param StockConfigurationInterface $stockConfiguration + * @param StockStatusRepositoryInterface $stockStatusRepository + * @param StockStatusCriteriaInterfaceFactory $stockStatusCriteriaFactory + */ + public function __construct( + StockConfigurationInterface $stockConfiguration, + StockStatusRepositoryInterface $stockStatusRepository, + StockStatusCriteriaInterfaceFactory $stockStatusCriteriaFactory + ) { + $this->stockConfiguration = $stockConfiguration; + $this->stockStatusRepository = $stockStatusRepository; + $this->stockStatusCriteriaFactory = $stockStatusCriteriaFactory; + } + + /** + * Filter out of stock options for configurable product. + * + * @param DataProvider $dataProvider + * @param array $indexData + * @param array $productData + * @param int $storeId + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforePrepareProductIndex( + DataProvider $dataProvider, + array $indexData, + array $productData, + int $storeId + ): array { + if (!$this->stockConfiguration->isShowOutOfStock($storeId)) { + $productIds = array_keys($indexData); + $stockStatusCriteria = $this->stockStatusCriteriaFactory->create(); + $stockStatusCriteria->setProductsFilter($productIds); + $stockStatusCollection = $this->stockStatusRepository->getList($stockStatusCriteria); + $stockStatuses = $stockStatusCollection->getItems(); + $stockStatuses = array_filter( + $stockStatuses, + function (StockStatusInterface $stockStatus) { + return StockStatusInterface::STATUS_IN_STOCK == $stockStatus->getStockStatus(); + } + ); + $indexData = array_intersect_key($indexData, $stockStatuses); + } + + return [ + $indexData, + $productData, + $storeId, + ]; + } +} diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php index edc65490a3c6..51879a3dcfa4 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Advanced/Collection.php @@ -125,7 +125,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param Product\OptionFactory $productOptionFactory @@ -160,7 +160,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php index 14305359a71b..f11ddb3a3d6b 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php @@ -146,7 +146,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -185,7 +185,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php index 6cdcc7c55a26..e625ccbe51fe 100644 --- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php +++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Search/Collection.php @@ -50,7 +50,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -74,7 +74,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontFillFormAdvancedSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontFillFormAdvancedSearchActionGroup.xml new file mode 100644 index 000000000000..1afdb6e5e46f --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontFillFormAdvancedSearchActionGroup.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontFillFormAdvancedSearchActionGroup"> + <arguments> + <argument name="productName" type="string" defaultValue=""/> + <argument name="sku" type="string" defaultValue=""/> + <argument name="description" type="string" defaultValue=""/> + <argument name="short_description" type="string" defaultValue=""/> + <argument name="price_from" type="string" defaultValue=""/> + <argument name="price_to" type="string" defaultValue=""/> + </arguments> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.ProductName}}" userInput="{{productName}}" stepKey="fillName"/> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.SKU}}" userInput="{{sku}}" stepKey="fillSku"/> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.Description}}" userInput="{{description}}" stepKey="fillDescription"/> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.ShortDescription}}" userInput="{{short_description}}" stepKey="fillShortDescription"/> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceFrom}}" userInput="{{price_from}}" stepKey="fillPriceFrom"/> + <fillField selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceTo}}" userInput="{{price_to}}" stepKey="fillPriceTo"/> + <click selector="{{StorefrontCatalogSearchAdvancedFormSection.SubmitButton}}" stepKey="clickSubmit"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchAdvancedResultMainSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchAdvancedResultMainSection.xml index 6b28b4f36c6a..eb3bc8e79d7b 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchAdvancedResultMainSection.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchAdvancedResultMainSection.xml @@ -17,5 +17,6 @@ <element name="message" type="text" selector="div.message div"/> <element name="itemFound" type="text" selector=".search.found>strong"/> <element name="productName" type="text" selector=".product.name.product-item-name>a"/> + <element name="nthProductName" type="text" selector="li.product-item:nth-of-type({{var1}}) .product-item-name>a" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml index 13665100f79a..0e92d9fb0c7a 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml @@ -13,6 +13,11 @@ <features value="CatalogSearch"/> <group value="CatalogSearch"/> </annotations> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroup"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameActionGroup" stepKey="search"> <argument name="name" value="$$product.name$$"/> @@ -26,6 +31,11 @@ <features value="CatalogSearch"/> <group value="CatalogSearch"/> </annotations> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroup"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByProductSkuActionGroup" stepKey="search"> <argument name="sku" value="$$product.sku$$"/> @@ -39,6 +49,10 @@ <features value="CatalogSearch"/> <group value="CatalogSearch"/> </annotations> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroup"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByDescriptionActionGroup" stepKey="search"> <argument name="description" value="$$product.custom_attributes[description]$$"/> @@ -52,6 +66,11 @@ <features value="CatalogSearch"/> <group value="CatalogSearch"/> </annotations> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroup"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByShortDescriptionActionGroup" stepKey="search"> <argument name="shortDescription" value="$$product.custom_attributes[short_description]$$"/> @@ -65,6 +84,11 @@ <features value="CatalogSearch"/> <group value="CatalogSearch"/> </annotations> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroup"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndPriceActionGroup" stepKey="search"> <argument name="name" value="$$arg1.name$$"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml index 99f3fc00a740..aa7cf933f632 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml @@ -9,6 +9,72 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="EndToEndB2CGuestUserTest"> + <!-- Step 2: User searches for product --> + <comment userInput="Start of searching products" stepKey="startOfSearchingProducts" after="endOfBrowsingCatalog"/> + <!-- Advanced Search with Product Data --> + <comment userInput="Advanced search" stepKey="commentAdvancedSearch" after="startOfSearchingProducts"/> + <actionGroup ref="StorefrontOpenAdvancedSearchActionGroup" stepKey="searchOpenAdvancedSearchForm" after="commentAdvancedSearch"/> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <fillField userInput="$$createSimpleProduct1.name$$" selector="{{StorefrontCatalogSearchAdvancedFormSection.ProductName}}" stepKey="searchAdvancedFillProductName" after="searchOpenAdvancedSearchForm"/> + <fillField userInput="$$createSimpleProduct1.sku$$" selector="{{StorefrontCatalogSearchAdvancedFormSection.SKU}}" stepKey="searchAdvancedFillSKU" after="searchAdvancedFillProductName"/> + <fillField userInput="$$createSimpleProduct1.price$$" selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceFrom}}" stepKey="searchAdvancedFillPriceFrom" after="searchAdvancedFillSKU"/> + <fillField userInput="$$createSimpleProduct1.price$$" selector="{{StorefrontCatalogSearchAdvancedFormSection.PriceTo}}" stepKey="searchAdvancedFillPriceTo" after="searchAdvancedFillPriceFrom"/> + <click selector="{{StorefrontCatalogSearchAdvancedFormSection.SubmitButton}}" stepKey="searchClickAdvancedSearchSubmitButton" after="searchAdvancedFillPriceTo"/> + <waitForLoadingMaskToDisappear stepKey="waitForSearchProductsloaded" after="searchClickAdvancedSearchSubmitButton"/> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="searchCheckAdvancedSearchResult" after="waitForSearchProductsloaded"/> + <see userInput="4" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.productCount}} span" stepKey="searchAdvancedAssertProductCount" after="searchCheckAdvancedSearchResult"/> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="searchAssertSimpleProduct1" after="searchAdvancedAssertProductCount"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="searchAdvancedGrabSimpleProduct1ImageSrc" after="searchAssertSimpleProduct1"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$searchAdvancedGrabSimpleProduct1ImageSrc" stepKey="searchAdvancedAssertSimpleProduct1ImageNotDefault" after="searchAdvancedGrabSimpleProduct1ImageSrc"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct1.name$$)}}" stepKey="searchClickSimpleProduct1View" after="searchAdvancedAssertSimpleProduct1ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForSearchSimpleProduct1Viewloaded" after="searchClickSimpleProduct1View"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="searchAssertSimpleProduct1Page" after="waitForSearchSimpleProduct1Viewloaded"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="searchAdvancedGrabSimpleProduct1PageImageSrc" after="searchAssertSimpleProduct1Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$searchAdvancedGrabSimpleProduct1PageImageSrc" stepKey="searchAdvancedAssertSimpleProduct1PageImageNotDefault" after="searchAdvancedGrabSimpleProduct1PageImageSrc"/> + + <!-- Quick Search with common part of product names --> + <comment userInput="Quick search" stepKey="commentQuickSearch" after="searchAdvancedAssertSimpleProduct1PageImageNotDefault"/> + <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="searchQuickSearchCommonPart" after="commentQuickSearch"> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="phrase" value="CONST.apiSimpleProduct"/> + </actionGroup> + <actionGroup ref="StorefrontSelectSearchFilterCategoryActionGroup" stepKey="searchSelectFilterCategoryCommonPart" after="searchQuickSearchCommonPart"> + <argument name="category" value="$$createCategory$$"/> + </actionGroup> + <see userInput="3" selector="{{StorefrontCategoryMainSection.productCount}} span" stepKey="searchAssertFilterCategoryProductCountCommonPart" after="searchSelectFilterCategoryCommonPart"/> + + <!-- Search simple product 1 --> + <comment userInput="Search simple product 1" stepKey="commentSearchSimpleProduct1" after="searchAssertFilterCategoryProductCountCommonPart"/> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="searchAssertFilterCategorySimpleProduct1" after="commentSearchSimpleProduct1"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="searchGrabSimpleProduct1ImageSrc" after="searchAssertFilterCategorySimpleProduct1"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$searchGrabSimpleProduct1ImageSrc" stepKey="searchAssertSimpleProduct1ImageNotDefault" after="searchGrabSimpleProduct1ImageSrc"/> + <!-- Search simple product2 --> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="searchAssertFilterCategorySimpleProduct2" after="searchAssertSimpleProduct1ImageNotDefault"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="searchGrabSimpleProduct2ImageSrc" after="searchAssertFilterCategorySimpleProduct2"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$searchGrabSimpleProduct2ImageSrc" stepKey="searchAssertSimpleProduct2ImageNotDefault" after="searchGrabSimpleProduct2ImageSrc"/> + + <!-- Quick Search with non-existent product name --> + <comment userInput="Quick Search with non-existent product name" stepKey="commentQuickSearchWithNonExistentProductName" after="searchAssertSimpleProduct2ImageNotDefault" /> + <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="searchFillQuickSearchNonExistent" after="commentQuickSearchWithNonExistentProductName"> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="phrase" value="CONST.nonexistentProductName"/> + </actionGroup> + <see userInput="Your search returned no results." selector="{{StorefrontCatalogSearchMainSection.message}}" stepKey="searchAssertQuickSearchMessageNonExistent" after="searchFillQuickSearchNonExistent"/> + <comment userInput="End of searching products" stepKey="endOfSearchingProducts" after="searchAssertQuickSearchMessageNonExistent" /> + </test> + <test name="EndToEndB2CGuestUserMysqlTest"> <!-- Step 2: User searches for product --> <comment userInput="Start of searching products" stepKey="startOfSearchingProducts" after="endOfBrowsingCatalog"/> <!-- Advanced Search with Product 1 Data --> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/LayerNavigationOfCatalogSearchTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/LayerNavigationOfCatalogSearchTest.xml index 210b474af2e0..c8f84c732d6b 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/LayerNavigationOfCatalogSearchTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/LayerNavigationOfCatalogSearchTest.xml @@ -57,6 +57,10 @@ <fillField selector="{{AdminProductAttributeSection.customAttribute($$createPriceAttribute.attribute_code$$)}}" userInput="70" stepKey="fillCustomPrice2"/> <click selector="{{AdminProductFormSection.save}}" stepKey="clickSaveButton2"/> <waitForPageLoad stepKey="waitForSimpleProductSaved2"/> + + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Navigate to category on Storefront--> <comment userInput="Navigate to category on Storefront" stepKey="comment3"/> <amOnPage url="{{StorefrontCategoryPage.url($$subCategory.name$$)}}" stepKey="goToCategoryStorefront"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/MinimalQueryLengthForCatalogSearchTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/MinimalQueryLengthForCatalogSearchTest.xml index b6417e12a6db..89269a1ad0d9 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/MinimalQueryLengthForCatalogSearchTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/MinimalQueryLengthForCatalogSearchTest.xml @@ -18,6 +18,7 @@ <testCaseId value="MC-6325"/> <useCaseId value="MAGETWO-58764"/> <group value="CatalogSearch"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiCategory" stepKey="createCategory"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml index 19db201e91f4..90b13bd1b6b4 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml @@ -23,6 +23,10 @@ <createData entity="_defaultProduct" stepKey="createSimpleProduct"> <requiredEntity createDataKey="createCategory"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteProduct" createDataKey="createSimpleProduct"/> @@ -87,6 +91,10 @@ <createData entity="_defaultProduct" stepKey="createSimpleProduct"> <requiredEntity createDataKey="createCategory"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteProduct" createDataKey="createSimpleProduct"/> @@ -124,6 +132,7 @@ <severity value="MAJOR"/> <testCaseId value="MC-15034"/> <group value="CatalogSearch"/> + <group value="SearchEngineMysql"/> <group value="mtf_migrated"/> </annotations> <executeJS function="var s = '$createSimpleProduct.name$'; var ret=s.substring(0,3); return ret;" stepKey="getFirstThreeLetters" before="searchStorefront"/> @@ -160,6 +169,7 @@ <severity value="MAJOR"/> <testCaseId value="MC-14796"/> <group value="CatalogSearch"/> + <group value="SearchEngineMysql"/> <group value="mtf_migrated"/> </annotations> <before> @@ -242,6 +252,7 @@ <severity value="MAJOR"/> <testCaseId value="MC-14797"/> <group value="CatalogSearch"/> + <group value="SearchEngineMysql"/> <group value="mtf_migrated"/> </annotations> <before> @@ -272,6 +283,9 @@ <testCaseId value="MC-14784"/> <group value="CatalogSearch"/> <group value="mtf_migrated"/> + <skip> + <issueId value="MC-21717"/> + </skip> </annotations> <before> <createData entity="_defaultCategory" stepKey="createCategory"/> @@ -306,6 +320,10 @@ <createData entity="VirtualProduct" stepKey="createVirtualProduct"> <requiredEntity createDataKey="createCategory"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteProduct" createDataKey="createVirtualProduct"/> @@ -336,6 +354,10 @@ <argument name="product" value="_defaultProduct"/> <argument name="category" value="$$createCategory$$"/> </actionGroup> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteCategory" createDataKey="createCategory"/> @@ -368,6 +390,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="DownloadableProductWithOneLink" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> @@ -375,8 +398,13 @@ <createData entity="downloadableLink1" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="createProduct"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <deleteData stepKey="deleteProduct" createDataKey="createProduct"/> <deleteData stepKey="deleteCategory" createDataKey="createCategory"/> </after> @@ -405,6 +433,10 @@ <requiredEntity createDataKey="createProduct"/> <requiredEntity createDataKey="simple1"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteProduct" createDataKey="createProduct"/> @@ -450,6 +482,10 @@ <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <amOnPage url="{{AdminProductEditPage.url($$createBundleProduct.id$$)}}" stepKey="goToProductEditPage"/> <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteBundleProduct" createDataKey="createBundleProduct"/> @@ -512,6 +548,10 @@ <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <amOnPage url="{{AdminProductEditPage.url($$createBundleProduct.id$$)}}" stepKey="goToProductEditPage"/> <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData stepKey="deleteBundleProduct" createDataKey="createBundleProduct"/> @@ -601,6 +641,10 @@ <requiredEntity createDataKey="createConfigProduct"/> <requiredEntity createDataKey="createConfigChildProduct1"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToFrontPage"/> <actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="searchStorefront"> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByAllParametersTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByAllParametersTest.xml new file mode 100644 index 000000000000..9ad868ff6db7 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByAllParametersTest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByAllParametersTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by name, sku, description, short description, price from and price to"/> + <description value="Search product in advanced search by name, sku, description, short description, price from and price to"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="$$createProduct.name$$"/> + <argument name="sku" value="abc_dfj"/> + <argument name="description" value="adc_Full"/> + <argument name="short_description" value="abc_short"/> + <argument name="price_to" value="500"/> + <argument name="price_from" value="49"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByDescriptionTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByDescriptionTest.xml new file mode 100644 index 000000000000..5693721e6ed6 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByDescriptionTest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByDescriptionTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by description"/> + <description value="Search product in advanced search by description"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="ABC_123_SimpleProduct" stepKey="createProduct"/> + </before> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="description" value="dfj_full"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameSkuDescriptionPriceTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameSkuDescriptionPriceTest.xml new file mode 100644 index 000000000000..4d3ba22f7935 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameSkuDescriptionPriceTest.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByNameSkuDescriptionPriceTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by name, sku, description, short description, price from 49 and price to 50"/> + <description value="Search product in advanced search by name, sku, description, short description, price from 49 and price to 50"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="$$createProduct.name$$"/> + <argument name="sku" value="abc_dfj"/> + <argument name="description" value="adc_Full"/> + <argument name="short_description" value="abc_short"/> + <argument name="price_to" value="50"/> + <argument name="price_from" value="49"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameTest.xml new file mode 100644 index 000000000000..f0b81e08252f --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByNameTest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + --> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByNameTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by name"/> + <description value="Search product in advanced search by name"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="ABC_123_SimpleProduct" stepKey="createProduct"/> + </before> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialNameTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialNameTest.xml new file mode 100644 index 000000000000..f875021bd966 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialNameTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPartialNameTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by partial name"/> + <description value="Search product in advanced search by partial name"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + <group value="SearchEngineMysql"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="abc"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialShortDescriptionTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialShortDescriptionTest.xml new file mode 100644 index 000000000000..0edc3f31216b --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialShortDescriptionTest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPartialShortDescriptionTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by partial short description"/> + <description value="Search product in advanced search by partial short description"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="short_description" value="abc_short"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuAndDescriptionTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuAndDescriptionTest.xml new file mode 100644 index 000000000000..b2b4ef9cc478 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuAndDescriptionTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPartialSkuAndDescriptionTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by partial sku and description"/> + <description value="Search product in advanced search by partial sku and description"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="sku" value="abc"/> + <argument name="description" value="adc_full"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuTest.xml new file mode 100644 index 000000000000..45cec0a89936 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPartialSkuTest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPartialSkuTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by partial sku"/> + <description value="Search product in advanced search by partial sku"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="sku" value="abc"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceFromAndPriceToTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceFromAndPriceToTest.xml new file mode 100644 index 000000000000..6b85cdf61c84 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceFromAndPriceToTest.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPriceFromAndPriceToTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by price from and price to"/> + <description value="Search product in advanced search by price from and price to"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="price_to" value="50"/> + <argument name="price_from" value="50"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml new file mode 100644 index 000000000000..755bb92c897e --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByPriceToTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by price to"/> + <description value="Search product in advanced search by price to"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="ABC_123_SimpleProduct" stepKey="createProduct2" after="createProduct"/> + </before> + <after> + <deleteData createDataKey="createProduct2" stepKey="deleteProduct2" after="deleteProduct"/> + </after> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="price_to" value="100"/> + </actionGroup> + <see userInput="2 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$createProduct2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.productName}}" stepKey="seeProduct2Name" after="seeProductName"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByShortDescriptionTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByShortDescriptionTest.xml new file mode 100644 index 000000000000..c4622d02a515 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByShortDescriptionTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchByShortDescriptionTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by short description"/> + <description value="Search product in advanced search by short description"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <remove keyForRemoval="createProduct"/> + <remove keyForRemoval="deleteProduct"/> + <remove keyForRemoval="seeProductName"/> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="short_description" value="dfj_short"/> + </actionGroup> + <see userInput="We can't find any items matching these search criteria. Modify your search." selector="{{StorefrontQuickSearchResultsSection.messageSection}}" stepKey="see"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchBySkuTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchBySkuTest.xml new file mode 100644 index 000000000000..ca5e23709968 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchBySkuTest.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchBySkuTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Search product in advanced search by sku"/> + <description value="Search product in advanced search by sku"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="sku" value="abc_dfj"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml new file mode 100644 index 000000000000..78110b531be3 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Use Advanced Search to Find the Product"/> + <description value="Use Advanced Search to Find the Product"/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-12421"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create Data --> + <createData entity="ABC_dfj_SimpleProduct" stepKey="createProduct"/> + </before> + <after> + <!-- Delete data --> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + </after> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + + <!-- 1. Navigate to Frontend --> + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStorefront"/> + + <!-- 2. Click "Advanced Search" --> + <actionGroup ref="StorefrontOpenAdvancedSearchActionGroup" stepKey="openAdvancedSearch"/> + + <!-- 3. Fill test data in to field(s) 4. Click "Search" button--> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="$$createProduct.name$$"/> + <argument name="sku" value="abc_dfj"/> + </actionGroup> + + <!-- 5. Perform all asserts --> + <actionGroup ref="StorefrontCheckAdvancedSearchResultActionGroup" stepKey="StorefrontCheckAdvancedSearchResult"/> + <see userInput="1 item" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$createProduct.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.productName}}" stepKey="seeProductName"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchNegativeProductSearchTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchNegativeProductSearchTest.xml new file mode 100644 index 000000000000..b4f2314295a0 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchNegativeProductSearchTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchNegativeProductSearchTest" extends="StorefrontAdvancedSearchEntitySimpleProductTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Negative product search"/> + <description value="Negative product search"/> + <testCaseId value="MAGETWO-24729"/> + <severity value="CRITICAL"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <remove keyForRemoval="createProduct"/> + <remove keyForRemoval="deleteProduct"/> + <remove keyForRemoval="seeProductName"/> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"> + <argument name="productName" value="Negative_product_search"/> + </actionGroup> + <see userInput="We can't find any items matching these search criteria. Modify your search." selector="{{StorefrontQuickSearchResultsSection.messageSection}}" stepKey="see"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchWithoutEnteringDataTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchWithoutEnteringDataTest.xml new file mode 100644 index 000000000000..8a29ab718bd2 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchWithoutEnteringDataTest.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvancedSearchWithoutEnteringDataTest"> + <annotations> + <stories value="Use Advanced Search"/> + <title value="Do Advanced Search without entering data"/> + <description value="'Enter a search term and try again.' error message is missed in Advanced Search"/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-14859"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <!-- 1. Navigate to Frontend --> + <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToStorefront"/> + + <!-- 2. Click "Advanced Search" --> + <actionGroup ref="StorefrontOpenAdvancedSearchActionGroup" stepKey="openAdvancedSearch"/> + + <!-- 3. Fill test data in to field(s) 4. Click "Search" button--> + <actionGroup ref="StorefrontFillFormAdvancedSearchActionGroup" stepKey="search"/> + + <!-- 5. Perform all asserts --> + <see userInput="Enter a search term and try again." selector="{{StorefrontQuickSearchResultsSection.messageSection}}" stepKey="see"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php new file mode 100644 index 000000000000..b9909ec2c74b --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php @@ -0,0 +1,122 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogSearch\Test\Unit\Model\Indexer\Plugin; + +use Magento\CatalogSearch\Model\Indexer\Plugin\StockedProductsFilterPlugin; +use Magento\CatalogInventory\Api\StockConfigurationInterface; +use Magento\CatalogInventory\Api\StockStatusRepositoryInterface; +use Magento\CatalogInventory\Api\StockStatusCriteriaInterfaceFactory; +use Magento\CatalogInventory\Api\StockStatusCriteriaInterface; +use Magento\CatalogInventory\Api\Data\StockStatusCollectionInterface; +use Magento\CatalogInventory\Api\Data\StockStatusInterface; +use Magento\CatalogInventory\Model\Stock; +use Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider; + +/** + * Test for Magento\CatalogSearch\Model\Indexer\Plugin\StockedProductsFilterPlugin class. + * + * This plugin reverts changes introduced in commit 9ab466d8569ea556cb01393989579c3aac53d9a3 which break extensions + * relying on stocks. Plugin location is changed for consistency purposes. + */ +class StockedProductsFilterPluginTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $stockConfigurationMock; + + /** + * @var StockStatusRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $stockStatusRepositoryMock; + + /** + * @var StockStatusCriteriaInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $stockStatusCriteriaFactoryMock; + + /** + * @var StockedProductsFilterPlugin + */ + private $plugin; + + /** + * {@inheritdoc} + */ + protected function setUp() + { + $this->stockConfigurationMock = $this->getMockBuilder(StockConfigurationInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->stockStatusRepositoryMock = $this->getMockBuilder(StockStatusRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->stockStatusCriteriaFactoryMock = $this->getMockBuilder(StockStatusCriteriaInterfaceFactory::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->plugin = new StockedProductsFilterPlugin( + $this->stockConfigurationMock, + $this->stockStatusRepositoryMock, + $this->stockStatusCriteriaFactoryMock + ); + } + + /** + * @return void + */ + public function testBeforePrepareProductIndex(): void + { + /** @var DataProvider|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */ + $dataProviderMock = $this->getMockBuilder(DataProvider::class)->disableOriginalConstructor()->getMock(); + $indexData = [ + 1 => [], + 2 => [], + ]; + $productData = []; + $storeId = 1; + + $this->stockConfigurationMock + ->expects($this->once()) + ->method('isShowOutOfStock') + ->willReturn(false); + + $stockStatusCriteriaMock = $this->getMockBuilder(StockStatusCriteriaInterface::class)->getMock(); + $stockStatusCriteriaMock + ->expects($this->once()) + ->method('setProductsFilter') + ->willReturn(true); + $this->stockStatusCriteriaFactoryMock + ->expects($this->once()) + ->method('create') + ->willReturn($stockStatusCriteriaMock); + + $stockStatusMock = $this->getMockBuilder(StockStatusInterface::class)->getMock(); + $stockStatusMock->expects($this->atLeastOnce()) + ->method('getStockStatus') + ->willReturnOnConsecutiveCalls(Stock::STOCK_IN_STOCK, Stock::STOCK_OUT_OF_STOCK); + $stockStatusCollectionMock = $this->getMockBuilder(StockStatusCollectionInterface::class)->getMock(); + $stockStatusCollectionMock + ->expects($this->once()) + ->method('getItems') + ->willReturn([1 => $stockStatusMock, 2 => $stockStatusMock]); + $this->stockStatusRepositoryMock + ->expects($this->once()) + ->method('getList') + ->willReturn($stockStatusCollectionMock); + + list ($indexData, $productData, $storeId) = $this->plugin->beforePrepareProductIndex( + $dataProviderMock, + $indexData, + $productData, + $storeId + ); + + $this->assertEquals([1], array_keys($indexData)); + } +} diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php new file mode 100644 index 000000000000..881c843ecf92 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogSearch\Test\Unit\Ui\DataProvider\Product; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\CatalogSearch\Model\ResourceModel\Search\Collection as SearchCollection; +use Magento\Framework\Data\Collection; +use Magento\CatalogSearch\Ui\DataProvider\Product\AddFulltextFilterToCollection; + +class AddFulltextFilterToCollectionTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var SearchCollection|\PHPUnit_Framework_MockObject_MockObject + */ + private $searchCollection; + + /** + * @var Collection|\PHPUnit_Framework_MockObject_MockObject + */ + private $collection; + + /** + * @var ObjectManagerHelper + */ + private $objectManager; + + /** + * @var AddFulltextFilterToCollection + */ + private $model; + + protected function setUp() + { + $this->objectManager = new ObjectManagerHelper($this); + + $this->searchCollection = $this->getMockBuilder(SearchCollection::class) + ->setMethods(['addBackendSearchFilter', 'load', 'getAllIds']) + ->disableOriginalConstructor() + ->getMock(); + $this->searchCollection->expects($this->any()) + ->method('load') + ->willReturnSelf(); + $this->collection = $this->getMockBuilder(Collection::class) + ->setMethods(['addIdFilter']) + ->disableOriginalConstructor() + ->getMock(); + + $this->model = $this->objectManager->getObject( + AddFulltextFilterToCollection::class, + [ + 'searchCollection' => $this->searchCollection + ] + ); + } + + public function testAddFilter() + { + $this->searchCollection->expects($this->once()) + ->method('addBackendSearchFilter') + ->with('test'); + $this->searchCollection->expects($this->once()) + ->method('getAllIds') + ->willReturn([]); + $this->collection->expects($this->once()) + ->method('addIdFilter') + ->with(-1); + $this->model->addFilter($this->collection, 'test', ['fulltext' => 'test']); + } +} diff --git a/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php index f312178e0bf0..af5020a2f8c9 100644 --- a/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php +++ b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php @@ -40,6 +40,10 @@ public function addFilter(Collection $collection, $field, $condition = null) if (isset($condition['fulltext']) && (string)$condition['fulltext'] !== '') { $this->searchCollection->addBackendSearchFilter($condition['fulltext']); $productIds = $this->searchCollection->load()->getAllIds(); + if (empty($productIds)) { + //add dummy id to prevent returning full unfiltered collection + $productIds = -1; + } $collection->addIdFilter($productIds); } } diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml index da0a60dad1f7..372b389c545e 100644 --- a/app/code/Magento/CatalogSearch/etc/di.xml +++ b/app/code/Magento/CatalogSearch/etc/di.xml @@ -374,4 +374,7 @@ </argument> </arguments> </type> + <type name="Magento\CatalogSearch\Model\Indexer\Fulltext\Action\DataProvider"> + <plugin name="stockedProductsFilterPlugin" type="Magento\CatalogSearch\Model\Indexer\Plugin\StockedProductsFilterPlugin"/> + </type> </config> diff --git a/app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml b/app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml index c63e6ff4abe0..32b26eec9dbe 100644 --- a/app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml +++ b/app/code/Magento/CatalogSearch/view/frontend/templates/result.phtml @@ -3,6 +3,9 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +/** This changes need to valid applying filters and configuration before search process is started. */ +$productList = $block->getProductListHtml(); ?> <?php if ($block->getResultCount()) : ?> <?= /* @noEscape */ $block->getChildHtml('tagged_product_list_rss_link') ?> @@ -16,7 +19,7 @@ </div> </div> <?php endif; ?> - <?= $block->getProductListHtml() ?> + <?= /* @noEscape */ $productList ?> </div> <?php else : ?> diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php b/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php index edca633fb14c..d9e9705ac039 100644 --- a/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php +++ b/app/code/Magento/CatalogUrlRewrite/Model/Storage/DynamicStorage.php @@ -148,7 +148,7 @@ private function getCategoryUrlSuffix($storeId = null): string CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX, ScopeInterface::SCOPE_STORE, $storeId - ); + ) ?? ''; } /** diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php index 704b60a8aaf2..b1dfa79373a0 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php @@ -23,7 +23,6 @@ use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Exception\NoSuchEntityException; use Magento\ImportExport\Model\Import as ImportExport; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; @@ -252,7 +251,7 @@ public function execute(Observer $observer) * @throws LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function _populateForUrlGeneration($rowData) + private function _populateForUrlGeneration($rowData) { $newSku = $this->import->getNewSku($rowData[ImportProduct::COL_SKU]); $oldSku = $this->import->getOldSku(); @@ -321,7 +320,7 @@ private function isNeedToPopulateForUrlGeneration($rowData, $newSku, $oldSku): b * @param array $rowData * @return void */ - protected function setStoreToProduct(Product $product, array $rowData) + private function setStoreToProduct(Product $product, array $rowData) { if (!empty($rowData[ImportProduct::COL_STORE]) && ($storeId = $this->import->getStoreIdByCode($rowData[ImportProduct::COL_STORE])) @@ -339,7 +338,7 @@ protected function setStoreToProduct(Product $product, array $rowData) * @param string $storeId * @return $this */ - protected function addProductToImport($product, $storeId) + private function addProductToImport($product, $storeId) { if ($product->getVisibility() == (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]) { return $this; @@ -357,7 +356,7 @@ protected function addProductToImport($product, $storeId) * @param Product $product * @return $this */ - protected function populateGlobalProduct($product) + private function populateGlobalProduct($product) { foreach ($this->import->getProductWebsites($product->getSku()) as $websiteId) { foreach ($this->websitesToStoreIds[$websiteId] as $storeId) { @@ -376,7 +375,7 @@ protected function populateGlobalProduct($product) * @return UrlRewrite[] * @throws LocalizedException */ - protected function generateUrls() + private function generateUrls() { $mergeDataProvider = clone $this->mergeDataProviderPrototype; $mergeDataProvider->merge($this->canonicalUrlRewriteGenerate()); @@ -398,7 +397,7 @@ protected function generateUrls() * @param int|null $storeId * @return bool */ - protected function isGlobalScope($storeId) + private function isGlobalScope($storeId) { return null === $storeId || $storeId == Store::DEFAULT_STORE_ID; } @@ -408,7 +407,7 @@ protected function isGlobalScope($storeId) * * @return UrlRewrite[] */ - protected function canonicalUrlRewriteGenerate() + private function canonicalUrlRewriteGenerate() { $urls = []; foreach ($this->products as $productId => $productsByStores) { @@ -433,7 +432,7 @@ protected function canonicalUrlRewriteGenerate() * @return UrlRewrite[] * @throws LocalizedException */ - protected function categoriesUrlRewriteGenerate() + private function categoriesUrlRewriteGenerate(): array { $urls = []; foreach ($this->products as $productId => $productsByStores) { @@ -444,17 +443,24 @@ protected function categoriesUrlRewriteGenerate() continue; } $requestPath = $this->productUrlPathGenerator->getUrlPathWithSuffix($product, $storeId, $category); - $urls[] = $this->urlRewriteFactory->create() - ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) - ->setEntityId($productId) - ->setRequestPath($requestPath) - ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product, $category)) - ->setStoreId($storeId) - ->setMetadata(['category_id' => $category->getId()]); + $urls[] = [ + $this->urlRewriteFactory->create() + ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) + ->setEntityId($productId) + ->setRequestPath($requestPath) + ->setTargetPath($this->productUrlPathGenerator->getCanonicalUrlPath($product, $category)) + ->setStoreId($storeId) + ->setMetadata(['category_id' => $category->getId()]) + ]; + $parentCategoryIds = $category->getAnchorsAbove(); + if ($parentCategoryIds) { + $urls[] = $this->getParentCategoriesUrlRewrites($parentCategoryIds, $storeId, $product); + } } } } - return $urls; + $result = !empty($urls) ? array_merge(...$urls) : []; + return $result; } /** @@ -462,7 +468,7 @@ protected function categoriesUrlRewriteGenerate() * * @return UrlRewrite[] */ - protected function currentUrlRewritesRegenerate() + private function currentUrlRewritesRegenerate() { $currentUrlRewrites = $this->urlFinder->findAllByData( [ @@ -496,7 +502,7 @@ protected function currentUrlRewritesRegenerate() * @param Category $category * @return array */ - protected function generateForAutogenerated($url, $category) + private function generateForAutogenerated($url, $category) { $storeId = $url->getStoreId(); $productId = $url->getEntityId(); @@ -532,7 +538,7 @@ protected function generateForAutogenerated($url, $category) * @param Category $category * @return array */ - protected function generateForCustom($url, $category) + private function generateForCustom($url, $category) { $storeId = $url->getStoreId(); $productId = $url->getEntityId(); @@ -566,7 +572,7 @@ protected function generateForCustom($url, $category) * @param UrlRewrite $url * @return Category|null|bool */ - protected function retrieveCategoryFromMetadata($url) + private function retrieveCategoryFromMetadata($url) { $metadata = $url->getMetadata(); if (isset($metadata['category_id'])) { @@ -576,32 +582,6 @@ protected function retrieveCategoryFromMetadata($url) return null; } - /** - * Check, category suited for url-rewrite generation. - * - * @param Category $category - * @param int $storeId - * @return bool - * @throws NoSuchEntityException - */ - protected function isCategoryProperForGenerating($category, $storeId) - { - if (isset($this->acceptableCategories[$storeId]) && - isset($this->acceptableCategories[$storeId][$category->getId()])) { - return $this->acceptableCategories[$storeId][$category->getId()]; - } - $acceptable = false; - if ($category->getParentId() != Category::TREE_ROOT_ID) { - list(, $rootCategoryId) = $category->getParentIds(); - $acceptable = ($rootCategoryId == $this->storeManager->getStore($storeId)->getRootCategoryId()); - } - if (!isset($this->acceptableCategories[$storeId])) { - $this->acceptableCategories[$storeId] = []; - } - $this->acceptableCategories[$storeId][$category->getId()] = $acceptable; - return $acceptable; - } - /** * Get category by id considering store scope. * @@ -635,4 +615,36 @@ private function isCategoryRewritesEnabled() { return (bool)$this->scopeConfig->getValue('catalog/seo/generate_category_product_rewrites'); } + + /** + * Generate url-rewrite for anchor parent-categories. + * + * @param array $categoryIds + * @param int $storeId + * @param Product $product + * @return array + * @throws LocalizedException + */ + private function getParentCategoriesUrlRewrites(array $categoryIds, int $storeId, Product $product): array + { + $urls = []; + foreach ($categoryIds as $categoryId) { + $category = $this->getCategoryById($categoryId, $storeId); + if ($category->getParentId() == Category::TREE_ROOT_ID) { + continue; + } + $requestPath = $this->productUrlPathGenerator + ->getUrlPathWithSuffix($product, $storeId, $category); + $targetPath = $this->productUrlPathGenerator + ->getCanonicalUrlPath($product, $category); + $urls[] = $this->urlRewriteFactory->create() + ->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE) + ->setEntityId($product->getId()) + ->setRequestPath($requestPath) + ->setTargetPath($targetPath) + ->setStoreId($storeId) + ->setMetadata(['category_id' => $category->getId()]); + } + return $urls; + } } diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php index 7f987124040f..54ef7102fcc4 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\CatalogUrlRewrite\Observer; use Magento\Catalog\Model\Category; @@ -18,6 +20,14 @@ */ class CategoryUrlPathAutogeneratorObserver implements ObserverInterface { + + /** + * Reserved endpoint names. + * + * @var string[] + */ + private $invalidValues = []; + /** * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator */ @@ -38,22 +48,34 @@ class CategoryUrlPathAutogeneratorObserver implements ObserverInterface */ private $categoryRepository; + /** + * @var \Magento\Backend\App\Area\FrontNameResolver + */ + private $frontNameResolver; + /** * @param CategoryUrlPathGenerator $categoryUrlPathGenerator * @param ChildrenCategoriesProvider $childrenCategoriesProvider * @param \Magento\CatalogUrlRewrite\Service\V1\StoreViewService $storeViewService * @param CategoryRepositoryInterface $categoryRepository + * @param \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver + * @param string[] $invalidValues */ public function __construct( CategoryUrlPathGenerator $categoryUrlPathGenerator, ChildrenCategoriesProvider $childrenCategoriesProvider, StoreViewService $storeViewService, - CategoryRepositoryInterface $categoryRepository + CategoryRepositoryInterface $categoryRepository, + \Magento\Backend\App\Area\FrontNameResolver $frontNameResolver = null, + array $invalidValues = [] ) { $this->categoryUrlPathGenerator = $categoryUrlPathGenerator; $this->childrenCategoriesProvider = $childrenCategoriesProvider; $this->storeViewService = $storeViewService; $this->categoryRepository = $categoryRepository; + $this->frontNameResolver = $frontNameResolver ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Backend\App\Area\FrontNameResolver::class); + $this->invalidValues = $invalidValues; } /** @@ -93,6 +115,17 @@ private function updateUrlKey($category, $urlKey) if (empty($urlKey)) { throw new \Magento\Framework\Exception\LocalizedException(__('Invalid URL key')); } + + if (in_array($urlKey, $this->getInvalidValues())) { + throw new \Magento\Framework\Exception\LocalizedException( + __( + 'URL key "%1" matches a reserved endpoint name (%2). Use another URL key.', + $urlKey, + implode(', ', $this->getInvalidValues()) + ) + ); + } + $category->setUrlKey($urlKey) ->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category)); if (!$category->isObjectNew()) { @@ -103,6 +136,16 @@ private function updateUrlKey($category, $urlKey) } } + /** + * Get reserved endpoint names. + * + * @return array + */ + private function getInvalidValues() + { + return array_unique(array_merge($this->invalidValues, [$this->frontNameResolver->getFrontName()])); + } + /** * Update url path for children category. * diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Data/AdminCategoryRestrictedUrlMessageData.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Data/AdminCategoryRestrictedUrlMessageData.xml new file mode 100644 index 000000000000..b463b0524d5f --- /dev/null +++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Data/AdminCategoryRestrictedUrlMessageData.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminCategoryRestrictedUrlErrorMessage"> + <data key="urlAdmin">URL key "admin" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data> + <data key="urlSoap">URL key "soap" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data> + <data key="urlRest">URL key "rest" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data> + <data key="urlGraphql">URL key "graphql" matches a reserved endpoint name (admin, soap, rest, graphql, standard). Use another URL key.</data> + </entity> +</entities> diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml new file mode 100644 index 000000000000..6538ec6e935d --- /dev/null +++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml @@ -0,0 +1,126 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCategoryWithRestrictedUrlKeyNotCreatedTest"> + <annotations> + <features value="CatalogUrlRewrite"/> + <stories value="Url rewrites"/> + <title value="Category with restricted Url Key cannot be created"/> + <description value="Category with restricted Url Key cannot be created"/> + <severity value="MAJOR"/> + <testCaseId value="MC-17515"/> + <useCaseId value="MAGETWO-69825"/> + <group value="CatalogUrlRewrite"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <!--Delete created categories--> + <comment userInput="Delete created categories" stepKey="commentDeleteCreatedCategories"/> + <actionGroup ref="AdminDeleteCategoryByName" stepKey="deleteAdminCategory"> + <argument name="categoryName" value="admin"/> + </actionGroup> + <actionGroup ref="AdminDeleteCategoryByName" stepKey="deleteSoapCategory"> + <argument name="categoryName" value="soap"/> + </actionGroup> + <actionGroup ref="AdminDeleteCategoryByName" stepKey="deleteRestCategory"> + <argument name="categoryName" value="rest"/> + </actionGroup> + <actionGroup ref="AdminDeleteCategoryByName" stepKey="deleteGraphQlCategory"> + <argument name="categoryName" value="graphql"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Check category creation with restricted url key 'admin'--> + <comment userInput="Check category creation with restricted url key 'admin'" stepKey="commentCheckAdminCategoryCreation"/> + <actionGroup ref="goToCreateCategoryPage" stepKey="goToCreateAdminCategoryPage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillAdminFirstCategoryForm"> + <argument name="categoryName" value="admin"/> + <argument name="categoryUrlKey" value=""/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlAdmin}}' stepKey="seeAdminFirstErrorMessage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillAdminSecondCategoryForm"> + <argument name="categoryName" value="{{SimpleSubCategory.name}}"/> + <argument name="categoryUrlKey" value="admin"/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlAdmin}}' stepKey="seeAdminSecondErrorMessage"/> + <!--Create category with 'admin' name--> + <comment userInput="Create category with 'admin' name" stepKey="commentAdminCategoryCreation"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillAdminThirdCategoryForm"> + <argument name="categoryName" value="admin"/> + <argument name="categoryUrlKey" value="{{SimpleSubCategory.name}}"/> + </actionGroup> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the category." stepKey="seeAdminSuccessMessage"/> + <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('admin')}}" stepKey="seeAdminCategoryInTree"/> + <!--Check category creation with restricted url key 'soap'--> + <comment userInput="Check category creation with restricted url key 'soap'" stepKey="commentCheckSoapCategoryCreation"/> + <actionGroup ref="goToCreateCategoryPage" stepKey="goToCreateSoapCategoryPage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillSoapFirstCategoryForm"> + <argument name="categoryName" value="soap"/> + <argument name="categoryUrlKey" value=""/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlSoap}}' stepKey="seeSoapFirstErrorMessage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillSoapSecondCategoryForm"> + <argument name="categoryName" value="{{ApiCategory.name}}"/> + <argument name="categoryUrlKey" value="soap"/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlSoap}}' stepKey="seeSoapSecondErrorMessage"/> + <!--Create category with 'soap' name--> + <comment userInput="Create category with 'soap' name" stepKey="commentSoapCategoryCreation"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillSoapThirdCategoryForm"> + <argument name="categoryName" value="soap"/> + <argument name="categoryUrlKey" value="{{ApiCategory.name}}"/> + </actionGroup> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the category." stepKey="seeSoapSuccessMessage"/> + <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('soap')}}" stepKey="seeSoapCategoryInTree"/> + <!--Check category creation with restricted url key 'rest'--> + <comment userInput="Check category creation with restricted url key 'rest'" stepKey="commentCheckRestCategoryCreation"/> + <actionGroup ref="goToCreateCategoryPage" stepKey="goToCreateRestCategoryPage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillRestFirstCategoryForm"> + <argument name="categoryName" value="rest"/> + <argument name="categoryUrlKey" value=""/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlRest}}' stepKey="seeRestFirstErrorMessage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillRestSecondCategoryForm"> + <argument name="categoryName" value="{{SubCategoryWithParent.name}}"/> + <argument name="categoryUrlKey" value="rest"/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlRest}}' stepKey="seeRestSecondErrorMessage"/> + <!--Create category with 'rest' name--> + <comment userInput="Create category with 'rest' name" stepKey="commentRestCategoryCreation"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillRestThirdCategoryForm"> + <argument name="categoryName" value="rest"/> + <argument name="categoryUrlKey" value="{{SubCategoryWithParent.name}}"/> + </actionGroup> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the category." stepKey="seeRestSuccessMesdgssage"/> + <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('rest')}}" stepKey="seeRestCategoryInTree"/> + <!--Check category creation with restricted url key 'graphql'--> + <comment userInput="Check category creation with restricted url key 'graphql'" stepKey="commentCheckGraphQlCategoryCreation"/> + <actionGroup ref="goToCreateCategoryPage" stepKey="goToCreateCategoryPage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillGraphQlFirstCategoryForm"> + <argument name="categoryName" value="graphql"/> + <argument name="categoryUrlKey" value=""/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlGraphql}}' stepKey="seeGraphQlFirstErrorMessage"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillGraphQlSecondCategoryForm"> + <argument name="categoryName" value="{{NewSubCategoryWithParent.name}}"/> + <argument name="categoryUrlKey" value="graphql"/> + </actionGroup> + <see selector="{{AdminMessagesSection.errorMessage}}" userInput='{{AdminCategoryRestrictedUrlErrorMessage.urlGraphql}}' stepKey="seeGraphQlSecondErrorMessage"/> + <!--Create category with 'graphql' name--> + <comment userInput="Create category with 'graphql' name" stepKey="commentGraphQlCategoryCreation"/> + <actionGroup ref="FillCategoryNameAndUrlKeyAndSave" stepKey="fillGraphQlThirdCategoryForm"> + <argument name="categoryName" value="graphql"/> + <argument name="categoryUrlKey" value="{{NewSubCategoryWithParent.name}}"/> + </actionGroup> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the category." stepKey="seeGraphQlSuccessMessage"/> + <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('graphql')}}" stepKey="seeGraphQlCategoryInTree"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php index 3984d949332d..94fe6ae8c54d 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/AfterImportDataObserverTest.php @@ -153,24 +153,32 @@ class AfterImportDataObserverTest extends \PHPUnit\Framework\TestCase */ protected function setUp() { - $this->importProduct = $this->createPartialMock(\Magento\CatalogImportExport\Model\Import\Product::class, [ + $this->importProduct = $this->createPartialMock( + \Magento\CatalogImportExport\Model\Import\Product::class, + [ 'getNewSku', 'getProductCategories', 'getProductWebsites', 'getStoreIdByCode', 'getCategoryProcessor', - ]); - $this->catalogProductFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, [ + ] + ); + $this->catalogProductFactory = $this->createPartialMock( + \Magento\Catalog\Model\ProductFactory::class, + [ 'create', - ]); + ] + ); $this->storeManager = $this ->getMockBuilder( \Magento\Store\Model\StoreManagerInterface::class ) ->disableOriginalConstructor() - ->setMethods([ - 'getWebsite', - ]) + ->setMethods( + [ + 'getWebsite', + ] + ) ->getMockForAbstractClass(); $this->event = $this->createPartialMock(\Magento\Framework\Event::class, ['getAdapter', 'getBunch']); $this->event->expects($this->any())->method('getAdapter')->willReturn($this->importProduct); @@ -202,9 +210,11 @@ protected function setUp() ); $this->urlFinder = $this ->getMockBuilder(\Magento\UrlRewrite\Model\UrlFinderInterface::class) - ->setMethods([ - 'findAllByData', - ]) + ->setMethods( + [ + 'findAllByData', + ] + ) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -269,9 +279,12 @@ public function testAfterImportData() $newSku = [['entity_id' => 'value'], ['entity_id' => 'value3']]; $websiteId = 'websiteId value'; $productsCount = count($this->products); - $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, [ + $websiteMock = $this->createPartialMock( + \Magento\Store\Model\Website::class, + [ 'getStoreIds', - ]); + ] + ); $storeIds = [1, Store::DEFAULT_STORE_ID]; $websiteMock ->expects($this->once()) @@ -315,13 +328,16 @@ public function testAfterImportData() ->expects($this->exactly(1)) ->method('getStoreIdByCode') ->will($this->returnValueMap($map)); - $product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ + $product = $this->createPartialMock( + \Magento\Catalog\Model\Product::class, + [ 'getId', 'setId', 'getSku', 'setStoreId', 'getStoreId', - ]); + ] + ); $product ->expects($this->exactly($productsCount)) ->method('setId') @@ -341,17 +357,21 @@ public function testAfterImportData() $product ->expects($this->exactly($productsCount)) ->method('getSku') - ->will($this->onConsecutiveCalls( - $this->products[0]['sku'], - $this->products[1]['sku'] - )); + ->will( + $this->onConsecutiveCalls( + $this->products[0]['sku'], + $this->products[1]['sku'] + ) + ); $product ->expects($this->exactly($productsCount)) ->method('getStoreId') - ->will($this->onConsecutiveCalls( - $this->products[0][ImportProduct::COL_STORE], - $this->products[1][ImportProduct::COL_STORE] - )); + ->will( + $this->onConsecutiveCalls( + $this->products[0][ImportProduct::COL_STORE], + $this->products[1][ImportProduct::COL_STORE] + ) + ); $product ->expects($this->exactly($productsCount)) ->method('setStoreId') @@ -540,7 +560,10 @@ public function testCategoriesUrlRewriteGenerate() ->expects($this->any()) ->method('getId') ->will($this->returnValue($this->categoryId)); - + $category + ->expects($this->any()) + ->method('getAnchorsAbove') + ->willReturn([]); $categoryCollection = $this->getMockBuilder(CategoryCollection::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/CatalogUrlRewrite/etc/di.xml b/app/code/Magento/CatalogUrlRewrite/etc/di.xml index e6fbcaefd076..2a74b5cd92b2 100644 --- a/app/code/Magento/CatalogUrlRewrite/etc/di.xml +++ b/app/code/Magento/CatalogUrlRewrite/etc/di.xml @@ -45,4 +45,15 @@ </argument> </arguments> </type> + <type name="Magento\CatalogUrlRewrite\Observer\CategoryUrlPathAutogeneratorObserver"> + <arguments> + <argument name="invalidValues" xsi:type="array"> + <item name="0" xsi:type="string">admin</item> + <item name="1" xsi:type="string">soap</item> + <item name="2" xsi:type="string">rest</item> + <item name="3" xsi:type="string">graphql</item> + <item name="4" xsi:type="string">standard</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv b/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv index b3335dc3523c..0f21e8ddf9fc 100644 --- a/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv +++ b/app/code/Magento/CatalogUrlRewrite/i18n/en_US.csv @@ -5,4 +5,5 @@ "Product URL Suffix","Product URL Suffix" "Use Categories Path for Product URLs","Use Categories Path for Product URLs" "Create Permanent Redirect for URLs if URL Key Changed","Create Permanent Redirect for URLs if URL Key Changed" -"Generate "category/product" URL Rewrites","Generate "category/product" URL Rewrites" \ No newline at end of file +"Generate "category/product" URL Rewrites","Generate "category/product" URL Rewrites" +"URL key ""%1"" matches a reserved endpoint name (%2). Use another URL key.","URL key ""%1"" matches a reserved endpoint name (%2). Use another URL key." diff --git a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php index e5fb20a58aea..a712ae91cbfa 100644 --- a/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php +++ b/app/code/Magento/CatalogWidget/Model/Rule/Condition/Product.php @@ -11,6 +11,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ProductCategoryList; +use Magento\Store\Model\Store; /** * Class Product @@ -106,7 +107,7 @@ function ($attribute) { } /** - * {@inheritdoc} + * @inheritdoc * * @param array &$attributes * @return void @@ -164,6 +165,8 @@ public function addToCollection($collection) } /** + * Adds Attributes that belong to Global Scope + * * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection * @return $this @@ -200,6 +203,8 @@ protected function addGlobalAttribute( } /** + * Adds Attributes that don't belong to Global Scope + * * @param \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection * @return $this @@ -208,7 +213,7 @@ protected function addNotGlobalAttribute( \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute, \Magento\Catalog\Model\ResourceModel\Product\Collection $collection ) { - $storeId = $this->storeManager->getStore()->getId(); + $storeId = $this->storeManager->getStore()->getId(); $values = $collection->getAllAttributeValues($attribute); $validEntities = []; if ($values) { @@ -218,7 +223,9 @@ protected function addNotGlobalAttribute( $validEntities[] = $entityId; } } else { - if ($this->validateAttribute($storeValues[\Magento\Store\Model\Store::DEFAULT_STORE_ID])) { + if (isset($storeValues[Store::DEFAULT_STORE_ID]) && + $this->validateAttribute($storeValues[Store::DEFAULT_STORE_ID]) + ) { $validEntities[] = $entityId; } } @@ -236,7 +243,7 @@ protected function addNotGlobalAttribute( } /** - * {@inheritdoc} + * @inheritdoc * * @return string */ @@ -257,7 +264,7 @@ public function getMappedSqlField() } /** - * {@inheritdoc} + * @inheritdoc * * @param \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection * @return $this diff --git a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php index 4941bf8451bf..c99c9041941b 100644 --- a/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php +++ b/app/code/Magento/Checkout/Block/Cart/Item/Renderer.php @@ -85,7 +85,7 @@ class Renderer extends \Magento\Framework\View\Element\Template implements protected $priceCurrency; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ public $moduleManager; @@ -105,7 +105,7 @@ class Renderer extends \Magento\Framework\View\Element\Template implements * @param \Magento\Framework\Url\Helper\Data $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param PriceCurrencyInterface $priceCurrency - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param InterpretationStrategyInterface $messageInterpretationStrategy * @param array $data * @param ItemResolverInterface|null $itemResolver @@ -120,7 +120,7 @@ public function __construct( \Magento\Framework\Url\Helper\Data $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, PriceCurrencyInterface $priceCurrency, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, InterpretationStrategyInterface $messageInterpretationStrategy, array $data = [], ItemResolverInterface $itemResolver = null diff --git a/app/code/Magento/Checkout/Block/Cart/Link.php b/app/code/Magento/Checkout/Block/Cart/Link.php index 6ea513752110..9e6db1754d9e 100644 --- a/app/code/Magento/Checkout/Block/Cart/Link.php +++ b/app/code/Magento/Checkout/Block/Cart/Link.php @@ -13,7 +13,7 @@ class Link extends \Magento\Framework\View\Element\Html\Link { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -24,14 +24,14 @@ class Link extends \Magento\Framework\View\Element\Html\Link /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Checkout\Helper\Cart $cartHelper * @param array $data * @codeCoverageIgnore */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Checkout\Helper\Cart $cartHelper, array $data = [] ) { diff --git a/app/code/Magento/Checkout/Block/Link.php b/app/code/Magento/Checkout/Block/Link.php index 3d0740181f4a..4ab2981e9185 100644 --- a/app/code/Magento/Checkout/Block/Link.php +++ b/app/code/Magento/Checkout/Block/Link.php @@ -13,7 +13,7 @@ class Link extends \Magento\Framework\View\Element\Html\Link { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -24,14 +24,14 @@ class Link extends \Magento\Framework\View\Element\Html\Link /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Checkout\Helper\Data $checkoutHelper * @param array $data * @codeCoverageIgnore */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Checkout\Helper\Data $checkoutHelper, array $data = [] ) { diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCheckoutSuccessActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCheckoutSuccessActionGroup.xml new file mode 100644 index 000000000000..9ff7e5a96fae --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCheckoutSuccessActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertStorefrontCheckoutSuccessActionGroup"> + <annotations> + <description>Verifies if the order is placed successfully on the 'one page checkout' page.</description> + </annotations> + <waitForElement selector="{{CheckoutSuccessMainSection.successTitle}}" stepKey="waitForLoadSuccessPageTitle"/> + <waitForElement selector="{{CheckoutSuccessMainSection.success}}" time="30" stepKey="waitForLoadSuccessPage"/> + <seeElement selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="seeOrderLink"/> + </actionGroup> +</actionGroups> + diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontMiniCartItemsActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontMiniCartItemsActionGroup.xml index 176eebed142c..8933ebbc1dd8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontMiniCartItemsActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontMiniCartItemsActionGroup.xml @@ -18,12 +18,24 @@ <argument name="cartSubtotal" type="string"/> <argument name="qty" type="string"/> </arguments> - - <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{productName}}" stepKey="seeProductNameInMiniCart"/> - <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{productPrice}}" stepKey="seeProductPriceInMiniCart"/> + + <see selector="{{StorefrontMinicartSection.productPriceByName(productName)}}" userInput="{{productPrice}}" stepKey="seeProductPriceInMiniCart"/> <seeElement selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="seeCheckOutButtonInMiniCart"/> <seeElement selector="{{StorefrontMinicartSection.productQuantity(productName, qty)}}" stepKey="seeProductQuantity1"/> <seeElement selector="{{StorefrontMinicartSection.productImage}}" stepKey="seeProductImage"/> <see selector="{{StorefrontMinicartSection.productSubTotal}}" userInput="{{cartSubtotal}}" stepKey="seeSubTotal"/> </actionGroup> + + <actionGroup name="AssertStorefrontMiniCartProductDetailsAbsentActionGroup"> + <annotations> + <description>Validates that the provided Product details (Name, Price) are + not present in the Storefront Mini Shopping Cart.</description> + </annotations> + <arguments> + <argument name="productName" type="string"/> + <argument name="productPrice" type="string"/> + </arguments> + + <dontSee selector="{{StorefrontMinicartSection.productPriceByName(productName)}}" userInput="{{productPrice}}" stepKey="dontSeeProductPriceInMiniCart"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml index 7f6980d0c974..e0519a126aa4 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml @@ -64,6 +64,7 @@ <fillField selector="{{CheckoutShippingSection.postcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/> <fillField selector="{{CheckoutShippingSection.telephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> + <waitForElement selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('shippingMethod')}}" stepKey="waitForShippingMethod"/> <click selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName('shippingMethod')}}" stepKey="selectShippingMethod"/> <waitForElement selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> @@ -221,7 +222,7 @@ <!-- Check product in checkout cart items --> <actionGroup name="CheckProductInCheckoutCartItemsActionGroup"> <annotations> - <description>Validates the the provided Product appears in the Storefront Checkout 'Order Summary' section.</description> + <description>Validates the provided Product appears in the Storefront Checkout 'Order Summary' section.</description> </annotations> <arguments> <argument name="productVar"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewBillingAddressActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewBillingAddressActionGroup.xml index 789a61a1700d..77734cc75497 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewBillingAddressActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewBillingAddressActionGroup.xml @@ -28,6 +28,10 @@ <fillField selector="{{CheckoutPaymentSection.guestPostcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/> <fillField selector="{{CheckoutPaymentSection.guestTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/> </actionGroup> + <actionGroup name="StorefrontCheckoutFillNewBillingAddressActionGroup" extends="GuestCheckoutFillNewBillingAddressActionGroup"> + <remove keyForRemoval="enterEmail"/> + <remove keyForRemoval="waitForLoading3"/> + </actionGroup> <actionGroup name="LoggedInCheckoutFillNewBillingAddressActionGroup"> <annotations> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckCartDiscountAndSummaryActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckCartDiscountAndSummaryActionGroup.xml index 112abfbb5897..9f766742b545 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckCartDiscountAndSummaryActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCheckCartDiscountAndSummaryActionGroup.xml @@ -17,13 +17,12 @@ <argument name="total" type="string"/> <argument name="discount" type="string"/> </arguments> - <waitForPageLoad stepKey="waitForPageLoad"/> - <waitForLoadingMaskToDisappear stepKey="waitForPrices"/> + <waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxForm"/> + <waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodForm"/> + <waitForElementVisible time="30" selector="{{CheckoutCartSummarySection.total}}" stepKey="waitForTotalElement"/> + <see selector="{{CheckoutCartSummarySection.total}}" userInput="${{total}}" stepKey="assertTotal"/> + <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-${{discount}}" stepKey="assertDiscount"/> - <wait time="10" stepKey="waitForTotalPrice"/> - <reloadPage stepKey="reloadPage" after="waitForTotalPrice" /> - <waitForPageLoad after="reloadPage" stepKey="WaitForPageLoaded" /> - <see selector="{{CheckoutCartSummarySection.total}}" userInput="${{total}}" stepKey="assertTotal" after="WaitForPageLoaded"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml b/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml index d3fa045e4654..d6173dfa1791 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml @@ -14,5 +14,6 @@ <section name="CheckoutOrderSummarySection"/> <section name="CheckoutSuccessMainSection"/> <section name="CheckoutPaymentSection"/> + <section name="SelectShippingBillingPopupSection"/> </page> </pages> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml index 3ab3fa5857b7..1b85f3b045c5 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml @@ -18,6 +18,7 @@ <element name="ProductRegularPriceByName" type="text" selector="//div[descendant::*[contains(text(), '{{var1}}')]]//*[contains(@class, 'subtotal')]" parameterized="true"/> + <element name="productFirstPrice" type="text" selector="td[class~=price] span[class='price']"/> <element name="ProductImageByName" type="text" selector="//main//table[@id='shopping-cart-table']//tbody//tr//img[contains(@class, 'product-image-photo') and @alt='{{var1}}']" parameterized="true"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml index 477451ef003c..20b71608cd03 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml @@ -20,7 +20,7 @@ <element name="totalAmount" type="text" selector="//*[@id='cart-totals']//tr[@class='grand totals']//td//span[@class='price' and contains(text(), '{{amount}}')]" parameterized="true"/> <element name="proceedToCheckout" type="button" selector=".action.primary.checkout span" timeout="30"/> <element name="discountAmount" type="text" selector="td[data-th='Discount']"/> - <element name="shippingHeading" type="button" selector="#block-shipping-heading" timeout="60"/> + <element name="shippingHeading" type="button" selector="#block-shipping-heading" timeout="10"/> <element name="postcode" type="input" selector="input[name='postcode']" timeout="10"/> <element name="stateProvince" type="select" selector="select[name='region_id']" timeout="10"/> <element name="stateProvinceInput" type="input" selector="input[name='region']"/> @@ -33,5 +33,6 @@ <element name="methodName" type="text" selector="#co-shipping-method-form label"/> <element name="shippingPrice" type="text" selector="#co-shipping-method-form span .price"/> <element name="shippingMethodElementId" type="radio" selector="#s_method_{{carrierCode}}_{{methodCode}}" parameterized="true"/> + <element name="estimateShippingAndTaxForm" type="block" selector="#shipping-zip-form"/> </section> </sections> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml index 903c21d7ec0c..be8519f920b9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutPaymentSection.xml @@ -31,7 +31,7 @@ <element name="cartItemsAreaActive" type="textarea" selector="div.block.items-in-cart.active" timeout="30"/> <element name="checkMoneyOrderPayment" type="radio" selector="input#checkmo.radio" timeout="30"/> <element name="placeOrder" type="button" selector=".payment-method._active button.action.primary.checkout" timeout="30"/> - <element name="paymentSectionTitle" type="text" selector="//*[@id='checkout-payment-method-load']//div[text()='Payment Method']" /> + <element name="paymentSectionTitle" type="text" selector="//*[@id='checkout-payment-method-load']//div[@data-role='title']" /> <element name="orderSummarySubtotal" type="text" selector="//tr[@class='totals sub']//span[@class='price']" /> <element name="orderSummaryShippingTotal" type="text" selector="//tr[@class='totals shipping excl']//span[@class='price']" /> <element name="orderSummaryShippingMethod" type="text" selector="//tr[@class='totals shipping excl']//span[@class='value']" /> @@ -42,6 +42,7 @@ <element name="ProductOptionLinkActiveByProductItemName" type="text" selector="//div[@class='product-item-details']//strong[@class='product-item-name'][text()='{{var1}}']//ancestor::div[@class='product-item-details']//div[@class='product options active']//a[text() = '{{var2}}']" parameterized="true" /> <element name="shipToInformation" type="text" selector="//div[@class='ship-to']//div[@class='shipping-information-content']" /> <element name="shippingMethodInformation" type="text" selector="//div[@class='ship-via']//div[@class='shipping-information-content']" /> + <element name="shippingInformationSection" type="text" selector=".ship-to .shipping-information-content" /> <element name="paymentMethodTitle" type="text" selector=".payment-method-title span" /> <element name="productOptionsByProductItemPrice" type="text" selector="//div[@class='product-item-inner']//div[@class='subtotal']//span[@class='price'][contains(.,'{{price}}')]//ancestor::div[@class='product-item-details']//div[@class='product options']" parameterized="true"/> <element name="productOptionsActiveByProductItemPrice" type="text" selector="//div[@class='subtotal']//span[@class='price'][contains(.,'{{price}}')]//ancestor::div[@class='product-item-details']//div[@class='product options active']" parameterized="true"/> @@ -51,6 +52,7 @@ <element name="orderSummaryTotalIncluding" type="text" selector="//tr[@class='grand totals incl']//span[@class='price']" /> <element name="orderSummaryTotalExcluding" type="text" selector="//tr[@class='grand totals excl']//span[@class='price']" /> <element name="shippingAndBillingAddressSame" type="input" selector="#billing-address-same-as-shipping-braintree_cc_vault"/> + <element name="myShippingAndBillingAddressSame" type="input" selector=".billing-address-same-as-shipping-block"/> <element name="addressAction" type="button" selector="//span[text()='{{action}}']" parameterized="true"/> <element name="addressBook" type="button" selector="//a[text()='Address Book']"/> <element name="noQuotes" type="text" selector=".no-quotes-block"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml index 3e1de2b14ba6..e00906386e46 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml @@ -13,7 +13,9 @@ <element name="productCount" type="text" selector="//header//div[contains(@class, 'minicart-wrapper')]//a[contains(@class, 'showcart')]//span[@class='counter-number']"/> <element name="productLinkByName" type="button" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details']//a[contains(text(), '{{var1}}')]" parameterized="true"/> <element name="productPriceByName" type="text" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/> - <element name="productImageByName" type="text" selector="//header//ol[@id='mini-cart']//span[@class='product-image-container']//img[@alt='{{var1}}']" parameterized="true"/> + <element name="productPriceByItsName" type="text" selector="//a[normalize-space()='{{prodName}}']/../following-sibling::*//*[@class='price']" parameterized="true"/> + <element name="productImageByName" type="text" selector="header ol[id='mini-cart'] span[class='product-image-container'] img[alt='{{prodName}}']" parameterized="true"/> + <element name="productImageByItsName" type="text" selector="img[alt='{{prodName}}']" parameterized="true"/> <element name="productName" type="text" selector=".product-item-name"/> <element name="productOptionsDetailsByName" type="button" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//span[.='See Details']" parameterized="true"/> <element name="productOptionByNameAndAttribute" type="text" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//dt[@class='label' and .='{{var2}}']/following-sibling::dd[@class='values']//span" parameterized="true"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml index 9714b76a0561..163e71c50053 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckCheckoutSuccessPageTest.xml @@ -30,7 +30,7 @@ <!--Logout from customer account--> <amOnPage url="customer/account/logout/" stepKey="logoutCustomerOne"/> <waitForPageLoad stepKey="waitLogoutCustomerOne"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createSimpleUsCustomer" stepKey="deleteCustomer"/> </after> @@ -147,7 +147,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> </after> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml index 1a51e1e02fe8..e16ef70c23e3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create downloadable product --> <createData entity="ApiDownloadableProduct" stepKey="createDownloadableProduct"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink"> @@ -30,6 +31,7 @@ </createData> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete downloadable product --> <deleteData createDataKey="createDownloadableProduct" stepKey="deleteDownloadableProduct"/> </after> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/EditShippingAddressOnePageCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/EditShippingAddressOnePageCheckoutTest.xml index 20015f76e08e..c61545e51d53 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/EditShippingAddressOnePageCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/EditShippingAddressOnePageCheckoutTest.xml @@ -25,6 +25,9 @@ <requiredEntity createDataKey="createCategory"/> </createData> <createData entity="Simple_US_Customer_NY" stepKey="createCustomer"/> + <!--Clear cache and reindex--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml index 5335ec2ad775..4281a0eb77da 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml @@ -184,6 +184,194 @@ <argument name="productVar" value="$$createSimpleProduct2$$"/> </actionGroup> + <comment userInput="Place order with check money order payment" stepKey="commentPlaceOrderWithCheckMoneyOrderPayment" after="guestCheckoutCheckSimpleProduct2InCartItems" /> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" after="commentPlaceOrderWithCheckMoneyOrderPayment"/> + <actionGroup ref="CheckBillingAddressInCheckoutActionGroup" stepKey="guestSeeBillingAddress" after="guestSelectCheckMoneyOrderPayment"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="CustomerAddressSimple" /> + </actionGroup> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceorder" after="guestSeeBillingAddress"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" /> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + <comment userInput="End of checking out" stepKey="endOfCheckingOut" after="guestPlaceorder" /> + </test> + <test name="EndToEndB2CGuestUserMysqlTest"> + <!-- Step 3: User adds products to cart --> + <comment userInput="Start of adding products to cart" stepKey="startOfAddingProductsToCart" after="endOfBrowsingCatalog"/> + <!-- Add Simple Product 1 to cart --> + <comment userInput="Add Simple Product 1 to cart" stepKey="commentAddSimpleProduct1ToCart" after="startOfAddingProductsToCart" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="cartClickCategory" after="commentAddSimpleProduct1ToCart"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartCategoryloaded" after="cartClickCategory"/> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="cartAssertCategory" after="waitForCartCategoryloaded"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="cartAssertSimpleProduct1" after="cartAssertCategory"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="cartGrabSimpleProduct1ImageSrc" after="cartAssertSimpleProduct1"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartGrabSimpleProduct1ImageSrc" stepKey="cartAssertSimpleProduct1ImageNotDefault" after="cartGrabSimpleProduct1ImageSrc"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createSimpleProduct1.name$$)}}" stepKey="cartClickSimpleProduct1" after="cartAssertSimpleProduct1ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartSimpleProduct1loaded" after="cartClickSimpleProduct1"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="cartAssertProduct1Page" after="waitForCartSimpleProduct1loaded"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartGrabSimpleProduct1PageImageSrc" after="cartAssertProduct1Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartGrabSimpleProduct1PageImageSrc" stepKey="cartAssertSimpleProduct1PageImageNotDefault" after="cartGrabSimpleProduct1PageImageSrc"/> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddProduct1ToCart" after="cartAssertSimpleProduct1PageImageNotDefault"> + <argument name="product" value="$$createSimpleProduct1$$"/> + <argument name="productCount" value="1"/> + </actionGroup> + + <!-- Add Simple Product 2 to cart --> + <comment userInput="Add Simple Product 2 to cart" stepKey="commentAddSimpleProduct2ToCart" after="cartAddProduct1ToCart" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="cartClickCategory1" after="commentAddSimpleProduct2ToCart"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartCategory1loaded" after="cartClickCategory1"/> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="cartAssertCategory1ForSimpleProduct2" after="waitForCartCategory1loaded"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCategorySimpleProduct" stepKey="cartAssertSimpleProduct2" after="cartAssertCategory1ForSimpleProduct2"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="cartGrabSimpleProduct2ImageSrc" after="cartAssertSimpleProduct2"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartGrabSimpleProduct2ImageSrc" stepKey="cartAssertSimpleProduct2ImageNotDefault" after="cartGrabSimpleProduct2ImageSrc"/> + <actionGroup ref="StorefrontAddCategoryProductToCartActionGroup" stepKey="cartAddProduct2ToCart" after="cartAssertSimpleProduct2ImageNotDefault"> + <argument name="product" value="$$createSimpleProduct2$$"/> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="productCount" value="CONST.two"/> + </actionGroup> + + <!-- Check products in minicart --> + <!-- Check simple product 1 in minicart --> + <comment userInput="Check simple product 1 in minicart" stepKey="commentCheckSimpleProduct1InMinicart" after="cartAddProduct2ToCart"/> + <actionGroup ref="StorefrontOpenMinicartAndCheckSimpleProductActionGroup" stepKey="cartOpenMinicartAndCheckSimpleProduct1" after="commentCheckSimpleProduct1InMinicart"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="cartMinicartGrabSimpleProduct1ImageSrc" after="cartOpenMinicartAndCheckSimpleProduct1"/> + <assertNotRegExp expected="'/placeholder\/thumbnail\.jpg/'" actual="$cartMinicartGrabSimpleProduct1ImageSrc" stepKey="cartMinicartAssertSimpleProduct1ImageNotDefault" after="cartMinicartGrabSimpleProduct1ImageSrc"/> + <click selector="{{StorefrontMinicartSection.productLinkByName($$createSimpleProduct1.name$$)}}" stepKey="cartMinicartClickSimpleProduct1" after="cartMinicartAssertSimpleProduct1ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForMinicartSimpleProduct1loaded" after="cartMinicartClickSimpleProduct1"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="cartAssertMinicartProduct1Page" after="waitForMinicartSimpleProduct1loaded"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartMinicartGrabSimpleProduct1PageImageSrc" after="cartAssertMinicartProduct1Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartMinicartGrabSimpleProduct1PageImageSrc" stepKey="cartMinicartAssertSimpleProduct1PageImageNotDefault" after="cartMinicartGrabSimpleProduct1PageImageSrc"/> + <actionGroup ref="StorefrontOpenMinicartAndCheckSimpleProductActionGroup" stepKey="cartOpenMinicartAndCheckSimpleProduct2" after="cartMinicartAssertSimpleProduct1PageImageNotDefault"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- Check simple product2 in minicart --> + <comment userInput="Check simple product 2 in minicart" stepKey="commentCheckSimpleProduct2InMinicart" after="cartOpenMinicartAndCheckSimpleProduct2"/> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="cartMinicartGrabSimpleProduct2ImageSrc" after="commentCheckSimpleProduct2InMinicart"/> + <assertNotRegExp expected="'/placeholder\/thumbnail\.jpg/'" actual="$cartMinicartGrabSimpleProduct2ImageSrc" stepKey="cartMinicartAssertSimpleProduct2ImageNotDefault" after="cartMinicartGrabSimpleProduct2ImageSrc"/> + <click selector="{{StorefrontMinicartSection.productLinkByName($$createSimpleProduct2.name$$)}}" stepKey="cartMinicartClickSimpleProduct2" after="cartMinicartAssertSimpleProduct2ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForMinicartSimpleProduct2loaded" after="cartMinicartClickSimpleProduct2"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="cartAssertMinicartProduct2Page" after="waitForMinicartSimpleProduct2loaded"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartMinicartGrabSimpleProduct2PageImageSrc" after="cartAssertMinicartProduct2Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartMinicartGrabSimpleProduct2PageImageSrc" stepKey="cartMinicartAssertSimpleProduct2PageImageNotDefault" after="cartMinicartGrabSimpleProduct2PageImageSrc"/> + + <!-- Check products in cart --> + <comment userInput="Check cart information" stepKey="commentCheckCartInformation" after="cartMinicartAssertSimpleProduct2PageImageNotDefault" /> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="cartOpenCart" after="commentCheckCartInformation"/> + <actionGroup ref="StorefrontCheckCartActionGroup" stepKey="cartAssertCart" after="cartOpenCart"> + <argument name="subtotal" value="480.00"/> + <argument name="shipping" value="15.00"/> + <argument name="shippingMethod" value="Flat Rate - Fixed"/> + <argument name="total" value="495.00"/> + </actionGroup> + + <!-- Check simple product 1 in cart --> + <comment userInput="Check simple product 1 in cart" stepKey="commentCheckSimpleProduct1InCart" after="cartAssertCart"/> + <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="cartAssertCartSimpleProduct1" after="commentCheckSimpleProduct1InCart"> + <argument name="product" value="$$createSimpleProduct1$$"/> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="productQuantity" value="CONST.one"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{CheckoutCartProductSection.ProductImageByName($$createSimpleProduct1.name$$)}}" userInput="src" stepKey="cartCartGrabSimpleProduct1ImageSrc" after="cartAssertCartSimpleProduct1"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartCartGrabSimpleProduct1ImageSrc" stepKey="cartCartAssertSimpleProduct1ImageNotDefault" after="cartCartGrabSimpleProduct1ImageSrc"/> + <click selector="{{CheckoutCartProductSection.ProductLinkByName($$createSimpleProduct1.name$$)}}" stepKey="cartClickCartSimpleProduct1" after="cartCartAssertSimpleProduct1ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartSimpleProduct1loadedAgain" after="cartClickCartSimpleProduct1"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="cartAssertCartProduct1Page" after="waitForCartSimpleProduct1loadedAgain"> + <argument name="product" value="$$createSimpleProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartCartGrabSimpleProduct2PageImageSrc1" after="cartAssertCartProduct1Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartCartGrabSimpleProduct2PageImageSrc1" stepKey="cartCartAssertSimpleProduct2PageImageNotDefault1" after="cartCartGrabSimpleProduct2PageImageSrc1"/> + + <!-- Check simple product 2 in cart --> + <comment userInput="Check simple product 2 in cart" stepKey="commentCheckSimpleProduct2InCart" after="cartCartAssertSimpleProduct2PageImageNotDefault1"/> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="cartOpenCart1" after="commentCheckSimpleProduct2InCart"/> + <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="cartAssertCartSimpleProduct2" after="cartOpenCart1"> + <argument name="product" value="$$createSimpleProduct2$$"/> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="productQuantity" value="CONST.one"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{CheckoutCartProductSection.ProductImageByName($$createSimpleProduct2.name$$)}}" userInput="src" stepKey="cartCartGrabSimpleProduct2ImageSrc" after="cartAssertCartSimpleProduct2"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartCartGrabSimpleProduct2ImageSrc" stepKey="cartCartAssertSimpleProduct2ImageNotDefault" after="cartCartGrabSimpleProduct2ImageSrc"/> + <click selector="{{CheckoutCartProductSection.ProductLinkByName($$createSimpleProduct2.name$$)}}" stepKey="cartClickCartSimpleProduct2" after="cartCartAssertSimpleProduct2ImageNotDefault"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartSimpleProduct2loaded" after="cartClickCartSimpleProduct2"/> + <actionGroup ref="StorefrontCheckSimpleProduct" stepKey="cartAssertCartProduct2Page" after="waitForCartSimpleProduct2loaded"> + <argument name="product" value="$$createSimpleProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartCartGrabSimpleProduct2PageImageSrc2" after="cartAssertCartProduct2Page"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartCartGrabSimpleProduct2PageImageSrc2" stepKey="cartCartAssertSimpleProduct2PageImageNotDefault2" after="cartCartGrabSimpleProduct2PageImageSrc2"/> + <comment userInput="End of adding products to cart" stepKey="endOfAddingProductsToCart" after="cartCartAssertSimpleProduct2PageImageNotDefault2" /> + + <!-- Step 6: Check out --> + <comment userInput="Start of checking out" stepKey="startOfCheckingOut" after="endOfUsingCouponCode" /> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutFromMinicart" after="startOfCheckingOut"/> + <actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShippingSection" after="guestGoToCheckoutFromMinicart"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="CustomerAddressSimple" /> + </actionGroup> + + <!-- Check order summary in checkout --> + <comment userInput="Check order summary in checkout" stepKey="commentCheckOrderSummaryInCheckout" after="guestCheckoutFillingShippingSection" /> + <actionGroup ref="CheckOrderSummaryInCheckoutActionGroup" stepKey="guestCheckoutCheckOrderSummary" after="commentCheckOrderSummaryInCheckout"> + <argument name="subtotal" value="480.00"/> + <argument name="shippingTotal" value="15.00"/> + <argument name="shippingMethod" value="Flat Rate - Fixed"/> + <argument name="total" value="495.00"/> + </actionGroup> + + <!-- Check ship to information in checkout --> + <comment userInput="Check ship to information in checkout" stepKey="commentCheckShipToInformationInCheckout" after="guestCheckoutCheckOrderSummary" /> + <actionGroup ref="CheckShipToInformationInCheckoutActionGroup" stepKey="guestCheckoutCheckShipToInformation" after="commentCheckShipToInformationInCheckout"> + <argument name="customerVar" value="CustomerEntityOne" /> + <argument name="customerAddressVar" value="CustomerAddressSimple" /> + </actionGroup> + + <!-- Check shipping method in checkout --> + <comment userInput="Check shipping method in checkout" stepKey="commentCheckShippingMethodInCheckout" after="guestCheckoutCheckShipToInformation" /> + <actionGroup ref="CheckShippingMethodInCheckoutActionGroup" stepKey="guestCheckoutCheckShippingMethod" after="commentCheckShippingMethodInCheckout"> + <argument name="shippingMethod" value="E2EB2CQuote.shippingMethod" /> + </actionGroup> + + <!-- Verify Simple Product 1 is in checkout cart items --> + <comment userInput="Verify Simple Product 1 is in checkout cart items" stepKey="commentVerifySimpleProduct1IsInCheckoutCartItems" after="guestCheckoutCheckShippingMethod" /> + <actionGroup ref="CheckProductInCheckoutCartItemsActionGroup" stepKey="guestCheckoutCheckSimpleProduct1InCartItems" after="commentVerifySimpleProduct1IsInCheckoutCartItems"> + <argument name="productVar" value="$$createSimpleProduct1$$"/> + </actionGroup> + + <!-- Verify Simple Product 2 is in checkout cart items --> + <comment userInput="Verify Simple Product 2 is in checkout cart items" stepKey="commentVerifySimpleProduct2IsInCheckoutCartItems" after="guestCheckoutCheckSimpleProduct1InCartItems" /> + <actionGroup ref="CheckProductInCheckoutCartItemsActionGroup" stepKey="guestCheckoutCheckSimpleProduct2InCartItems" after="commentVerifySimpleProduct2IsInCheckoutCartItems"> + <argument name="productVar" value="$$createSimpleProduct2$$"/> + </actionGroup> + <comment userInput="Place order with check money order payment" stepKey="commentPlaceOrderWithCheckMoneyOrderPayment" after="guestCheckoutCheckSimpleProduct2InCartItems" /> <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" after="commentPlaceOrderWithCheckMoneyOrderPayment"/> <actionGroup ref="CheckBillingAddressInCheckoutActionGroup" stepKey="guestSeeBillingAddress" after="guestSelectCheckMoneyOrderPayment"> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml index 3c98f9177f4a..fd6656b1d1b2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml @@ -26,6 +26,8 @@ <field key="price">100.00</field> <requiredEntity createDataKey="createCategory"/> </createData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index 3ec73aec580d..e85a47ab7a91 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="_defaultCategory" stepKey="createCategory"/> @@ -90,6 +91,7 @@ <magentoCLI command="indexer:reindex" stepKey="reindex"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml index 5a46dbc90e20..ec9852a6a939 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml @@ -18,6 +18,7 @@ </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/> <magentoCLI command="config:set {{EnableFlatRateDefaultPriceConfigData.path}} {{EnableFlatRateDefaultPriceConfigData.value}}" stepKey="enableFlatRateDefaultPrice"/> <createData entity="ApiDownloadableProduct" stepKey="createDownloadableProduct"/> @@ -31,6 +32,7 @@ <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <deleteData createDataKey="createDownloadableProduct" stepKey="deleteProduct"/> <actionGroup ref="logout" stepKey="logout"/> </after> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCartItemDisplayWhenMoreItemsAddedToTheCartThanDefaultDisplayLimitTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCartItemDisplayWhenMoreItemsAddedToTheCartThanDefaultDisplayLimitTest.xml index 09a5ce4c7037..8b8aed3ac620 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCartItemDisplayWhenMoreItemsAddedToTheCartThanDefaultDisplayLimitTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckCartItemDisplayWhenMoreItemsAddedToTheCartThanDefaultDisplayLimitTest.xml @@ -15,9 +15,6 @@ <testCaseId value="MC-14720"/> <severity value="CRITICAL"/> <group value="mtf_migrated"/> - <skip> - <issueId value="MC-17140"/> - </skip> </annotations> <before> @@ -280,7 +277,9 @@ </actionGroup> <!-- Verify Product11 is not displayed in Mini Cart --> - <dontSee selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="$$simpleProduct11.name$$" stepKey="dontSeeProduct11NameInMiniCart"/> - <dontSee selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="110" stepKey="dontSeeProduct11PriceInMiniCart"/> + <actionGroup ref="AssertStorefrontMiniCartProductDetailsAbsentActionGroup" stepKey="assertSimpleProduct11IsNotInMiniCart"> + <argument name="productName" value="$$simpleProduct11.name$$"/> + <argument name="productPrice" value="$110.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml index 40b781df9b2a..4e19de659be2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest.xml @@ -148,7 +148,7 @@ <argument name="name" value="{{SimpleTaxCA.state}}-{{SimpleTaxCA.rate}}"/> <argument name="searchInput" value="{{AdminSecondaryGridSection.taxIdentifierSearch}}"/> </actionGroup> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="simpleproduct1" stepKey="deleteProduct1"/> <deleteData createDataKey="simplecategory" stepKey="deleteCategory"/> <deleteData createDataKey="multiple_address_customer" stepKey="deleteCustomer"/> @@ -221,6 +221,10 @@ <magentoCLI command="config:set payment/checkmo/allowspecific 1" stepKey="allowSpecificValue" /> <magentoCLI command="config:set payment/checkmo/specificcountry GB" stepKey="specificCountryValue" /> <createData entity="Simple_US_Customer" stepKey="simpleuscustomer"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml index 6a3f6ab4f705..0fa503e1783b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml @@ -19,6 +19,7 @@ </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/> <magentoCLI command="config:set {{EnableFlatRateDefaultPriceConfigData.path}} {{EnableFlatRateDefaultPriceConfigData.value}}" stepKey="enableFlatRateDefaultPrice"/> @@ -30,6 +31,7 @@ <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <deleteData createDataKey="createDownloadableProduct" stepKey="deleteProduct"/> <actionGroup ref="logout" stepKey="logout"/> </after> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml index a77341b8697b..b6b9fe1e1a11 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml @@ -23,9 +23,13 @@ <createData entity="ApiSimpleProduct" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> </createData> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> </after> @@ -112,7 +116,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> <magentoCLI stepKey="allowSpecificValue" command="config:set payment/checkmo/allowspecific 0" /> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutJsValidationTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutJsValidationTest.xml index 63751ad697ed..8ed8e590eb22 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutJsValidationTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutJsValidationTest.xml @@ -11,6 +11,7 @@ <test name="StorefrontOnePageCheckoutJsValidationTest"> <annotations> <features value="Checkout"/> + <stories value="Checkout"/> <title value="Js validation error messages must be absent for required fields after checkout start."/> <description value="Js validation error messages must be absent for required fields after checkout start."/> <severity value="MAJOR" /> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRegionUpdatesAfterChangingCountryAndLeavingRegionSelectUnselectedTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRegionUpdatesAfterChangingCountryAndLeavingRegionSelectUnselectedTest.xml new file mode 100644 index 000000000000..44bfe81b40dc --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRegionUpdatesAfterChangingCountryAndLeavingRegionSelectUnselectedTest.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontRegionUpdatesAfterChangingCountryAndLeavingRegionSelectUnselectedTest"> + <annotations> + <features value="Checkout"/> + <stories value="Region updates after changing country "/> + <title value="Region updates after changing country "/> + <description value="Region dupdates after changing country and leaving region select unselected"/> + <severity value="CRITICAL"/> + <testCaseId value="https://github.com/magento/magento2/issues/23460"/> + <group value="checkout"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + </before> + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + </after> + + <!-- Login to storefront from customer --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + + <actionGroup ref="StorefrontOpenMyAccountPageActionGroup" stepKey="goToMyAccountPage"/> + + <actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToAddressBookPage"> + <argument name="menu" value="Address Book"/> + </actionGroup> + <actionGroup ref="StoreFrontClickEditDefaultShippingAddressActionGroup" stepKey="clickEditAddress"/> + <selectOption selector="{{StorefrontCustomerAddressFormSection.country}}" userInput="{{updateCustomerFranceAddress.country}}" stepKey="selectCountry"/> + <actionGroup ref="AdminSaveCustomerAddressActionGroup" stepKey="saveAddress"/> + + <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{updateCustomerFranceAddress.country}}" stepKey="seeAssertCustomerDefaultShippingAddressCountry"/> + </test> +</tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index ebf24e710fe3..482e2fb6233a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -18,7 +18,7 @@ </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="loginToAdminPanel"/> + <magentoCLI command="downloadable:domains:add" arguments="example.com static.magento.com" stepKey="addDownloadableDomain"/> <createData entity="ApiDownloadableProduct" stepKey="createDownloadableProduct"> <field key="price">20.00</field> </createData> @@ -38,10 +38,12 @@ </createData> </before> <after> + <magentoCLI command="downloadable:domains:remove" arguments="example.com static.magento.com" stepKey="removeDownloadableDomain"/> <deleteData createDataKey="createDownloadableProduct" stepKey="deleteProduct"/> <deleteData createDataKey="virtualProduct" stepKey="deleteVirtualProduct"/> <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/> + <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/> <actionGroup ref="logout" stepKey="logout"/> </after> @@ -106,6 +108,9 @@ <seeElement selector="{{StorefrontMiniCartSection.emptyMiniCart}}" stepKey="assertEmptyCart" /> <grabTextFrom selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="orderId"/> + <!-- Login to Admin Page --> + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdminPanel"/> + <!-- Open Order Index Page --> <amOnPage url="{{AdminOrdersPage.url}}" stepKey="goToOrders"/> <waitForPageLoad stepKey="waitForPageLoad5"/> @@ -127,4 +132,4 @@ <see selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$15.00" stepKey="seeGrandTotal"/> <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeOrderStatus"/> </test> -</tests> \ No newline at end of file +</tests> diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestQuantityProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestQuantityProcessorTest.php index daabb080b1c9..82384fa83ab9 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestQuantityProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Cart/RequestQuantityProcessorTest.php @@ -48,6 +48,9 @@ public function testProcess($cartData, $expected) $this->assertEquals($this->requestProcessor->process($cartData), $expected); } + /** + * @return array + */ public function cartDataProvider() { return [ diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 3cc80e14fd02..350f9954208f 100644 --- a/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -43,7 +43,7 @@ protected function setUp() ); $this->checkoutSessionMock = $this->createPartialMock(\Magento\Checkout\Model\Session::class, ['clearStorage']); $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\ModuleManagerInterface::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); $this->cacheConfigMock = $this->createMock(\Magento\PageCache\Model\Config::class); $this->depersonalizeCheckerMock = $this->createMock(\Magento\PageCache\Model\DepersonalizeChecker::class); diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml index a305413bcf1f..fed0c951eff9 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml @@ -118,7 +118,7 @@ </item> <item name="component" xsi:type="string">Magento_Checkout/js/view/shipping</item> <item name="provider" xsi:type="string">checkoutProvider</item> - <item name="sortOrder" xsi:type="string">1</item> + <item name="sortOrder" xsi:type="string">10</item> <item name="children" xsi:type="array"> <item name="customer-email" xsi:type="array"> <item name="component" xsi:type="string">Magento_Checkout/js/view/form/element/email</item> @@ -246,6 +246,7 @@ <item name="component" xsi:type="string">Magento_Checkout/js/view/payment</item> <item name="config" xsi:type="array"> <item name="title" xsi:type="string" translate="true">Payment</item> + <item name="sortOrder" xsi:type="string">20</item> </item> <item name="children" xsi:type="array"> <item name="renders" xsi:type="array"> diff --git a/app/code/Magento/Checkout/view/frontend/templates/button.phtml b/app/code/Magento/Checkout/view/frontend/templates/button.phtml index b0087794ea85..6d1f076e6b26 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/button.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/button.phtml @@ -7,7 +7,10 @@ <?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?> <?php if ($block->getCanViewOrder() && $block->getCanPrintOrder()) :?> - <a href="<?= $block->escapeUrl($block->getPrintUrl()) ?>" target="_blank" class="print"> + <a href="<?= $block->escapeUrl($block->getPrintUrl()) ?>" + class="action print" + target="_blank" + rel="noopener"> <?= $block->escapeHtml(__('Print receipt')) ?> </a> <?= $block->getChildHtml() ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml index 2a7ccc38e9d8..b3b94cfae18d 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/onepage/review/item.phtml @@ -28,9 +28,9 @@ $taxDataHelper = $this->helper(Magento\Tax\Helper\Data::class); <dt><?= $block->escapeHtml($_option['label']) ?></dt> <dd> <?php if (isset($_formatedOptionValue['full_view'])) :?> - <?= $block->escapeHtml($_formatedOptionValue['full_view']) ?> + <?= /* @noEscape */ $_formatedOptionValue['full_view'] ?> <?php else :?> - <?= $block->escapeHtml($_formatedOptionValue['value']) ?> + <?= /* @noEscape */ $_formatedOptionValue['value'] ?> <?php endif; ?> </dd> <?php endforeach; ?> diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js b/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js index 702df4752671..34f170074979 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/select-payment-method.js @@ -12,6 +12,11 @@ define([ 'use strict'; return function (paymentMethod) { + if (paymentMethod) { + paymentMethod.__disableTmpl = { + title: true + }; + } quote.paymentMethod(paymentMethod); }; }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js b/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js index 4085da82f415..9de8a93905c9 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js @@ -13,14 +13,33 @@ define([ 'Magento_Checkout/js/model/error-processor', 'Magento_Customer/js/model/customer', 'Magento_Checkout/js/action/get-totals', - 'Magento_Checkout/js/model/full-screen-loader' -], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader) { + 'Magento_Checkout/js/model/full-screen-loader', + 'underscore' +], function (quote, urlBuilder, storage, errorProcessor, customer, getTotalsAction, fullScreenLoader, _) { 'use strict'; + /** + * Filter template data. + * + * @param {Object|Array} data + */ + var filterTemplateData = function (data) { + return _.each(data, function (value, key, list) { + if (_.isArray(value) || _.isObject(value)) { + list[key] = filterTemplateData(value); + } + + if (key === '__disableTmpl') { + delete list[key]; + } + }); + }; + return function (messageContainer, paymentData, skipBilling) { var serviceUrl, payload; + paymentData = filterTemplateData(paymentData); skipBilling = skipBilling || false; payload = { cartId: quote.getQuoteId(), diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js index 9b20a782c38d..6e1b031ab48c 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js @@ -9,8 +9,9 @@ define([ 'jquery', 'Magento_Checkout/js/model/new-customer-address', 'Magento_Customer/js/customer-data', - 'mage/utils/objects' -], function ($, address, customerData, mageUtils) { + 'mage/utils/objects', + 'underscore' +], function ($, address, customerData, mageUtils, _) { 'use strict'; var countryData = customerData.get('directory-data'); @@ -18,6 +19,7 @@ define([ return { /** * Convert address form data to Address object + * * @param {Object} formData * @returns {Object} */ @@ -59,13 +61,15 @@ define([ delete addressData['region_id']; if (addressData['custom_attributes']) { - addressData['custom_attributes'] = Object.entries(addressData['custom_attributes']) - .map(function (customAttribute) { + addressData['custom_attributes'] = _.map( + addressData['custom_attributes'], + function (value, key) { return { - 'attribute_code': customAttribute[0], - 'value': customAttribute[1] + 'attribute_code': key, + 'value': value }; - }); + } + ); } return address(addressData); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js index 54e496131972..fd12eed76ed5 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js @@ -13,8 +13,8 @@ define([ ], function (quote, defaultProcessor, totalsDefaultProvider, shippingService, cartCache, customerData) { 'use strict'; - var rateProcessors = [], - totalsProcessors = [], + var rateProcessors = {}, + totalsProcessors = {}, /** * Estimate totals for shipping address and update shipping rates. diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js b/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js index bc0ab59b622a..16f84da0aced 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js @@ -170,9 +170,6 @@ define([ if (!availableRate && window.checkoutConfig.selectedShippingMethod) { availableRate = window.checkoutConfig.selectedShippingMethod; - selectShippingMethodAction(window.checkoutConfig.selectedShippingMethod); - - return; } //Unset selected shipping method if not available diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js index 7eddc0d1a58d..be2199961e07 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rate-service.js @@ -10,7 +10,7 @@ define([ ], function (quote, defaultProcessor, customerAddressProcessor) { 'use strict'; - var processors = []; + var processors = {}; processors.default = defaultProcessor; processors['customer-address'] = customerAddressProcessor; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js index d506f0a4359c..cf26f682ad3a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-save-processor.js @@ -11,7 +11,7 @@ define([ ], function (defaultProcessor) { 'use strict'; - var processors = []; + var processors = {}; processors['default'] = defaultProcessor; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js b/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js index a9cbb1194cfd..6d54f607484b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/region-updater.js @@ -162,6 +162,9 @@ define([ this._clearError(); this._checkRegionRequired(country); + $(regionList).find('option:selected').removeAttr('selected'); + regionInput.val(''); + // Populate state/province dropdown list if available or use input box if (this.options.regionJson[country]) { this._removeSelectOptions(regionList); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js index f58a560a6b3c..6fc5ef9d2a57 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/sidebar.js @@ -13,7 +13,8 @@ define([ 'jquery-ui-modules/widget', 'mage/decorate', 'mage/collapsible', - 'mage/cookies' + 'mage/cookies', + 'jquery-ui-modules/effect-fade' ], function ($, authenticationPopup, customerData, alert, confirm, _) { 'use strict'; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 59d1daa75713..e728a5c0fcdd 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -159,7 +159,6 @@ function ( } addressData['save_in_address_book'] = this.saveInAddressBook() ? 1 : 0; newBillingAddress = createBillingAddress(addressData); - // New address must be selected as a billing address selectBillingAddress(newBillingAddress); checkoutData.setSelectedBillingAddress(newBillingAddress.getKey()); @@ -237,6 +236,30 @@ function ( */ getCode: function (parent) { return _.isFunction(parent.getCode) ? parent.getCode() : 'shared'; + }, + + /** + * Get customer attribute label + * + * @param {*} attribute + * @returns {*} + */ + getCustomAttributeLabel: function (attribute) { + var resultAttribute; + + if (typeof attribute === 'string') { + return attribute; + } + + if (attribute.label) { + return attribute.label; + } + + resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], { + value: attribute.value + }); + + return resultAttribute && resultAttribute.label || attribute.value; } }); }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js index c0de643d3a22..74b1e6ac55ea 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js @@ -185,6 +185,10 @@ define([ * @returns {Boolean} - initial visibility state. */ resolveInitialPasswordVisibility: function () { + if (checkoutData.getInputFieldEmailValue() !== '' && checkoutData.getCheckedEmailValue() === '') { + return true; + } + if (checkoutData.getInputFieldEmailValue() !== '') { return checkoutData.getInputFieldEmailValue() === checkoutData.getCheckedEmailValue(); } diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js b/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js index e8994c61b722..716fb367b2e1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/payment.js @@ -54,7 +54,7 @@ define([ $t('Review & Payments'), this.isVisible, _.bind(this.navigate, this), - 20 + this.sortOrder ); return this; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js index 54381ad96b0b..939a2af1a25a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/address-renderer/default.js @@ -7,12 +7,13 @@ define([ 'jquery', 'ko', 'uiComponent', + 'underscore', 'Magento_Checkout/js/action/select-shipping-address', 'Magento_Checkout/js/model/quote', 'Magento_Checkout/js/model/shipping-address/form-popup-state', 'Magento_Checkout/js/checkout-data', 'Magento_Customer/js/customer-data' -], function ($, ko, Component, selectShippingAddressAction, quote, formPopUpState, checkoutData, customerData) { +], function ($, ko, Component, _, selectShippingAddressAction, quote, formPopUpState, checkoutData, customerData) { 'use strict'; var countryData = customerData.get('directory-data'); @@ -47,6 +48,30 @@ define([ return countryData()[countryId] != undefined ? countryData()[countryId].name : ''; //eslint-disable-line }, + /** + * Get customer attribute label + * + * @param {*} attribute + * @returns {*} + */ + getCustomAttributeLabel: function (attribute) { + var resultAttribute; + + if (typeof attribute === 'string') { + return attribute; + } + + if (attribute.label) { + return attribute.label; + } + + resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], { + value: attribute.value + }); + + return resultAttribute && resultAttribute.label || attribute.value; + }, + /** Set selected customer shipping address */ selectAddress: function () { selectShippingAddressAction(this.address()); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js index 4f4fc3de3e1a..2bdfd063cb6f 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-address/list.js @@ -16,7 +16,8 @@ define([ var defaultRendererTemplate = { parent: '${ $.$data.parentName }', name: '${ $.$data.name }', - component: 'Magento_Checkout/js/view/shipping-address/address-renderer/default' + component: 'Magento_Checkout/js/view/shipping-address/address-renderer/default', + provider: 'checkoutProvider' }; return Component.extend({ diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js index acc9f1c2391d..009178cbb19b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/address-renderer/default.js @@ -5,8 +5,9 @@ define([ 'uiComponent', + 'underscore', 'Magento_Customer/js/customer-data' -], function (Component, customerData) { +], function (Component, _, customerData) { 'use strict'; var countryData = customerData.get('directory-data'); @@ -22,6 +23,30 @@ define([ */ getCountryName: function (countryId) { return countryData()[countryId] != undefined ? countryData()[countryId].name : ''; //eslint-disable-line + }, + + /** + * Get customer attribute label + * + * @param {*} attribute + * @returns {*} + */ + getCustomAttributeLabel: function (attribute) { + var resultAttribute; + + if (typeof attribute === 'string') { + return attribute; + } + + if (attribute.label) { + return attribute.label; + } + + resultAttribute = _.findWhere(this.source.get('customAttributes')[attribute['attribute_code']], { + value: attribute.value + }); + + return resultAttribute && resultAttribute.label || attribute.value; } }); }); diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js index 28eb83c8be3e..3bb2715c78a7 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping-information/list.js @@ -16,7 +16,8 @@ define([ var defaultRendererTemplate = { parent: '${ $.$data.parentName }', name: '${ $.$data.name }', - component: 'Magento_Checkout/js/view/shipping-information/address-renderer/default' + component: 'Magento_Checkout/js/view/shipping-information/address-renderer/default', + provider: 'checkoutProvider' }; return Component.extend({ diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index c811d3a1e836..1c3f38a37c7f 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -87,7 +87,7 @@ define([ '', $t('Shipping'), this.visible, _.bind(this.navigate, this), - 10 + this.sortOrder ); } checkoutDataResolver.resolveShippingAddress(); @@ -249,6 +249,16 @@ define([ if (this.validateShippingInformation()) { quote.billingAddress(null); checkoutDataResolver.resolveBillingAddress(); + registry.async('checkoutProvider')(function (checkoutProvider) { + var shippingAddressData = checkoutData.getShippingAddressFromData(); + + if (shippingAddressData) { + checkoutProvider.set( + 'shippingAddress', + $.extend(true, {}, checkoutProvider.get('shippingAddress'), shippingAddressData) + ); + } + }); setShippingInformationAction().done( function () { stepNavigator.next(); diff --git a/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html b/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html index a0827d17d662..23bbce48fee2 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html @@ -13,19 +13,8 @@ <a if="currentBillingAddress().telephone" attr="'href': 'tel:' + currentBillingAddress().telephone" text="currentBillingAddress().telephone"></a><br/> <each args="data: currentBillingAddress().customAttributes, as: 'element'"> - <if args="typeof element === 'object'"> - <if args="element.label"> - <text args="element.label"/> - </if> - <ifnot args="element.label"> - <if args="element.value"> - <text args="element.value"/> - </if> - </ifnot> - </if> - <if args="typeof element === 'string'"> - <text args="element"/> - </if><br/> + <text args="$parent.getCustomAttributeLabel(element)"/> + <br/> </each> <button visible="!isAddressSameAsShipping()" diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html index cf64c0140b95..b14f4da3f5f7 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -13,21 +13,8 @@ <a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br/> <each args="data: address().customAttributes, as: 'element'"> - <each args="data: Object.keys(element), as: 'attribute'"> - <if args="typeof element[attribute] === 'object'"> - <if args="element[attribute].label"> - <text args="element[attribute].label"/> - </if> - <ifnot args="element[attribute].label"> - <if args="element[attribute].value"> - <text args="element[attribute].value"/> - </if> - </ifnot> - </if> - <if args="typeof element[attribute] === 'string'"> - <text args="element[attribute]"/> - </if><br/> - </each> + <text args="$parent.getCustomAttributeLabel(element)"/> + <br/> </each> <button visible="address().isEditable()" type="button" diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html index 75e061426d81..26dd7742d1da 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html @@ -13,18 +13,7 @@ <a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br/> <each args="data: address().customAttributes, as: 'element'"> - <if args="typeof element === 'object'"> - <if args="element.label"> - <text args="element.label"/> - </if> - <ifnot args="element.label"> - <if args="element.value"> - <text args="element.value"/> - </if> - </ifnot> - </if> - <if args="typeof element === 'string'"> - <text args="element"/> - </if><br/> + <text args="$parent.getCustomAttributeLabel(element)"/> + <br/> </each> </if> diff --git a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php index e94992ae26b6..9efd24e5003c 100644 --- a/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php +++ b/app/code/Magento/Cms/Block/Adminhtml/Wysiwyg/Images/Content.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Cms\Block\Adminhtml\Wysiwyg\Images; /** @@ -45,8 +47,12 @@ protected function _construct() $this->buttonList->remove('edit'); $this->buttonList->add( 'cancel', - ['class' => 'cancel action-quaternary', 'label' => __('Cancel'), 'type' => 'button', - 'onclick' => 'MediabrowserUtility.closeDialog();'], + [ + 'class' => 'cancel action-quaternary', + 'label' => __('Cancel'), + 'type' => 'button', + 'onclick' => 'MediabrowserUtility.closeDialog();' + ], 0, 0, 'header' @@ -54,7 +60,11 @@ protected function _construct() $this->buttonList->add( 'delete_folder', - ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Folder'), 'type' => 'button'], + [ + 'class' => 'delete no-display action-quaternary', + 'label' => __('Delete Folder'), + 'type' => 'button' + ], 0, 0, 'header' @@ -62,7 +72,11 @@ protected function _construct() $this->buttonList->add( 'delete_files', - ['class' => 'delete no-display action-quaternary', 'label' => __('Delete Selected'), 'type' => 'button'], + [ + 'class' => 'delete no-display action-quaternary', + 'label' => __('Delete Selected'), + 'type' => 'button' + ], 0, 0, 'header' @@ -70,7 +84,11 @@ protected function _construct() $this->buttonList->add( 'new_folder', - ['class' => 'save', 'label' => __('Create Folder'), 'type' => 'button'], + [ + 'class' => 'save new_folder', + 'label' => __('Create Folder'), + 'type' => 'button' + ], 0, 0, 'header' @@ -78,7 +96,11 @@ protected function _construct() $this->buttonList->add( 'insert_files', - ['class' => 'save no-display action-primary', 'label' => __('Add Selected'), 'type' => 'button'], + [ + 'class' => 'save no-display action-primary', + 'label' => __('Add Selected'), + 'type' => 'button' + ], 0, 0, 'header' @@ -92,9 +114,7 @@ protected function _construct() */ public function getContentsUrl() { - return $this->getUrl('cms/*/contents', [ - 'type' => $this->getRequest()->getParam('type'), - ]); + return $this->getUrl('cms/*/contents', ['type' => $this->getRequest()->getParam('type')]); } /** diff --git a/app/code/Magento/Cms/Block/Block.php b/app/code/Magento/Cms/Block/Block.php index c611f4b1e9f0..86cf059525e1 100644 --- a/app/code/Magento/Cms/Block/Block.php +++ b/app/code/Magento/Cms/Block/Block.php @@ -13,6 +13,11 @@ */ class Block extends AbstractBlock implements \Magento\Framework\DataObject\IdentityInterface { + /** + * Prefix for cache key of CMS block + */ + const CACHE_KEY_PREFIX = 'CMS_BLOCK_'; + /** * @var \Magento\Cms\Model\Template\FilterProvider */ diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php index 8774d7e69adf..2237f35ed0b8 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/InlineEdit.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action\Context; use Magento\Cms\Api\PageRepositoryInterface as PageRepository; +use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\Result\JsonFactory; use Magento\Cms\Api\Data\PageInterface; @@ -15,7 +16,7 @@ * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class InlineEdit extends \Magento\Backend\App\Action +class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionInterface { /** * Authorization level of a basic admin session @@ -56,6 +57,8 @@ public function __construct( } /** + * Process the request + * * @return \Magento\Framework\Controller\ResultInterface * @throws \Magento\Framework\Exception\LocalizedException */ @@ -68,10 +71,12 @@ public function execute() $postItems = $this->getRequest()->getParam('items', []); if (!($this->getRequest()->getParam('isAjax') && count($postItems))) { - return $resultJson->setData([ - 'messages' => [__('Please correct the data sent.')], - 'error' => true, - ]); + return $resultJson->setData( + [ + 'messages' => [__('Please correct the data sent.')], + 'error' => true, + ] + ); } foreach (array_keys($postItems) as $pageId) { @@ -98,10 +103,12 @@ public function execute() } } - return $resultJson->setData([ - 'messages' => $messages, - 'error' => $error - ]); + return $resultJson->setData( + [ + 'messages' => $messages, + 'error' => $error + ] + ); } /** @@ -131,7 +138,7 @@ protected function filterPost($postData = []) */ protected function validatePost(array $pageData, \Magento\Cms\Model\Page $page, &$error, array &$messages) { - if (!($this->dataProcessor->validate($pageData) && $this->dataProcessor->validateRequireEntry($pageData))) { + if (!$this->dataProcessor->validateRequireEntry($pageData)) { $error = true; foreach ($this->messageManager->getMessages(true)->getItems() as $error) { $messages[] = $this->getErrorWithPageId($page, $error->getText()); diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php index 9b8933c8dba2..46f68955531a 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php @@ -12,8 +12,7 @@ use Magento\Framework\Config\Dom\ValidationSchemaException; /** - * Class PostDataProcessor - * @package Magento\Cms\Controller\Adminhtml\Page + * Processes form data */ class PostDataProcessor { @@ -80,6 +79,7 @@ public function filter($data) * * @param array $data * @return bool Return FALSE if some item is invalid + * @deprecated */ public function validate($data) { diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php index 37cb45753174..569f6b256163 100644 --- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php +++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php @@ -107,10 +107,6 @@ public function execute() ['page' => $model, 'request' => $this->getRequest()] ); - if (!$this->dataProcessor->validate($data)) { - return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]); - } - try { $this->pageRepository->save($model); $this->messageManager->addSuccessMessage(__('You saved the page.')); diff --git a/app/code/Magento/Cms/Model/BlockSearchResults.php b/app/code/Magento/Cms/Model/BlockSearchResults.php new file mode 100644 index 000000000000..2fa5dbb40139 --- /dev/null +++ b/app/code/Magento/Cms/Model/BlockSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Cms\Model; + +use Magento\Cms\Api\Data\BlockSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Block search results. + */ +class BlockSearchResults extends SearchResults implements BlockSearchResultsInterface +{ +} diff --git a/app/code/Magento/Cms/Model/PageRepository/ValidationComposite.php b/app/code/Magento/Cms/Model/PageRepository/ValidationComposite.php new file mode 100644 index 000000000000..9fd94d4c11e1 --- /dev/null +++ b/app/code/Magento/Cms/Model/PageRepository/ValidationComposite.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Cms\Model\PageRepository; + +use Magento\Cms\Api\Data\PageInterface; +use Magento\Cms\Api\PageRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaInterface; + +/** + * Validates and saves a page + */ +class ValidationComposite implements PageRepositoryInterface +{ + /** + * @var PageRepositoryInterface + */ + private $repository; + + /** + * @var array + */ + private $validators; + + /** + * @param PageRepositoryInterface $repository + * @param ValidatorInterface[] $validators + */ + public function __construct( + PageRepositoryInterface $repository, + array $validators = [] + ) { + foreach ($validators as $validator) { + if (!$validator instanceof ValidatorInterface) { + throw new \InvalidArgumentException( + sprintf('Supplied validator does not implement %s', ValidatorInterface::class) + ); + } + } + $this->repository = $repository; + $this->validators = $validators; + } + + /** + * @inheritdoc + */ + public function save(PageInterface $page) + { + foreach ($this->validators as $validator) { + $validator->validate($page); + } + + return $this->repository->save($page); + } + + /** + * @inheritdoc + */ + public function getById($pageId) + { + return $this->repository->getById($pageId); + } + + /** + * @inheritdoc + */ + public function getList(SearchCriteriaInterface $searchCriteria) + { + return $this->repository->getList($searchCriteria); + } + + /** + * @inheritdoc + */ + public function delete(PageInterface $page) + { + return $this->repository->delete($page); + } + + /** + * @inheritdoc + */ + public function deleteById($pageId) + { + return $this->repository->deleteById($pageId); + } +} diff --git a/app/code/Magento/Cms/Model/PageRepository/Validator/LayoutUpdateValidator.php b/app/code/Magento/Cms/Model/PageRepository/Validator/LayoutUpdateValidator.php new file mode 100644 index 000000000000..721fd9efbdd9 --- /dev/null +++ b/app/code/Magento/Cms/Model/PageRepository/Validator/LayoutUpdateValidator.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Cms\Model\PageRepository\Validator; + +use Magento\Cms\Api\Data\PageInterface; +use Magento\Cms\Model\PageRepository\ValidatorInterface; +use Magento\Framework\Config\Dom\ValidationException; +use Magento\Framework\Config\Dom\ValidationSchemaException; +use Magento\Framework\Config\ValidationStateInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\View\Model\Layout\Update\Validator; +use Magento\Framework\View\Model\Layout\Update\ValidatorFactory; + +/** + * Validate a given page + */ +class LayoutUpdateValidator implements ValidatorInterface +{ + /** + * @var ValidatorFactory + */ + private $validatorFactory; + + /** + * @var ValidationStateInterface + */ + private $validationState; + + /** + * @param ValidatorFactory $validatorFactory + * @param ValidationStateInterface $validationState + */ + public function __construct( + ValidatorFactory $validatorFactory, + ValidationStateInterface $validationState + ) { + $this->validatorFactory = $validatorFactory; + $this->validationState = $validationState; + } + + /** + * Validate the data before saving + * + * @param PageInterface $page + * @throws LocalizedException + */ + public function validate(PageInterface $page): void + { + $this->validateRequiredFields($page); + $this->validateLayoutUpdate($page); + $this->validateCustomLayoutUpdate($page); + } + + /** + * Validate required fields + * + * @param PageInterface $page + * @throws LocalizedException + */ + private function validateRequiredFields(PageInterface $page): void + { + if (empty($page->getTitle())) { + throw new LocalizedException(__('Required field "%1" is empty.', 'title')); + } + } + + /** + * Validate layout update + * + * @param PageInterface $page + * @throws LocalizedException + */ + private function validateLayoutUpdate(PageInterface $page): void + { + $layoutXmlValidator = $this->getLayoutValidator(); + + try { + if (!empty($page->getLayoutUpdateXml()) + && !$layoutXmlValidator->isValid($page->getLayoutUpdateXml()) + ) { + throw new LocalizedException(__('Layout update is invalid')); + } + } catch (ValidationException|ValidationSchemaException $e) { + throw new LocalizedException(__('Layout update is invalid')); + } + } + + /** + * Validate custom layout update + * + * @param PageInterface $page + * @throws LocalizedException + */ + private function validateCustomLayoutUpdate(PageInterface $page): void + { + $layoutXmlValidator = $this->getLayoutValidator(); + + try { + if (!empty($page->getCustomLayoutUpdateXml()) + && !$layoutXmlValidator->isValid($page->getCustomLayoutUpdateXml()) + ) { + throw new LocalizedException(__('Custom layout update is invalid')); + } + } catch (ValidationException|ValidationSchemaException $e) { + throw new LocalizedException(__('Custom layout update is invalid')); + } + } + + /** + * Return a new validator + * + * @return Validator + */ + private function getLayoutValidator(): Validator + { + return $this->validatorFactory->create( + [ + 'validationState' => $this->validationState, + ] + ); + } +} diff --git a/app/code/Magento/Cms/Model/PageRepository/ValidatorInterface.php b/app/code/Magento/Cms/Model/PageRepository/ValidatorInterface.php new file mode 100644 index 000000000000..ff5c7648a9fa --- /dev/null +++ b/app/code/Magento/Cms/Model/PageRepository/ValidatorInterface.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Cms\Model\PageRepository; + +use Magento\Cms\Api\Data\PageInterface; +use Magento\Framework\Exception\LocalizedException; + +/** + * Validate a page repository + */ +interface ValidatorInterface +{ + /** + * Assert the given page valid + * + * @param PageInterface $page + * @return void + * @throws LocalizedException + */ + public function validate(PageInterface $page): void; +} diff --git a/app/code/Magento/Cms/Model/PageSearchResults.php b/app/code/Magento/Cms/Model/PageSearchResults.php new file mode 100644 index 000000000000..7985e382be27 --- /dev/null +++ b/app/code/Magento/Cms/Model/PageSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Cms\Model; + +use Magento\Cms\Api\Data\PageSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Page search results. + */ +class PageSearchResults extends SearchResults implements PageSearchResultsInterface +{ +} diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCMSBlockContentActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCMSBlockContentActionGroup.xml new file mode 100644 index 000000000000..711a8af38efe --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminCMSBlockContentActionGroup.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAddImageToCMSBlockContent"> + <arguments> + <argument name="image" type="entity" defaultValue="MagentoLogo"/> + </arguments> + <click selector="{{TinyMCESection.InsertImage}}" stepKey="clickAddImageButton"/> + <waitForElementVisible selector="{{MediaGallerySection.Browse}}" stepKey="waitForBrowseImage"/> + <click selector="{{MediaGallerySection.Browse}}" stepKey="clickBrowseImage"/> + <waitForElementVisible selector="{{MediaGallerySection.StorageRootArrow}}" stepKey="waitForAttacheFiles"/> + <waitForLoadingMaskToDisappear stepKey="waitForStorageRootLoadingMaskDisappear"/> + <click selector="{{MediaGallerySection.StorageRootArrow}}" stepKey="clickRoot"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <attachFile selector="{{MediaGallerySection.BrowseUploadImage}}" userInput="{{image.file}}" stepKey="attachLogo"/> + <waitForElementVisible selector="{{MediaGallerySection.InsertFile}}" stepKey="waitForAddSelected"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear"/> + <click selector="{{MediaGallerySection.InsertFile}}" stepKey="clickAddSelected"/> + <waitForElementVisible selector="{{MediaGallerySection.OkBtn}}" stepKey="waitForOkButton"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear2"/> + <click selector="{{MediaGallerySection.OkBtn}}" stepKey="clickOk"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml index 2efa7f62fc4e..445279a8b140 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml @@ -24,6 +24,8 @@ </section> <section name="BlockContentSection"> <element name="TextArea" type="input" selector="#cms_block_form_content"/> + <element name="image" type="file" selector="#tinymce img"/> + <element name="contentIframe" type="iframe" selector="cms_block_form_content_ifr"/> </section> <section name="CmsBlockBlockActionSection"> <element name="deleteBlock" type="button" selector="#delete" timeout="30"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml index fccc5b5980f2..b7c7e4a4212f 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml @@ -23,7 +23,7 @@ <actionGroup ref="DisabledWYSIWYG" stepKey="disableWYSIWYG"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <amOnPage url="{{CmsPagesPage.url}}" stepKey="amOnPagePagesGrid"/> <waitForPageLoad stepKey="waitForPageLoad1"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminMediaGalleryPopupUploadImagesWithoutErrorTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminMediaGalleryPopupUploadImagesWithoutErrorTest.xml new file mode 100644 index 000000000000..bc1688c9d692 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminMediaGalleryPopupUploadImagesWithoutErrorTest.xml @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminMediaGalleryPopupUploadImagesWithoutErrorTest"> + <annotations> + <features value="Cms"/> + <stories value="Spinner is Always Displayed on Media Gallery popup"/> + <title value="Media Gallery popup upload images without error"/> + <description value="Media Gallery popup upload images without error"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-18962"/> + <useCaseId value="MC-18709"/> + <group value="Cms"/> + </annotations> + <before> + <!--Enable WYSIWYG options--> + <comment userInput="Enable WYSIWYG options" stepKey="commentEnableWYSIWYG"/> + <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYGEditor"/> + <magentoCLI command="config:set cms/wysiwyg/editor 'TinyMCE 4'" stepKey="setValueWYSIWYGEditor"/> + <!--Create block--> + <comment userInput="Create block" stepKey="commentCreateBlock"/> + <createData entity="Sales25offBlock" stepKey="createBlock"/> + <actionGroup ref="LoginActionGroup" stepKey="login"/> + </before> + <after> + <!--Disable WYSIWYG options--> + <comment userInput="Disable WYSIWYG options" stepKey="commentDisableWYSIWYG"/> + <magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/> + <deleteData createDataKey="createBlock" stepKey="deleteBlock" /> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Open created block page and add image--> + <comment userInput="Open create block page and add image" stepKey="commentOpenBlockPage"/> + <actionGroup ref="navigateToCreatedCMSBlockPage" stepKey="navigateToCreatedCMSBlockPage1"> + <argument name="CMSBlockPage" value="$$createBlock$$"/> + </actionGroup> + <actionGroup ref="AdminAddImageToCMSBlockContent" stepKey="addImage"> + <argument name="image" value="TestImageNew"/> + </actionGroup> + <click selector="{{BlockWYSIWYGSection.ShowHideBtn}}" stepKey="clickShowHideBtnFirstTime"/> + <click selector="{{BlockWYSIWYGSection.ShowHideBtn}}" stepKey="clickShowHideBtnSecondTime"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <!--Switch to content frame and click on image--> + <comment userInput="Switch to content frame and click on image" stepKey="commentSwitchToIframe"/> + <switchToIFrame selector="{{BlockContentSection.contentIframe}}" stepKey="switchToContentFrame"/> + <click selector="{{BlockContentSection.image}}" stepKey="clickImage"/> + <switchToIFrame stepKey="switchBack"/> + <!--Add image second time and assert--> + <comment userInput="Add image second time and assert" stepKey="commentAddImageAndAssert"/> + <actionGroup ref="AdminAddImageToCMSBlockContent" stepKey="addImageSecondTime"> + <argument name="image" value="MagentoLogo"/> + </actionGroup> + <switchToIFrame selector="{{BlockContentSection.contentIframe}}" stepKey="switchToContentFrameSecondTime"/> + <seeElement selector="{{BlockContentSection.image}}" stepKey="seeImageElement"/> + </test> +</tests> diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php index 9d51431b26d8..7f2ff2086df9 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/InlineEditTest.php @@ -102,10 +102,6 @@ public function prepareMocksForTestExecute() ->method('filter') ->with($postData[1]) ->willReturnArgument(0); - $this->dataProcessor->expects($this->once()) - ->method('validate') - ->with($postData[1]) - ->willReturn(false); $this->messageManager->expects($this->once()) ->method('getMessages') ->with(true) @@ -122,19 +118,23 @@ public function prepareMocksForTestExecute() ->willReturn('1'); $this->cmsPage->expects($this->atLeastOnce()) ->method('getData') - ->willReturn([ - 'layout' => '1column', - 'identifier' => 'test-identifier' - ]); + ->willReturn( + [ + 'layout' => '1column', + 'identifier' => 'test-identifier' + ] + ); $this->cmsPage->expects($this->once()) ->method('setData') - ->with([ - 'layout' => '1column', - 'title' => '404 Not Found', - 'identifier' => 'no-route', - 'custom_theme' => '1', - 'custom_root_template' => '2' - ]); + ->with( + [ + 'layout' => '1column', + 'title' => '404 Not Found', + 'identifier' => 'no-route', + 'custom_theme' => '1', + 'custom_root_template' => '2' + ] + ); $this->jsonFactory->expects($this->once()) ->method('create') ->willReturn($this->resultJson); @@ -149,13 +149,15 @@ public function testExecuteWithLocalizedException() ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('LocalizedException'))); $this->resultJson->expects($this->once()) ->method('setData') - ->with([ - 'messages' => [ - '[Page ID: 1] Error message', - '[Page ID: 1] LocalizedException' - ], - 'error' => true - ]) + ->with( + [ + 'messages' => [ + '[Page ID: 1] Error message', + '[Page ID: 1] LocalizedException' + ], + 'error' => true + ] + ) ->willReturnSelf(); $this->assertSame($this->resultJson, $this->controller->execute()); @@ -170,13 +172,15 @@ public function testExecuteWithRuntimeException() ->willThrowException(new \RuntimeException(__('RuntimeException'))); $this->resultJson->expects($this->once()) ->method('setData') - ->with([ - 'messages' => [ - '[Page ID: 1] Error message', - '[Page ID: 1] RuntimeException' - ], - 'error' => true - ]) + ->with( + [ + 'messages' => [ + '[Page ID: 1] Error message', + '[Page ID: 1] RuntimeException' + ], + 'error' => true + ] + ) ->willReturnSelf(); $this->assertSame($this->resultJson, $this->controller->execute()); @@ -191,13 +195,15 @@ public function testExecuteWithException() ->willThrowException(new \Exception(__('Exception'))); $this->resultJson->expects($this->once()) ->method('setData') - ->with([ - 'messages' => [ - '[Page ID: 1] Error message', - '[Page ID: 1] Something went wrong while saving the page.' - ], - 'error' => true - ]) + ->with( + [ + 'messages' => [ + '[Page ID: 1] Error message', + '[Page ID: 1] Something went wrong while saving the page.' + ], + 'error' => true + ] + ) ->willReturnSelf(); $this->assertSame($this->resultJson, $this->controller->execute()); @@ -218,12 +224,14 @@ public function testExecuteWithoutData() ); $this->resultJson->expects($this->once()) ->method('setData') - ->with([ - 'messages' => [ - 'Please correct the data sent.' - ], - 'error' => true - ]) + ->with( + [ + 'messages' => [ + 'Please correct the data sent.' + ], + 'error' => true + ] + ) ->willReturnSelf(); $this->assertSame($this->resultJson, $this->controller->execute()); diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageRepository/ValidationCompositeTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageRepository/ValidationCompositeTest.php new file mode 100644 index 000000000000..f73396230a66 --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Model/PageRepository/ValidationCompositeTest.php @@ -0,0 +1,145 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Cms\Test\Unit\Model\PageRepository; + +use Magento\Cms\Api\Data\PageInterface; +use Magento\Cms\Api\PageRepositoryInterface; +use Magento\Cms\Model\PageRepository\ValidationComposite; +use Magento\Cms\Model\PageRepository\ValidatorInterface; +use Magento\Framework\Api\SearchCriteriaInterface; +use Magento\Framework\Exception\LocalizedException; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +/** + * Validate behavior of the validation composite + */ +class ValidationCompositeTest extends TestCase +{ + /** + * @var PageRepositoryInterface|MockObject + */ + private $subject; + + protected function setUp() + { + /** @var PageRepositoryInterface subject */ + $this->subject = $this->createMock(PageRepositoryInterface::class); + } + + /** + * @param $validators + * @expectedException \InvalidArgumentException + * @dataProvider constructorArgumentProvider + */ + public function testConstructorValidation($validators) + { + new ValidationComposite($this->subject, $validators); + } + + public function testSaveInvokesValidatorsWithSucess() + { + $validator1 = $this->createMock(ValidatorInterface::class); + $validator2 = $this->createMock(ValidatorInterface::class); + $page = $this->createMock(PageInterface::class); + + // Assert each are called + $validator1 + ->expects($this->once()) + ->method('validate') + ->with($page); + $validator2 + ->expects($this->once()) + ->method('validate') + ->with($page); + + // Assert that the success is called + $this->subject + ->expects($this->once()) + ->method('save') + ->with($page) + ->willReturn('foo'); + + $composite = new ValidationComposite($this->subject, [$validator1, $validator2]); + $result = $composite->save($page); + + self::assertSame('foo', $result); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Oh no. That isn't right. + */ + public function testSaveInvokesValidatorsWithErrors() + { + $validator1 = $this->createMock(ValidatorInterface::class); + $validator2 = $this->createMock(ValidatorInterface::class); + $page = $this->createMock(PageInterface::class); + + // Assert the first is called + $validator1 + ->expects($this->once()) + ->method('validate') + ->with($page) + ->willThrowException(new LocalizedException(__('Oh no. That isn\'t right.'))); + + // Assert the second is NOT called + $validator2 + ->expects($this->never()) + ->method('validate'); + + // Assert that the success is NOT called + $this->subject + ->expects($this->never()) + ->method('save'); + + $composite = new ValidationComposite($this->subject, [$validator1, $validator2]); + $composite->save($page); + } + + /** + * @param $method + * @param $arg + * @dataProvider passthroughMethodDataProvider + */ + public function testPassthroughMethods($method, $arg) + { + $this->subject + ->method($method) + ->with($arg) + ->willReturn('foo'); + + $composite = new ValidationComposite($this->subject, []); + $result = $composite->{$method}($arg); + + self::assertSame('foo', $result); + } + + public function constructorArgumentProvider() + { + return [ + [[null], false], + [[''], false], + [['foo'], false], + [[new \stdClass()], false], + [[$this->createMock(ValidatorInterface::class), 'foo'], false], + ]; + } + + public function passthroughMethodDataProvider() + { + return [ + ['save', $this->createMock(PageInterface::class)], + ['getById', 1], + ['getList', $this->createMock(SearchCriteriaInterface::class)], + ['delete', $this->createMock(PageInterface::class)], + ['deleteById', 1], + ]; + } +} diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageRepository/Validator/LayoutUpdateValidatorTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageRepository/Validator/LayoutUpdateValidatorTest.php new file mode 100644 index 000000000000..487a90bb9a18 --- /dev/null +++ b/app/code/Magento/Cms/Test/Unit/Model/PageRepository/Validator/LayoutUpdateValidatorTest.php @@ -0,0 +1,124 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Cms\Test\Unit\Model\PageRepository\Validator; + +use Magento\Cms\Api\Data\PageInterface; +use Magento\Cms\Model\PageRepository\Validator\LayoutUpdateValidator; +use Magento\Framework\Config\Dom\ValidationException; +use Magento\Framework\Config\Dom\ValidationSchemaException; +use Magento\Framework\Config\ValidationStateInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\View\Model\Layout\Update\ValidatorFactory; +use Magento\Framework\View\Model\Layout\Update\Validator; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +/** + * Test cases for the layout update validator + */ +class LayoutUpdateValidatorTest extends TestCase +{ + /** + * @var Validator|MockObject + */ + private $layoutValidator; + + /** + * @var LayoutUpdateValidator + */ + private $validator; + + protected function setUp() + { + $layoutValidatorFactory = $this->createMock(ValidatorFactory::class); + $this->layoutValidator = $this->createMock(Validator::class); + $layoutValidatorState = $this->createMock(ValidationStateInterface::class); + + $layoutValidatorFactory + ->method('create') + ->with(['validationState' => $layoutValidatorState]) + ->willReturn($this->layoutValidator); + + $this->validator = new LayoutUpdateValidator($layoutValidatorFactory, $layoutValidatorState); + } + + /** + * @dataProvider validationSetDataProvider + */ + public function testValidate($data, $expectedExceptionMessage, $layoutValidatorException, $isLayoutValid = false) + { + if ($expectedExceptionMessage) { + $this->expectException(LocalizedException::class); + $this->expectExceptionMessage($expectedExceptionMessage); + } + + if ($layoutValidatorException) { + $this->layoutValidator + ->method('isValid') + ->with($data['getLayoutUpdateXml'] ?? $data['getCustomLayoutUpdateXml']) + ->willThrowException($layoutValidatorException); + } elseif (!empty($data['getLayoutUpdateXml'])) { + $this->layoutValidator + ->method('isValid') + ->with($data['getLayoutUpdateXml']) + ->willReturn($isLayoutValid); + } elseif (!empty($data['getCustomLayoutUpdateXml'])) { + $this->layoutValidator + ->method('isValid') + ->with($data['getCustomLayoutUpdateXml']) + ->willReturn($isLayoutValid); + } + + $page = $this->createMock(PageInterface::class); + foreach ($data as $method => $value) { + $page + ->method($method) + ->willReturn($value); + } + + self::assertNull($this->validator->validate($page)); + } + + public function validationSetDataProvider() + { + $layoutError = 'Layout update is invalid'; + $customLayoutError = 'Custom layout update is invalid'; + $validationException = new ValidationException('Invalid format'); + $schemaException = new ValidationSchemaException(__('Invalid format')); + + return [ + [['getTitle' => ''], 'Required field "title" is empty.', null], + [['getTitle' => null], 'Required field "title" is empty.', null], + [['getTitle' => false], 'Required field "title" is empty.', null], + [['getTitle' => 0], 'Required field "title" is empty.', null], + [['getTitle' => '0'], 'Required field "title" is empty.', null], + [['getTitle' => []], 'Required field "title" is empty.', null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => ''], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => null], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => false], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => 0], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => '0'], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => []], null, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => 'foo'], $layoutError, null], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => 'foo'], $layoutError, $validationException], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => 'foo'], $layoutError, $schemaException], + [['getTitle' => 'foo', 'getLayoutUpdateXml' => 'foo'], null, null, true], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => ''], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => null], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => false], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => 0], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => '0'], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => []], null, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => 'foo'], $customLayoutError, null], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => 'foo'], $customLayoutError, $validationException], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => 'foo'], $customLayoutError, $schemaException], + [['getTitle' => 'foo', 'getCustomLayoutUpdateXml' => 'foo'], null, null, true], + ]; + } +} diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index 8741e37016b6..4ffe4a6ad877 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -58,7 +58,10 @@ protected function setUp() $this->blockActions = $objectManager->getObject( BlockActions::class, - ['context' => $context, 'urlBuilder' => $this->urlBuilder] + [ + 'context' => $context, + 'urlBuilder' => $this->urlBuilder + ] ); $objectManager->setBackwardCompatibleProperty($this->blockActions, 'escaper', $this->escaper); @@ -93,6 +96,7 @@ public function testPrepareDataSource() 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), + '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -102,6 +106,7 @@ public function testPrepareDataSource() 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, + '__disableTmpl' => true, ], ], ], diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index 32bbeed0788a..53d8ee522076 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -65,6 +65,7 @@ public function testPrepareItemsByPageId() 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), + '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -75,6 +76,7 @@ public function testPrepareItemsByPageId() '__disableTmpl' => true, ], 'post' => true, + '__disableTmpl' => true, ], ], ], @@ -84,7 +86,6 @@ public function testPrepareItemsByPageId() ->method('escapeHtml') ->with($title) ->willReturn($title); - // Configure mocks and object data $urlBuilderMock->expects($this->any()) ->method('getUrl') @@ -106,7 +107,6 @@ public function testPrepareItemsByPageId() ], ] ); - $model->setName($name); $items = $model->prepareDataSource($items); // Run test diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index 6e9eef47281c..65940c5d7b4f 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -70,6 +70,7 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), + '__disableTmpl' => true, ], 'delete' => [ 'href' => $this->urlBuilder->getUrl( @@ -84,6 +85,7 @@ public function prepareDataSource(array $dataSource) 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, + '__disableTmpl' => true, ], ]; } diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 5cefa212d165..fa3756abfded 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -86,7 +86,8 @@ public function prepareDataSource(array $dataSource) if (isset($item['page_id'])) { $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl($this->editUrl, ['page_id' => $item['page_id']]), - 'label' => __('Edit') + 'label' => __('Edit'), + '__disableTmpl' => true, ]; $title = $this->getEscaper()->escapeHtml($item['title']); $item[$name]['delete'] = [ @@ -98,6 +99,7 @@ public function prepareDataSource(array $dataSource) '__disableTmpl' => true, ], 'post' => true, + '__disableTmpl' => true, ]; } if (isset($item['identifier'])) { @@ -107,7 +109,8 @@ public function prepareDataSource(array $dataSource) isset($item['_first_store_id']) ? $item['_first_store_id'] : null, isset($item['store_code']) ? $item['store_code'] : null ), - 'label' => __('View') + 'label' => __('View'), + '__disableTmpl' => true, ]; } } diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml index e41f50091591..f510a0a026f7 100644 --- a/app/code/Magento/Cms/etc/di.xml +++ b/app/code/Magento/Cms/etc/di.xml @@ -7,15 +7,15 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\Cms\Api\Data\PageSearchResultsInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\Cms\Model\PageSearchResults" /> <preference for="Magento\Cms\Api\Data\BlockSearchResultsInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\Cms\Model\BlockSearchResults" /> <preference for="Magento\Cms\Api\GetBlockByIdentifierInterface" type="Magento\Cms\Model\GetBlockByIdentifier" /> <preference for="Magento\Cms\Api\GetPageByIdentifierInterface" type="Magento\Cms\Model\GetPageByIdentifier" /> <preference for="Magento\Cms\Api\Data\PageInterface" type="Magento\Cms\Model\Page" /> <preference for="Magento\Cms\Api\Data\BlockInterface" type="Magento\Cms\Model\Block" /> <preference for="Magento\Cms\Api\BlockRepositoryInterface" type="Magento\Cms\Model\BlockRepository" /> - <preference for="Magento\Cms\Api\PageRepositoryInterface" type="Magento\Cms\Model\PageRepository" /> + <preference for="Magento\Cms\Api\PageRepositoryInterface" type="Magento\Cms\Model\PageRepository\ValidationComposite" /> <preference for="Magento\Ui\Component\Wysiwyg\ConfigInterface" type="Magento\Cms\Model\Wysiwyg\Config"/> <preference for="Magento\Cms\Api\GetUtilityPageIdentifiersInterface" type="Magento\Cms\Model\GetUtilityPageIdentifiers" /> <type name="Magento\Cms\Model\Wysiwyg\Config"> @@ -235,4 +235,12 @@ <type name="Magento\Catalog\Model\Product"> <plugin name="cms" type="Magento\Cms\Model\Plugin\Product" sortOrder="100"/> </type> + <type name="Magento\Cms\Model\PageRepository\ValidationComposite"> + <arguments> + <argument name="repository" xsi:type="object">Magento\Cms\Model\PageRepository</argument> + <argument name="validators" xsi:type="array"> + <item name="layout_update" xsi:type="object">Magento\Cms\Model\PageRepository\Validator\LayoutUpdateValidator</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Cms/view/adminhtml/web/css/source/_module.less b/app/code/Magento/Cms/view/adminhtml/web/css/source/_module.less index af8fa2758f5a..715ad40dc475 100644 --- a/app/code/Magento/Cms/view/adminhtml/web/css/source/_module.less +++ b/app/code/Magento/Cms/view/adminhtml/web/css/source/_module.less @@ -3,13 +3,20 @@ * See COPYING.txt for license details. */ .modal-slide { - .media-gallery-modal { - .page-main-actions { - margin-bottom: 3rem; + .media-gallery-modal { + .page-main-actions { + margin-bottom: 3rem; + } + + .new_folder { + margin-right: 10px; + } } +} - #new_folder { - margin-right: 10px; +.tree-actions { + a { + cursor: pointer; } - } } + diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Template.php b/app/code/Magento/Config/Model/Config/Source/Email/Template.php index 04222733418d..e4f1ae65bcac 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Template.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Template.php @@ -6,6 +6,8 @@ namespace Magento\Config\Model\Config\Source\Email; /** + * Source for template + * * @api * @since 100.0.2 */ @@ -62,6 +64,12 @@ public function toOptionArray() $templateLabel = $this->_emailConfig->getTemplateLabel($templateId); $templateLabel = __('%1 (Default)', $templateLabel); array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]); + array_walk( + $options, + function (&$item) { + $item['__disableTmpl'] = true; + } + ); return $options; } } diff --git a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php index db815ec87ed7..23a3dea1a702 100644 --- a/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php +++ b/app/code/Magento/Config/Model/Config/Structure/AbstractElement.php @@ -40,7 +40,7 @@ abstract class AbstractElement implements StructureElementInterface protected $_storeManager; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -50,15 +50,11 @@ abstract class AbstractElement implements StructureElementInterface private $elementVisibility; /** - * Construct. - * * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager */ - public function __construct( - StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager - ) { + public function __construct(StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager) + { $this->_storeManager = $storeManager; $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php b/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php index efb918226aa3..a14114a116e7 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/AbstractComposite.php @@ -23,12 +23,12 @@ abstract class AbstractComposite extends \Magento\Config\Model\Config\Structure\ /** * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param Iterator $childrenIterator */ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, Iterator $childrenIterator ) { parent::__construct($storeManager, $moduleManager); diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Field.php b/app/code/Magento/Config/Model/Config/Structure/Element/Field.php index 6a8cc6e76746..834b2a9e17e3 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Field.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Field.php @@ -56,7 +56,7 @@ class Field extends \Magento\Config\Model\Config\Structure\AbstractElement /** * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Config\Model\Config\BackendFactory $backendFactory * @param \Magento\Config\Model\Config\SourceFactory $sourceFactory * @param \Magento\Config\Model\Config\CommentFactory $commentFactory @@ -65,7 +65,7 @@ class Field extends \Magento\Config\Model\Config\Structure\AbstractElement */ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Config\Model\Config\BackendFactory $backendFactory, \Magento\Config\Model\Config\SourceFactory $sourceFactory, \Magento\Config\Model\Config\CommentFactory $commentFactory, diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Group.php b/app/code/Magento/Config/Model/Config/Structure/Element/Group.php index db479e8b795a..1ca0afa942f8 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Group.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Group.php @@ -29,14 +29,14 @@ class Group extends AbstractComposite /** * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param Iterator\Field $childrenIterator * @param \Magento\Config\Model\Config\BackendClone\Factory $cloneModelFactory * @param Dependency\Mapper $dependencyMapper */ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Config\Model\Config\Structure\Element\Iterator\Field $childrenIterator, \Magento\Config\Model\Config\BackendClone\Factory $cloneModelFactory, \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper diff --git a/app/code/Magento/Config/Model/Config/Structure/Element/Section.php b/app/code/Magento/Config/Model/Config/Structure/Element/Section.php index 134411fbd87c..80c029dfea2d 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Element/Section.php +++ b/app/code/Magento/Config/Model/Config/Structure/Element/Section.php @@ -22,13 +22,13 @@ class Section extends AbstractComposite /** * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param Iterator $childrenIterator * @param \Magento\Framework\AuthorizationInterface $authorization */ public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, Iterator $childrenIterator, \Magento\Framework\AuthorizationInterface $authorization ) { diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminConfigCreateNewAccountActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminConfigCreateNewAccountActionGroup.xml index 10d22b61ecae..2a3a14293a05 100644 --- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminConfigCreateNewAccountActionGroup.xml +++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminConfigCreateNewAccountActionGroup.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="SetGroupForValidVATIdIntraUnionActionGroup"> <annotations> - <description>Goes to the 'Configuration' page for 'Customer Configuration'. Sets the 'Group For Valid VAT ID Intra Union' option. Clicks on the Save button. Validates the the Save message is present.</description> + <description>Goes to the 'Configuration' page for 'Customer Configuration'. Sets the 'Group For Valid VAT ID Intra Union' option. Clicks on the Save button. Validates the Save message is present.</description> </annotations> <arguments> <argument name="value" type="string"/> diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml index 8fafdc202bf0..a1ee5348d094 100644 --- a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml +++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml @@ -24,4 +24,7 @@ <page name="AdminConfigDeveloperPage" url="admin/system_config/edit/section/dev/" area="admin" module="Magento_Config"> <section name="AdminConfigSection" /> </page> + <page name="AdminConfigAdvancedAdmin" url="admin/system_config/edit/section/admin/" area="admin" module="Magento_Config"> + <section name="AdvanceAdminSection"/> + </page> </pages> diff --git a/app/code/Magento/Paypal/Test/Mftf/Suite/suite.xml b/app/code/Magento/Config/Test/Mftf/Suite/AppConfigDumpSuite.xml similarity index 55% rename from app/code/Magento/Paypal/Test/Mftf/Suite/suite.xml rename to app/code/Magento/Config/Test/Mftf/Suite/AppConfigDumpSuite.xml index 621f2e6a6768..762d17bdf87f 100644 --- a/app/code/Magento/Paypal/Test/Mftf/Suite/suite.xml +++ b/app/code/Magento/Config/Test/Mftf/Suite/AppConfigDumpSuite.xml @@ -6,11 +6,14 @@ */ --> <suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd"> - <suite name="PaypalTestSuite"> + <suite name="AppConfigDumpSuite"> + <before> + <magentoCLI command="app:config:dump" stepKey="configDump"/> + </before> + <after> + </after> <include> - <test name="CheckDefaultValueOfPayPalCustomizeButtonTest"/> - <test name="PayPalSmartButtonInCheckoutPage"/> - <test name="CheckCreditButtonConfiguration"/> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"/> </include> </suite> -</suites> \ No newline at end of file +</suites> diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index b29ad244e7a8..9fabe6fef0c8 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -6,6 +6,9 @@ namespace Magento\Config\Test\Unit\Model\Config\Source\Email; +/** + * Test class for Template. + */ class TemplateTest extends \PHPUnit\Framework\TestCase { /** @@ -76,9 +79,21 @@ public function testToOptionArray() $this->returnValue('Template New') ); $expectedResult = [ - ['value' => 'template_new', 'label' => 'Template New (Default)'], - ['value' => 'template_one', 'label' => 'Template One'], - ['value' => 'template_two', 'label' => 'Template Two'], + [ + 'value' => 'template_new', + 'label' => 'Template New (Default)', + '__disableTmpl' => true + ], + [ + 'value' => 'template_one', + 'label' => 'Template One', + '__disableTmpl' => true + ], + [ + 'value' => 'template_two', + 'label' => 'Template Two', + '__disableTmpl' => true + ], ]; $this->_model->setPath('template/new'); $this->assertEquals($expectedResult, $this->_model->toOptionArray()); diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php index e448b628ef02..8c54a02a491c 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Structure/Element/AbstractCompositeTest.php @@ -29,7 +29,7 @@ class AbstractCompositeTest extends \PHPUnit\Framework\TestCase protected $_iteratorMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface | \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager | \PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; @@ -56,7 +56,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->_iteratorMock = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Iterator::class); $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class); - $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\ModuleManagerInterface::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); $this->_model = $this->getMockForAbstractClass( \Magento\Config\Model\Config\Structure\Element\AbstractComposite::class, [$this->_storeManagerMock, $this->moduleManagerMock, $this->_iteratorMock] diff --git a/app/code/Magento/Config/etc/db_schema.xml b/app/code/Magento/Config/etc/db_schema.xml index 46dd77959b9d..54680c0be7b0 100644 --- a/app/code/Magento/Config/etc/db_schema.xml +++ b/app/code/Magento/Config/etc/db_schema.xml @@ -15,6 +15,8 @@ default="0" comment="Config Scope ID"/> <column xsi:type="varchar" name="path" nullable="false" length="255" default="general" comment="Config Path"/> <column xsi:type="text" name="value" nullable="true" comment="Config Value"/> + <column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" + comment="Updated At"/> <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="config_id"/> </constraint> diff --git a/app/code/Magento/Config/etc/db_schema_whitelist.json b/app/code/Magento/Config/etc/db_schema_whitelist.json index 850e160bc732..51ca41d8e6af 100644 --- a/app/code/Magento/Config/etc/db_schema_whitelist.json +++ b/app/code/Magento/Config/etc/db_schema_whitelist.json @@ -5,11 +5,12 @@ "scope": true, "scope_id": true, "path": true, - "value": true + "value": true, + "updated_at": true }, "constraint": { "PRIMARY": true, "CORE_CONFIG_DATA_SCOPE_SCOPE_ID_PATH": true } } -} \ No newline at end of file +} diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php index 4874dc8ea03a..b9fcf307b613 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php @@ -197,6 +197,7 @@ protected function getAttributes() foreach ($attributes as $key => $attribute) { if (isset($configurableData[$key])) { $attributes[$key] = array_replace_recursive($attribute, $configurableData[$key]); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $attributes[$key]['values'] = array_merge( isset($attribute['values']) ? $attribute['values'] : [], isset($configurableData[$key]['values']) @@ -411,15 +412,17 @@ private function prepareAttributes( 'id' => $attribute->getAttributeId(), 'position' => $configurableAttributes[$attribute->getAttributeId()]['position'], 'chosen' => [], + '__disableTmpl' => true ]; - foreach ($attribute->getOptions() as $option) { - if (!empty($option->getValue())) { + $options = $attribute->usesSource() ? $attribute->getSource()->getAllOptions() : []; + foreach ($options as $option) { + if (!empty($option['value'])) { $attributes[$attribute->getAttributeId()]['options'][] = [ 'attribute_code' => $attribute->getAttributeCode(), 'attribute_label' => $attribute->getStoreLabel(0), - 'id' => $option->getValue(), - 'label' => $option->getLabel(), - 'value' => $option->getValue(), + 'id' => $option['value'], + 'label' => $option['label'], + 'value' => $option['value'], '__disableTmpl' => true, ]; } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php index e8b7299a03db..cb4ac975cd58 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Plugin.php @@ -6,7 +6,7 @@ */ namespace Magento\ConfigurableProduct\Model\Product\Type; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; /** * Type plugin. @@ -14,14 +14,14 @@ class Plugin { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php index 979587dc500a..f837444aa45c 100644 --- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php +++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/VariationMatrix.php @@ -3,9 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\ConfigurableProduct\Model\Product\Type; /** + * Variation matrix. + * * @api * @since 100.0.2 */ @@ -40,7 +43,9 @@ public function getVariations($usedProductAttributes) for ($attributeIndex = $attributesCount; $attributeIndex--;) { $currentAttribute = $variationalAttributes[$attributeIndex]; $currentVariationValue = $currentVariation[$attributeIndex]; - $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; + if (!empty($currentAttribute['id'])) { + $filledVariation[$currentAttribute['id']] = $currentAttribute['values'][$currentVariationValue]; + } } $variations[] = $filledVariation; diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml index 3f21c98068d8..6ae3c4f4e16c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml @@ -60,6 +60,19 @@ <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> </entity> + <entity name="ApiConfigurableProductWithDescriptionUnderscoredSku" type="product"> + <data key="sku" unique="suffix">api_configurable_product</data> + <data key="type_id">configurable</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">API Configurable Product</data> + <data key="urlKey" unique="suffix">api-configurable-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + </entity> <entity name="ConfigurableProductAddChild" type="ConfigurableProductAddChild"> <var key="sku" entityKey="sku" entityType="product" /> <var key="childSku" entityKey="sku" entityType="product2"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml index 9021bf981ac1..430007ae761f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml @@ -26,7 +26,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a configurable product via the UI --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductDeleteTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductDeleteTest.xml index 1a694b8adf17..33a6da9dabf3 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductDeleteTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductDeleteTest.xml @@ -66,7 +66,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> @@ -216,7 +216,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> <deleteData createDataKey="createConfigChildProduct3" stepKey="deleteConfigChildProduct3"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductLongSkuTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductLongSkuTest.xml index c599a6a23f19..cd09cbd29587 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductLongSkuTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductLongSkuTest.xml @@ -52,7 +52,7 @@ <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> <!--Clean up category--> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Create a configurable product with long name and sku--> @@ -87,6 +87,9 @@ <see selector="{{AdminProductFormConfigurationsSection.currentVariationsSkuCells}}" userInput="LongSku-$$getConfigAttributeOption2.label$$" stepKey="seeChildProductSku2"/> <see selector="{{AdminProductFormConfigurationsSection.currentVariationsPriceCells}}" userInput="{{ProductWithLongNameSku.price}}" stepKey="seeConfigurationsPrice"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Assert storefront category list page--> <amOnPage url="/" stepKey="amOnStorefront"/> <waitForPageLoad stepKey="waitForStorefrontLoad"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductOutOfStockTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductOutOfStockTest.xml index ad30c91967c3..51b3e49f5191 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductOutOfStockTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductOutOfStockTest.xml @@ -77,7 +77,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> @@ -200,7 +200,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> @@ -301,7 +301,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductSearchTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductSearchTest.xml index 059a18200e90..410c85d31490 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductSearchTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductSearchTest.xml @@ -68,7 +68,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> @@ -147,7 +147,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateAttributeTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateAttributeTest.xml index 00ffe70380d1..dba481b64810 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateAttributeTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateAttributeTest.xml @@ -96,7 +96,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <!-- Delete everything that was created in the before block --> <deleteData createDataKey="createCategory" stepKey="deleteCatagory" /> @@ -213,7 +213,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <!-- Delete everything that was created in the before block --> <deleteData createDataKey="createCategory" stepKey="deleteCatagory" /> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml index 3a6a20de3ed9..5d5590011a85 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml @@ -37,7 +37,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> </after> @@ -277,7 +277,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a configurable product via the UI --> @@ -326,7 +326,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a configurable product via the UI --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithImagesTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithImagesTest.xml index 925e7a890cea..9796c14f5519 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithImagesTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithImagesTest.xml @@ -129,6 +129,9 @@ <!-- Save product --> <actionGroup ref="saveConfigurableProductAddToCurrentAttributeSet" stepKey="saveProduct"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!-- Assert configurable product in category --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml index c303e4d19db8..037028030927 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml @@ -80,6 +80,8 @@ <after> <deleteData createDataKey="simple1Handle" stepKey="deleteSimple1" before="deleteSimple2"/> <deleteData createDataKey="simple2Handle" stepKey="deleteSimple2" before="delete"/> + <deleteData createDataKey="childProductHandle1" stepKey="deleteChildProduct1" before="delete"/> + <deleteData createDataKey="childProductHandle2" stepKey="deleteChildProduct2" before="delete"/> </after> </test> <test name="AdvanceCatalogSearchConfigurableBySkuTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> @@ -104,7 +106,7 @@ </createData> <!-- TODO: Move configurable product creation to an actionGroup when MQE-697 is fixed --> - <createData entity="ApiConfigurableProductWithDescription" stepKey="product"/> + <createData entity="ApiConfigurableProductWithDescriptionUnderscoredSku" stepKey="product"/> <createData entity="productDropDownAttribute" stepKey="productAttributeHandle"/> @@ -154,6 +156,8 @@ <after> <deleteData createDataKey="simple1Handle" stepKey="deleteSimple1" before="deleteSimple2"/> <deleteData createDataKey="simple2Handle" stepKey="deleteSimple2" before="delete"/> + <deleteData createDataKey="childProductHandle1" stepKey="deleteChildProduct1" before="delete"/> + <deleteData createDataKey="childProductHandle2" stepKey="deleteChildProduct2" before="delete"/> </after> </test> <test name="AdvanceCatalogSearchConfigurableByDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> @@ -228,6 +232,8 @@ <after> <deleteData createDataKey="simple1Handle" stepKey="deleteSimple1" before="deleteSimple2"/> <deleteData createDataKey="simple2Handle" stepKey="deleteSimple2" before="delete"/> + <deleteData createDataKey="childProductHandle1" stepKey="deleteChildProduct1" before="delete"/> + <deleteData createDataKey="childProductHandle2" stepKey="deleteChildProduct2" before="delete"/> </after> </test> <test name="AdvanceCatalogSearchConfigurableByShortDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> @@ -302,6 +308,8 @@ <after> <deleteData createDataKey="simple1Handle" stepKey="deleteSimple1" before="deleteSimple2"/> <deleteData createDataKey="simple2Handle" stepKey="deleteSimple2" before="delete"/> + <deleteData createDataKey="childProductHandle1" stepKey="deleteChildProduct1" before="delete"/> + <deleteData createDataKey="childProductHandle2" stepKey="deleteChildProduct2" before="delete"/> </after> </test> </tests> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ConfigurableProductPriceAdditionalStoreViewTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ConfigurableProductPriceAdditionalStoreViewTest.xml index a71f51526c8a..83d9bbe8c270 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ConfigurableProductPriceAdditionalStoreViewTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ConfigurableProductPriceAdditionalStoreViewTest.xml @@ -77,7 +77,7 @@ <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteSecondWebsite"> <argument name="websiteName" value="Second Website"/> </actionGroup> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml index 47ee09e4b208..04687a2314dc 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml @@ -217,4 +217,213 @@ <grabAttributeFrom selector="{{StorefrontProductCompareMainSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="compareGrabConfigProductImageSrcInComparison" after="compareAssertConfigProductInComparison"/> <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabConfigProductImageSrcInComparison" stepKey="compareAssertConfigProductImageNotDefaultInComparison" after="compareGrabConfigProductImageSrcInComparison"/> </test> + <test name="EndToEndB2CGuestUserMysqlTest"> + <before> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOption1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOption2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <createData entity="ApiSimpleOne" stepKey="createConfigChildProduct1"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createConfigChildProduct1Image"> + <requiredEntity createDataKey="createConfigChildProduct1"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigChildProduct2"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryMagentoLogo" stepKey="createConfigChildProduct2Image"> + <requiredEntity createDataKey="createConfigChildProduct2"/> + </createData> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOption1"/> + <requiredEntity createDataKey="getConfigAttributeOption2"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild1"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct1"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddChild2"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigChildProduct2"/> + </createData> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createConfigProductImage"> + <requiredEntity createDataKey="createConfigProduct"/> + </createData> + <updateData entity="ApiSimpleProductUpdateDescription" stepKey="updateConfigProduct" createDataKey="createConfigProduct"/> + </before> + <after> + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createConfigChildProduct1Image" stepKey="deleteConfigChildProduct1Image"/>--> + <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createConfigChildProduct2Image" stepKey="deleteConfigChildProduct2Image"/>--> + <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> + <!-- @TODO: Uncomment once MQE-679 is fixed --> + <!--<deleteData createDataKey="createConfigProductImage" stepKey="deleteConfigProductImage"/>--> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + </after> + + <!-- Verify Configurable Product in checkout cart items --> + <comment userInput="Verify Configurable Product in checkout cart items" stepKey="commentVerifyConfigurableProductInCheckoutCartItems" after="guestCheckoutCheckSimpleProduct2InCartItems" /> + <actionGroup ref="CheckConfigurableProductInCheckoutCartItemsActionGroup" stepKey="guestCheckoutCheckConfigurableProductInCartItems" after="commentVerifyConfigurableProductInCheckoutCartItems"> + <argument name="productVar" value="$$createConfigProduct$$"/> + <argument name="optionLabel" value="$$createConfigProductAttribute.attribute[frontend_labels][0][label]$$" /> + <argument name="optionValue" value="$$createConfigProductAttributeOption2.option[store_labels][1][label]$$" /> + </actionGroup> + + <!-- Check configurable product in category --> + <comment userInput="Verify Configurable Product in category" stepKey="commentVerifyConfigurableProductInCategory" after="browseAssertSimpleProduct2ImageNotDefault" /> + <actionGroup ref="StorefrontCheckCategoryConfigurableProduct" stepKey="browseAssertCategoryConfigProduct" after="commentVerifyConfigurableProductInCategory"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="browseGrabConfigProductImageSrc" after="browseAssertCategoryConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$browseGrabConfigProductImageSrc" stepKey="browseAssertConfigProductImageNotDefault" after="browseGrabConfigProductImageSrc"/> + + <!-- View Configurable Product --> + <comment userInput="View Configurable Product" stepKey="commentViewConfigurableProduct" after="browseAssertSimpleProduct2PageImageNotDefault" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="clickCategory2" after="commentViewConfigurableProduct"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createConfigProduct.name$$)}}" stepKey="browseClickCategoryConfigProductView" after="clickCategory2"/> + <waitForLoadingMaskToDisappear stepKey="waitForConfigurableProductViewloaded" after="browseClickCategoryConfigProductView"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="browseAssertConfigProductPage" after="waitForConfigurableProductViewloaded"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="browseGrabConfigProductPageImageSrc" after="browseAssertConfigProductPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$browseGrabConfigProductPageImageSrc" stepKey="browseAssertConfigProductPageImageNotDefault" after="browseGrabConfigProductPageImageSrc"/> + + <!-- Add Configurable Product to cart --> + <comment userInput="Add Configurable Product to cart" stepKey="commentAddConfigurableProductToCart" after="cartAddProduct2ToCart" /> + <click selector="{{StorefrontHeaderSection.NavigationCategoryByName($$createCategory.name$$)}}" stepKey="cartClickCategory2" after="commentAddConfigurableProductToCart"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartCategory2loaded" after="cartClickCategory2"/> + <actionGroup ref="StorefrontCheckCategoryActionGroup" stepKey="cartAssertCategory1ForConfigurableProduct" after="waitForCartCategory2loaded"> + <argument name="category" value="$$createCategory$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCategoryConfigurableProduct" stepKey="cartAssertConfigProduct" after="cartAssertCategory1ForConfigurableProduct"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="cartGrabConfigProductImageSrc" after="cartAssertConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartGrabConfigProductImageSrc" stepKey="cartAssertConfigProductImageNotDefault" after="cartGrabConfigProductImageSrc"/> + <click selector="{{StorefrontCategoryProductSection.ProductAddToCartByName($$createConfigProduct.name$$)}}" stepKey="cartClickCategoryConfigProductAddToCart" after="cartAssertConfigProductImageNotDefault"/> + <waitForElement selector="{{StorefrontMessagesSection.message('You need to choose options for your item.')}}" time="30" stepKey="cartWaitForConfigProductPageLoad" after="cartClickCategoryConfigProductAddToCart"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="cartAssertConfigProductPage" after="cartWaitForConfigProductPageLoad"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartGrabConfigProductPageImageSrc1" after="cartAssertConfigProductPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartGrabConfigProductPageImageSrc1" stepKey="cartAssertConfigProductPageImageNotDefault1" after="cartGrabConfigProductPageImageSrc1"/> + <selectOption userInput="$$createConfigProductAttributeOption2.option[store_labels][1][label]$$" selector="{{StorefrontProductInfoMainSection.optionByAttributeId($$createConfigProductAttribute.attribute_id$$)}}" stepKey="cartConfigProductFillOption" after="cartAssertConfigProductPageImageNotDefault1"/> + <waitForLoadingMaskToDisappear stepKey="waitForConfigurableProductOptionloaded" after="cartConfigProductFillOption"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="cartAssertConfigProductWithOptionPage" after="waitForConfigurableProductOptionloaded"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartGrabConfigProductPageImageSrc2" after="cartAssertConfigProductWithOptionPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartGrabConfigProductPageImageSrc2" stepKey="cartAssertConfigProductPageImageNotDefault2" after="cartGrabConfigProductPageImageSrc2"/> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddConfigProductToCart" after="cartAssertConfigProductPageImageNotDefault2"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="productCount" value="3"/> + </actionGroup> + + <!-- Check configurable product in minicart --> + <comment userInput="Check configurable product in minicart" stepKey="commentCheckConfigurableProductInMinicart" after="cartMinicartAssertSimpleProduct2PageImageNotDefault" /> + <actionGroup ref="StorefrontOpenMinicartAndCheckConfigurableProductActionGroup" stepKey="cartOpenMinicartAndCheckConfigProduct" after="commentCheckConfigurableProductInMinicart"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct2$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="cartMinicartGrabConfigProductImageSrc" after="cartOpenMinicartAndCheckConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/thumbnail\.jpg/'" actual="$cartMinicartGrabConfigProductImageSrc" stepKey="cartMinicartAssertConfigProductImageNotDefault" after="cartMinicartGrabConfigProductImageSrc"/> + <click selector="{{StorefrontMinicartSection.productOptionsDetailsByName($$createConfigProduct.name$$)}}" stepKey="cartMinicartClickConfigProductDetails" after="cartMinicartAssertConfigProductImageNotDefault"/> + <see userInput="$$createConfigProductAttributeOption2.option[store_labels][1][label]$$" selector="{{StorefrontMinicartSection.productOptionByNameAndAttribute($$createConfigProduct.name$$, $$createConfigProductAttribute.attribute[frontend_labels][0][label]$$)}}" stepKey="cartMinicartCheckConfigProductOption" after="cartMinicartClickConfigProductDetails"/> + <click selector="{{StorefrontMinicartSection.productLinkByName($$createConfigProduct.name$$)}}" stepKey="cartMinicartClickConfigProduct" after="cartMinicartCheckConfigProductOption"/> + <waitForLoadingMaskToDisappear stepKey="waitForMinicartConfigProductloaded" after="cartMinicartClickConfigProduct"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="cartAssertMinicartConfigProductPage" after="waitForMinicartConfigProductloaded"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartMinicartGrabConfigProductPageImageSrc" after="cartAssertMinicartConfigProductPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartMinicartGrabConfigProductPageImageSrc" stepKey="cartMinicartAssertConfigProductPageImageNotDefault" after="cartMinicartGrabConfigProductPageImageSrc"/> + + <!-- Check configurable product in cart --> + <comment userInput="Check configurable product in cart" stepKey="commentCheckConfigurableProductInCart" after="cartCartAssertSimpleProduct2PageImageNotDefault2" /> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="cartOpenCart2" after="commentCheckConfigurableProductInCart"/> + <actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="cartAssertCartConfigProduct" after="cartOpenCart2"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct2$$"/> + <!-- @TODO: Change to scalar value after MQE-498 is implemented --> + <argument name="productQuantity" value="CONST.one"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{CheckoutCartProductSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="cartCartGrabConfigProduct2ImageSrc" after="cartAssertCartConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$cartCartGrabConfigProduct2ImageSrc" stepKey="cartCartAssertConfigProduct2ImageNotDefault" after="cartCartGrabConfigProduct2ImageSrc"/> + <see userInput="$$createConfigProductAttributeOption2.option[store_labels][1][label]$$" selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute($$createConfigProduct.name$$, $$createConfigProductAttribute.attribute[frontend_labels][0][label]$$)}}" stepKey="cartCheckConfigProductOption" after="cartCartAssertConfigProduct2ImageNotDefault"/> + <click selector="{{CheckoutCartProductSection.ProductLinkByName($$createConfigProduct.name$$)}}" stepKey="cartClickCartConfigProduct" after="cartCheckConfigProductOption"/> + <waitForLoadingMaskToDisappear stepKey="waitForCartConfigProductloaded" after="cartClickCartConfigProduct"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="cartAssertCartConfigProductPage" after="waitForCartConfigProductloaded"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="cartCartGrabConfigProductPageImageSrc" after="cartAssertCartConfigProductPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$cartCartGrabConfigProductPageImageSrc" stepKey="cartCartAssertConfigProductPageImageNotDefault" after="cartCartGrabConfigProductPageImageSrc"/> + + <!-- Add Configurable Product to comparison --> + <comment userInput="Add Configurable Product to comparison" stepKey="commentAddConfigurableProductToComparison" after="compareAddSimpleProduct2ToCompare" /> + <actionGroup ref="StorefrontCheckCategoryConfigurableProduct" stepKey="compareAssertConfigProduct" after="commentAddConfigurableProductToComparison"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="compareGrabConfigProductImageSrc" after="compareAssertConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabConfigProductImageSrc" stepKey="compareAssertConfigProductImageNotDefault" after="compareGrabConfigProductImageSrc"/> + <actionGroup ref="StorefrontAddCategoryProductToCompareActionGroup" stepKey="compareAddConfigProductToCompare" after="compareAssertConfigProductImageNotDefault"> + <argument name="productVar" value="$$createConfigProduct$$"/> + </actionGroup> + + <!-- Check configurable product in comparison sidebar --> + <comment userInput="Add Configurable Product in comparison sidebar" stepKey="commentAddConfigurableProductInComparisonSidebar" after="compareSimpleProduct2InSidebar" /> + <actionGroup ref="StorefrontCheckCompareSidebarProductActionGroup" stepKey="compareConfigProductInSidebar" after="commentAddConfigurableProductInComparisonSidebar"> + <argument name="productVar" value="$$createConfigProduct$$"/> + </actionGroup> + + <!-- Check configurable product on comparison page --> + <comment userInput="Add Configurable Product on comparison page" stepKey="commentAddConfigurableProductOnComparisonPage" after="compareAssertSimpleProduct2ImageNotDefaultInComparison" /> + <actionGroup ref="StorefrontCheckCompareConfigurableProductActionGroup" stepKey="compareAssertConfigProductInComparison" after="commentAddConfigurableProductOnComparisonPage"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductCompareMainSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="compareGrabConfigProductImageSrcInComparison" after="compareAssertConfigProductInComparison"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$compareGrabConfigProductImageSrcInComparison" stepKey="compareAssertConfigProductImageNotDefaultInComparison" after="compareGrabConfigProductImageSrcInComparison"/> + </test> </tests> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchConfigurableBySkuWithHyphenTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchConfigurableBySkuWithHyphenTest.xml new file mode 100644 index 000000000000..a8e982475253 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchConfigurableBySkuWithHyphenTest.xml @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchConfigurableBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="ConfigurableProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search configurable product with product sku that contains hyphen"/> + <description value="Guest customer should be able to advance search configurable product with product sku that contains hyphen"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20389"/> + <group value="ConfigurableProduct"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="SimpleSubCategory" stepKey="categoryHandle" before="simple1Handle"/> + + <createData entity="SimpleProduct" stepKey="simple1Handle" before="simple2Handle"> + <requiredEntity createDataKey="categoryHandle"/> + </createData> + + <createData entity="SimpleProduct" stepKey="simple2Handle" before="product"> + <requiredEntity createDataKey="categoryHandle"/> + </createData> + + <!-- TODO: Move configurable product creation to an actionGroup when MQE-697 is fixed --> + <createData entity="ApiConfigurableProductWithDescription" stepKey="product"/> + + <createData entity="productDropDownAttribute" stepKey="productAttributeHandle"/> + + <createData entity="productAttributeOption1" stepKey="productAttributeOption1Handle"> + <requiredEntity createDataKey="productAttributeHandle"/> + </createData> + <createData entity="productAttributeOption2" stepKey="productAttributeOption2Handle"> + <requiredEntity createDataKey="productAttributeHandle"/> + </createData> + + <createData entity="AddToDefaultSet" stepKey="addToAttributeSetHandle"> + <requiredEntity createDataKey="productAttributeHandle"/> + </createData> + + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getAttributeOption1Handle"> + <requiredEntity createDataKey="productAttributeHandle"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getAttributeOption2Handle"> + <requiredEntity createDataKey="productAttributeHandle"/> + </getData> + + <createData entity="SimpleOne" stepKey="childProductHandle1"> + <requiredEntity createDataKey="productAttributeHandle"/> + <requiredEntity createDataKey="getAttributeOption1Handle"/> + </createData> + <createData entity="SimpleOne" stepKey="childProductHandle2"> + <requiredEntity createDataKey="productAttributeHandle"/> + <requiredEntity createDataKey="getAttributeOption2Handle"/> + </createData> + + <createData entity="ConfigurableProductTwoOptions" stepKey="configProductOptionHandle"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="productAttributeHandle"/> + <requiredEntity createDataKey="getAttributeOption1Handle"/> + <requiredEntity createDataKey="getAttributeOption2Handle"/> + </createData> + + <createData entity="ConfigurableProductAddChild" stepKey="configProductHandle1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="childProductHandle1"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="configProductHandle2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="childProductHandle2"/> + </createData> + </before> + <after> + <deleteData createDataKey="simple1Handle" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2Handle" stepKey="deleteSimple2" before="delete"/> + <deleteData createDataKey="childProductHandle1" stepKey="deleteChildProduct1" before="delete"/> + <deleteData createDataKey="childProductHandle2" stepKey="deleteChildProduct2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductCategoryViewChildOnlyTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductCategoryViewChildOnlyTest.xml index ac468fc92e4d..805727e29a17 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductCategoryViewChildOnlyTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductCategoryViewChildOnlyTest.xml @@ -88,7 +88,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductChildSearchTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductChildSearchTest.xml index 1075f79aef18..16400fa837b1 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductChildSearchTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductChildSearchTest.xml @@ -17,6 +17,7 @@ <severity value="MAJOR"/> <testCaseId value="MC-249"/> <group value="ConfigurableProduct"/> + <group value="SearchEngineMysql"/> </annotations> <before> <!-- TODO: This should be converted to an actionGroup once MQE-993 is fixed. --> @@ -131,7 +132,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2" stepKey="deleteConfigChildProduct2"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml index 836bc2cdca97..f75e30907a1f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml @@ -31,7 +31,7 @@ </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify configurable product details in storefront product view --> @@ -72,7 +72,7 @@ </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify configurable product options in storefront product view --> @@ -113,7 +113,7 @@ </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify adding configurable product to cart after an option is selected in storefront product view --> @@ -151,7 +151,7 @@ </before> <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify not able to add configurable product to cart when no option is selected in storefront product view --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductViewTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductViewTest.xml index cc8291a83eb4..0ade410714a2 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductViewTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductViewTest.xml @@ -32,7 +32,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify the storefront category grid view --> @@ -68,7 +68,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Verify storefront category list view --> @@ -106,7 +106,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Should be taken to product details page when adding to cart because an option needs to be selected --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml index d890d5985811..4c955f338564 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml @@ -25,7 +25,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVerifyConfigurableProductLayeredNavigationTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVerifyConfigurableProductLayeredNavigationTest.xml index bb69122dc0be..182c8c069ab2 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVerifyConfigurableProductLayeredNavigationTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVerifyConfigurableProductLayeredNavigationTest.xml @@ -135,6 +135,9 @@ <waitForPageLoad stepKey="waitForPageLoad1"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Open Category in Store Front and select product attribute option from sidebar --> <actionGroup ref="SelectStorefrontSideBarAttributeOption" stepKey="selectStorefrontProductAttributeOption"> <argument name="categoryName" value="$$createCategory.name$$"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php index 41995be41813..29bca356c118 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/Product/Type/VariationMatrixTest.php @@ -25,46 +25,117 @@ protected function setUp() ); } - public function testGetVariations() + /** + * Variations matrix test. + * + * @param array $expectedResult + * @dataProvider variationProvider + */ + public function testGetVariations($expectedResult) { - $result = [ - [ - 130 => [ - 'value' => '3', - 'label' => 'red', - 'price' => ['value_index' => '3', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',], - ], - ], - [ - 130 => [ - 'value' => '4', - 'label' => 'blue', - 'price' => ['value_index' => '4', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1',], - ], - ], - ]; - $input = [ - 130 => [ - 'values' => [ - [ - 'value_index' => '3', - 'pricing_value' => '', - 'is_percent' => '0', - 'include' => '1' - ], - [ - 'value_index' => '4', - 'pricing_value' => '', - 'is_percent' => '0', - 'include' => '1' + $this->assertEquals($expectedResult['result'], $this->model->getVariations($expectedResult['input'])); + } + + /** + * Test data provider. + */ + public function variationProvider() + { + return [ + [ + 'with_attribute_id' => [ + 'result' => [ + [ + 130 => [ + 'value' => '3', + 'label' => 'red', + 'price' => [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], + [ + 130 => [ + 'value' => '4', + 'label' => 'blue', + 'price' => [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], ], + 'input' => [ + 130 => [ + 'values' => [ + [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + 'attribute_id' => '130', + 'options' => [ + [ + 'value' => '3', + 'label' => 'red' + ], + ['value' => '4', + 'label' => 'blue' + ] + ], + ], + ] ], - 'attribute_id' => '130', - 'options' => [['value' => '3', 'label' => 'red',], ['value' => '4', 'label' => 'blue',],], - ], + 'without_attribute_id' => [ + 'result' => [ + [ + 130 => [ + 'value' => '4', + 'label' => 'blue', + 'price' => [ + 'value_index' => '4', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ], + ], + ], + ], + 'input' => [ + 130 => [ + 'values' => [ + [ + 'value_index' => '3', + 'pricing_value' => '', + 'is_percent' => '0', + 'include' => '1' + ] + ], + 'attribute_id' => '', + 'options' => [ + [ + 'value' => '3', + 'label' => 'red' + ] + ], + ], + ] + ] + ] ]; - - $this->assertEquals($result, $this->model->getVariations($input)); } } diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php index 7d337c57d7e7..055891ff79c6 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php @@ -3,9 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier; use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; +use Magento\Catalog\Model\Locator\LocatorInterface; /** * Data provider for quantity in the Configurable products @@ -16,7 +19,22 @@ class ConfigurableQty extends AbstractModifier const CODE_QTY_CONTAINER = 'quantity_and_stock_status_qty'; /** - * {@inheritdoc} + * @var LocatorInterface + */ + private $locator; + + /** + * ConfigurableQty constructor + * + * @param LocatorInterface $locator + */ + public function __construct(LocatorInterface $locator) + { + $this->locator = $locator; + } + + /** + * @inheritdoc */ public function modifyData(array $data) { @@ -24,13 +42,14 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { if ($groupCode = $this->getGroupCodeByField($meta, self::CODE_QTY_CONTAINER)) { $parentChildren = &$meta[$groupCode]['children']; - if (!empty($parentChildren[self::CODE_QTY_CONTAINER])) { + $isConfigurable = $this->locator->getProduct()->getTypeId() === 'configurable'; + if (!empty($parentChildren[self::CODE_QTY_CONTAINER]) && $isConfigurable) { $parentChildren[self::CODE_QTY_CONTAINER] = array_replace_recursive( $parentChildren[self::CODE_QTY_CONTAINER], [ diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php index c474acbec509..ec69baeb92cb 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php @@ -21,6 +21,8 @@ use Magento\Framework\Escaper; /** + * Associated products helper + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AssociatedProducts @@ -213,6 +215,7 @@ public function getConfigurableAttributesData() 'code' => $attribute['code'], 'label' => $attribute['label'], 'position' => $attribute['position'], + '__disableTmpl' => true ]; foreach ($attribute['chosen'] as $chosenOption) { @@ -231,6 +234,8 @@ public function getConfigurableAttributesData() * * @return void * @throws \Zend_Currency_Exception + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * phpcs:disable Generic.Metrics.NestingLevel.TooHigh */ protected function prepareVariations() { @@ -261,15 +266,18 @@ protected function prepareVariations() 'id' => $attribute->getAttributeId(), 'position' => $configurableAttributes[$attribute->getAttributeId()]['position'], 'chosen' => [], + '__disableTmpl' => true ]; - foreach ($attribute->getOptions() as $option) { - if (!empty($option->getValue())) { - $attributes[$attribute->getAttributeId()]['options'][$option->getValue()] = [ + $options = $attribute->usesSource() ? $attribute->getSource()->getAllOptions() : []; + foreach ($options as $option) { + if (!empty($option['value'])) { + $attributes[$attribute->getAttributeId()]['options'][$option['value']] = [ 'attribute_code' => $attribute->getAttributeCode(), 'attribute_label' => $attribute->getStoreLabel(0), - 'id' => $option->getValue(), - 'label' => $option->getLabel(), - 'value' => $option->getValue(), + 'id' => $option['value'], + 'label' => $option['label'], + 'value' => $option['value'], + '__disableTmpl' => true ]; } } @@ -281,6 +289,7 @@ protected function prepareVariations() 'id' => $optionId, 'label' => $variation[$attribute->getId()]['label'], 'value' => $optionId, + '__disableTmpl' => true ]; $variationOptions[] = $variationOption; $attributes[$attribute->getAttributeId()]['chosen'][$optionId] = $variationOption; @@ -306,6 +315,7 @@ protected function prepareVariations() 'newProduct' => 0, 'attributes' => $this->getTextAttributes($variationOptions), 'thumbnail_image' => $this->imageHelper->init($product, 'product_thumbnail_image')->getUrl(), + '__disableTmpl' => true ]; $productIds[] = $product->getId(); } @@ -316,6 +326,7 @@ protected function prepareVariations() $this->productIds = $productIds; $this->productAttributes = array_values($attributes); } + //phpcs: enable /** * Get JSON string that contains attribute code and value diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php b/app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php index f1971e228ac0..4a613254ddf8 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/Cart/BuyRequest/SuperAttributeDataProvider.php @@ -9,6 +9,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; use Magento\Framework\Stdlib\ArrayManager; use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface; @@ -76,6 +77,10 @@ public function execute(array $cartItemData): array } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__('Could not find specified product.')); } + $configurableProductLinks = $parentProduct->getExtensionAttributes()->getConfigurableProductLinks(); + if (!in_array($product->getId(), $configurableProductLinks)) { + throw new GraphQlInputException(__('Could not find specified product.')); + } $linkField = $this->metadataPool->getMetadata(ProductInterface::class)->getLinkField(); $this->optionCollection->addProductId((int)$parentProduct->getData($linkField)); $options = $this->optionCollection->getAttributesByProductId((int)$parentProduct->getData($linkField)); diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Product/Price/Provider.php b/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Product/Price/Provider.php new file mode 100644 index 000000000000..4dfa09d77cec --- /dev/null +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/Resolver/Product/Price/Provider.php @@ -0,0 +1,112 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\ConfigurableProductGraphQl\Model\Resolver\Product\Price; + +use Magento\Catalog\Pricing\Price\FinalPrice; +use Magento\Catalog\Pricing\Price\RegularPrice; +use Magento\ConfigurableProduct\Pricing\Price\ConfigurableRegularPrice; +use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Framework\Pricing\SaleableInterface; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface; +use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface; + +/** + * Provides product prices for configurable products + */ +class Provider implements ProviderInterface +{ + /** + * @var ConfigurableOptionsProviderInterface + */ + private $optionsProvider; + + /** + * @var array + */ + private $minimumFinalAmounts = []; + + /** + * @var array + */ + private $maximumFinalAmounts = []; + + /** + * @param ConfigurableOptionsProviderInterface $optionsProvider + */ + public function __construct( + ConfigurableOptionsProviderInterface $optionsProvider + ) { + $this->optionsProvider = $optionsProvider; + } + + /** + * @inheritdoc + */ + public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface + { + if (!isset($this->minimumFinalAmounts[$product->getId()])) { + $minimumAmount = null; + foreach ($this->optionsProvider->getProducts($product) as $variant) { + $variantAmount = $variant->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getAmount(); + if (!$minimumAmount || ($variantAmount->getValue() < $minimumAmount->getValue())) { + $minimumAmount = $variantAmount; + $this->minimumFinalAmounts[$product->getId()] = $variantAmount; + } + } + } + + return $this->minimumFinalAmounts[$product->getId()]; + } + + /** + * @inheritdoc + */ + public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface + { + /** @var ConfigurableRegularPrice $regularPrice */ + $regularPrice = $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE); + return $regularPrice->getMinRegularAmount(); + } + + /** + * @inheritdoc + */ + public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface + { + if (!isset($this->maximumFinalAmounts[$product->getId()])) { + $maximumAmount = null; + foreach ($this->optionsProvider->getProducts($product) as $variant) { + $variantAmount = $variant->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getAmount(); + if (!$maximumAmount || ($variantAmount->getValue() > $maximumAmount->getValue())) { + $maximumAmount = $variantAmount; + $this->maximumFinalAmounts[$product->getId()] = $variantAmount; + } + } + } + + return $this->maximumFinalAmounts[$product->getId()]; + } + + /** + * @inheritdoc + */ + public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface + { + /** @var ConfigurableRegularPrice $regularPrice */ + $regularPrice = $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE); + return $regularPrice->getMaxRegularAmount(); + } + + /** + * @inheritdoc + */ + public function getRegularPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getAmount(); + } +} diff --git a/app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml b/app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml index 1d72524a31b7..f82bb0dbd4d9 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/ConfigurableProductGraphQl/etc/graphql/di.xml @@ -29,4 +29,11 @@ </argument> </arguments> </type> + <type name="Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="configurable" xsi:type="object">Magento\ConfigurableProductGraphQl\Model\Resolver\Product\Price\Provider</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Cookie/Block/DataProviders/SessionConfig.php b/app/code/Magento/Cookie/Block/DataProviders/SessionConfig.php new file mode 100644 index 000000000000..9d8ae5b19be9 --- /dev/null +++ b/app/code/Magento/Cookie/Block/DataProviders/SessionConfig.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Cookie\Block\DataProviders; + +use Magento\Framework\Session\Config\ConfigInterface; +use Magento\Framework\View\Element\Block\ArgumentInterface; + +/** + * Provide cookie configuration + */ +class SessionConfig implements ArgumentInterface +{ + /** + * Session config + * + * @var ConfigInterface + */ + private $sessionConfig; + + /** + * Constructor + * + * @param ConfigInterface $sessionConfig + */ + public function __construct( + ConfigInterface $sessionConfig + ) { + $this->sessionConfig = $sessionConfig; + } + /** + * Get session.cookie_secure + * + * @return bool + * @SuppressWarnings(PHPMD.BooleanGetMethodName) + */ + public function getCookieSecure() + { + return $this->sessionConfig->getCookieSecure(); + } +} diff --git a/app/code/Magento/Cookie/view/adminhtml/layout/default.xml b/app/code/Magento/Cookie/view/adminhtml/layout/default.xml new file mode 100644 index 000000000000..2862cf917856 --- /dev/null +++ b/app/code/Magento/Cookie/view/adminhtml/layout/default.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <body> + <referenceContainer name="after.body.start"> + <block class="Magento\Framework\View\Element\Js\Cookie" name="cookie_config" template="Magento_Cookie::html/cookie.phtml"> + <arguments> + <argument name="session_config" xsi:type="object">Magento\Cookie\Block\DataProviders\SessionConfig</argument> + </arguments> + </block> + </referenceContainer> + </body> +</page> diff --git a/app/code/Magento/Cookie/view/base/requirejs-config.js b/app/code/Magento/Cookie/view/base/requirejs-config.js new file mode 100644 index 000000000000..b4362ffd80cb --- /dev/null +++ b/app/code/Magento/Cookie/view/base/requirejs-config.js @@ -0,0 +1,10 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +var config = { + paths: { + 'jquery/jquery-storageapi': 'Magento_Cookie/js/jquery.storageapi.extended' + } +}; diff --git a/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml b/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml new file mode 100644 index 000000000000..b05c53db02ab --- /dev/null +++ b/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * Cookie settings initialization script + * + * @var $block \Magento\Framework\View\Element\Js\Cookie + */ +?> + +<script> + window.cookiesConfig = window.cookiesConfig || {}; + window.cookiesConfig.secure = <?= /* @noEscape */ $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false' ?>; +</script> diff --git a/app/code/Magento/Cookie/view/base/web/js/jquery.storageapi.extended.js b/app/code/Magento/Cookie/view/base/web/js/jquery.storageapi.extended.js new file mode 100644 index 000000000000..c026b205f037 --- /dev/null +++ b/app/code/Magento/Cookie/view/base/web/js/jquery.storageapi.extended.js @@ -0,0 +1,69 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'jquery/jquery.cookie', + 'jquery/jquery.storageapi.min' +], function ($) { + 'use strict'; + + /** + * + * @param {Object} storage + * @private + */ + function _extend(storage) { + $.extend(storage, { + _secure: window.cookiesConfig ? window.cookiesConfig.secure : false, + + /** + * Set value under name + * @param {String} name + * @param {String} value + * @param {Object} [options] + */ + setItem: function (name, value, options) { + var _default = { + expires: this._expires, + path: this._path, + domain: this._domain, + secure: this._secure + }; + + $.cookie(this._prefix + name, value, $.extend(_default, options || {})); + }, + + /** + * Set default options + * @param {Object} c + * @returns {storage} + */ + setConf: function (c) { + if (c.path) { + this._path = c.path; + } + + if (c.domain) { + this._domain = c.domain; + } + + if (c.expires) { + this._expires = c.expires; + } + + if (typeof c.secure !== 'undefined') { + this._secure = c.secure; + } + + return this; + } + }); + } + + if (window.cookieStorage) { + _extend(window.cookieStorage); + } +}); diff --git a/app/code/Magento/Cookie/view/frontend/layout/default.xml b/app/code/Magento/Cookie/view/frontend/layout/default.xml index 8b6b86e81c51..5202c624fefe 100644 --- a/app/code/Magento/Cookie/view/frontend/layout/default.xml +++ b/app/code/Magento/Cookie/view/frontend/layout/default.xml @@ -9,6 +9,11 @@ <body> <referenceContainer name="after.body.start"> <block class="Magento\Cookie\Block\Html\Notices" name="cookie_notices" template="Magento_Cookie::html/notices.phtml"/> + <block class="Magento\Framework\View\Element\Js\Cookie" name="cookie_config" template="Magento_Cookie::html/cookie.phtml"> + <arguments> + <argument name="session_config" xsi:type="object">Magento\Cookie\Block\DataProviders\SessionConfig</argument> + </arguments> + </block> </referenceContainer> </body> </page> diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php index 34d24a8b0a7a..a6e29db1e1c4 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -13,6 +12,9 @@ use Magento\Framework\Controller\ResultFactory; use Magento\CurrencySymbol\Controller\Adminhtml\System\Currency as CurrencyAction; +/** + * Class FetchRates + */ class FetchRates extends CurrencyAction implements HttpGetActionInterface, HttpPostActionInterface { /** @@ -41,20 +43,20 @@ public function execute() } $rates = $importModel->fetchRates(); $errors = $importModel->getMessages(); - if (sizeof($errors) > 0) { + if (count($errors) > 0) { foreach ($errors as $error) { - $this->messageManager->addWarning($error); + $this->messageManager->addWarningMessage($error); } - $this->messageManager->addWarning( + $this->messageManager->addWarningMessage( __('Click "Save" to apply the rates we found.') ); } else { - $this->messageManager->addSuccess(__('Click "Save" to apply the rates we found.')); + $this->messageManager->addSuccessMessage(__('Click "Save" to apply the rates we found.')); } $backendSession->setRates($rates); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRates.php index 8dd6b5e6fac4..f5e1fdbdb0c5 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRates.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRates.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -9,6 +8,9 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +/** + * Class SaveRates + */ class SaveRates extends \Magento\CurrencySymbol\Controller\Adminhtml\System\Currency implements HttpPostActionInterface { /** @@ -23,12 +25,13 @@ public function execute() try { foreach ($data as $currencyCode => $rate) { foreach ($rate as $currencyTo => $value) { - $value = abs($this->_objectManager->get( - \Magento\Framework\Locale\FormatInterface::class - )->getNumber($value)); + $value = abs( + $this->_objectManager->get(\Magento\Framework\Locale\FormatInterface::class) + ->getNumber($value) + ); $data[$currencyCode][$currencyTo] = $value; if ($value == 0) { - $this->messageManager->addWarning( + $this->messageManager->addWarningMessage( __('Please correct the input data for "%1 => %2" rate.', $currencyCode, $currencyTo) ); } @@ -36,9 +39,9 @@ public function execute() } $this->_objectManager->create(\Magento\Directory\Model\Currency::class)->saveRates($data); - $this->messageManager->addSuccess(__('All valid rates have been saved.')); + $this->messageManager->addSuccessMessage(__('All valid rates have been saved.')); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } } diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/Save.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/Save.php index 703117f34fce..f77976cc9e2f 100644 --- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/Save.php +++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/Save.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -8,6 +7,9 @@ use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +/** + * Class Save + */ class Save extends \Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol implements HttpPostActionInterface { /** @@ -29,9 +31,9 @@ public function execute() try { $this->_objectManager->create(\Magento\CurrencySymbol\Model\System\Currencysymbol::class) ->setCurrencySymbolsData($symbolsDataArray); - $this->messageManager->addSuccess(__('You applied the custom currency symbols.')); + $this->messageManager->addSuccessMessage(__('You applied the custom currency symbols.')); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml new file mode 100644 index 000000000000..6b8a93ef3542 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminSetCurrencyRatesActionGroup"> + <arguments> + <argument name="firstCurrency" type="string" defaultValue="USD"/> + <argument name="secondCurrency" type="string" defaultValue="EUR"/> + <argument name="rate" type="string" defaultValue="0.5"/> + </arguments> + <fillField selector="{{AdminCurrencyRatesSection.currencyRate(firstCurrency, secondCurrency)}}" userInput="{{rate}}" stepKey="setCurrencyRate"/> + <click selector="{{AdminCurrencyRatesSection.saveCurrencyRates}}" stepKey="clickSaveCurrencyRates"/> + <waitForPageLoad stepKey="waitForSave"/> + <see selector="{{AdminMessagesSection.success}}" userInput="{{AdminSaveCurrencyRatesMessageData.success}}" stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml new file mode 100644 index 000000000000..61a6123b1a7a --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontSwitchCurrency"> + <arguments> + <argument name="currency" type="string" defaultValue="EUR"/> + </arguments> + <click selector="{{StorefrontSwitchCurrencyRatesSection.currencyTrigger}}" stepKey="openTrigger"/> + <waitForElementVisible selector="{{StorefrontSwitchCurrencyRatesSection.currency(currency)}}" stepKey="waitForCurrency"/> + <click selector="{{StorefrontSwitchCurrencyRatesSection.currency(currency)}}" stepKey="chooseCurrency"/> + <see selector="{{StorefrontSwitchCurrencyRatesSection.selectedCurrency}}" userInput="{{currency}}" stepKey="seeSelectedCurrency"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Data/AdminCurrencyRatesMessageData.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Data/AdminCurrencyRatesMessageData.xml new file mode 100644 index 000000000000..90d22b06fcb8 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Data/AdminCurrencyRatesMessageData.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminSaveCurrencyRatesMessageData"> + <data key="success">All valid rates have been saved.</data> + </entity> +</entities> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Data/CurrencyRatesConfigData.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Data/CurrencyRatesConfigData.xml new file mode 100644 index 000000000000..6194287dd058 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Data/CurrencyRatesConfigData.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="SetCurrencyUSDBaseConfig"> + <data key="path">currency/options/base</data> + <data key="value">USD</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetCurrencyEURBaseConfig"> + <data key="path">currency/options/base</data> + <data key="value">EUR</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetAllowedCurrenciesConfigForUSD"> + <data key="path">currency/options/allow</data> + <data key="value">USD</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetAllowedCurrenciesConfigForEUR"> + <data key="path">currency/options/allow</data> + <data key="value">EUR</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetAllowedCurrenciesConfigForRUB"> + <data key="path">currency/options/allow</data> + <data key="value">RUB</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetDefaultCurrencyEURConfig"> + <data key="path">currency/options/default</data> + <data key="value">EUR</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> + <entity name="SetDefaultCurrencyUSDConfig"> + <data key="path">currency/options/default</data> + <data key="value">USD</data> + <data key="scope">websites</data> + <data key="scope_code">base</data> + </entity> +</entities> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml new file mode 100644 index 000000000000..d31dd71d474b --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="AdminCurrencyRatesPage" url="admin/system_currency/" area="admin" module="CurrencySymbol"> + <section name="AdminCurrencyRatesSection"/> + </page> +</pages> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml new file mode 100644 index 000000000000..a5799356eb45 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminCurrencyRatesSection"> + <element name="import" type="button" selector="//button[@title='Import']"/> + <element name="saveCurrencyRates" type="button" selector="//button[@title='Save Currency Rates']"/> + <element name="oldRate" type="text" selector="//div[contains(@class, 'admin__field-note') and contains(text(), 'Old rate:')]/strong"/> + <element name="currencyRate" type="input" selector="input[name='rate[{{fistCurrency}}][{{secondCurrency}}]']" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml new file mode 100644 index 000000000000..e69823ad68e0 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontSwitchCurrencyRatesSection"> + <element name="currencyTrigger" type="select" selector="#switcher-currency-trigger" timeout="30"/> + <element name="currency" type="button" selector="//div[@id='switcher-currency-trigger']/following-sibling::ul//a[contains(text(), '{{currency}}')]" parameterized="true" timeout="10"/> + <element name="selectedCurrency" type="text" selector="#switcher-currency-trigger span"/> + </section> +</sections> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayWhenChooseThreeAllowedCurrenciesTest.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayWhenChooseThreeAllowedCurrenciesTest.xml new file mode 100644 index 000000000000..26fbfd394be6 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayWhenChooseThreeAllowedCurrenciesTest.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminOrderRateDisplayWhenChooseThreeAllowedCurrenciesTest" extends="AdminOrderRateDisplayedInOneLineTest"> + <annotations> + <features value="CurrencySymbol"/> + <stories value="Currency rates order page"/> + <title value="Order rate converting currency for 'Base Currency' and 'Default Display Currency' displayed correct"/> + <description value="Order rate converting currency for 'Base Currency' and 'Default Display Currency' displayed correct"/> + <severity value="MAJOR"/> + <testCaseId value="MC-17255" /> + <useCaseId value="MAGETWO-67450"/> + <group value="currency"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create product--> + <createData entity="SimpleProduct2" stepKey="createNewProduct"/> + <!--Set Currency options for Website--> + <magentoCLI command="config:set --scope={{SetCurrencyUSDBaseConfig.scope}} --scope-code={{SetCurrencyUSDBaseConfig.scope_code}} {{SetCurrencyUSDBaseConfig.path}} {{SetCurrencyUSDBaseConfig.value}}" stepKey="setCurrencyBaseUSDWebsites"/> + <magentoCLI command="config:set --scope={{SetAllowedCurrenciesConfigForUSD.scope}} --scope-code={{SetAllowedCurrenciesConfigForUSD.scope_code}} {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}},{{SetAllowedCurrenciesConfigForRUB.value}}" stepKey="setAllowedCurrencyWebsitesEURandRUBandUSD"/> + <magentoCLI command="config:set --scope={{SetDefaultCurrencyEURConfig.scope}} --scope-code={{SetDefaultCurrencyEURConfig.scope_code}} {{SetDefaultCurrencyEURConfig.path}} {{SetDefaultCurrencyEURConfig.value}}" stepKey="setCurrencyDefaultEURWebsites"/> + </before> + <after> + <!--Delete created product--> + <comment userInput="Delete created product" stepKey="commentDeleteCreatedProduct"/> + <deleteData createDataKey="createNewProduct" stepKey="deleteNewProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Set currency rates--> + <amOnPage url="{{AdminCurrencyRatesPage.url}}" stepKey="gotToCurrencyRatesPageSecondTime"/> + <waitForPageLoad stepKey="waitForLoadRatesPageSecondTime"/> + <actionGroup ref="AdminSetCurrencyRatesActionGroup" stepKey="setCurrencyRates"> + <argument name="firstCurrency" value="USD"/> + <argument name="secondCurrency" value="RUB"/> + <argument name="rate" value="0.8"/> + </actionGroup> + <!--Open created product on Storefront and place for order--> + <amOnPage url="{{StorefrontProductPage.url($$createNewProduct.custom_attributes[url_key]$$)}}" stepKey="goToNewProductPage"/> + <waitForPageLoad stepKey="waitForNewProductPagePageLoad"/> + <actionGroup ref="StorefrontSwitchCurrency" stepKey="switchCurrency"> + <argument name="currency" value="RUB"/> + </actionGroup> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontNewProductPage"> + <argument name="productName" value="$$createNewProduct.name$$"/> + </actionGroup> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutNewProductFromMinicart" /> + <actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutNewFillingShippingSection"> + </actionGroup> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectNewCheckMoneyOrderPayment" /> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceNewOrder"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" /> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabNewOrderNumber"/> + <!--Open order and check rates display in one line--> + <actionGroup ref="OpenOrderById" stepKey="openNewOrderById"> + <argument name="orderId" value="$grabNewOrderNumber"/> + </actionGroup> + <see selector="{{AdminOrderDetailsInformationSection.orderInformationTable}}" userInput="EUR / USD rate" stepKey="seeUSDandEURRate"/> + <see selector="{{AdminOrderDetailsInformationSection.orderInformationTable}}" userInput="RUB / USD rate:" stepKey="seeRUBandEURRate"/> + <grabMultiple selector="{{AdminOrderDetailsInformationSection.rate}}" stepKey="grabRates" /> + <assertEquals stepKey="assertRates"> + <actualResult type="variable">grabRates</actualResult> + <expectedResult type="array">['EUR / USD rate:', 'RUB / USD rate:']</expectedResult> + </assertEquals> + </test> +</tests> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayedInOneLineTest.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayedInOneLineTest.xml new file mode 100644 index 000000000000..dc6bdf3db542 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminOrderRateDisplayedInOneLineTest.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminOrderRateDisplayedInOneLineTest"> + <annotations> + <features value="CurrencySymbol"/> + <stories value="Currency rates order page"/> + <title value="Order rate converting currency for 'Base Currency' and 'Default Display Currency' displayed correct once"/> + <description value="Order rate converting currency for 'Base Currency' and 'Default Display Currency' displayed correct once"/> + <severity value="MAJOR"/> + <testCaseId value="MC-17255" /> + <useCaseId value="MAGETWO-67450"/> + <group value="currency"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create product--> + <createData entity="SimpleProduct2" stepKey="createProduct"/> + <!--Set price scope website--> + <magentoCLI command="config:set {{CatalogPriceScopeWebsiteConfigData.path}} {{CatalogPriceScopeWebsiteConfigData.value}}" stepKey="setCatalogPriceScopeWebsite"/> + <!--Set Currency options for Default Config--> + <magentoCLI command="config:set {{SetCurrencyEURBaseConfig.path}} {{SetCurrencyEURBaseConfig.value}}" stepKey="setCurrencyBaseEUR"/> + <magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setAllowedCurrencyEURandUSD"/> + <magentoCLI command="config:set {{SetDefaultCurrencyEURConfig.path}} {{SetDefaultCurrencyEURConfig.value}}" stepKey="setCurrencyDefaultEUR"/> + <!--Set Currency options for Website--> + <magentoCLI command="config:set --scope={{SetCurrencyUSDBaseConfig.scope}} --scope-code={{SetCurrencyUSDBaseConfig.scope_code}} {{SetCurrencyUSDBaseConfig.path}} {{SetCurrencyUSDBaseConfig.value}}" stepKey="setCurrencyBaseEURWebsites"/> + <magentoCLI command="config:set --scope={{SetAllowedCurrenciesConfigForUSD.scope}} --scope-code={{SetAllowedCurrenciesConfigForUSD.scope_code}} {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setAllowedCurrencyWebsitesForEURandUSD"/> + <magentoCLI command="config:set --scope={{SetDefaultCurrencyEURConfig.scope}} --scope-code={{SetDefaultCurrencyEURConfig.scope_code}} {{SetDefaultCurrencyEURConfig.path}} {{SetDefaultCurrencyEURConfig.value}}" stepKey="setCurrencyDefaultEURWebsites"/> + </before> + <after> + <!--Delete created product--> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <!--Reset configurations--> + <magentoCLI command="config:set {{CatalogPriceScopeGlobalConfigData.path}} {{CatalogPriceScopeGlobalConfigData.value}}" stepKey="setCatalogPriceScopeGlobal"/> + <magentoCLI command="config:set {{SetCurrencyUSDBaseConfig.path}} {{SetCurrencyUSDBaseConfig.value}}" stepKey="setCurrencyBaseUSD"/> + <magentoCLI command="config:set {{SetDefaultCurrencyUSDConfig.path}} {{SetDefaultCurrencyUSDConfig.value}}" stepKey="setCurrencyDefaultUSD"/> + <magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setAllowedCurrencyUSD"/> + <!--Set Currency options for Website--> + <magentoCLI command="config:set --scope={{SetCurrencyUSDBaseConfig.scope}} --scope-code={{SetCurrencyUSDBaseConfig.scope_code}} {{SetCurrencyUSDBaseConfig.path}} {{SetCurrencyUSDBaseConfig.value}}" stepKey="setCurrencyBaseUSDWebsites"/> + <magentoCLI command="config:set --scope={{SetDefaultCurrencyUSDConfig.scope}} --scope-code={{SetDefaultCurrencyUSDConfig.scope_code}} {{SetDefaultCurrencyUSDConfig.path}} {{SetDefaultCurrencyUSDConfig.value}}" stepKey="setCurrencyDefaultUSDWebsites"/> + <magentoCLI command="config:set --scope={{SetAllowedCurrenciesConfigForUSD.scope}} --scope-code={{SetAllowedCurrenciesConfigForUSD.scope_code}} {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setAllowedCurrencyUSDWebsites"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Open created product on Storefront and place for order--> + <amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="goToProductPage"/> + <waitForPageLoad stepKey="waitForProductPagePageLoad"/> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="guestGoToCheckoutFromMinicart" /> + <actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShippingSection"> + </actionGroup> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="guestSelectCheckMoneyOrderPayment" /> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="guestPlaceOrder"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage" /> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumber"/> + <!--Open order and check rates display in one line--> + <actionGroup ref="OpenOrderById" stepKey="openOrderById"> + <argument name="orderId" value="$grabOrderNumber"/> + </actionGroup> + <see selector="{{AdminOrderDetailsInformationSection.orderInformationTable}}" userInput="EUR / USD rate" stepKey="seeEURandUSDRate"/> + <grabMultiple selector="{{AdminOrderDetailsInformationSection.rate}}" stepKey="grabRate" /> + <assertEquals stepKey="assertSelectedCategories"> + <actualResult type="variable">grabRate</actualResult> + <expectedResult type="array">[EUR / USD rate:]</expectedResult> + </assertEquals> + </test> +</tests> diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currency/SaveRatesTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currency/SaveRatesTest.php new file mode 100644 index 000000000000..b561c02c7b36 --- /dev/null +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currency/SaveRatesTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CurrencySymbol\Test\Unit\Controller\Adminhtml\System\Currency; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +/** + * Class SaveRatesTest + */ +class SaveRatesTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\CurrencySymbol\Controller\Adminhtml\System\Currency\SaveRates + */ + protected $action; + + /** + * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $requestMock; + + /** + * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $responseMock; + + /** + * + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + + $this->requestMock = $this->createMock(\Magento\Framework\App\RequestInterface::class); + + $this->responseMock = $this->createPartialMock( + \Magento\Framework\App\ResponseInterface::class, + ['setRedirect', 'sendResponse'] + ); + + $this->action = $objectManager->getObject( + \Magento\CurrencySymbol\Controller\Adminhtml\System\Currency\SaveRates::class, + [ + 'request' => $this->requestMock, + 'response' => $this->responseMock, + ] + ); + } + + /** + * + */ + public function testWithNullRateExecute() + { + $this->requestMock->expects($this->once()) + ->method('getParam') + ->with('rate') + ->willReturn(null); + + $this->responseMock->expects($this->once())->method('setRedirect'); + + $this->action->execute(); + } +} diff --git a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php index 0863104a2bf8..06f4294ce639 100644 --- a/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php +++ b/app/code/Magento/CurrencySymbol/Test/Unit/Controller/Adminhtml/System/Currencysymbol/SaveTest.php @@ -128,7 +128,7 @@ public function testExecute() ->willReturn($this->filterManagerMock); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with(__('You applied the custom currency symbols.')); $this->action->execute(); diff --git a/app/code/Magento/Customer/Block/Form/Register.php b/app/code/Magento/Customer/Block/Form/Register.php index be16046d6907..46d1088e37d0 100644 --- a/app/code/Magento/Customer/Block/Form/Register.php +++ b/app/code/Magento/Customer/Block/Form/Register.php @@ -24,7 +24,7 @@ class Register extends \Magento\Directory\Block\Data protected $_customerSession; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -47,7 +47,7 @@ class Register extends \Magento\Directory\Block\Data * @param \Magento\Framework\App\Cache\Type\Config $configCacheType * @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory * @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Url $customerUrl * @param array $data @@ -62,7 +62,7 @@ public function __construct( \Magento\Framework\App\Cache\Type\Config $configCacheType, \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollectionFactory, \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollectionFactory, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Url $customerUrl, array $data = [], diff --git a/app/code/Magento/Customer/Block/Widget/Dob.php b/app/code/Magento/Customer/Block/Widget/Dob.php index d874729d9132..e020de79a3a6 100644 --- a/app/code/Magento/Customer/Block/Widget/Dob.php +++ b/app/code/Magento/Customer/Block/Widget/Dob.php @@ -267,6 +267,8 @@ public function getHtmlExtraParams() $validators['validate-date'] = [ 'dateFormat' => $this->getDateFormat() ]; + $validators['validate-dob'] = true; + return 'data-validate="' . $this->_escaper->escapeHtml(json_encode($validators)) . '"'; } @@ -277,7 +279,11 @@ public function getHtmlExtraParams() */ public function getDateFormat() { - return $this->_localeDate->getDateFormatWithLongYear(); + $dateFormat = $this->_localeDate->getDateFormatWithLongYear(); + /** Escape RTL characters which are present in some locales and corrupt formatting */ + $escapedDateFormat = preg_replace('/[^MmDdYy\/\.\-]/', '', $dateFormat); + + return $escapedDateFormat; } /** diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php index a2be0f68b56c..57b670684411 100644 --- a/app/code/Magento/Customer/Controller/Account/CreatePost.php +++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php @@ -21,6 +21,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Message\MessageInterface; use Magento\Framework\Phrase; use Magento\Store\Model\StoreManagerInterface; use Magento\Customer\Api\AccountManagementInterface; @@ -118,6 +119,11 @@ class CreatePost extends AbstractAccount implements CsrfAwareActionInterface, Ht */ protected $session; + /** + * @var StoreManagerInterface + */ + protected $storeManager; + /** * @var AccountRedirect */ @@ -365,20 +371,19 @@ public function execute() ); $confirmationStatus = $this->accountManagement->getConfirmationStatus($customer->getId()); if ($confirmationStatus === AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED) { - $email = $this->customerUrl->getEmailConfirmationUrl($customer->getEmail()); - // @codingStandardsIgnoreStart - $this->messageManager->addSuccess( - __( - 'You must confirm your account. Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.', - $email - ) + $this->messageManager->addComplexSuccessMessage( + 'confirmAccountSuccessMessage', + [ + 'url' => $this->customerUrl->getEmailConfirmationUrl($customer->getEmail()), + ] ); - // @codingStandardsIgnoreEnd $url = $this->urlModel->getUrl('*/*/index', ['_secure' => true]); $resultRedirect->setUrl($this->_redirect->success($url)); } else { $this->session->setCustomerDataAsLoggedIn($customer); - $this->messageManager->addSuccess($this->getSuccessMessage()); + + $this->messageManager->addMessage($this->getMessageManagerSuccessMessage()); + $requestedRedirect = $this->accountRedirect->getRedirectCookie(); if (!$this->scopeConfig->getValue('customer/startup/redirect_dashboard') && $requestedRedirect) { $resultRedirect->setUrl($this->_redirect->success($requestedRedirect)); @@ -395,23 +400,21 @@ public function execute() return $resultRedirect; } catch (StateException $e) { - $url = $this->urlModel->getUrl('customer/account/forgotpassword'); - // @codingStandardsIgnoreStart - $message = __( - 'There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', - $url + $this->messageManager->addComplexErrorMessage( + 'customerAlreadyExistsErrorMessage', + [ + 'url' => $this->urlModel->getUrl('customer/account/forgotpassword'), + ] ); - // @codingStandardsIgnoreEnd - $this->messageManager->addError($message); } catch (InputException $e) { - $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage())); + $this->messageManager->addErrorMessage($e->getMessage()); foreach ($e->getErrors() as $error) { - $this->messageManager->addError($this->escaper->escapeHtml($error->getMessage())); + $this->messageManager->addErrorMessage($error->getMessage()); } } catch (LocalizedException $e) { - $this->messageManager->addError($this->escaper->escapeHtml($e->getMessage())); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('We can\'t save the customer.')); + $this->messageManager->addExceptionMessage($e, __('We can\'t save the customer.')); } $this->session->setCustomerFormData($this->getRequest()->getPostValue()); @@ -437,6 +440,8 @@ protected function checkPasswordConfirmation($password, $confirmation) /** * Retrieve success message * + * @deprecated + * @see getMessageManagerSuccessMessage() * @return string */ protected function getSuccessMessage() @@ -462,4 +467,37 @@ protected function getSuccessMessage() } return $message; } + + /** + * Retrieve success message manager message + * + * @return MessageInterface + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + private function getMessageManagerSuccessMessage(): MessageInterface + { + if ($this->addressHelper->isVatValidationEnabled()) { + if ($this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING) { + $identifier = 'customerVatShippingAddressSuccessMessage'; + } else { + $identifier = 'customerVatBillingAddressSuccessMessage'; + } + + $message = $this->messageManager + ->createMessage(MessageInterface::TYPE_SUCCESS, $identifier) + ->setData( + [ + 'url' => $this->urlModel->getUrl('customer/address/edit'), + ] + ); + } else { + $message = $this->messageManager + ->createMessage(MessageInterface::TYPE_SUCCESS) + ->setText( + __('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName()) + ); + } + + return $message; + } } diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php index 04051fbbf366..4091a068e309 100644 --- a/app/code/Magento/Customer/Controller/Account/LoginPost.php +++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php @@ -26,6 +26,8 @@ use Magento\Framework\Phrase; /** + * Post login customer action. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class LoginPost extends AbstractAccount implements CsrfAwareActionInterface, HttpPostActionInterface @@ -183,7 +185,6 @@ public function execute() try { $customer = $this->customerAccountManagement->authenticate($login['username'], $login['password']); $this->session->setCustomerDataAsLoggedIn($customer); - $this->session->regenerateId(); if ($this->getCookieManager()->getCookie('mage-cache-sessid')) { $metadata = $this->getCookieMetadataFactory()->createCookieMetadata(); $metadata->setPath('/'); diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php index 7220de035681..eff812a65a3b 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php @@ -70,6 +70,11 @@ class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionIn */ private $addressRegistry; + /** + * @var \Magento\Framework\Escaper + */ + private $escaper; + /** * @param Action\Context $context * @param CustomerRepositoryInterface $customerRepository @@ -78,6 +83,7 @@ class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionIn * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Psr\Log\LoggerInterface $logger * @param AddressRegistry|null $addressRegistry + * @param \Magento\Framework\Escaper $escaper */ public function __construct( Action\Context $context, @@ -86,7 +92,8 @@ public function __construct( \Magento\Customer\Model\Customer\Mapper $customerMapper, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Psr\Log\LoggerInterface $logger, - AddressRegistry $addressRegistry = null + AddressRegistry $addressRegistry = null, + \Magento\Framework\Escaper $escaper = null ) { $this->customerRepository = $customerRepository; $this->resultJsonFactory = $resultJsonFactory; @@ -94,6 +101,7 @@ public function __construct( $this->dataObjectHelper = $dataObjectHelper; $this->logger = $logger; $this->addressRegistry = $addressRegistry ?: ObjectManager::getInstance()->get(AddressRegistry::class); + $this->escaper = $escaper ?: ObjectManager::getInstance()->get(\Magento\Framework\Escaper::class); parent::__construct($context); } @@ -128,10 +136,14 @@ public function execute() $postItems = $this->getRequest()->getParam('items', []); if (!($this->getRequest()->getParam('isAjax') && count($postItems))) { - return $resultJson->setData([ - 'messages' => [__('Please correct the data sent.')], - 'error' => true, - ]); + return $resultJson->setData( + [ + 'messages' => [ + __('Please correct the data sent.') + ], + 'error' => true, + ] + ); } foreach (array_keys($postItems) as $customerId) { @@ -147,10 +159,12 @@ public function execute() $this->getEmailNotification()->credentialsChanged($this->getCustomer(), $currentCustomer->getEmail()); } - return $resultJson->setData([ - 'messages' => $this->getErrorMessages(), - 'error' => $this->isErrorExists() - ]); + return $resultJson->setData( + [ + 'messages' => $this->getErrorMessages(), + 'error' => $this->isErrorExists() + ] + ); } /** @@ -234,13 +248,16 @@ protected function saveCustomer(CustomerInterface $customer) $this->disableAddressValidation($customer); $this->customerRepository->save($customer); } catch (\Magento\Framework\Exception\InputException $e) { - $this->getMessageManager()->addError($this->getErrorWithCustomerId($e->getMessage())); + $this->getMessageManager() + ->addError($this->getErrorWithCustomerId($this->escaper->escapeHtml($e->getMessage()))); $this->logger->critical($e); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->getMessageManager()->addError($this->getErrorWithCustomerId($e->getMessage())); + $this->getMessageManager() + ->addError($this->getErrorWithCustomerId($this->escaper->escapeHtml($e->getMessage()))); $this->logger->critical($e); } catch (\Exception $e) { - $this->getMessageManager()->addError($this->getErrorWithCustomerId('We can\'t save the customer.')); + $this->getMessageManager() + ->addError($this->getErrorWithCustomerId('We can\'t save the customer.')); $this->logger->critical($e); } } diff --git a/app/code/Magento/Customer/Controller/Ajax/Login.php b/app/code/Magento/Customer/Controller/Ajax/Login.php index 5049c83e60f3..1215c47ab990 100644 --- a/app/code/Magento/Customer/Controller/Ajax/Login.php +++ b/app/code/Magento/Customer/Controller/Ajax/Login.php @@ -191,7 +191,6 @@ public function execute() $credentials['password'] ); $this->customerSession->setCustomerDataAsLoggedIn($customer); - $this->customerSession->regenerateId(); $redirectRoute = $this->getAccountRedirect()->getRedirectCookie(); if ($this->cookieManager->getCookie('mage-cache-sessid')) { $metadata = $this->cookieMetadataFactory->createCookieMetadata(); diff --git a/app/code/Magento/Customer/Helper/Session/CurrentCustomer.php b/app/code/Magento/Customer/Helper/Session/CurrentCustomer.php index 5cd09aca9f87..d48ff5918c3f 100644 --- a/app/code/Magento/Customer/Helper/Session/CurrentCustomer.php +++ b/app/code/Magento/Customer/Helper/Session/CurrentCustomer.php @@ -10,7 +10,7 @@ use Magento\Customer\Model\Session as CustomerSession; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ViewInterface; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Framework\View\LayoutInterface; /** @@ -45,7 +45,7 @@ class CurrentCustomer protected $request; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php index 7be8699495bf..985cfe0621bf 100644 --- a/app/code/Magento/Customer/Model/AccountManagement.php +++ b/app/code/Magento/Customer/Model/AccountManagement.php @@ -978,6 +978,7 @@ protected function sendEmailConfirmation(CustomerInterface $customer, $redirectU $templateType = self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD; } $this->getEmailNotification()->newAccount($customer, $templateType, $redirectUrl, $customer->getStoreId()); + $customer->setConfirmation(null); } catch (MailException $e) { // If we are not able to send a new account email, this should be ignored $this->logger->critical($e); diff --git a/app/code/Magento/Customer/Model/AddressSearchResults.php b/app/code/Magento/Customer/Model/AddressSearchResults.php new file mode 100644 index 000000000000..7e83aa8f8d8d --- /dev/null +++ b/app/code/Magento/Customer/Model/AddressSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Model; + +use Magento\Customer\Api\Data\AddressSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Address search results. + */ +class AddressSearchResults extends SearchResults implements AddressSearchResultsInterface +{ +} diff --git a/app/code/Magento/Customer/Model/AttributeMetadataResolver.php b/app/code/Magento/Customer/Model/AttributeMetadataResolver.php index 979730eb1c9c..c936de1bd023 100644 --- a/app/code/Magento/Customer/Model/AttributeMetadataResolver.php +++ b/app/code/Magento/Customer/Model/AttributeMetadataResolver.php @@ -16,6 +16,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Model\Config\Share as ShareConfig; +use Magento\Customer\Model\FileUploaderDataResolver; /** * Class to build meta data of the customer or customer address attribute @@ -77,14 +78,14 @@ class AttributeMetadataResolver /** * @param CountryWithWebsites $countryWithWebsiteSource * @param EavValidationRules $eavValidationRules - * @param \Magento\Customer\Model\FileUploaderDataResolver $fileUploaderDataResolver + * @param FileUploaderDataResolver $fileUploaderDataResolver * @param ContextInterface $context * @param ShareConfig $shareConfig */ public function __construct( CountryWithWebsites $countryWithWebsiteSource, EavValidationRules $eavValidationRules, - fileUploaderDataResolver $fileUploaderDataResolver, + FileUploaderDataResolver $fileUploaderDataResolver, ContextInterface $context, ShareConfig $shareConfig ) { @@ -113,7 +114,12 @@ public function getAttributesMeta( // use getDataUsingMethod, since some getters are defined and apply additional processing of returning value foreach (self::$metaProperties as $metaName => $origName) { $value = $attribute->getDataUsingMethod($origName); - $meta['arguments']['data']['config'][$metaName] = ($metaName === 'label') ? __($value) : $value; + if ($metaName === 'label') { + $meta['arguments']['data']['config'][$metaName] = __($value); + $meta['arguments']['data']['config']['__disableTmpl'] = [$metaName => true]; + } else { + $meta['arguments']['data']['config'][$metaName] = $value; + } if ('frontend_input' === $origName) { $meta['arguments']['data']['config']['formElement'] = self::$formElement[$value] ?? $value; } @@ -124,7 +130,14 @@ public function getAttributesMeta( $meta['arguments']['data']['config']['options'] = $this->countryWithWebsiteSource ->getAllOptions(); } else { - $meta['arguments']['data']['config']['options'] = $attribute->getSource()->getAllOptions(); + $options = $attribute->getSource()->getAllOptions(); + array_walk( + $options, + function (&$item) { + $item['__disableTmpl'] = ['label' => true]; + } + ); + $meta['arguments']['data']['config']['options'] = $options; } } @@ -144,7 +157,6 @@ public function getAttributesMeta( $attribute, $meta['arguments']['data']['config'] ); - return $meta; } diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php index 1f8f7d90f6d0..2692d1edf014 100644 --- a/app/code/Magento/Customer/Model/Customer.php +++ b/app/code/Magento/Customer/Model/Customer.php @@ -20,6 +20,7 @@ use Magento\Framework\Reflection\DataObjectProcessor; use Magento\Store\Model\ScopeInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Math\Random; /** * Customer model @@ -180,7 +181,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel protected $_encryptor; /** - * @var \Magento\Framework\Math\Random + * @var Random */ protected $mathRandom; @@ -248,6 +249,7 @@ class Customer extends \Magento\Framework\Model\AbstractModel * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @param AccountConfirmation|null $accountConfirmation + * @param Random|null $mathRandom * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -272,7 +274,8 @@ public function __construct( \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], - AccountConfirmation $accountConfirmation = null + AccountConfirmation $accountConfirmation = null, + Random $mathRandom = null ) { $this->metadataService = $metadataService; $this->_scopeConfig = $scopeConfig; @@ -291,6 +294,7 @@ public function __construct( $this->indexerRegistry = $indexerRegistry; $this->accountConfirmation = $accountConfirmation ?: ObjectManager::getInstance() ->get(AccountConfirmation::class); + $this->mathRandom = $mathRandom ?: ObjectManager::getInstance()->get(Random::class); parent::__construct( $context, $registry, @@ -815,8 +819,7 @@ public function isConfirmationRequired() */ public function getRandomConfirmationKey() { - // phpcs:ignore Magento2.Security.InsecureFunction - return md5(uniqid()); + return $this->mathRandom->getRandomString(32); } /** diff --git a/app/code/Magento/Customer/Model/Customer/Source/Group.php b/app/code/Magento/Customer/Model/Customer/Source/Group.php index efcc7d0fe93a..1064152b20fd 100644 --- a/app/code/Magento/Customer/Model/Customer/Source/Group.php +++ b/app/code/Magento/Customer/Model/Customer/Source/Group.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Model\Customer\Source; use Magento\Customer\Api\Data\GroupSearchResultsInterface; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Customer\Api\Data\GroupInterface; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; diff --git a/app/code/Magento/Customer/Model/CustomerSearchResults.php b/app/code/Magento/Customer/Model/CustomerSearchResults.php new file mode 100644 index 000000000000..1d7f0e265641 --- /dev/null +++ b/app/code/Magento/Customer/Model/CustomerSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Model; + +use Magento\Customer\Api\Data\CustomerSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Customer search results. + */ +class CustomerSearchResults extends SearchResults implements CustomerSearchResultsInterface +{ +} diff --git a/app/code/Magento/Customer/Model/EmailNotification.php b/app/code/Magento/Customer/Model/EmailNotification.php index 573f86247e0c..432317444f4b 100644 --- a/app/code/Magento/Customer/Model/EmailNotification.php +++ b/app/code/Magento/Customer/Model/EmailNotification.php @@ -340,7 +340,7 @@ public function passwordReminder(CustomerInterface $customer) */ public function passwordResetConfirmation(CustomerInterface $customer) { - $storeId = $this->storeManager->getStore()->getId(); + $storeId = $customer->getStoreId(); if (!$storeId) { $storeId = $this->getWebsiteStoreId($customer); } diff --git a/app/code/Magento/Customer/Model/GroupSearchResults.php b/app/code/Magento/Customer/Model/GroupSearchResults.php new file mode 100644 index 000000000000..1de4cd078db8 --- /dev/null +++ b/app/code/Magento/Customer/Model/GroupSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Model; + +use Magento\Customer\Api\Data\GroupSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Customer Groups search results. + */ +class GroupSearchResults extends SearchResults implements GroupSearchResultsInterface +{ +} diff --git a/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php b/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php index 517aef5690ee..577c97a19268 100644 --- a/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php +++ b/app/code/Magento/Customer/Model/Plugin/CustomerNotification.php @@ -15,6 +15,11 @@ use Magento\Framework\Exception\NoSuchEntityException; use Psr\Log\LoggerInterface; +/** + * Plugin before \Magento\Framework\App\Action\AbstractAction::dispatch. + * + * Plugin to remove notifications from cache. + */ class CustomerNotification { /** @@ -66,6 +71,8 @@ public function __construct( } /** + * Removes notifications from cache. + * * @param AbstractAction $subject * @param RequestInterface $request * @return void @@ -82,10 +89,10 @@ public function beforeDispatch(AbstractAction $subject, RequestInterface $reques ) ) { try { + $this->session->regenerateId(); $customer = $this->customerRepository->getById($customerId); $this->session->setCustomerData($customer); $this->session->setCustomerGroupId($customer->getGroupId()); - $this->session->regenerateId(); $this->notificationStorage->remove(NotificationStorage::UPDATE_CUSTOMER_SESSION, $customer->getId()); } catch (NoSuchEntityException $e) { $this->logger->error($e); diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php index 529b0e806972..03cf4b1bddde 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php @@ -7,24 +7,25 @@ namespace Magento\Customer\Model\ResourceModel; use Magento\Customer\Api\CustomerMetadataInterface; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory; -use Magento\Framework\Api\ExtensibleDataObjectConverter; -use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; +use Magento\Customer\Model\Customer as CustomerModel; +use Magento\Customer\Model\Customer\NotificationStorage; use Magento\Customer\Model\CustomerFactory; use Magento\Customer\Model\CustomerRegistry; use Magento\Customer\Model\Data\CustomerSecureFactory; -use Magento\Customer\Model\Customer\NotificationStorage; use Magento\Customer\Model\Delegation\Data\NewOperation; -use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Model\Delegation\Storage as DelegatedStorage; use Magento\Framework\Api\DataObjectHelper; +use Magento\Framework\Api\ExtensibleDataObjectConverter; +use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface; use Magento\Framework\Api\ImageProcessorInterface; +use Magento\Framework\Api\Search\FilterGroup; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; use Magento\Framework\Api\SearchCriteriaInterface; -use Magento\Framework\Api\Search\FilterGroup; -use Magento\Framework\Event\ManagerInterface; -use Magento\Customer\Model\Delegation\Storage as DelegatedStorage; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Event\ManagerInterface; use Magento\Store\Model\StoreManagerInterface; /** @@ -203,7 +204,7 @@ public function save(CustomerInterface $customer, $passwordHash = null) $customer->setAddresses([]); $customerData = $this->extensibleDataObjectConverter->toNestedArray($customer, [], CustomerInterface::class); $customer->setAddresses($origAddresses); - /** @var Customer $customerModel */ + /** @var CustomerModel $customerModel */ $customerModel = $this->customerFactory->create(['data' => $customerData]); //Model's actual ID field maybe different than "id" so "id" field from $customerData may be ignored. $customerModel->setId($customer->getId()); diff --git a/app/code/Magento/Customer/Model/Session.php b/app/code/Magento/Customer/Model/Session.php index 047327a0b6c2..e9dc7700ec09 100644 --- a/app/code/Magento/Customer/Model/Session.php +++ b/app/code/Magento/Customer/Model/Session.php @@ -370,7 +370,9 @@ public function setCustomerGroupId($id) } /** - * Get customer group id. If customer is not logged in system, 'not logged in' group id will be returned. + * Get customer group id. + * + * If customer is not logged in system, 'not logged in' group id will be returned. * * @return int * @throws \Magento\Framework\Exception\LocalizedException @@ -431,21 +433,22 @@ public function checkCustomerId($customerId) */ public function setCustomerAsLoggedIn($customer) { + $this->regenerateId(); $this->setCustomer($customer); $this->_eventManager->dispatch('customer_login', ['customer' => $customer]); $this->_eventManager->dispatch('customer_data_object_login', ['customer' => $this->getCustomerDataObject()]); - $this->regenerateId(); return $this; } /** - * Sets customer data as logged in + * Sets customer as logged in * * @param CustomerData $customer * @return $this */ public function setCustomerDataAsLoggedIn($customer) { + $this->regenerateId(); $this->_httpContext->setValue(Context::CONTEXT_AUTH, true, false); $this->setCustomerData($customer); @@ -590,7 +593,7 @@ public function regenerateId() } /** - * Creates URL factory + * Creates URL object * * @return \Magento\Framework\UrlInterface */ diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php index 4f129f05aa82..6935b9dca7f2 100644 --- a/app/code/Magento/Customer/Model/Visitor.php +++ b/app/code/Magento/Customer/Model/Visitor.php @@ -169,6 +169,11 @@ public function initByRequest($observer) $this->setLastVisitAt((new \DateTime())->format(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)); + // prevent saving Visitor for safe methods, e.g. GET request + if ($this->requestSafety->isSafeMethod()) { + return $this; + } + if (!$this->getId()) { $this->setSessionId($this->session->getSessionId()); $this->save(); @@ -260,7 +265,7 @@ public function bindCustomerLogout($observer) * Create binding of checkout quote * * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Customer\Model\Visitor + * @return \Magento\Customer\Model\Visitor */ public function bindQuoteCreate($observer) { @@ -278,7 +283,7 @@ public function bindQuoteCreate($observer) * Destroy binding of checkout quote * * @param \Magento\Framework\Event\Observer $observer - * @return \Magento\Customer\Model\Visitor + * @return \Magento\Customer\Model\Visitor */ public function bindQuoteDestroy($observer) { diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StoreFrontClickEditDefaultShippingAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StoreFrontClickEditDefaultShippingAddressActionGroup.xml new file mode 100644 index 000000000000..36c62a887c18 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StoreFrontClickEditDefaultShippingAddressActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + --> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> +<actionGroup name="StoreFrontClickEditDefaultShippingAddressActionGroup"> + <annotations> + <description>Click on the edit default shipping address link.</description> + </annotations> + + <click stepKey="ClickEditDefaultShippingAddress" selector="{{StorefrontCustomerAddressesSection.editDefaultShippingAddress}}"/> + <waitForPageLoad stepKey="waitForStorefrontSignInPageLoad"/> +</actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml b/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml index 4d7a39b3246e..74365ef02fe8 100644 --- a/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml +++ b/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml @@ -51,6 +51,21 @@ <data key="default_shipping">Yes</data> <requiredEntity type="region">RegionTX</requiredEntity> </entity> + <entity name="US_Address_TX_Without_Default" type="address"> + <data key="firstname">John</data> + <data key="lastname">Doe</data> + <data key="company">Magento</data> + <array key="street"> + <item>7700 West Parmer Lane</item> + </array> + <data key="city">Austin</data> + <data key="state">Texas</data> + <data key="country_id">US</data> + <data key="country">United States</data> + <data key="postcode">78729</data> + <data key="telephone">512-345-6789</data> + <requiredEntity type="region">RegionTX</requiredEntity> + </entity> <entity name="US_Address_TX_Default_Billing" type="address"> <data key="firstname">John</data> <data key="lastname">Doe</data> @@ -239,6 +254,21 @@ <data key="state">Côtes-d'Armor</data> <data key="postcode">12345</data> </entity> + <entity name="updateCustomerChinaAddress" type="address"> + <data key="firstname">Xian</data> + <data key="lastname">Shai</data> + <data key="company">Hunan Fenmian</data> + <data key="telephone">+86 851 8410 4337</data> + <array key="street"> + <item>Nanyuan Rd, Wudang</item> + <item>Hunan Fenmian</item> + </array> + <data key="country_id">CN</data> + <data key="country">China</data> + <data key="city">Guiyang</data> + <data key="state">Guizhou Sheng</data> + <data key="postcode">550002</data> + </entity> <entity name="updateCustomerNoXSSInjection" type="address"> <data key="firstname">Jany</data> <data key="lastname">Doe</data> @@ -312,4 +342,37 @@ <data key="postcode">90230</data> <data key="telephone">555-55-555-55</data> </entity> + <entity name="US_Address_AE" type="address"> + <data key="firstname">John</data> + <data key="lastname">Doe</data> + <data key="company">Magento</data> + <array key="street"> + <item>7700 West Parmer Lane</item> + <item>113</item> + </array> + <data key="city">Los Angeles</data> + <data key="state">Armed Forces Europe</data> + <data key="country_id">US</data> + <data key="country">United States</data> + <data key="postcode">90001</data> + <data key="telephone">512-345-6789</data> + <data key="default_billing">Yes</data> + <data key="default_shipping">Yes</data> + <requiredEntity type="region">RegionAE</requiredEntity> + </entity> + <entity name="updateCustomerBelgiumAddress" type="address"> + <data key="firstname">John</data> + <data key="lastname">Doe</data> + <data key="company">Magento</data> + <array key="street"> + <item>Chaussee de Wavre</item> + <item>318</item> + </array> + <data key="city">Bihain</data> + <data key="state">Hainaut</data> + <data key="country_id">BE</data> + <data key="country">Belgium</data> + <data key="postcode">6690</data> + <data key="telephone">0477-58-77867</data> + </entity> </entities> diff --git a/app/code/Magento/Customer/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml b/app/code/Magento/Customer/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml new file mode 100644 index 000000000000..e4c020cc449f --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Data/AdminGeneralStoreInfomationConfigData.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminGeneralSetVatNumberConfigData"> + <data key="path">general/store_information/merchant_vat_number</data> + <data key="value">111607872</data> + </entity> +</entities> diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml index c7a73b61dc48..093d6a05e8c5 100644 --- a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml +++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml @@ -47,6 +47,20 @@ <data key="group">General</data> <requiredEntity type="address">US_Address_TX</requiredEntity> </entity> + <entity name="Simple_US_Customer_Without_Default_Address" type="customer"> + <data key="group_id">1</data> + <data key="default_billing">true</data> + <data key="default_shipping">true</data> + <data key="email" unique="prefix">John.Doe@example.com</data> + <data key="firstname">John</data> + <data key="lastname">Doe</data> + <data key="fullname">John Doe</data> + <data key="password">pwdTest123!</data> + <data key="store_id">0</data> + <data key="website_id">0</data> + <data key="group">General</data> + <requiredEntity type="address">US_Address_TX_Without_Default</requiredEntity> + </entity> <entity name="SimpleUsCustomerWithNewCustomerGroup" type="customer"> <data key="default_billing">true</data> <data key="default_shipping">true</data> @@ -309,4 +323,17 @@ <data key="store_id">0</data> <data key="website_id">0</data> </entity> + <entity name="Simple_US_Customer_ArmedForcesEurope" type="customer"> + <data key="group_id">0</data> + <data key="default_billing">true</data> + <data key="default_shipping">true</data> + <data key="email" unique="prefix">John.Doe@example.com</data> + <data key="firstname">John</data> + <data key="lastname">Doe</data> + <data key="fullname">John Doe</data> + <data key="password">pwdTest123!</data> + <data key="store_id">0</data> + <data key="website_id">0</data> + <requiredEntity type="address">US_Address_AE</requiredEntity> + </entity> </entities> diff --git a/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml b/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml index 280bae7de411..0a956f16767b 100644 --- a/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml +++ b/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml @@ -32,4 +32,9 @@ <data key="region_code">UT</data> <data key="region_id">58</data> </entity> + <entity name="RegionAE" type="region"> + <data key="region">Armed Forces Europe</data> + <data key="region_code">AFE</data> + <data key="region_id">9</data> + </entity> </entities> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressesGridActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressesGridActionsSection.xml index e743c4af66d9..3ecbf5ff450c 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressesGridActionsSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAddressesGridActionsSection.xml @@ -17,5 +17,6 @@ <element name="filters" type="button" selector="button[data-action='grid-filter-expand']" timeout="30"/> <element name="ok" type="button" selector="//button[@data-role='action']//span[text()='OK']" timeout="30"/> <element name="headerRow" type="text" selector=".admin__data-grid-header-row.row.row-gutter"/> + <element name="clearFilter" type="button" selector=".admin__data-grid-header .admin__data-grid-filters-current button.action-clear" timeout="30"/> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml index 78bae7ad60dd..a11fb9d0eaa8 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml @@ -23,7 +23,7 @@ <magentoCLI command="indexer:reindex customer_grid" stepKey="reindexCustomerGrid"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml index 43f2aa7f8de9..a487571c4353 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerWithCountryUSATest.xml @@ -85,6 +85,7 @@ <see selector="{{AdminCustomerAddressesDefaultBillingSection.addressDetails}}" userInput="{{US_Address_CA.telephone}}" stepKey="seePhoneNumberInDefaultAddressSection"/> <!--Assert Customer Address Grid --> + <conditionalClick selector="{{AdminCustomerAddressesGridActionsSection.clearFilter}}" dependentSelector="{{AdminCustomerAddressesGridActionsSection.clearFilter}}" visible="true" stepKey="clearAddressesGridFilter"/> <see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.street}}" stepKey="seeStreetAddress"/> <see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.city}}" stepKey="seeCity"/> <see selector="{{AdminCustomerAddressesGridSection.customerAddressGrid}}" userInput="{{US_Address_CA.country}}" stepKey="seeCountry"/> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml new file mode 100644 index 000000000000..d2d3343a3b8d --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest"> + <annotations> + <features value="Customer"/> + <stories value="Customer Order"/> + <title value="Place an order and click print"/> + <description value="Admin panel is not frozen if Storefront is opened via Customer View"/> + <severity value="MAJOR"/> + <testCaseId value="https://github.com/magento/magento2/pull/24845"/> + <group value="customer"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="simpleCustomer"/> + <createData entity="SimpleSubCategory" stepKey="createSimpleCategory"/> + <createData entity="SimpleProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createSimpleCategory"/> + </createData> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + </before> + <after> + <deleteData createDataKey="createSimpleCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderPage"> + <argument name="customer" value="$simpleCustomer$"/> + </actionGroup> + <actionGroup ref="addSimpleProductToOrder" stepKey="addSecondProduct"> + <argument name="product" value="$createSimpleProduct$"/> + </actionGroup> + <actionGroup ref="fillOrderCustomerInformation" stepKey="fillCustomerInfo"> + <argument name="customer" value="$simpleCustomer$"/> + <argument name="address" value="US_Address_TX"/> + </actionGroup> + <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRate"/> + <actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/> + <grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/> + + <actionGroup ref="StartCreateInvoiceFromOrderPage" stepKey="startCreateInvoice"/> + <actionGroup ref="SubmitInvoice" stepKey="submitInvoice"/> + <actionGroup ref="goToShipmentIntoOrder" stepKey="goToShipment"/> + <actionGroup ref="submitShipmentIntoOrder" stepKey="submitShipment"/> + + <!--Create Credit Memo--> + <actionGroup ref="StartToCreateCreditMemoActionGroup" stepKey="startToCreateCreditMemo"> + <argument name="orderId" value="{$getOrderId}"/> + </actionGroup> + <actionGroup ref="SubmitCreditMemoActionGroup" stepKey="submitCreditMemo"/> + + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="logInCustomer"> + <argument name="Customer" value="$$simpleCustomer$$"/> + </actionGroup> + <actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToMyOrdersPage"> + <argument name="menu" value="My Orders"/> + </actionGroup> + <click selector="{{StorefrontCustomerOrderSection.viewOrder}}" stepKey="clickViewOrder"/> + <click selector="{{StorefrontCustomerOrderViewSection.printOrderLink}}" stepKey="clickPrintOrderLink"/> + <waitForPageLoad stepKey="waitPageReload"/> + <switchToWindow stepKey="switchToWindow"/> + <switchToPreviousTab stepKey="switchToPreviousTab"/> + + <actionGroup ref="StorefrontCustomerGoToSidebarMenu" stepKey="goToAddressBook"> + <argument name="menu" value="Address Book"/> + </actionGroup> + <see selector="{{CheckoutOrderSummarySection.shippingAddress}}" userInput="{{US_Address_TX.street[0]}} {{US_Address_TX.city}}, {{US_Address_TX.state}}, {{US_Address_TX.postcode}}" stepKey="checkShippingAddress"/> + </test> +</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml index 2b24233e8b07..bf8844b2cc7a 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml @@ -25,7 +25,7 @@ <resetCookie userInput="PHPSESSID" stepKey="resetCookieForCart"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Step 0: User signs up an account --> <comment userInput="Start of signing up user account" stepKey="startOfSigningUpUserAccount" /> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddCustomerAddressTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddCustomerAddressTest.xml index 413bbfd06a53..e2c55eb3962f 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddCustomerAddressTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontAddCustomerAddressTest.xml @@ -24,7 +24,7 @@ </before> <after> <deleteData createDataKey="createCustomer" stepKey="DeleteCustomer"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="AmOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Log in to Storefront as Customer 1 --> @@ -101,7 +101,7 @@ </before> <after> <deleteData createDataKey="createCustomer" stepKey="DeleteCustomer"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="AmOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Log in to Storefront as Customer 1 --> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml index ada3adbfeb83..40b05153f1a7 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml @@ -20,6 +20,7 @@ </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create Simple Customer --> <createData entity="Simple_US_Customer_CA" stepKey="createSimpleCustomer1"/> @@ -108,6 +109,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Logout --> <actionGroup ref="logout" stepKey="logoutOfAdmin1"/> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerTest.xml index 97c932f0cb28..7d51f97f2463 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerTest.xml @@ -20,7 +20,7 @@ <group value="create"/> </annotations> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml new file mode 100644 index 000000000000..6c0615f701df --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontUpdateCustomerAddressBelgiumTest"> + <annotations> + <stories value="Update Regions list for Belgium country"/> + <title value="Update customer address on storefront with Belgium address"/> + <description value="Update customer address on storefront with Belgium address and verify you can select a region"/> + <testCaseId value="MC-20234"/> + <severity value="AVERAGE"/> + <group value="customer"/> + </annotations> + + <before> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> + <argument name="Customer" value="CustomerEntityOne"/> + </actionGroup> + </before> + <after> + <actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser"> + <argument name="email" value="{{CustomerEntityOne.email}}"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--Update customer address Belgium in storefront--> + <actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress"> + <argument name="Address" value="updateCustomerBelgiumAddress"/> + </actionGroup> + <!--Verify customer address save success message--> + <see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/> + + <!--Verify customer default billing address--> + <actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress"> + <argument name="address" value="updateCustomerBelgiumAddress"/> + </actionGroup> + + <!--Verify customer default shipping address--> + <actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress"> + <argument name="address" value="updateCustomerBelgiumAddress"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml new file mode 100644 index 000000000000..285de8d777b4 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontUpdateCustomerAddressChinaTest"> + <annotations> + <stories value="Update Regions list for China country"/> + <title value="Update customer address on storefront with china address"/> + <description value="Update customer address on storefront with china address and verify you can select a region"/> + <testCaseId value="MC-20234"/> + <severity value="AVERAGE"/> + <group value="customer"/> + </annotations> + + <before> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> + <argument name="Customer" value="CustomerEntityOne"/> + </actionGroup> + </before> + <after> + <actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser"> + <argument name="email" value="{{CustomerEntityOne.email}}"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--Update customer address in storefront--> + <actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress"> + <argument name="Address" value="updateCustomerChinaAddress"/> + </actionGroup> + <!--Verify customer address save success message--> + <see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/> + + <!--Verify customer default billing address--> + <actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress"> + <argument name="address" value="updateCustomerChinaAddress"/> + </actionGroup> + + <!--Verify customer default shipping address--> + <actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress"> + <argument name="address" value="updateCustomerChinaAddress"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php index 3022177ffb9e..5ec2ad56560d 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/RegisterTest.php @@ -39,7 +39,7 @@ class RegisterTest extends \PHPUnit\Framework\TestCase /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session */ private $_customerSession; - /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Module\ModuleManagerInterface */ + /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Module\Manager */ private $_moduleManager; /** @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Url */ diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php index 8bfddac3cef8..b1d7c455324b 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php @@ -9,13 +9,13 @@ use Magento\Customer\Api\CustomerMetadataInterface; use Magento\Customer\Api\Data\AttributeMetadataInterface; use Magento\Customer\Api\Data\ValidationRuleInterface; +use Magento\Customer\Block\Widget\Dob; use Magento\Customer\Helper\Address; use Magento\Framework\App\CacheInterface; use Magento\Framework\Cache\FrontendInterface; use Magento\Framework\Data\Form\FilterFactory; use Magento\Framework\Escaper; use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Customer\Block\Widget\Dob; use Magento\Framework\Locale\Resolver; use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Stdlib\DateTime\Timezone; @@ -23,7 +23,7 @@ use Magento\Framework\View\Element\Html\Date; use Magento\Framework\View\Element\Template\Context; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject; +use PHPUnit\Framework\MockObject\MockObject; use Zend_Cache_Backend_BlackHole; use Zend_Cache_Core; @@ -60,17 +60,17 @@ class DobTest extends TestCase const YEAR_HTML = '<div><label for="year"><span>yy</span></label><input type="text" id="year" name="Year" value="14"></div>'; - /** @var PHPUnit_Framework_MockObject_MockObject|AttributeMetadataInterface */ + /** @var MockObject|AttributeMetadataInterface */ protected $attribute; /** @var Dob */ protected $_block; - /** @var PHPUnit_Framework_MockObject_MockObject|CustomerMetadataInterface */ + /** @var MockObject|CustomerMetadataInterface */ protected $customerMetadata; /** - * @var FilterFactory|PHPUnit_Framework_MockObject_MockObject + * @var FilterFactory|MockObject */ protected $filterFactory; @@ -336,12 +336,27 @@ public function getYearDataProvider() } /** - * is used to derive the Locale that is used to determine the - * value of Dob::getDateFormat() for that Locale. + * Is used to derive the Locale that is used to determine the value of Dob::getDateFormat() for that Locale + * + * @param string $locale + * @param string $expectedFormat + * @dataProvider getDateFormatDataProvider + */ + public function testGetDateFormat(string $locale, string $expectedFormat) + { + $this->_locale = $locale; + $this->assertEquals($expectedFormat, $this->_block->getDateFormat()); + } + + /** + * @return array */ - public function testGetDateFormat() + public function getDateFormatDataProvider(): array { - $this->assertEquals(self::DATE_FORMAT, $this->_block->getDateFormat()); + return [ + ['ar_SA', 'd/M/y'], + [Resolver::DEFAULT_LOCALE, self::DATE_FORMAT], + ]; } /** @@ -521,8 +536,8 @@ public function testGetHtmlExtraParamsWithoutRequiredOption() { $this->escaper->expects($this->any()) ->method('escapeHtml') - ->with('{"validate-date":{"dateFormat":"M\/d\/Y"}}') - ->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"}}')); + ->with('{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}') + ->will($this->returnValue('{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}')); $this->attribute->expects($this->once()) ->method("isRequired") @@ -530,7 +545,7 @@ public function testGetHtmlExtraParamsWithoutRequiredOption() $this->assertEquals( $this->_block->getHtmlExtraParams(), - 'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"}}"' + 'data-validate="{"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}"' ); } @@ -544,13 +559,17 @@ public function testGetHtmlExtraParamsWithRequiredOption() ->willReturn(true); $this->escaper->expects($this->any()) ->method('escapeHtml') - ->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}') - ->will($this->returnValue('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}')); + ->with('{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}') + ->will( + $this->returnValue( + '{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}' + ) + ); $this->context->expects($this->any())->method('getEscaper')->will($this->returnValue($this->escaper)); $this->assertEquals( - 'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"}}"', + 'data-validate="{"required":true,"validate-date":{"dateFormat":"M\/d\/Y"},"validate-dob":true}"', $this->_block->getHtmlExtraParams() ); } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php index f8f47eedba3e..faf55347dba7 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePostTest.php @@ -346,11 +346,13 @@ public function testSuccessMessage( $this->requestMock->expects($this->any()) ->method('getParam') - ->willReturnMap([ - ['password', null, $password], - ['password_confirmation', null, $password], - ['is_subscribed', false, true], - ]); + ->willReturnMap( + [ + ['password', null, $password], + ['password_confirmation', null, $password], + ['is_subscribed', false, true], + ] + ); $this->customerMock->expects($this->once()) ->method('setAddresses') @@ -371,7 +373,7 @@ public function testSuccessMessage( ->with($this->equalTo($customerId)); $this->messageManagerMock->expects($this->any()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with($this->stringContains($successMessage)) ->will($this->returnSelf()); @@ -477,11 +479,13 @@ public function testSuccessRedirect( $this->requestMock->expects($this->any()) ->method('getParam') - ->willReturnMap([ - ['password', null, $password], - ['password_confirmation', null, $password], - ['is_subscribed', false, true], - ]); + ->willReturnMap( + [ + ['password', null, $password], + ['password_confirmation', null, $password], + ['is_subscribed', false, true], + ] + ); $this->customerMock->expects($this->once()) ->method('setAddresses') @@ -502,16 +506,18 @@ public function testSuccessRedirect( ->with($this->equalTo($customerId)); $this->messageManagerMock->expects($this->any()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with($this->stringContains($successMessage)) ->will($this->returnSelf()); $this->urlMock->expects($this->any()) ->method('getUrl') - ->willReturnMap([ - ['*/*/index', ['_secure' => true], $successUrl], - ['*/*/create', ['_secure' => true], $successUrl], - ]); + ->willReturnMap( + [ + ['*/*/index', ['_secure' => true], $successUrl], + ['*/*/create', ['_secure' => true], $successUrl], + ] + ); $this->redirectMock->expects($this->once()) ->method('success') ->with($this->equalTo($successUrl)) 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 762c76b695de..13cf195ab5f6 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php @@ -93,13 +93,14 @@ protected function setUp() $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() - ->setMethods([ - 'isLoggedIn', - 'setCustomerDataAsLoggedIn', - 'regenerateId', - 'setUsername', - ]) - ->getMock(); + ->setMethods( + [ + 'isLoggedIn', + 'setCustomerDataAsLoggedIn', + 'regenerateId', + 'setUsername', + ] + )->getMock(); $this->accountManagement = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class) ->getMockForAbstractClass(); @@ -253,10 +254,12 @@ public function testExecuteSuccessCustomRedirect() $this->request->expects($this->once()) ->method('getPost') ->with('login') - ->willReturn([ - 'username' => $username, - 'password' => $password, - ]); + ->willReturn( + [ + 'username' => $username, + 'password' => $password, + ] + ); $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); @@ -292,9 +295,8 @@ public function testExecuteSuccessCustomRedirect() ->method('setCustomerDataAsLoggedIn') ->with($customerMock) ->willReturnSelf(); - $this->session->expects($this->once()) - ->method('regenerateId') - ->willReturnSelf(); + $this->session->expects($this->never()) + ->method('regenerateId'); $this->accountRedirect->expects($this->never()) ->method('getRedirect') @@ -335,10 +337,12 @@ public function testExecuteSuccess() $this->request->expects($this->once()) ->method('getPost') ->with('login') - ->willReturn([ - 'username' => $username, - 'password' => $password, - ]); + ->willReturn( + [ + 'username' => $username, + 'password' => $password, + ] + ); $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class) ->getMockForAbstractClass(); @@ -357,9 +361,8 @@ public function testExecuteSuccess() ->method('setCustomerDataAsLoggedIn') ->with($customerMock) ->willReturnSelf(); - $this->session->expects($this->once()) - ->method('regenerateId') - ->willReturnSelf(); + $this->session->expects($this->never()) + ->method('regenerateId'); $this->accountRedirect->expects($this->once()) ->method('getRedirect') @@ -426,10 +429,12 @@ public function testExecuteWithException( $this->request->expects($this->once()) ->method('getPost') ->with('login') - ->willReturn([ - 'username' => $username, - 'password' => $password, - ]); + ->willReturn( + [ + 'username' => $username, + 'password' => $password, + ] + ); $exception = new $exceptionData['exception'](__($exceptionData['message'])); @@ -488,11 +493,12 @@ protected function prepareContext() $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) ->disableOriginalConstructor() - ->setMethods([ - 'isPost', - 'getPost', - ]) - ->getMock(); + ->setMethods( + [ + 'isPost', + 'getPost', + ] + )->getMock(); $this->resultRedirect = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php index 45e64f6557d5..8267624f7b00 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php @@ -9,6 +9,7 @@ use Magento\Customer\Model\EmailNotificationInterface; use Magento\Framework\DataObject; use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Escaper; /** * Unit tests for Inline customer edit @@ -78,6 +79,9 @@ class InlineEditTest extends \PHPUnit\Framework\TestCase /** @var array */ private $items; + /** @var \Magento\Framework\Escaper */ + private $escaper; + /** * Sets up mocks * @@ -86,7 +90,7 @@ class InlineEditTest extends \PHPUnit\Framework\TestCase protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - + $this->escaper = new Escaper(); $this->request = $this->getMockForAbstractClass( \Magento\Framework\App\RequestInterface::class, [], @@ -172,7 +176,8 @@ protected function setUp() 'addressDataFactory' => $this->addressDataFactory, 'addressRepository' => $this->addressRepository, 'logger' => $this->logger, - 'addressRegistry' => $this->addressRegistry + 'addressRegistry' => $this->addressRegistry, + 'escaper' => $this->escaper, ] ); $reflection = new \ReflectionClass(get_class($this->controller)); @@ -291,10 +296,14 @@ protected function prepareMocksForErrorMessagesProcessing() ->willReturn('Error text'); $this->resultJson->expects($this->once()) ->method('setData') - ->with([ - 'messages' => ['Error text'], - 'error' => true, - ]) + ->with( + [ + 'messages' => [ + 'Error text', + ], + 'error' => true, + ] + ) ->willReturnSelf(); } @@ -340,10 +349,14 @@ public function testExecuteWithoutItems() $this->resultJson ->expects($this->once()) ->method('setData') - ->with([ - 'messages' => [__('Please correct the data sent.')], - 'error' => true, - ]) + ->with( + [ + 'messages' => [ + __('Please correct the data sent.'), + ], + 'error' => true, + ] + ) ->willReturnSelf(); $this->assertSame($this->resultJson, $this->controller->execute()); } @@ -365,6 +378,7 @@ public function testExecuteLocalizedException() ->method('save') ->with($this->customerData) ->willThrowException($exception); + $this->messageManager->expects($this->once()) ->method('addError') ->with('[Customer ID: 12] Exception message'); diff --git a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php index 03158d05db8e..15ced1ce66d0 100644 --- a/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Helper/Session/CurrentCustomerTest.php @@ -47,7 +47,7 @@ class CurrentCustomerTest extends \PHPUnit\Framework\TestCase protected $requestMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; @@ -80,7 +80,7 @@ protected function setUp() $this->customerDataMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class); $this->customerRepositoryMock = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class); $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\ModuleManagerInterface::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); $this->viewMock = $this->createMock(\Magento\Framework\App\View::class); $this->currentCustomer = new \Magento\Customer\Helper\Session\CurrentCustomer( diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php index 9128d7c67526..bc4c19bc23ac 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/Source/GroupTest.php @@ -6,7 +6,7 @@ namespace Magento\Customer\Test\Unit\Model\Customer\Source; use Magento\Customer\Model\Customer\Source\Group; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\SearchCriteria; @@ -23,7 +23,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase private $model; /** - * @var ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var Manager|\PHPUnit_Framework_MockObject_MockObject */ private $moduleManagerMock; @@ -49,7 +49,7 @@ class GroupTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $this->moduleManagerMock = $this->getMockBuilder(ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(Manager::class) ->disableOriginalConstructor() ->getMock(); $this->groupRepositoryMock = $this->getMockBuilder(GroupRepositoryInterface::class) diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php index 65831069aa1f..170cd001e5b9 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php @@ -15,6 +15,7 @@ use Magento\Customer\Model\AccountConfirmation; use Magento\Customer\Model\ResourceModel\Address\CollectionFactory as AddressCollectionFactory; use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Framework\Math\Random; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -86,6 +87,14 @@ class CustomerTest extends \PHPUnit\Framework\TestCase */ private $dataObjectHelper; + /** + * @var Random|\PHPUnit_Framework_MockObject_MockObject + */ + private $mathRandom; + + /** + * @inheritdoc + */ protected function setUp() { $this->_website = $this->createMock(\Magento\Store\Model\Website::class); @@ -130,6 +139,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['populateWithArray']) ->getMock(); + $this->mathRandom = $this->createMock(Random::class); $this->_model = $helper->getObject( \Magento\Customer\Model\Customer::class, @@ -146,7 +156,8 @@ protected function setUp() 'accountConfirmation' => $this->accountConfirmation, '_addressesFactory' => $this->addressesFactory, 'customerDataFactory' => $this->customerDataFactory, - 'dataObjectHelper' => $this->dataObjectHelper + 'dataObjectHelper' => $this->dataObjectHelper, + 'mathRandom' => $this->mathRandom, ] ); } @@ -219,15 +230,17 @@ public function testSendNewAccountEmailWithoutStoreId() ->method('getTransport') ->will($this->returnValue($transportMock)); - $this->_model->setData([ - 'website_id' => 1, - 'store_id' => 1, - 'email' => 'email@example.com', - 'firstname' => 'FirstName', - 'lastname' => 'LastName', - 'middlename' => 'MiddleName', - 'prefix' => 'Name Prefix', - ]); + $this->_model->setData( + [ + 'website_id' => 1, + 'store_id' => 1, + 'email' => 'email@example.com', + 'firstname' => 'FirstName', + 'lastname' => 'LastName', + 'middlename' => 'MiddleName', + 'prefix' => 'Name Prefix', + ] + ); $this->_model->sendNewAccountEmail('registered'); } @@ -383,4 +396,20 @@ public function testGetDataModel() $this->_model->getDataModel(); $this->assertEquals($customerDataObject, $this->_model->getDataModel()); } + + /** + * Check getRandomConfirmationKey use cryptographically secure function + * + * @return void + */ + public function testGetRandomConfirmationKey() : void + { + $this->mathRandom + ->expects($this->once()) + ->method('getRandomString') + ->with(32) + ->willReturn('random_string'); + + $this->_model->getRandomConfirmationKey(); + } } diff --git a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php index 318023d8068c..ff83ef62c6aa 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php @@ -521,7 +521,7 @@ public function testPasswordResetConfirmation() /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */ $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->any()) + $customer->expects($this->once()) ->method('getStoreId') ->willReturn($customerStoreId); $customer->expects($this->any()) @@ -539,11 +539,6 @@ public function testPasswordResetConfirmation() ->method('getStore') ->willReturn($this->storeMock); - $this->storeManagerMock->expects($this->at(1)) - ->method('getStore') - ->with($customerStoreId) - ->willReturn($this->storeMock); - $this->customerRegistryMock->expects($this->once()) ->method('retrieveSecureData') ->with($customerId) 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 056c7e71e182..4a16acd98d82 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 @@ -7,6 +7,9 @@ use Magento\Customer\Ui\Component\Listing\Column\Actions; +/** + * Class ActionsTest + */ class ActionsTest extends \PHPUnit\Framework\TestCase { /** @var Actions */ @@ -64,7 +67,8 @@ public function testPrepareDataSource() 'edit' => [ 'href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), - 'hidden' => false + 'hidden' => false, + '__disableTmpl' => true, ] ] ], diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php index d6a4067ef3db..9441beeb7dc6 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php @@ -60,6 +60,7 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, + '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php index 6870bd1136d1..12f6f2705125 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php @@ -79,6 +79,7 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), + '__disableTmpl' => true ], ]; @@ -102,7 +103,8 @@ public function prepareDataSource(array $dataSource) $this->escaper->escapeJs($title) ) ], - 'post' => true + 'post' => true, + '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 3b7191e7ed32..6086a61157dd 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -28,11 +28,11 @@ <preference for="Magento\Customer\Api\Data\ValidationResultsInterface" type="Magento\Customer\Model\Data\ValidationResults" /> <preference for="Magento\Customer\Api\Data\GroupSearchResultsInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\Customer\Model\GroupSearchResults" /> <preference for="Magento\Customer\Api\Data\CustomerSearchResultsInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\Customer\Model\CustomerSearchResults" /> <preference for="Magento\Customer\Api\Data\AddressSearchResultsInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\Customer\Model\AddressSearchResults" /> <preference for="Magento\Customer\Api\AccountManagementInterface" type="Magento\Customer\Model\AccountManagement" /> <preference for="Magento\Customer\Api\CustomerMetadataInterface" diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index c31742519e58..3b9675178c05 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -77,4 +77,34 @@ </argument> </arguments> </type> -</config> \ No newline at end of file + <type name="Magento\Framework\View\Element\Message\MessageConfigurationsPool"> + <arguments> + <argument name="configurationsMap" xsi:type="array"> + <item name="customerAlreadyExistsErrorMessage" xsi:type="array"> + <item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item> + <item name="data" xsi:type="array"> + <item name="template" xsi:type="string">Magento_Customer::messages/customerAlreadyExistsErrorMessage.phtml</item> + </item> + </item> + <item name="confirmAccountSuccessMessage" xsi:type="array"> + <item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item> + <item name="data" xsi:type="array"> + <item name="template" xsi:type="string">Magento_Customer::messages/confirmAccountSuccessMessage.phtml</item> + </item> + </item> + <item name="customerVatShippingAddressSuccessMessage" xsi:type="array"> + <item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item> + <item name="data" xsi:type="array"> + <item name="template" xsi:type="string">Magento_Customer::messages/customerVatShippingAddressSuccessMessage.phtml</item> + </item> + </item> + <item name="customerVatBillingAddressSuccessMessage" xsi:type="array"> + <item name="renderer" xsi:type="const">\Magento\Framework\View\Element\Message\Renderer\BlockRenderer::CODE</item> + <item name="data" xsi:type="array"> + <item name="template" xsi:type="string">Magento_Customer::messages/customerVatBillingAddressSuccessMessage.phtml</item> + </item> + </item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/Customer/i18n/en_US.csv b/app/code/Magento/Customer/i18n/en_US.csv index 3495feb925cb..a70aa08dba73 100644 --- a/app/code/Magento/Customer/i18n/en_US.csv +++ b/app/code/Magento/Customer/i18n/en_US.csv @@ -539,3 +539,4 @@ Addresses,Addresses "Prefix","Prefix" "Middle Name/Initial","Middle Name/Initial" "Suffix","Suffix" +"The Date of Birth should not be greater than today.","The Date of Birth should not be greater than today." diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml index 5fb8b17dbb8c..954b44ec19bb 100644 --- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml +++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml @@ -265,10 +265,20 @@ <settings> <validation> <rule name="validate-date" xsi:type="boolean">true</rule> + <rule name="validate-dob" xsi:type="boolean">true</rule> </validation> <dataType>text</dataType> <visible>true</visible> </settings> + <formElements> + <date> + <settings> + <options> + <option name="maxDate" xsi:type="string">-1d</option> + </options> + </settings> + </date> + </formElements> </field> <field name="taxvat" formElement="input"> <argument name="data" xsi:type="array"> diff --git a/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountSuccessMessage.phtml b/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountSuccessMessage.phtml new file mode 100644 index 000000000000..a2edb20e967c --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/messages/confirmAccountSuccessMessage.phtml @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** @var \Magento\Framework\View\Element\Template $block */ +?> +<?= $block->escapeHtml(__('You must confirm your account. Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.', $block->getData('url')), ['a']); diff --git a/app/code/Magento/Customer/view/frontend/templates/messages/customerAlreadyExistsErrorMessage.phtml b/app/code/Magento/Customer/view/frontend/templates/messages/customerAlreadyExistsErrorMessage.phtml new file mode 100644 index 000000000000..32982551b5b1 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/messages/customerAlreadyExistsErrorMessage.phtml @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** @var \Magento\Framework\View\Element\Template $block */ +?> +<?= $block->escapeHtml(__('There is already an account with this email address. If you are sure that it is your email address, <a href="%1">click here</a> to get your password and access your account.', $block->getData('url')), ['a']); diff --git a/app/code/Magento/Customer/view/frontend/templates/messages/customerVatBillingAddressSuccessMessage.phtml b/app/code/Magento/Customer/view/frontend/templates/messages/customerVatBillingAddressSuccessMessage.phtml new file mode 100644 index 000000000000..294412cbc706 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/messages/customerVatBillingAddressSuccessMessage.phtml @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** @var \Magento\Framework\View\Element\Template $block */ +?> +<?= $block->escapeHtml(__('If you are a registered VAT customer, please <a href="%1">click here</a> to enter your billing address for proper VAT calculation.', $block->getData('url')), ['a']); diff --git a/app/code/Magento/Customer/view/frontend/templates/messages/customerVatShippingAddressSuccessMessage.phtml b/app/code/Magento/Customer/view/frontend/templates/messages/customerVatShippingAddressSuccessMessage.phtml new file mode 100644 index 000000000000..72dbf3f5e03d --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/templates/messages/customerVatShippingAddressSuccessMessage.phtml @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** @var \Magento\Framework\View\Element\Template $block */ +?> +<?= $block->escapeHtml(__('If you are a registered VAT customer, please <a href="%1">click here</a> to enter your shipping address for proper VAT calculation.', $block->getData('url')), ['a']); diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/dob.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/dob.phtml index ac4b9f93e0c5..3c2f970faade 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/dob.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/dob.phtml @@ -35,3 +35,11 @@ $fieldCssClass .= $block->isRequired() ? ' required' : ''; <?php endif; ?> </div> </div> + +<script type="text/x-magento-init"> + { + "*": { + "Magento_Customer/js/validation": {} + } + } + </script> diff --git a/app/code/Magento/Customer/view/frontend/web/js/validation.js b/app/code/Magento/Customer/view/frontend/web/js/validation.js new file mode 100644 index 000000000000..67a714212026 --- /dev/null +++ b/app/code/Magento/Customer/view/frontend/web/js/validation.js @@ -0,0 +1,20 @@ +define([ + 'jquery', + 'moment', + 'jquery/validate', + 'mage/translate' +], function ($, moment) { + 'use strict'; + + $.validator.addMethod( + 'validate-dob', + function (value) { + if (value === '') { + return true; + } + + return moment(value).isBefore(moment()); + }, + $.mage.__('The Date of Birth should not be greater than today.') + ); +}); diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php index 388b6dc2ea94..9637b3e555b8 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php @@ -67,6 +67,10 @@ public function __construct( */ public function execute(int $customerId, array $data): AddressInterface { + // It is needed because AddressInterface has country_id field. + if (isset($data['country_code'])) { + $data['country_id'] = $data['country_code']; + } $this->validateData($data); /** @var AddressInterface $address */ diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php index 8741bff7aa88..7992ca834292 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php @@ -127,6 +127,10 @@ public function execute(AddressInterface $address): array $addressData['customer_id'] = null; + if (isset($addressData['country_id'])) { + $addressData['country_code'] = $addressData['country_id']; + } + return $addressData; } } diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php index 65745a20bc8e..26e53c7c3a0a 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php @@ -66,6 +66,9 @@ public function __construct( */ public function execute(AddressInterface $address, array $data): void { + if (isset($data['country_code'])) { + $data['country_id'] = $data['country_code']; + } $this->validateData($data); $filteredData = array_diff_key($data, array_flip($this->restrictedKeys)); diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php b/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php index 3cc831e1ca40..c252628b6566 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php @@ -9,12 +9,8 @@ use Magento\Customer\Model\AuthenticationInterface; use Magento\Framework\Exception\InvalidEmailOrPasswordException; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\State\UserLockedException; use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException; -use Magento\Framework\GraphQl\Exception\GraphQlInputException; -use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; /** * Check customer password @@ -41,8 +37,6 @@ public function __construct( * @param string $password * @param int $customerId * @throws GraphQlAuthenticationException - * @throws GraphQlInputException - * @throws GraphQlNoSuchEntityException */ public function execute(string $password, int $customerId) { @@ -52,10 +46,6 @@ public function execute(string $password, int $customerId) throw new GraphQlAuthenticationException(__($e->getMessage()), $e); } catch (UserLockedException $e) { throw new GraphQlAuthenticationException(__($e->getMessage()), $e); - } catch (NoSuchEntityException $e) { - throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); - } catch (LocalizedException $e) { - throw new GraphQlInputException(__($e->getMessage()), $e); } } } diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/ExtractCustomerData.php b/app/code/Magento/CustomerGraphQl/Model/Customer/ExtractCustomerData.php index 542165b49dc1..c62a93180964 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/ExtractCustomerData.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/ExtractCustomerData.php @@ -101,11 +101,16 @@ public function execute(CustomerInterface $customer): array } } $customerData = array_merge($customerData, $customAttributes); - //Field is deprecated and should not be exposed on storefront. + //Fields are deprecated and should not be exposed on storefront. $customerData['group_id'] = null; - $customerData['model'] = $customer; $customerData['id'] = null; + $customerData['model'] = $customer; + + //'dob' is deprecated, 'date_of_birth' is used instead. + if (!empty($customerData['dob'])) { + $customerData['date_of_birth'] = $customerData['dob']; + } return $customerData; } } diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/GetCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Customer/GetCustomer.php index 63f42ea1825a..812b3fd28352 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/GetCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/GetCustomer.php @@ -70,6 +70,7 @@ public function execute(ContextInterface $context): CustomerInterface try { $customer = $this->customerRepository->getById($currentUserId); + // @codeCoverageIgnoreStart } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException( __('Customer with id "%customer_id" does not exist.', ['customer_id' => $currentUserId]), @@ -77,6 +78,7 @@ public function execute(ContextInterface $context): CustomerInterface ); } catch (LocalizedException $e) { throw new GraphQlInputException(__($e->getMessage())); + // @codeCoverageIgnoreEnd } if (true === $this->authentication->isLocked($currentUserId)) { @@ -85,8 +87,10 @@ public function execute(ContextInterface $context): CustomerInterface try { $confirmationStatus = $this->accountManagement->getConfirmationStatus($currentUserId); + // @codeCoverageIgnoreStart } catch (LocalizedException $e) { throw new GraphQlInputException(__($e->getMessage())); + // @codeCoverageIgnoreEnd } if ($confirmationStatus === AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED) { diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index 6d33dea35835..c690e11bd494 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -70,7 +70,9 @@ public function resolve( if (!$this->newsLetterConfig->isActive(ScopeInterface::SCOPE_STORE)) { $args['input']['is_subscribed'] = false; } - + if (isset($args['input']['date_of_birth'])) { + $args['input']['dob'] = $args['input']['date_of_birth']; + } $customer = $this->createCustomerAccount->execute( $args['input'], $context->getExtensionAttributes()->getStore() diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php index b2ef03fc40e5..f2b0d0e2a049 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/UpdateCustomer.php @@ -70,6 +70,9 @@ public function resolve( if (empty($args['input']) || !is_array($args['input'])) { throw new GraphQlInputException(__('"input" value should be specified')); } + if (isset($args['input']['date_of_birth'])) { + $args['input']['dob'] = $args['input']['date_of_birth']; + } $customer = $this->getCustomer->execute($context); $this->updateCustomerAccount->execute( diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls index b5cd2f595a4c..86ab39bbee25 100644 --- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls @@ -28,7 +28,8 @@ input CustomerAddressInput { city: String @doc(description: "The city or town") region: CustomerAddressRegionInput @doc(description: "An object containing the region name, region code, and region ID") postcode: String @doc(description: "The customer's ZIP or postal code") - country_id: CountryCodeEnum @doc(description: "The customer's country") + country_id: CountryCodeEnum @doc(description: "Deprecated: use `country_code` instead.") + country_code: CountryCodeEnum @doc(description: "The customer's country") default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address") default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address") fax: String @doc(description: "The fax number") @@ -60,10 +61,11 @@ input CustomerInput { middlename: String @doc(description: "The customer's middle name") lastname: String @doc(description: "The customer's family name") suffix: String @doc(description: "A value such as Sr., Jr., or III") - email: String @doc(description: "The customer's email address. Required") - dob: String @doc(description: "The customer's date of birth") + email: String! @doc(description: "The customer's email address. Required") + dob: String @doc(description: "Deprecated: Use `date_of_birth` instead") + date_of_birth: String @doc(description: "The customer's date of birth") taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)") - gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)") + gender: Int @doc(description: "The customer's gender (Male - 1, Female - 2)") password: String @doc(description: "The customer's password") is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") } @@ -87,12 +89,13 @@ type Customer @doc(description: "Customer defines the customer name and address email: String @doc(description: "The customer's email address. Required") default_billing: String @doc(description: "The ID assigned to the billing address") default_shipping: String @doc(description: "The ID assigned to the shipping address") - dob: String @doc(description: "The customer's date of birth") - taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)") + dob: String @doc(description: "The customer's date of birth") @deprecated(reason: "Use `date_of_birth` instead") + date_of_birth: String @doc(description: "The customer's date of birth") + taxvat: String @doc(description: "The customer's Value-added tax (VAT) number (for corporate customers)") id: Int @doc(description: "The ID assigned to the customer") @deprecated(reason: "id is not needed as part of Customer because on server side it can be identified based on customer token used for authentication. There is no need to know customer ID on the client side.") is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\IsSubscribed") addresses: [CustomerAddress] @doc(description: "An array containing the customer's shipping and billing addresses") @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CustomerAddresses") - gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)") + gender: Int @doc(description: "The customer's gender (Male - 1, Female - 2)") } type CustomerAddress @doc(description: "CustomerAddress contains detailed information about a customer's billing and shipping addresses"){ @@ -100,7 +103,8 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform customer_id: Int @doc(description: "The customer ID") @deprecated(reason: "customer_id is not needed as part of CustomerAddress, address ID (id) is unique identifier for the addresses.") region: CustomerAddressRegion @doc(description: "An object containing the region name, region code, and region ID") region_id: Int @deprecated(reason: "Region ID is excessive on storefront and region code should suffice for all scenarios") - country_id: String @doc(description: "The customer's country") + country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use `country_code` instead.") + country_code: CountryCodeEnum @doc(description: "The customer's country") street: [String] @doc(description: "An array of strings that define the street number and name") company: String @doc(description: "The customer's company") telephone: String @doc(description: "The telephone number") @@ -112,7 +116,7 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform middlename: String @doc(description: "The middle name of the person associated with the shipping/billing address") prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.") suffix: String @doc(description: "A value such as Sr., Jr., or III") - vat_id: String @doc(description: "The customer's Tax/VAT number (for corporate customers)") + vat_id: String @doc(description: "The customer's Value-added tax (VAT) number (for corporate customers)") default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address") default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address") custom_attributes: [CustomerAddressAttribute] @deprecated(reason: "Custom attributes should not be put into container") diff --git a/app/code/Magento/Deploy/Collector/Collector.php b/app/code/Magento/Deploy/Collector/Collector.php index 7742f2971a2f..b09001a7ac04 100644 --- a/app/code/Magento/Deploy/Collector/Collector.php +++ b/app/code/Magento/Deploy/Collector/Collector.php @@ -9,7 +9,7 @@ use Magento\Deploy\Package\Package; use Magento\Deploy\Package\PackageFactory; use Magento\Deploy\Package\PackageFile; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\View\Asset\PreProcessor\FileNameResolver; /** @@ -45,8 +45,8 @@ class Collector implements CollectorInterface * @var PackageFactory */ private $packageFactory; - - /** @var \Magento\Framework\Module\ModuleManagerInterface */ + + /** @var \Magento\Framework\Module\Manager */ private $moduleManager; /** @@ -66,19 +66,19 @@ class Collector implements CollectorInterface * @param SourcePool $sourcePool * @param FileNameResolver $fileNameResolver * @param PackageFactory $packageFactory - * @param ModuleManagerInterface|null $moduleManager + * @param Manager|null $moduleManager */ public function __construct( SourcePool $sourcePool, FileNameResolver $fileNameResolver, PackageFactory $packageFactory, - ModuleManagerInterface $moduleManager = null + Manager $moduleManager = null ) { $this->sourcePool = $sourcePool; $this->fileNameResolver = $fileNameResolver; $this->packageFactory = $packageFactory; $this->moduleManager = $moduleManager ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Module\ModuleManagerInterface::class); + ->get(\Magento\Framework\Module\Manager::class); } /** diff --git a/app/code/Magento/Deploy/Console/DeployStaticOptions.php b/app/code/Magento/Deploy/Console/DeployStaticOptions.php index 1c02d24f7e99..06887fc0206f 100644 --- a/app/code/Magento/Deploy/Console/DeployStaticOptions.php +++ b/app/code/Magento/Deploy/Console/DeployStaticOptions.php @@ -78,6 +78,11 @@ class DeployStaticOptions */ const NO_JAVASCRIPT = 'no-javascript'; + /** + * Key for js-bundle option + */ + const NO_JS_BUNDLE = 'no-js-bundle'; + /** * Key for css option */ @@ -122,9 +127,6 @@ class DeployStaticOptions */ const NO_LESS = 'no-less'; - /** - * Default jobs amount - */ const DEFAULT_JOBS_AMOUNT = 0; /** @@ -275,6 +277,12 @@ private function getSkipOptions() InputOption::VALUE_NONE, 'Do not deploy JavaScript files.' ), + new InputOption( + self::NO_JS_BUNDLE, + null, + InputOption::VALUE_NONE, + 'Do not deploy JavaScript bundle files.' + ), new InputOption( self::NO_CSS, null, diff --git a/app/code/Magento/Deploy/Package/Package.php b/app/code/Magento/Deploy/Package/Package.php index 2e924d41a1b8..423f3072c462 100644 --- a/app/code/Magento/Deploy/Package/Package.php +++ b/app/code/Magento/Deploy/Package/Package.php @@ -459,17 +459,17 @@ public function getParentMap() */ public function getParentFiles($type = null) { - $files = []; + $files = [[]]; foreach ($this->getParentPackages() as $parentPackage) { if ($type === null) { // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge - $files = array_merge($files, $parentPackage->getFiles()); + $files[] = $parentPackage->getFiles(); } else { // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge - $files = array_merge($files, $parentPackage->getFilesByType($type)); + $files[] = $parentPackage->getFilesByType($type); } } - return $files; + return array_merge(...$files); } /** diff --git a/app/code/Magento/Deploy/Process/Queue.php b/app/code/Magento/Deploy/Process/Queue.php index 2f2a14923999..6c8db345187c 100644 --- a/app/code/Magento/Deploy/Process/Queue.php +++ b/app/code/Magento/Deploy/Process/Queue.php @@ -161,6 +161,7 @@ public function getPackages() public function process() { $returnStatus = 0; + $logDelay = 10; $this->start = $this->lastJobStarted = time(); $packages = $this->packages; while (count($packages) && $this->checkTimeout()) { @@ -168,12 +169,24 @@ public function process() // Unsets each member of $packages array (passed by reference) as each is executed $this->assertAndExecute($name, $packages, $packageJob); } - $this->logger->info('.'); - // phpcs:ignore Magento2.Functions.DiscouragedFunction - sleep(3); - foreach ($this->inProgress as $name => $package) { - if ($this->isDeployed($package)) { - unset($this->inProgress[$name]); + + // refresh current status in console once in 10 iterations (once in 5 sec) + if ($logDelay >= 10) { + $this->logger->info('.'); + $logDelay = 0; + } else { + $logDelay++; + } + + if ($this->isCanBeParalleled()) { + // in parallel mode sleep before trying to check status and run new jobs + // phpcs:ignore Magento2.Functions.DiscouragedFunction + usleep(500000); // 0.5 sec (less sleep == less time waste) + + foreach ($this->inProgress as $name => $package) { + if ($this->isDeployed($package)) { + unset($this->inProgress[$name]); + } } } } @@ -243,15 +256,25 @@ private function executePackage(Package $package, string $name, array &$packages */ private function awaitForAllProcesses() { + $logDelay = 10; while ($this->inProgress && $this->checkTimeout()) { foreach ($this->inProgress as $name => $package) { if ($this->isDeployed($package)) { unset($this->inProgress[$name]); } } - $this->logger->info('.'); + + // refresh current status in console once in 10 iterations (once in 5 sec) + if ($logDelay >= 10) { + $this->logger->info('.'); + $logDelay = 0; + } else { + $logDelay++; + } + + // sleep before checking parallel jobs status // phpcs:ignore Magento2.Functions.DiscouragedFunction - sleep(5); + usleep(500000); // 0.5 sec (less sleep == less time waste) } if ($this->isCanBeParalleled()) { // close connections only if ran with forks diff --git a/app/code/Magento/Deploy/Service/DeployPackage.php b/app/code/Magento/Deploy/Service/DeployPackage.php index 34a6b147a055..90d4cdb11696 100644 --- a/app/code/Magento/Deploy/Service/DeployPackage.php +++ b/app/code/Magento/Deploy/Service/DeployPackage.php @@ -249,23 +249,6 @@ private function checkFileSkip($filePath, array $options) */ private function register(Package $package, PackageFile $file = null, $skipLogging = false) { - $logMessage = '.'; - if ($file) { - $logMessage = "Processing file '{$file->getSourcePath()}'"; - if ($file->getArea()) { - $logMessage .= " for area '{$file->getArea()}'"; - } - if ($file->getTheme()) { - $logMessage .= ", theme '{$file->getTheme()}'"; - } - if ($file->getLocale()) { - $logMessage .= ", locale '{$file->getLocale()}'"; - } - if ($file->getModule()) { - $logMessage .= "module '{$file->getModule()}'"; - } - } - $info = [ 'count' => $this->count, 'last' => $file ? $file->getSourcePath() : '' @@ -273,6 +256,23 @@ private function register(Package $package, PackageFile $file = null, $skipLoggi $this->deployStaticFile->writeTmpFile('info.json', $package->getPath(), json_encode($info)); if (!$skipLogging) { + $logMessage = '.'; + if ($file) { + $logMessage = "Processing file '{$file->getSourcePath()}'"; + if ($file->getArea()) { + $logMessage .= " for area '{$file->getArea()}'"; + } + if ($file->getTheme()) { + $logMessage .= ", theme '{$file->getTheme()}'"; + } + if ($file->getLocale()) { + $logMessage .= ", locale '{$file->getLocale()}'"; + } + if ($file->getModule()) { + $logMessage .= "module '{$file->getModule()}'"; + } + } + $this->logger->info($logMessage); } } diff --git a/app/code/Magento/Deploy/Service/DeployStaticContent.php b/app/code/Magento/Deploy/Service/DeployStaticContent.php index 890399715991..b6333d6fec71 100644 --- a/app/code/Magento/Deploy/Service/DeployStaticContent.php +++ b/app/code/Magento/Deploy/Service/DeployStaticContent.php @@ -5,9 +5,9 @@ */ namespace Magento\Deploy\Service; -use Magento\Deploy\Strategy\DeployStrategyFactory; -use Magento\Deploy\Process\QueueFactory; use Magento\Deploy\Console\DeployStaticOptions as Options; +use Magento\Deploy\Process\QueueFactory; +use Magento\Deploy\Strategy\DeployStrategyFactory; use Magento\Framework\App\View\Deployment\Version\StorageInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\ObjectManagerInterface; @@ -75,6 +75,9 @@ public function __construct( * @param array $options * @throws LocalizedException * @return void + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) */ public function deploy(array $options) { @@ -106,27 +109,35 @@ public function deploy(array $options) $deployStrategy = $this->deployStrategyFactory->create( $options[Options::STRATEGY], - [ - 'queue' => $this->queueFactory->create($queueOptions) - ] + ['queue' => $this->queueFactory->create($queueOptions)] ); $packages = $deployStrategy->deploy($options); if ($options[Options::NO_JAVASCRIPT] !== true) { - $deployRjsConfig = $this->objectManager->create(DeployRequireJsConfig::class, [ - 'logger' => $this->logger - ]); - $deployI18n = $this->objectManager->create(DeployTranslationsDictionary::class, [ - 'logger' => $this->logger - ]); - $deployBundle = $this->objectManager->create(Bundle::class, [ - 'logger' => $this->logger - ]); + $deployRjsConfig = $this->objectManager->create( + DeployRequireJsConfig::class, + ['logger' => $this->logger] + ); + $deployI18n = $this->objectManager->create( + DeployTranslationsDictionary::class, + ['logger' => $this->logger] + ); foreach ($packages as $package) { if (!$package->isVirtual()) { $deployRjsConfig->deploy($package->getArea(), $package->getTheme(), $package->getLocale()); $deployI18n->deploy($package->getArea(), $package->getTheme(), $package->getLocale()); + } + } + } + + if ($options[Options::NO_JAVASCRIPT] !== true && $options[Options::NO_JS_BUNDLE] !== true) { + $deployBundle = $this->objectManager->create( + Bundle::class, + ['logger' => $this->logger] + ); + foreach ($packages as $package) { + if (!$package->isVirtual()) { $deployBundle->deploy($package->getArea(), $package->getTheme(), $package->getLocale()); } } diff --git a/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php b/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php index dc32de527c8c..540826c67b79 100644 --- a/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php @@ -112,6 +112,7 @@ public function testProcess() $package->expects($this->any())->method('getArea')->willReturn('area'); $package->expects($this->any())->method('getPath')->willReturn('path'); $package->expects($this->any())->method('getFiles')->willReturn([]); + $this->logger->expects($this->exactly(2))->method('info')->willReturnSelf(); $this->appState->expects($this->once())->method('emulateAreaCode'); diff --git a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php index 396381960e54..fcc02476bb85 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php @@ -103,7 +103,7 @@ public function testDeploy($options, $expectedContentVersion) $package->expects($this->never())->method('getTheme'); $package->expects($this->never())->method('getLocale'); } else { - $package->expects($this->exactly(1))->method('isVirtual')->willReturn(false); + $package->expects($this->exactly(2))->method('isVirtual')->willReturn(false); $package->expects($this->exactly(3))->method('getArea')->willReturn('area'); $package->expects($this->exactly(3))->method('getTheme')->willReturn('theme'); $package->expects($this->exactly(3))->method('getLocale')->willReturn('locale'); @@ -198,6 +198,7 @@ public function deployDataProvider() [ 'strategy' => 'compact', 'no-javascript' => false, + 'no-js-bundle' => false, 'no-html-minify' => false, 'refresh-content-version-only' => false, ], @@ -207,6 +208,7 @@ public function deployDataProvider() [ 'strategy' => 'compact', 'no-javascript' => false, + 'no-js-bundle' => false, 'no-html-minify' => false, 'refresh-content-version-only' => false, 'content-version' => '123456', @@ -226,25 +228,28 @@ public function deployDataProvider() public function testMaxExecutionTimeOptionPassed() { $options = [ - DeployStaticOptions::MAX_EXECUTION_TIME => 100, + DeployStaticOptions::MAX_EXECUTION_TIME => 100, DeployStaticOptions::REFRESH_CONTENT_VERSION_ONLY => false, - DeployStaticOptions::JOBS_AMOUNT => 3, - DeployStaticOptions::STRATEGY => 'compact', - DeployStaticOptions::NO_JAVASCRIPT => true, - DeployStaticOptions::NO_HTML_MINIFY => true, + DeployStaticOptions::JOBS_AMOUNT => 3, + DeployStaticOptions::STRATEGY => 'compact', + DeployStaticOptions::NO_JAVASCRIPT => true, + DeployStaticOptions::NO_JS_BUNDLE => true, + DeployStaticOptions::NO_HTML_MINIFY => true, ]; $queueMock = $this->createMock(Queue::class); $strategyMock = $this->createMock(CompactDeploy::class); $this->queueFactory->expects($this->once()) ->method('create') - ->with([ - 'logger' => $this->logger, - 'maxExecTime' => 100, - 'maxProcesses' => 3, - 'options' => $options, - 'deployPackageService' => null - ]) + ->with( + [ + 'logger' => $this->logger, + 'maxExecTime' => 100, + 'maxProcesses' => 3, + 'options' => $options, + 'deployPackageService' => null + ] + ) ->willReturn($queueMock); $this->deployStrategyFactory->expects($this->once()) ->method('create') diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 5959294fe6dc..0890466e8a40 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -10,7 +10,6 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Async\CallbackDeferred; -use Magento\Framework\Async\ProxyDeferredFactory; use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; @@ -21,6 +20,7 @@ use Magento\Quote\Model\Quote\Address\RateResult\Error; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Rate\Result; +use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; use Magento\Framework\Xml\Security; use Magento\Dhl\Model\Validator\XmlValidator; @@ -389,16 +389,17 @@ public function collectRates(RateRequest $request) //Saving $result to use proper result with the callback $this->_result = $result = $this->_getQuotes(); //After quotes are loaded parsing the response. - return $this->proxyDeferredFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($request, $result) { - $this->_result = $result; - $this->_updateFreeMethodQuote($request); - - return $this->_result; - } - ) + return $this->proxyDeferredFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($request, $result) { + $this->_result = $result; + $this->_updateFreeMethodQuote($request); + + return $this->_result; + } + ) + ] ); } @@ -818,16 +819,16 @@ protected function _getAllItems() if (!empty($decimalItems)) { foreach ($decimalItems as $decimalItem) { - $fullItems = array_merge( - $fullItems, - array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']) - ); + $fullItems[] = array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']); } } else { - $fullItems = array_merge($fullItems, array_fill(0, $qty, $this->_getWeight($itemWeight))); + $fullItems[] = array_fill(0, $qty, $this->_getWeight($itemWeight)); } } - sort($fullItems); + if ($fullItems) { + $fullItems = array_merge(...$fullItems); + sort($fullItems); + } return $fullItems; } @@ -1057,23 +1058,24 @@ protected function _getQuotes() } } - return $this->proxyDeferredFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($deferredResponses, $responseBodies) { - //Loading rates not found in cache - foreach ($deferredResponses as $deferredResponseData) { - $responseBodies[] = [ - 'body' => $deferredResponseData['deferred']->get()->getBody(), - 'date' => $deferredResponseData['date'], - 'request' => $deferredResponseData['request'], - 'from_cache' => false - ]; - } + return $this->proxyDeferredFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($deferredResponses, $responseBodies) { + //Loading rates not found in cache + foreach ($deferredResponses as $deferredResponseData) { + $responseBodies[] = [ + 'body' => $deferredResponseData['deferred']->get()->getBody(), + 'date' => $deferredResponseData['date'], + 'request' => $deferredResponseData['request'], + 'from_cache' => false + ]; + } - return $this->processQuotesResponses($responseBodies); - } - ) + return $this->processQuotesResponses($responseBodies); + } + ) + ] ); } diff --git a/app/code/Magento/Dhl/Test/Mftf/Section/AdminShippingMethodDHLSection.xml b/app/code/Magento/Dhl/Test/Mftf/Section/AdminShippingMethodDHLSection.xml new file mode 100644 index 000000000000..1256bb5443e0 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Mftf/Section/AdminShippingMethodDHLSection.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShippingMethodDHLSection"> + <element name="carriersDHLTab" type="button" selector="#carriers_dhl-head"/> + <element name="carriersDHLActive" type="input" selector="#carriers_dhl_active_inherit"/> + <element name="carriersDHLTitle" type="input" selector="#carriers_dhl_title_inherit"/> + <element name="carriersDHLAccessId" type="input" selector="#carriers_dhl_id"/> + <element name="carriersDHLPassword" type="input" selector="#carriers_dhl_password"/> + <element name="carriersDHLAccount" type="input" selector="#carriers_dhl_account_inherit"/> + <element name="carriersDHLContentType" type="input" selector="#carriers_dhl_content_type_inherit"/> + <element name="carriersDHLHandlingType" type="input" selector="#carriers_dhl_handling_type_inherit"/> + <element name="carriersDHLHandlingAction" type="input" selector="#carriers_dhl_handling_action_inherit"/> + <element name="carriersDHLDivideOrderWeight" type="input" selector="#carriers_dhl_divide_order_weight_inherit"/> + <element name="carriersDHLUnitOfMeasure" type="input" selector="#carriers_dhl_unit_of_measure_inherit"/> + <element name="carriersDHLSize" type="input" selector="#carriers_dhl_size_inherit"/> + <element name="carriersDHLNonDocAllowedMethod" type="input" selector="#carriers_dhl_nondoc_methods_inherit"/> + <element name="carriersDHLSmartPostHubId" type="input" selector="#carriers_dhl_doc_methods_inherit"/> + <element name="carriersDHLSpecificErrMsg" type="input" selector="#carriers_dhl_specificerrmsg_inherit"/> + <element name="carriersDHLAllowSpecific" type="input" selector="#carriers_dhl_sallowspecific_inherit"/> + <element name="carriersDHLSpecificCountry" type="input" selector="#carriers_dhl_specificcountry"/> + </section> +</sections> diff --git a/app/code/Magento/Dhl/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml b/app/code/Magento/Dhl/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml new file mode 100644 index 000000000000..f5e1e8ef0c8e --- /dev/null +++ b/app/code/Magento/Dhl/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"> + <!--Assert configuration are disabled in DHL section--> + <comment userInput="Assert configuration are disabled in DHL section" stepKey="commentSeeDisabledDHLConfigs"/> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <conditionalClick selector="{{AdminShippingMethodDHLSection.carriersDHLTab}}" dependentSelector="{{AdminShippingMethodDHLSection.carriersDHLActive}}" visible="false" stepKey="expandDHLTab"/> + <waitForElementVisible selector="{{AdminShippingMethodDHLSection.carriersDHLActive}}" stepKey="waitDHLTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLActive}}" userInput="disabled" stepKey="grabDHLActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLActiveDisabled" stepKey="assertDHLActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLTitle}}" userInput="disabled" stepKey="grabDHLTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLTitleDisabled" stepKey="assertDHLTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLAccessId}}" userInput="disabled" stepKey="grabDHLAccessIdDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLAccessIdDisabled" stepKey="assertDHLAccessIdDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLPassword}}" userInput="disabled" stepKey="grabDHLPasswordDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLPasswordDisabled" stepKey="assertDHLPasswordDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLAccount}}" userInput="disabled" stepKey="grabDHLAccountDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLAccountDisabled" stepKey="assertDHLAccountDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLContentType}}" userInput="disabled" stepKey="grabDHLContentTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLContentTypeDisabled" stepKey="assertDHLContentTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLHandlingType}}" userInput="disabled" stepKey="grabDHLHandlingTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLHandlingTypeDisabled" stepKey="assertDHLHandlingTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLHandlingAction}}" userInput="disabled" stepKey="grabDHLHandlingDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLHandlingDisabled" stepKey="assertDHLHandlingDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLDivideOrderWeight}}" userInput="disabled" stepKey="grabDHLDivideOrderWeightDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLDivideOrderWeightDisabled" stepKey="assertDHLDivideOrderWeightDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLUnitOfMeasure}}" userInput="disabled" stepKey="grabDHLUnitOfMeasureDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLUnitOfMeasureDisabled" stepKey="assertDHLUnitOfMeasureDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLSize}}" userInput="disabled" stepKey="grabDHLSizeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLSizeDisabled" stepKey="assertDHLSizeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLNonDocAllowedMethod}}" userInput="disabled" stepKey="grabDHLNonDocAllowedMethodDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLNonDocAllowedMethodDisabled" stepKey="assertDHLNonDocAllowedMethodDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLSmartPostHubId}}" userInput="disabled" stepKey="grabDHLSmartPostHubIdDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLSmartPostHubIdDisabled" stepKey="assertDHLSmartPostHubIdDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodDHLSection.carriersDHLSpecificErrMsg}}" userInput="disabled" stepKey="grabDHLSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabDHLSpecificErrMsgDisabled" stepKey="assertDHLSpecificErrMsgDisabled"/> + </test> +</tests> diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddCountriesCaribbeanCuracaoKosovoSintMaarten.php b/app/code/Magento/Directory/Setup/Patch/Data/AddCountriesCaribbeanCuracaoKosovoSintMaarten.php new file mode 100644 index 000000000000..d7bec84e5440 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddCountriesCaribbeanCuracaoKosovoSintMaarten.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Directory\Setup\Patch\Data; + +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\Setup\Patch\DataPatchInterface; + +/** + * Class AddCountriesCaribbeanCuracaoKosovoSintMaarten + * + * @package Magento\Directory\Setup\Patch + */ +class AddCountriesCaribbeanCuracaoKosovoSintMaarten implements DataPatchInterface +{ + /** + * @var ModuleDataSetupInterface + */ + private $moduleDataSetup; + + /** + * AddCountriesCaribbeanCuracaoKosovoSintMaarten constructor. + * @param ModuleDataSetupInterface $moduleDataSetup + */ + public function __construct( + ModuleDataSetupInterface $moduleDataSetup + ) { + $this->moduleDataSetup = $moduleDataSetup; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** + * Fill table directory/country + */ + $data = [ + [ + 'country_id' => 'BQ', + 'iso2_code' => 'BQ', + 'iso3_code' => 'BES', + ], + [ + 'country_id' => 'CW', + 'iso2_code' => 'CW', + 'iso3_code' => 'CUW', + ], + [ + 'country_id' => 'SX', + 'iso2_code' => 'SX', + 'iso3_code' => 'SXM', + ], + [ + 'country_id' => 'XK', + 'iso2_code' => 'XK', + 'iso3_code' => 'XKX', + ], + ]; + + $this->moduleDataSetup->getConnection()->insertOnDuplicate( + $this->moduleDataSetup->getTable('directory_country'), + $data + ); + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelgium.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelgium.php new file mode 100644 index 000000000000..fa5fff3486a9 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelgium.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Directory\Setup\Patch\Data; + +use Magento\Directory\Setup\DataInstaller; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\Setup\Patch\DataPatchInterface; + +/** + * Add Regions for Belgium. + */ +class AddDataForBelgium implements DataPatchInterface +{ + /** + * @var ModuleDataSetupInterface + */ + private $moduleDataSetup; + + /** + * @var \Magento\Directory\Setup\DataInstallerFactory + */ + private $dataInstallerFactory; + + /** + * @param ModuleDataSetupInterface $moduleDataSetup + * @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + */ + public function __construct( + ModuleDataSetupInterface $moduleDataSetup, + \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + ) { + $this->moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForBelgium() + ); + } + + /** + * Belgium states data. + * + * @return array + */ + private function getDataForBelgium() + { + return [ + ['BE', 'VAN', 'Antwerpen'], + ['BE', 'WBR', 'Brabant wallon'], + ['BE', 'BRU', 'Brussels-Capital Region'], + ['BE', 'WHT', 'Hainaut'], + ['BE', 'VLI', 'Limburg'], + ['BE', 'WLG', 'Liège'], + ['BE', 'WLX', 'Luxembourg'], + ['BE', 'WNA', 'Namur'], + ['BE', 'VOV', 'Oost-Vlaanderen'], + ['BE', 'VBR', 'Vlaams-Brabant'], + ['BE', 'VWV', 'West-Vlaanderen'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForChina.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForChina.php new file mode 100644 index 000000000000..0750f8056c4d --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForChina.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Directory\Setup\Patch\Data; + +use Magento\Directory\Setup\DataInstaller; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Framework\Setup\Patch\DataPatchInterface; + +/** + * Add China States + */ +class AddDataForChina implements DataPatchInterface +{ + /** + * @var ModuleDataSetupInterface + */ + private $moduleDataSetup; + + /** + * @var \Magento\Directory\Setup\DataInstallerFactory + */ + private $dataInstallerFactory; + + /** + * @param ModuleDataSetupInterface $moduleDataSetup + * @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + */ + public function __construct( + ModuleDataSetupInterface $moduleDataSetup, + \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory + ) { + $this->moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForChina() + ); + } + + /** + * China states data. + * + * @return array + */ + private function getDataForChina() + { + return [ + ['CN', 'CN-AH', 'Anhui Sheng'], + ['CN', 'CN-BJ', 'Beijing Shi'], + ['CN', 'CN-CQ', 'Chongqing Shi'], + ['CN', 'CN-FJ', 'Fujian Sheng'], + ['CN', 'CN-GS', 'Gansu Sheng'], + ['CN', 'CN-GD', 'Guangdong Sheng'], + ['CN', 'CN-GX', 'Guangxi Zhuangzu Zizhiqu'], + ['CN', 'CN-GZ', 'Guizhou Sheng'], + ['CN', 'CN-HI', 'Hainan Sheng'], + ['CN', 'CN-HE', 'Hebei Sheng'], + ['CN', 'CN-HL', 'Heilongjiang Sheng'], + ['CN', 'CN-HA', 'Henan Sheng'], + ['CN', 'CN-HK', 'Hong Kong SAR'], + ['CN', 'CN-HB', 'Hubei Sheng'], + ['CN', 'CN-HN', 'Hunan Sheng'], + ['CN', 'CN-JS', 'Jiangsu Sheng'], + ['CN', 'CN-JX', 'Jiangxi Sheng'], + ['CN', 'CN-JL', 'Jilin Sheng'], + ['CN', 'CN-LN', 'Liaoning Sheng'], + ['CN', 'CN-MO', 'Macao SAR'], + ['CN', 'CN-NM', 'Nei Mongol Zizhiqu'], + ['CN', 'CN-NX', 'Ningxia Huizi Zizhiqu'], + ['CN', 'CN-QH', 'Qinghai Sheng'], + ['CN', 'CN-SN', 'Shaanxi Sheng'], + ['CN', 'CN-SD', 'Shandong Sheng'], + ['CN', 'CN-SH', 'Shanghai Shi'], + ['CN', 'CN-SX', 'Shanxi Sheng'], + ['CN', 'CN-SC', 'Sichuan Sheng'], + ['CN', 'CN-TW', 'Taiwan Sheng'], + ['CN', 'CN-TJ', 'Tianjin Shi'], + ['CN', 'CN-XJ', 'Xinjiang Uygur Zizhiqu'], + ['CN', 'CN-XZ', 'Xizang Zizhiqu'], + ['CN', 'CN-YN', 'Yunnan Sheng'], + ['CN', 'CN-ZJ', 'Zhejiang Sheng'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/etc/adminhtml/system.xml b/app/code/Magento/Directory/etc/adminhtml/system.xml index 7d650b14b3d9..474b8357dfe1 100644 --- a/app/code/Magento/Directory/etc/adminhtml/system.xml +++ b/app/code/Magento/Directory/etc/adminhtml/system.xml @@ -67,27 +67,45 @@ <field id="error_email" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Error Email Recipient</label> <validate>validate-email</validate> + <depends> + <field id="enabled">1</field> + </depends> </field> <field id="error_email_identity" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Error Email Sender</label> <source_model>Magento\Config\Model\Config\Source\Email\Identity</source_model> + <depends> + <field id="enabled">1</field> + </depends> </field> <field id="error_email_template" translate="label comment" type="select" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Error Email Template</label> <comment>Email template chosen based on theme fallback when "Default" option is selected.</comment> <source_model>Magento\Config\Model\Config\Source\Email\Template</source_model> + <depends> + <field id="enabled">1</field> + </depends> </field> <field id="frequency" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Frequency</label> <source_model>Magento\Cron\Model\Config\Source\Frequency</source_model> + <depends> + <field id="enabled">1</field> + </depends> </field> <field id="service" translate="label" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Service</label> <source_model>Magento\Directory\Model\Currency\Import\Source\Service</source_model> <backend_model>Magento\Config\Model\Config\Backend\Currency\Cron</backend_model> + <depends> + <field id="enabled">1</field> + </depends> </field> <field id="time" translate="label" type="time" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Start Time</label> + <depends> + <field id="enabled">1</field> + </depends> </field> </group> </section> diff --git a/app/code/Magento/Directory/etc/config.xml b/app/code/Magento/Directory/etc/config.xml index c18c4f29d582..2ff0b484fe97 100644 --- a/app/code/Magento/Directory/etc/config.xml +++ b/app/code/Magento/Directory/etc/config.xml @@ -36,7 +36,7 @@ <general> <country> <optional_zip_countries>HK,IE,MO,PA,GB</optional_zip_countries> - <allow>AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AX,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BL,BT,BO,BA,BW,BV,BR,IO,VG,BN,BG,BF,BI,KH,CM,CA,CD,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CK,CR,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GG,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,HN,HK,HU,IS,IM,IN,ID,IR,IQ,IE,IL,IT,CI,JE,JM,JP,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,ME,MF,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,FX,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,KP,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PS,PT,PR,QA,RE,RO,RS,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,KR,ES,LK,SD,SR,SJ,SZ,SE,CH,SY,TL,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,VI,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,WF,EH,YE,ZM,ZW</allow> + <allow>AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AX,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BL,BT,BO,BQ,BA,BW,BV,BR,IO,VG,BN,BG,BF,BI,KH,CM,CA,CD,CV,KY,CF,TD,CL,CN,CX,CW,CC,CO,KM,CG,CK,CR,HR,CU,CY,CZ,DK,DJ,DM,DO,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GG,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,HN,HK,HU,IS,IM,IN,ID,IR,IQ,IE,IL,IT,CI,JE,JM,JP,JO,KZ,KE,KI,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,ME,MF,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,FX,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,KP,MP,NO,OM,PK,PW,PA,PG,PY,PE,PH,PN,PL,PS,PT,PR,QA,RE,RO,RS,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,KR,ES,LK,SD,SR,SJ,SZ,SE,CH,SX,SY,TL,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,VI,UG,UA,AE,GB,US,UM,UY,UZ,VU,VA,VE,VN,WF,EH,XK,YE,ZM,ZW</allow> <default>US</default> </country> <locale> diff --git a/app/code/Magento/Downloadable/Api/DomainManagerInterface.php b/app/code/Magento/Downloadable/Api/DomainManagerInterface.php new file mode 100644 index 000000000000..ca98f18e36c3 --- /dev/null +++ b/app/code/Magento/Downloadable/Api/DomainManagerInterface.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Downloadable\Api; + +/** + * Interface DomainManagerInterface + * Manage downloadable domains whitelist. + */ +interface DomainManagerInterface +{ + /** + * Get the whitelist. + * + * @return array + */ + public function getDomains(): array; + + /** + * Add host to the whitelist. + * + * @param array $hosts + * @return void + */ + public function addDomains(array $hosts): void; + + /** + * Remove host from the whitelist. + * + * @param array $hosts + * @return void + */ + public function removeDomains(array $hosts): void; +} diff --git a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php index 51efc7473804..8b8a9b6bf289 100644 --- a/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php +++ b/app/code/Magento/Downloadable/Block/Checkout/Cart/Item/Renderer.php @@ -37,7 +37,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer * @param \Magento\Framework\Url\Helper\Data $urlHelper * @param \Magento\Framework\Message\ManagerInterface $messageManager * @param PriceCurrencyInterface $priceCurrency - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param InterpretationStrategyInterface $messageInterpretationStrategy * @param \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration * @param array $data @@ -51,7 +51,7 @@ public function __construct( \Magento\Framework\Url\Helper\Data $urlHelper, \Magento\Framework\Message\ManagerInterface $messageManager, PriceCurrencyInterface $priceCurrency, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, InterpretationStrategyInterface $messageInterpretationStrategy, \Magento\Downloadable\Helper\Catalog\Product\Configuration $downloadableProductConfiguration, array $data = [] diff --git a/app/code/Magento/Downloadable/Console/Command/DomainsAddCommand.php b/app/code/Magento/Downloadable/Console/Command/DomainsAddCommand.php new file mode 100644 index 000000000000..76d9a13f70f1 --- /dev/null +++ b/app/code/Magento/Downloadable/Console/Command/DomainsAddCommand.php @@ -0,0 +1,91 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Downloadable\Console\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Magento\Downloadable\Api\DomainManagerInterface as DomainManager; + +/** + * Class DomainsAddCommand + * + * Command for adding downloadable domain to the whitelist + */ +class DomainsAddCommand extends Command +{ + /** + * Name of domains input argument + */ + public const INPUT_KEY_DOMAINS = 'domains'; + + /** + * @var DomainManager + */ + private $domainManager; + + /** + * DomainsAddCommand constructor. + * @param DomainManager $domainManager + */ + public function __construct( + DomainManager $domainManager + ) { + $this->domainManager = $domainManager; + parent::__construct(); + } + + /** + * @inheritdoc + */ + protected function configure() + { + $description = 'Add domains to the downloadable domains whitelist'; + + $this->setName('downloadable:domains:add') + ->setDescription($description) + ->setDefinition( + [ + new InputArgument( + self::INPUT_KEY_DOMAINS, + InputArgument::IS_ARRAY, + 'Domains name' + ) + ] + ); + parent::configure(); + } + + /** + * @inheritdoc + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + if ($input->getArgument(self::INPUT_KEY_DOMAINS)) { + $whitelistBefore = $this->domainManager->getDomains(); + $newDomains = $input->getArgument(self::INPUT_KEY_DOMAINS); + $newDomains = array_filter(array_map('trim', $newDomains), 'strlen'); + + $this->domainManager->addDomains($newDomains); + + foreach (array_diff($this->domainManager->getDomains(), $whitelistBefore) as $newHost) { + $output->writeln( + $newHost . ' was added to the whitelist.' + ); + } + } + } catch (\Exception $e) { + $output->writeln('<error>' . $e->getMessage() . '</error>'); + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { + $output->writeln($e->getTraceAsString()); + } + return; + } + } +} diff --git a/app/code/Magento/Downloadable/Console/Command/DomainsRemoveCommand.php b/app/code/Magento/Downloadable/Console/Command/DomainsRemoveCommand.php new file mode 100644 index 000000000000..a30e99a24859 --- /dev/null +++ b/app/code/Magento/Downloadable/Console/Command/DomainsRemoveCommand.php @@ -0,0 +1,91 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Downloadable\Console\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Magento\Downloadable\Api\DomainManagerInterface as DomainManager; + +/** + * Class DomainsRemoveCommand + * + * Command for removing downloadable domain from the whitelist + */ +class DomainsRemoveCommand extends Command +{ + /** + * Name of domains input argument + */ + public const INPUT_KEY_DOMAINS = 'domains'; + + /** + * @var DomainManager + */ + private $domainManager; + + /** + * DomainsRemoveCommand constructor. + * + * @param DomainManager $domainManager + */ + public function __construct( + DomainManager $domainManager + ) { + $this->domainManager = $domainManager; + parent::__construct(); + } + + /** + * @inheritdoc + */ + protected function configure() + { + $description = 'Remove domains from the downloadable domains whitelist'; + + $this->setName('downloadable:domains:remove') + ->setDescription($description) + ->setDefinition( + [ + new InputArgument( + self::INPUT_KEY_DOMAINS, + InputArgument::IS_ARRAY, + 'Domain names' + ) + ] + ); + parent::configure(); + } + + /** + * @inheritdoc + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + if ($input->getArgument(self::INPUT_KEY_DOMAINS)) { + $whitelistBefore = $this->domainManager->getDomains(); + $removeDomains = $input->getArgument(self::INPUT_KEY_DOMAINS); + $removeDomains = array_filter(array_map('trim', $removeDomains), 'strlen'); + $this->domainManager->removeDomains($removeDomains); + + foreach (array_diff($whitelistBefore, $this->domainManager->getDomains()) as $removedHost) { + $output->writeln( + $removedHost . ' was removed from the whitelist.' + ); + } + } + } catch (\Exception $e) { + $output->writeln('<error>' . $e->getMessage() . '</error>'); + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { + $output->writeln($e->getTraceAsString()); + } + return; + } + } +} diff --git a/app/code/Magento/Downloadable/Console/Command/DomainsShowCommand.php b/app/code/Magento/Downloadable/Console/Command/DomainsShowCommand.php new file mode 100644 index 000000000000..eb4488353a09 --- /dev/null +++ b/app/code/Magento/Downloadable/Console/Command/DomainsShowCommand.php @@ -0,0 +1,67 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Downloadable\Console\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputInterface; +use Magento\Downloadable\Api\DomainManagerInterface as DomainManager; + +/** + * Class DomainsShowCommand + * + * Command for listing allowed downloadable domains + */ +class DomainsShowCommand extends Command +{ + /** + * @var DomainManager + */ + private $domainManager; + + /** + * DomainsShowCommand constructor. + * @param DomainManager $domainManager + */ + public function __construct( + DomainManager $domainManager + ) { + $this->domainManager = $domainManager; + parent::__construct(); + } + + /** + * @inheritdoc + */ + protected function configure() + { + $description = 'Display downloadable domains whitelist'; + + $this->setName('downloadable:domains:show') + ->setDescription($description); + parent::configure(); + } + + /** + * @inheritdoc + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + $whitelist = implode("\n", $this->domainManager->getDomains()); + $output->writeln( + "Downloadable domains whitelist:\n$whitelist" + ); + } catch (\Exception $e) { + $output->writeln('<error>' . $e->getMessage() . '</error>'); + if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { + $output->writeln($e->getTraceAsString()); + } + return; + } + } +} diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php index 83b2797050db..a7c32eed8bb1 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Downloadable/File/Upload.php @@ -7,6 +7,8 @@ use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\LocalizedException; /** * Class Upload @@ -76,23 +78,27 @@ public function __construct( */ public function execute() { - $type = $this->getRequest()->getParam('type'); - $tmpPath = ''; - if ($type == 'samples') { - $tmpPath = $this->_sample->getBaseTmpPath(); - } elseif ($type == 'links') { - $tmpPath = $this->_link->getBaseTmpPath(); - } elseif ($type == 'link_samples') { - $tmpPath = $this->_link->getBaseSampleTmpPath(); - } - try { + $type = $this->getRequest()->getParam('type'); + $tmpPath = ''; + if ($type === 'samples') { + $tmpPath = $this->_sample->getBaseTmpPath(); + } elseif ($type === 'links') { + $tmpPath = $this->_link->getBaseTmpPath(); + } elseif ($type === 'link_samples') { + $tmpPath = $this->_link->getBaseSampleTmpPath(); + } else { + throw new LocalizedException(__('Upload type can not be determined.')); + } + $uploader = $this->uploaderFactory->create(['fileId' => $type]); $result = $this->_fileHelper->uploadFromTmp($tmpPath, $uploader); if (!$result) { - throw new \Exception('File can not be moved from temporary folder to the destination folder.'); + throw new FileSystemException( + __('File can not be moved from temporary folder to the destination folder.') + ); } unset($result['tmp_name'], $result['path']); @@ -101,7 +107,7 @@ public function execute() $relativePath = rtrim($tmpPath, '/') . '/' . ltrim($result['file'], '/'); $this->storageDatabase->saveFile($relativePath); } - } catch (\Exception $e) { + } catch (\Throwable $e) { $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()]; } diff --git a/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php b/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php index a283891afc40..f310b376633d 100644 --- a/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php +++ b/app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php @@ -5,11 +5,14 @@ */ namespace Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin; -use Magento\Framework\App\RequestInterface; +use Magento\Downloadable\Api\Data\LinkInterfaceFactory; +use Magento\Downloadable\Api\Data\SampleInterfaceFactory; +use Magento\Downloadable\Helper\Download; use Magento\Downloadable\Model\Link\Builder as LinkBuilder; +use Magento\Downloadable\Model\Product\Type; +use Magento\Downloadable\Model\ResourceModel\Sample\Collection; use Magento\Downloadable\Model\Sample\Builder as SampleBuilder; -use Magento\Downloadable\Api\Data\SampleInterfaceFactory; -use Magento\Downloadable\Api\Data\LinkInterfaceFactory; +use Magento\Framework\App\RequestInterface; /** * Class for initialization downloadable info from request. @@ -42,8 +45,6 @@ class Downloadable private $linkBuilder; /** - * Constructor - * * @param RequestInterface $request * @param LinkBuilder $linkBuilder * @param SampleBuilder $sampleBuilder @@ -79,14 +80,18 @@ public function afterInitialize( \Magento\Catalog\Model\Product $product ) { if ($downloadable = $this->request->getPost('downloadable')) { + $product->setTypeId(Type::TYPE_DOWNLOADABLE); $product->setDownloadableData($downloadable); $extension = $product->getExtensionAttributes(); + $productLinks = $product->getTypeInstance()->getLinks($product); + $productSamples = $product->getTypeInstance()->getSamples($product); if (isset($downloadable['link']) && is_array($downloadable['link'])) { $links = []; foreach ($downloadable['link'] as $linkData) { if (!$linkData || (isset($linkData['is_delete']) && $linkData['is_delete'])) { continue; } else { + $linkData = $this->processLink($linkData, $productLinks); $links[] = $this->linkBuilder->setData( $linkData )->build( @@ -104,6 +109,7 @@ public function afterInitialize( if (!$sampleData || (isset($sampleData['is_delete']) && (bool)$sampleData['is_delete'])) { continue; } else { + $sampleData = $this->processSample($sampleData, $productSamples); $samples[] = $this->sampleBuilder->setData( $sampleData )->build( @@ -124,4 +130,69 @@ public function afterInitialize( } return $product; } + + /** + * Check Links type and status. + * + * @param array $linkData + * @param array $productLinks + * @return array + */ + private function processLink(array $linkData, array $productLinks): array + { + $linkId = $linkData['link_id'] ?? null; + if ($linkId && isset($productLinks[$linkId])) { + $linkData = $this->processFileStatus($linkData, $productLinks[$linkId]->getLinkFile()); + $linkData['sample'] = $this->processFileStatus( + $linkData['sample'] ?? [], + $productLinks[$linkId]->getSampleFile() + ); + } else { + $linkData = $this->processFileStatus($linkData, null); + $linkData['sample'] = $this->processFileStatus($linkData['sample'] ?? [], null); + } + + return $linkData; + } + + /** + * Check Sample type and status. + * + * @param array $sampleData + * @param Collection $productSamples + * @return array + */ + private function processSample(array $sampleData, Collection $productSamples): array + { + $sampleId = $sampleData['sample_id'] ?? null; + /** @var \Magento\Downloadable\Model\Sample $productSample */ + $productSample = $sampleId ? $productSamples->getItemById($sampleId) : null; + if ($sampleId && $productSample) { + $sampleData = $this->processFileStatus($sampleData, $productSample->getSampleFile()); + } else { + $sampleData = $this->processFileStatus($sampleData, null); + } + + return $sampleData; + } + + /** + * Compare file path from request with DB and set status. + * + * @param array $data + * @param string|null $file + * @return array + */ + private function processFileStatus(array $data, ?string $file): array + { + if (isset($data['type']) && $data['type'] === Download::LINK_TYPE_FILE && isset($data['file']['0']['file'])) { + if ($data['file'][0]['file'] !== $file) { + $data['file'][0]['status'] = 'new'; + } else { + $data['file'][0]['status'] = 'old'; + } + } + + return $data; + } } diff --git a/app/code/Magento/Downloadable/Model/DomainManager.php b/app/code/Magento/Downloadable/Model/DomainManager.php new file mode 100644 index 000000000000..e1f275902b03 --- /dev/null +++ b/app/code/Magento/Downloadable/Model/DomainManager.php @@ -0,0 +1,105 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Downloadable\Model; + +use Magento\Framework\App\DeploymentConfig\Writer as ConfigWriter; +use Magento\Downloadable\Api\DomainManagerInterface; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Config\File\ConfigFilePool; + +/** + * Class DomainManager + * + * Manage downloadable domains whitelist in the environment config. + */ +class DomainManager implements DomainManagerInterface +{ + /** + * Path to the allowed domains in the deployment config + */ + private const PARAM_DOWNLOADABLE_DOMAINS = 'downloadable_domains'; + + /** + * @var ConfigWriter + */ + private $configWriter; + + /** + * @var DeploymentConfig + */ + private $deploymentConfig; + + /** + * DomainManager constructor. + * + * @param ConfigWriter $configWriter + * @param DeploymentConfig $deploymentConfig + */ + public function __construct( + ConfigWriter $configWriter, + DeploymentConfig $deploymentConfig + ) { + $this->configWriter = $configWriter; + $this->deploymentConfig = $deploymentConfig; + } + + /** + * @inheritdoc + */ + public function getDomains(): array + { + return array_map('strtolower', $this->deploymentConfig->get(self::PARAM_DOWNLOADABLE_DOMAINS) ?? []); + } + + /** + * @inheritdoc + */ + public function addDomains(array $hosts): void + { + $whitelist = $this->getDomains(); + foreach (array_map('strtolower', $hosts) as $host) { + if (!in_array($host, $whitelist)) { + $whitelist[] = $host; + } + } + + $this->configWriter->saveConfig( + [ + ConfigFilePool::APP_ENV => [ + self::PARAM_DOWNLOADABLE_DOMAINS => $whitelist + ] + ], + true + ); + } + + /** + * @inheritdoc + */ + public function removeDomains(array $hosts): void + { + $whitelist = $this->getDomains(); + foreach (array_map('strtolower', $hosts) as $host) { + if (in_array($host, $whitelist)) { + $index = array_search($host, $whitelist); + unset($whitelist[$index]); + } + } + + $whitelist = array_values($whitelist); // reindex whitelist to prevent non-sequential keying + + $this->configWriter->saveConfig( + [ + ConfigFilePool::APP_ENV => [ + self::PARAM_DOWNLOADABLE_DOMAINS => $whitelist + ] + ], + true + ); + } +} diff --git a/app/code/Magento/Downloadable/Model/Link/Builder.php b/app/code/Magento/Downloadable/Model/Link/Builder.php index 83d01f76fe9c..ff76f7eeda44 100644 --- a/app/code/Magento/Downloadable/Model/Link/Builder.php +++ b/app/code/Magento/Downloadable/Model/Link/Builder.php @@ -69,6 +69,8 @@ public function __construct( } /** + * Set Data. + * * @param array $data * @return $this * @since 100.1.0 @@ -80,6 +82,8 @@ public function setData(array $data) } /** + * Build correct data structure. + * * @param \Magento\Downloadable\Api\Data\LinkInterface $link * @return \Magento\Downloadable\Api\Data\LinkInterface * @throws \Magento\Framework\Exception\LocalizedException @@ -134,6 +138,8 @@ public function build(\Magento\Downloadable\Api\Data\LinkInterface $link) } /** + * Reset data. + * * @return void */ private function resetData() @@ -142,6 +148,8 @@ private function resetData() } /** + * Get existing component or create new. + * * @return Link */ private function getComponent() @@ -153,6 +161,8 @@ private function getComponent() } /** + * Build correct sample structure. + * * @param \Magento\Downloadable\Api\Data\LinkInterface $link * @param array $sample * @return \Magento\Downloadable\Api\Data\LinkInterface @@ -174,7 +184,8 @@ private function buildSample(\Magento\Downloadable\Api\Data\LinkInterface $link, ), \Magento\Downloadable\Api\Data\LinkInterface::class ); - if ($link->getSampleType() === \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE) { + if ($link->getSampleType() === \Magento\Downloadable\Helper\Download::LINK_TYPE_FILE + && isset($sample['file'])) { $linkSampleFileName = $this->downloadableFile->moveFileFromTmp( $this->getComponent()->getBaseSampleTmpPath(), $this->getComponent()->getBaseSamplePath(), diff --git a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php index 088356caefad..28d61986a4f5 100644 --- a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php +++ b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php @@ -6,12 +6,29 @@ namespace Magento\Downloadable\Model\Link; use Magento\Downloadable\Api\Data\LinkInterface; +use Magento\Downloadable\Helper\File; use Magento\Downloadable\Model\File\ContentValidator as FileContentValidator; use Magento\Framework\Exception\InputException; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\ValidatorException; use Magento\Framework\Url\Validator as UrlValidator; +use Magento\Downloadable\Model\Url\DomainValidator; +/** + * Class to validate Link Content. + */ class ContentValidator { + /** + * @var DomainValidator + */ + private $domainValidator; + + /** + * @var File + */ + private $fileHelper; + /** * @var FileContentValidator */ @@ -25,17 +42,23 @@ class ContentValidator /** * @param FileContentValidator $fileContentValidator * @param UrlValidator $urlValidator + * @param DomainValidator $domainValidator + * @param File|null $fileHelper */ public function __construct( FileContentValidator $fileContentValidator, - UrlValidator $urlValidator + UrlValidator $urlValidator, + DomainValidator $domainValidator, + File $fileHelper = null ) { $this->fileContentValidator = $fileContentValidator; $this->urlValidator = $urlValidator; + $this->domainValidator = $domainValidator; + $this->fileHelper = $fileHelper ?? ObjectManager::getInstance()->get(File::class); } /** - * Check if link content is valid + * Check if link content is valid. * * @param LinkInterface $link * @param bool $validateLinkContent @@ -63,50 +86,74 @@ public function isValid(LinkInterface $link, $validateLinkContent = true, $valid if ($validateSampleContent) { $this->validateSampleResource($link); } + return true; } /** - * Validate link resource (file or URL) + * Validate link resource (file or URL). * * @param LinkInterface $link - * @throws InputException * @return void + * @throws InputException */ protected function validateLinkResource(LinkInterface $link) { - if ($link->getLinkType() == 'url' - && !$this->urlValidator->isValid($link->getLinkUrl()) - ) { - throw new InputException(__('Link URL must have valid format.')); - } - if ($link->getLinkType() == 'file' - && (!$link->getLinkFileContent() - || !$this->fileContentValidator->isValid($link->getLinkFileContent())) - ) { - throw new InputException(__('Provided file content must be valid base64 encoded data.')); + if ($link->getLinkType() === 'url') { + if (!$this->urlValidator->isValid($link->getLinkUrl())) { + throw new InputException(__('Link URL must have valid format.')); + } + + if (!$this->domainValidator->isValid($link->getLinkUrl())) { + throw new InputException(__('Link URL\'s domain is not in list of downloadable_domains in env.php.')); + } + } elseif ($link->getLinkFileContent()) { + if (!$this->fileContentValidator->isValid($link->getLinkFileContent())) { + throw new InputException(__('Provided file content must be valid base64 encoded data.')); + } + } elseif (!$this->isFileValid($link->getBasePath() . $link->getLinkFile())) { + throw new InputException(__('Link file not found. Please try again.')); } } /** - * Validate sample resource (file or URL) + * Validate sample resource (file or URL). * * @param LinkInterface $link - * @throws InputException * @return void + * @throws InputException */ protected function validateSampleResource(LinkInterface $link) { - if ($link->getSampleType() == 'url' - && !$this->urlValidator->isValid($link->getSampleUrl()) - ) { - throw new InputException(__('Sample URL must have valid format.')); + if ($link->getSampleType() === 'url') { + if (!$this->urlValidator->isValid($link->getSampleUrl())) { + throw new InputException(__('Sample URL must have valid format.')); + } + + if (!$this->domainValidator->isValid($link->getSampleUrl())) { + throw new InputException(__('Sample URL\'s domain is not in list of downloadable_domains in env.php.')); + } + } elseif ($link->getSampleFileContent()) { + if (!$this->fileContentValidator->isValid($link->getSampleFileContent())) { + throw new InputException(__('Provided file content must be valid base64 encoded data.')); + } + } elseif (!$this->isFileValid($link->getBaseSamplePath() . $link->getSampleFile())) { + throw new InputException(__('Link sample file not found. Please try again.')); } - if ($link->getSampleType() == 'file' - && (!$link->getSampleFileContent() - || !$this->fileContentValidator->isValid($link->getSampleFileContent())) - ) { - throw new InputException(__('Provided file content must be valid base64 encoded data.')); + } + + /** + * Check that Links File or Sample is valid. + * + * @param string $file + * @return bool + */ + private function isFileValid(string $file): bool + { + try { + return $this->fileHelper->ensureFileInFilesystem($file); + } catch (ValidatorException $e) { + return false; } } } diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php index 0898f1924e53..68fbba2a7d38 100644 --- a/app/code/Magento/Downloadable/Model/LinkRepository.php +++ b/app/code/Magento/Downloadable/Model/LinkRepository.php @@ -97,7 +97,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getList($sku) { @@ -107,6 +107,8 @@ public function getList($sku) } /** + * @inheritdoc + * * @param \Magento\Catalog\Api\Data\ProductInterface $product * @return array */ @@ -166,9 +168,11 @@ protected function setBasicFields($resourceData, $dataObject) } /** - * {@inheritdoc} + * @inheritdoc + * * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) + * @throws InputException */ public function save($sku, LinkInterface $link, $isGlobalScopeContent = true) { @@ -176,29 +180,28 @@ public function save($sku, LinkInterface $link, $isGlobalScopeContent = true) if ($link->getId() !== null) { return $this->updateLink($product, $link, $isGlobalScopeContent); } else { - if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { + if ($product->getTypeId() !== Type::TYPE_DOWNLOADABLE) { throw new InputException( __('The product needs to be the downloadable type. Verify the product and try again.') ); } - $validateLinkContent = !($link->getLinkType() === 'file' && $link->getLinkFile()); - $validateSampleContent = !($link->getSampleType() === 'file' && $link->getSampleFile()); - if (!$this->contentValidator->isValid($link, $validateLinkContent, $validateSampleContent)) { + $this->validateLinkType($link); + $this->validateSampleType($link); + if (!$this->contentValidator->isValid($link, true, $link->hasSampleType())) { throw new InputException(__('The link information is invalid. Verify the link and try again.')); } - - if (!in_array($link->getLinkType(), ['url', 'file'], true)) { - throw new InputException(__('The link type is invalid. Verify and try again.')); - } $title = $link->getTitle(); if (empty($title)) { throw new InputException(__('The link title is empty. Enter the link title and try again.')); } + return $this->saveLink($product, $link, $isGlobalScopeContent); } } /** + * Construct Data structure and Save it. + * * @param \Magento\Catalog\Api\Data\ProductInterface $product * @param LinkInterface $link * @param bool $isGlobalScopeContent @@ -220,7 +223,7 @@ protected function saveLink( 'is_shareable' => $link->getIsShareable(), ]; - if ($link->getLinkType() == 'file' && $link->getLinkFile() === null) { + if ($link->getLinkType() == 'file' && $link->getLinkFileContent() !== null) { $linkData['file'] = $this->jsonEncoder->encode( [ $this->fileContentUploader->upload($link->getLinkFileContent(), 'link_file'), @@ -242,7 +245,7 @@ protected function saveLink( if ($link->getSampleType() == 'file') { $linkData['sample']['type'] = 'file'; - if ($link->getSampleFile() === null) { + if ($link->getSampleFileContent() !== null) { $fileData = [ $this->fileContentUploader->upload($link->getSampleFileContent(), 'link_sample_file'), ]; @@ -269,6 +272,8 @@ protected function saveLink( } /** + * Update existing Link. + * * @param \Magento\Catalog\Api\Data\ProductInterface $product * @param LinkInterface $link * @param bool $isGlobalScopeContent @@ -298,9 +303,10 @@ protected function updateLink( __("The downloadable link isn't related to the product. Verify the link and try again.") ); } - $validateLinkContent = !($link->getLinkFileContent() === null); - $validateSampleContent = !($link->getSampleFileContent() === null); - if (!$this->contentValidator->isValid($link, $validateLinkContent, $validateSampleContent)) { + $this->validateLinkType($link); + $this->validateSampleType($link); + $validateSampleContent = $link->hasSampleType(); + if (!$this->contentValidator->isValid($link, true, $validateSampleContent)) { throw new InputException(__('The link information is invalid. Verify the link and try again.')); } if ($isGlobalScopeContent) { @@ -312,20 +318,16 @@ protected function updateLink( throw new InputException(__('The link title is empty. Enter the link title and try again.')); } } - - if ($link->getLinkType() == 'file' && $link->getLinkFileContent() === null && !$link->getLinkFile()) { - $link->setLinkFile($existingLink->getLinkFile()); - } - if ($link->getSampleType() == 'file' && $link->getSampleFileContent() === null && !$link->getSampleFile()) { - $link->setSampleFile($existingLink->getSampleFile()); + if (!$validateSampleContent) { + $this->resetLinkSampleContent($link, $existingLink); } - $this->saveLink($product, $link, $isGlobalScopeContent); + return $existingLink->getId(); } /** - * {@inheritdoc} + * @inheritdoc */ public function delete($id) { @@ -344,6 +346,52 @@ public function delete($id) return true; } + /** + * Check that Link type exist. + * + * @param LinkInterface $link + * @return void + * @throws InputException + */ + private function validateLinkType(LinkInterface $link): void + { + if (!in_array($link->getLinkType(), ['url', 'file'], true)) { + throw new InputException(__('The link type is invalid. Verify and try again.')); + } + } + + /** + * Check that Link sample type exist. + * + * @param LinkInterface $link + * @return void + * @throws InputException + */ + private function validateSampleType(LinkInterface $link): void + { + if ($link->hasSampleType() && !in_array($link->getSampleType(), ['url', 'file'], true)) { + throw new InputException(__('The link sample type is invalid. Verify and try again.')); + } + } + + /** + * Reset Sample type and file. + * + * @param LinkInterface $link + * @param LinkInterface $existingLink + * @return void + */ + private function resetLinkSampleContent(LinkInterface $link, LinkInterface $existingLink): void + { + $existingType = $existingLink->getSampleType(); + $link->setSampleType($existingType); + if ($existingType === 'file') { + $link->setSampleFile($existingLink->getSampleFile()); + } else { + $link->setSampleUrl($existingLink->getSampleUrl()); + } + } + /** * Get MetadataPool instance * diff --git a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php index 6a273bfe5d34..697878017ee8 100644 --- a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php +++ b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php @@ -6,12 +6,29 @@ namespace Magento\Downloadable\Model\Sample; use Magento\Downloadable\Api\Data\SampleInterface; +use Magento\Downloadable\Helper\File; use Magento\Downloadable\Model\File\ContentValidator as FileContentValidator; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\ValidatorException; use Magento\Framework\Url\Validator as UrlValidator; +use Magento\Downloadable\Model\Url\DomainValidator; +/** + * Class to validate Sample Content. + */ class ContentValidator { + /** + * @var File + */ + private $fileHelper; + + /** + * @var DomainValidator + */ + private $domainValidator; + /** * @var UrlValidator */ @@ -25,17 +42,23 @@ class ContentValidator /** * @param FileContentValidator $fileContentValidator * @param UrlValidator $urlValidator + * @param DomainValidator $domainValidator + * @param File|null $fileHelper */ public function __construct( FileContentValidator $fileContentValidator, - UrlValidator $urlValidator + UrlValidator $urlValidator, + DomainValidator $domainValidator, + File $fileHelper = null ) { $this->fileContentValidator = $fileContentValidator; $this->urlValidator = $urlValidator; + $this->domainValidator = $domainValidator; + $this->fileHelper = $fileHelper ?? ObjectManager::getInstance()->get(File::class); } /** - * Check if sample content is valid + * Check if sample content is valid. * * @param SampleInterface $sample * @param bool $validateSampleContent @@ -51,29 +74,48 @@ public function isValid(SampleInterface $sample, $validateSampleContent = true) if ($validateSampleContent) { $this->validateSampleResource($sample); } + return true; } /** - * Validate sample resource (file or URL) + * Validate sample resource (file or URL). * * @param SampleInterface $sample - * @throws InputException * @return void + * @throws InputException */ protected function validateSampleResource(SampleInterface $sample) { - $sampleFile = $sample->getSampleFileContent(); - if ($sample->getSampleType() == 'file' - && (!$sampleFile || !$this->fileContentValidator->isValid($sampleFile)) - ) { - throw new InputException(__('Provided file content must be valid base64 encoded data.')); + if ($sample->getSampleType() === 'url') { + if (!$this->urlValidator->isValid($sample->getSampleUrl())) { + throw new InputException(__('Sample URL must have valid format.')); + } + + if (!$this->domainValidator->isValid($sample->getSampleUrl())) { + throw new InputException(__('Sample URL\'s domain is not in list of downloadable_domains in env.php.')); + } + } elseif ($sample->getSampleFileContent()) { + if (!$this->fileContentValidator->isValid($sample->getSampleFileContent())) { + throw new InputException(__('Provided file content must be valid base64 encoded data.')); + } + } elseif (!$this->isFileValid($sample->getBasePath() . $sample->getSampleFile())) { + throw new InputException(__('Sample file not found. Please try again.')); } + } - if ($sample->getSampleType() == 'url' - && !$this->urlValidator->isValid($sample->getSampleUrl()) - ) { - throw new InputException(__('Sample URL must have valid format.')); + /** + * Check that Samples file is valid. + * + * @param string $file + * @return bool + */ + private function isFileValid(string $file): bool + { + try { + return $this->fileHelper->ensureFileInFilesystem($file); + } catch (ValidatorException $e) { + return false; } } } diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php index 07c7631fade1..37f376e66624 100644 --- a/app/code/Magento/Downloadable/Model/SampleRepository.php +++ b/app/code/Magento/Downloadable/Model/SampleRepository.php @@ -189,17 +189,12 @@ public function save( __('The product needs to be the downloadable type. Verify the product and try again.') ); } - $validateSampleContent = !($sample->getSampleType() === 'file' && $sample->getSampleFile()); - if (!$this->contentValidator->isValid($sample, $validateSampleContent)) { + $this->validateSampleType($sample); + if (!$this->contentValidator->isValid($sample, true)) { throw new InputException( __('The sample information is invalid. Verify the information and try again.') ); } - - if (!in_array($sample->getSampleType(), ['url', 'file'], true)) { - throw new InputException(__('The sample type is invalid. Verify the sample type and try again.')); - } - $title = $sample->getTitle(); if (empty($title)) { throw new InputException(__('The sample title is empty. Enter the title and try again.')); @@ -230,7 +225,7 @@ protected function saveSample( 'title' => $sample->getTitle(), ]; - if ($sample->getSampleType() === 'file' && $sample->getSampleFile() === null) { + if ($sample->getSampleType() === 'file' && $sample->getSampleFileContent() !== null) { $sampleData['file'] = $this->jsonEncoder->encode( [ $this->fileContentUploader->upload($sample->getSampleFileContent(), 'sample'), @@ -293,9 +288,8 @@ protected function updateSample( __("The downloadable sample isn't related to the product. Verify the link and try again.") ); } - - $validateFileContent = $sample->getSampleFileContent() === null ? false : true; - if (!$this->contentValidator->isValid($sample, $validateFileContent)) { + $this->validateSampleType($sample); + if (!$this->contentValidator->isValid($sample, true)) { throw new InputException(__('The sample information is invalid. Verify the information and try again.')); } if ($isGlobalScopeContent) { @@ -312,14 +306,8 @@ protected function updateSample( } else { $existingSample->setTitle($sample->getTitle()); } - - if ($sample->getSampleType() === 'file' - && $sample->getSampleFileContent() === null - && $sample->getSampleFile() !== null - ) { - $existingSample->setSampleFile($sample->getSampleFile()); - } $this->saveSample($product, $sample, $isGlobalScopeContent); + return $existingSample->getId(); } @@ -343,6 +331,20 @@ public function delete($id) return true; } + /** + * Check that Sample type exist. + * + * @param SampleInterface $sample + * @throws InputException + * @return void + */ + private function validateSampleType(SampleInterface $sample): void + { + if (!in_array($sample->getSampleType(), ['url', 'file'], true)) { + throw new InputException(__('The sample type is invalid. Verify the sample type and try again.')); + } + } + /** * Get MetadataPool instance * diff --git a/app/code/Magento/Downloadable/Model/Url/DomainValidator.php b/app/code/Magento/Downloadable/Model/Url/DomainValidator.php new file mode 100644 index 000000000000..cab7fb134ea3 --- /dev/null +++ b/app/code/Magento/Downloadable/Model/Url/DomainValidator.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Downloadable\Model\Url; + +use Magento\Downloadable\Api\DomainManagerInterface as DomainManager; +use Magento\Framework\Validator\Ip as IpValidator; +use Zend\Uri\Uri as UriHandler; + +/** + * Class is responsible for checking if downloadable product link domain is allowed. + */ +class DomainValidator +{ + /** + * Path to the allowed domains in the deployment config + */ + public const PARAM_DOWNLOADABLE_DOMAINS = 'downloadable_domains'; + + /** + * @var IpValidator + */ + private $ipValidator; + + /** + * @var UriHandler + */ + private $uriHandler; + + /** + * @var DomainManager + */ + private $domainManager; + + /** + * @param DomainManager $domainManager + * @param IpValidator $ipValidator + * @param UriHandler $uriHandler + */ + public function __construct( + DomainManager $domainManager, + IpValidator $ipValidator, + UriHandler $uriHandler + ) { + $this->domainManager = $domainManager; + $this->ipValidator = $ipValidator; + $this->uriHandler = $uriHandler; + } + + /** + * Validate url input. + * + * Assert parsed host of $value is contained within environment whitelist + * + * @param string $value + * @return bool + */ + public function isValid($value): bool + { + $host = $this->getHost($value); + + $isIpAddress = $this->ipValidator->isValid($host); + $isValid = !$isIpAddress && in_array($host, $this->domainManager->getDomains()); + + return $isValid; + } + + /** + * Extract host from url + * + * @param string $url + * @return string + */ + private function getHost($url): string + { + $host = $this->uriHandler->parse($url)->getHost(); + + if ($host === null) { + return ''; + } + + // ipv6 hosts are brace-delimited in url; they are removed here for subsequent validation + return trim($host, '[] '); + } +} diff --git a/app/code/Magento/Downloadable/Setup/Patch/Data/AddDownloadableHostsConfig.php b/app/code/Magento/Downloadable/Setup/Patch/Data/AddDownloadableHostsConfig.php new file mode 100644 index 000000000000..0e88bd166b60 --- /dev/null +++ b/app/code/Magento/Downloadable/Setup/Patch/Data/AddDownloadableHostsConfig.php @@ -0,0 +1,217 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Downloadable\Setup\Patch\Data; + +use Magento\Config\Model\Config\Backend\Admin\Custom; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Setup\Patch\DataPatchInterface; +use Magento\Framework\UrlInterface; +use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\Store; +use Zend\Uri\Uri as UriHandler; +use Magento\Framework\Url\ScopeResolverInterface; +use Magento\Downloadable\Api\DomainManagerInterface as DomainManager; +use Magento\Framework\Setup\ModuleDataSetupInterface; +use Magento\Backend\App\Area\FrontNameResolver; + +/** + * Adding base url as allowed downloadable domain. + */ +class AddDownloadableHostsConfig implements DataPatchInterface +{ + /** + * @var UriHandler + */ + private $uriHandler; + + /** + * @var ScopeResolverInterface + */ + private $scopeResolver; + + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + + /** + * @var ModuleDataSetupInterface + */ + private $moduleDataSetup; + + /** + * @var DomainManager + */ + private $domainManager; + + /** + * @var array + */ + private $whitelist = []; + + /** + * AddDownloadableHostsConfig constructor. + * + * @param UriHandler $uriHandler + * @param ScopeResolverInterface $scopeResolver + * @param ScopeConfigInterface $scopeConfig + * @param DomainManager $domainManager + * @param ModuleDataSetupInterface $moduleDataSetup + */ + public function __construct( + UriHandler $uriHandler, + ScopeResolverInterface $scopeResolver, + ScopeConfigInterface $scopeConfig, + DomainManager $domainManager, + ModuleDataSetupInterface $moduleDataSetup + ) { + $this->uriHandler = $uriHandler; + $this->scopeResolver = $scopeResolver; + $this->scopeConfig = $scopeConfig; + $this->domainManager = $domainManager; + $this->moduleDataSetup = $moduleDataSetup; + } + + /** + * @inheritdoc + */ + public function apply() + { + $customStoreScope = $this->scopeResolver->getScope(Custom::CONFIG_SCOPE_ID); + $storeScopes = $this->scopeResolver->getScopes(); + $allStoreScopes = array_merge($storeScopes, [$customStoreScope]); + + foreach ($allStoreScopes as $scope) { + $this->addStoreAndWebsiteUrlsFromScope($scope); + } + + $customAdminUrl = $this->scopeConfig->getValue( + FrontNameResolver::XML_PATH_CUSTOM_ADMIN_URL, + ScopeInterface::SCOPE_STORE + ); + + if ($customAdminUrl) { + $this->addHost($customAdminUrl); + } + + if ($this->moduleDataSetup->tableExists('downloadable_link')) { + $select = $this->moduleDataSetup->getConnection() + ->select() + ->from( + $this->moduleDataSetup->getTable('downloadable_link'), + ['link_url'] + ) + ->where('link_type = ?', 'url'); + + foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $link) { + $this->addHost($link['link_url']); + } + + $select = $this->moduleDataSetup->getConnection() + ->select() + ->from( + $this->moduleDataSetup->getTable('downloadable_link'), + ['sample_url'] + ) + ->where('sample_type = ?', 'url'); + + foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $link) { + $this->addHost($link['sample_url']); + } + } + + if ($this->moduleDataSetup->tableExists('downloadable_sample')) { + $select = $this->moduleDataSetup->getConnection() + ->select() + ->from( + $this->moduleDataSetup->getTable('downloadable_sample'), + ['sample_url'] + ) + ->where('sample_type = ?', 'url'); + + foreach ($this->moduleDataSetup->getConnection()->fetchAll($select) as $link) { + $this->addHost($link['sample_url']); + } + } + + $this->domainManager->addDomains($this->whitelist); + } + + /** + * Add stores and website urls from store scope + * + * @param Store $scope + */ + private function addStoreAndWebsiteUrlsFromScope(Store $scope) + { + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_WEB, false)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_WEB, true)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_LINK, false)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_LINK, true)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_DIRECT_LINK, false)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_DIRECT_LINK, true)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_MEDIA, false)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_MEDIA, true)); + + try { + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_STATIC, false)); + $this->addHost($scope->getBaseUrl(UrlInterface::URL_TYPE_STATIC, true)); + } catch (\UnexpectedValueException $e) {} //@codingStandardsIgnoreLine + + try { + $website = $scope->getWebsite(); + } catch (NoSuchEntityException $e) { + return; + } + + if ($website) { + $this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_LINK_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_LINK_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_MEDIA_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_MEDIA_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_SECURE_BASE_STATIC_URL)); + $this->addHost($website->getConfig(Store::XML_PATH_UNSECURE_BASE_STATIC_URL)); + } + } + + /** + * Add host to whitelist + * + * @param string $url + */ + private function addHost($url) + { + if (!is_string($url)) { + return; + } + + $host = $this->uriHandler->parse($url)->getHost(); + if ($host && !in_array($host, $this->whitelist)) { + $this->whitelist[] = $host; + } + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return []; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Downloadable/Setup/Patch/Schema/ChangeTmpTablesEngine.php b/app/code/Magento/Downloadable/Setup/Patch/Schema/ChangeTmpTablesEngine.php deleted file mode 100644 index caf2f7745a3d..000000000000 --- a/app/code/Magento/Downloadable/Setup/Patch/Schema/ChangeTmpTablesEngine.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Downloadable\Setup\Patch\Schema; - -use Magento\Framework\Setup\Patch\SchemaPatchInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Change engine for temporary tables to InnoDB. - */ -class ChangeTmpTablesEngine implements SchemaPatchInterface -{ - /** - * @var SchemaSetupInterface - */ - private $schemaSetup; - - /** - * @param SchemaSetupInterface $schemaSetup - */ - public function __construct(SchemaSetupInterface $schemaSetup) - { - $this->schemaSetup = $schemaSetup; - } - - /** - * @inheritdoc - */ - public function apply() - { - $this->schemaSetup->startSetup(); - - $tableName = $this->schemaSetup->getTable('catalog_product_index_price_downlod_tmp'); - if ($this->schemaSetup->getConnection()->isTableExists($tableName)) { - $this->schemaSetup->getConnection()->changeTableEngine($tableName, 'InnoDB'); - } - - $this->schemaSetup->endSetup(); - } - - /** - * @inheritdoc - */ - public static function getDependencies() - { - return []; - } - - /** - * @inheritdoc - */ - public function getAliases() - { - return []; - } -} diff --git a/app/code/Magento/Downloadable/Test/Mftf/ActionGroup/AdminDownloadableProductActionGroup.xml b/app/code/Magento/Downloadable/Test/Mftf/ActionGroup/AdminDownloadableProductActionGroup.xml index f40f5cb47e4d..2d2cdd969ac9 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/ActionGroup/AdminDownloadableProductActionGroup.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/ActionGroup/AdminDownloadableProductActionGroup.xml @@ -51,18 +51,20 @@ </annotations> <arguments> <argument name="link" defaultValue="downloadableLink"/> + <argument name="index" type="string" defaultValue="1"/> </arguments> <click selector="{{AdminProductDownloadableSection.linksAddLinkButton}}" stepKey="clickLinkAddLinkButton"/> <waitForPageLoad stepKey="waitForPageLoad"/> - <fillField userInput="{{link.title}}" selector="{{AdminProductDownloadableSection.addLinkTitleInput('1')}}" stepKey="fillDownloadableLinkTitle"/> - <fillField userInput="{{link.price}}" selector="{{AdminProductDownloadableSection.addLinkPriceInput('1')}}" stepKey="fillDownloadableLinkPrice"/> - <selectOption userInput="{{link.file_type}}" selector="{{AdminProductDownloadableSection.addLinkFileTypeSelector('1')}}" stepKey="selectDownloadableLinkFileType"/> - <selectOption userInput="{{link.sample_type}}" selector="{{AdminProductDownloadableSection.addLinkSampleTypeSelector('1')}}" stepKey="selectDownloadableLinkSampleType"/> - <selectOption userInput="{{link.shareable}}" selector="{{AdminProductDownloadableSection.addLinkShareableSelector('1')}}" stepKey="selectDownloadableLinkShareable"/> - <checkOption selector="{{AdminProductDownloadableSection.addLinkIsUnlimitedDownloads('1')}}" stepKey="checkDownloadableLinkUnlimited"/> - <fillField userInput="{{link.file}}" selector="{{AdminProductDownloadableSection.addLinkFileUrlInput('1')}}" stepKey="fillDownloadableLinkFileUrl"/> - <attachFile userInput="{{link.sample}}" selector="{{AdminProductDownloadableSection.addLinkSampleUploadFile('1')}}" stepKey="attachDownloadableLinkUploadSample"/> + <fillField userInput="{{link.title}}" selector="{{AdminProductDownloadableSection.addLinkTitleInput(index)}}" stepKey="fillDownloadableLinkTitle"/> + <fillField userInput="{{link.price}}" selector="{{AdminProductDownloadableSection.addLinkPriceInput(index)}}" stepKey="fillDownloadableLinkPrice"/> + <selectOption userInput="{{link.file_type}}" selector="{{AdminProductDownloadableSection.addLinkFileTypeSelector(index)}}" stepKey="selectDownloadableLinkFileType"/> + <selectOption userInput="{{link.sample_type}}" selector="{{AdminProductDownloadableSection.addLinkSampleTypeSelector(index)}}" stepKey="selectDownloadableLinkSampleType"/> + <selectOption userInput="{{link.shareable}}" selector="{{AdminProductDownloadableSection.addLinkShareableSelector(index)}}" stepKey="selectDownloadableLinkShareable"/> + <checkOption selector="{{AdminProductDownloadableSection.addLinkIsUnlimitedDownloads(index)}}" stepKey="checkDownloadableLinkUnlimited"/> + <fillField userInput="{{link.file}}" selector="{{AdminProductDownloadableSection.addLinkFileUrlInput(index)}}" stepKey="fillDownloadableLinkFileUrl"/> + <attachFile userInput="{{link.sample}}" selector="{{AdminProductDownloadableSection.addLinkSampleUploadFile(index)}}" stepKey="attachDownloadableLinkUploadSample"/> + <waitForPageLoad stepKey="waitForPageLoadAfterFillingOutForm" /> </actionGroup> <!--Add a downloadable sample file--> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Downloadable/Test/Mftf/Data/ProductData.xml index 1a6be43b38d2..2986532ef113 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Data/ProductData.xml @@ -74,6 +74,21 @@ <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> <requiredEntity type="downloadable_link">apiDownloadableLink</requiredEntity> </entity> + <entity name="ApiDownloadableProductUnderscoredSku" type="product"> + <data key="sku" unique="suffix">api_downloadable_product</data> + <data key="type_id">downloadable</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">Api Downloadable Product</data> + <data key="price">123.00</data> + <data key="urlKey" unique="suffix">api-downloadable-product</data> + <data key="status">1</data> + <data key="quantity">100</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + <requiredEntity type="downloadable_link">apiDownloadableLink</requiredEntity> + </entity> <entity name="DownloadableProductWithTwoLink100" type="product"> <data key="sku" unique="suffix">downloadableproduct</data> <data key="type_id">downloadable</data> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml b/app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml index 20b62ef06030..dc2a58be138e 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Section/StorefrontDownloadableProductSection.xml @@ -15,5 +15,6 @@ <element name="downloadableLinkSampleByTitle" type="text" selector="//label[contains(., '{{title}}')]/a[contains(@class, 'sample link')]" parameterized="true"/> <element name="downloadableSampleLabel" type="text" selector="//a[contains(.,normalize-space('{{title}}'))]" parameterized="true" timeout="30"/> <element name="downloadableLinkSelectAllCheckbox" type="checkbox" selector="#links_all" /> + <element name="downloadableLinkSelectAllLabel" type="text" selector="label[for='links_all']" /> </section> </sections> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultImageDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultImageDownloadableProductTest.xml index 64f33b01e668..a7ce96ddf1fd 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultImageDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultImageDownloadableProductTest.xml @@ -19,12 +19,14 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct"> <argument name="product" value="DownloadableProduct"/> </actionGroup> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> </after> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml index a7acdfded29b..d95ddaf12470 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml @@ -18,7 +18,12 @@ <testCaseId value="MC-114"/> <group value="Downloadable"/> </annotations> - + <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="enableAdminAccountSharing"/> + </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="setStoreDefaultConfig"/> + </after> <!-- Create a downloadable product --> <!-- Replacing steps in base AdminAddDefaultVideoSimpleProductTest --> <actionGroup ref="goToCreateProductPage" stepKey="goToCreateProductPage"> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml index 5d7e4518525f..4f07334640cf 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductAndAssignItToCustomStoreTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithCustomOptionsTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithCustomOptionsTest.xml index 0ae2c1254be0..54a2ff606f38 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithCustomOptionsTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithCustomOptionsTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml index eadefabb8bbc..8194e600673c 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml @@ -8,7 +8,7 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminCreateDownloadableProductWithLinkTest"> + <test name="AdminCreateDownloadableProductWithDefaultSetLinksTest"> <annotations> <features value="Catalog"/> <stories value="Create Downloadable Product"/> @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithGroupPriceTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithGroupPriceTest.xml index 8bd4305e6b35..06cf31b763f1 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithGroupPriceTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithGroupPriceTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithInvalidDomainLinkUrlTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithInvalidDomainLinkUrlTest.xml new file mode 100644 index 000000000000..f2e4bdfb4890 --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithInvalidDomainLinkUrlTest.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateDownloadableProductWithInvalidDomainLinkUrlTest" extends="AdminCreateDownloadableProductWithLinkTest"> + <annotations> + <stories value="Create Downloadable Product"/> + <title value="Create Downloadable Product with invalid domain link url"/> + <description value="Admin should not be able to create downloadable product with invalid domain link url"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-18282"/> + <useCaseId value="MC-17700"/> + <group value="Downloadable"/> + </annotations> + <before> + <remove keyForRemoval="addDownloadableDomain" /> + </before> + <actionGroup ref="addDownloadableProductLink" stepKey="addDownloadableProductLink"> + <argument name="link" value="downloadableLink"/> + <argument name="index" value="0"/> + </actionGroup> + <actionGroup ref="SaveProductFormNoSuccessCheck" stepKey="saveProduct"/> + <see selector="{{AdminProductMessagesSection.errorMessage}}" userInput="Link URL's domain is not in list of downloadable_domains in env.php." stepKey="seeLinkUrlInvalidMessage" after="saveProduct" /> + <magentoCLI stepKey="addDownloadableDomain2" command="downloadable:domains:add static.magento.com" after="seeLinkUrlInvalidMessage" /> + <actionGroup ref="fillMainProductFormNoWeight" stepKey="fillDownloadableProductFormAgain" after="addDownloadableDomain2"> + <argument name="product" value="DownloadableProduct"/> + </actionGroup> + <checkOption selector="{{AdminProductDownloadableSection.isDownloadableProduct}}" stepKey="checkIsDownloadable" after="fillDownloadableProductFormAgain"/> + <checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}" stepKey="checkIsLinksPurchasedSeparately" after="checkIsDownloadable"/> + <actionGroup ref="addDownloadableProductLink" stepKey="addDownloadableProductLinkAgain" after="checkIsLinksPurchasedSeparately"> + <argument name="link" value="downloadableLink"/> + <argument name="index" value="0"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProductAfterAddingDomainToWhitelist" after="addDownloadableProductLinkAgain" /> + <scrollTo selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" stepKey="scrollToLinks"/> + <click selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" stepKey="selectProductLink"/> + <see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$52.99" stepKey="assertProductPriceInCart"/> + </test> +</tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml index d8bd641e84e5..e43b8f94c7a3 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml @@ -8,7 +8,7 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminCreateDownloadableProductWithDefaultSetLinksTest"> + <test name="AdminCreateDownloadableProductWithLinkTest"> <annotations> <features value="Catalog"/> <stories value="Create Downloadable Product"/> @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithManageStockTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithManageStockTest.xml index 3efd4b8ab276..fb6a48254fa8 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithManageStockTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithManageStockTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithOutOfStockStatusTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithOutOfStockStatusTest.xml index 07f7c40bb356..5e3fe6836f7e 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithOutOfStockStatusTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithOutOfStockStatusTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithSpecialPriceTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithSpecialPriceTest.xml index 275e72b2ec8c..fb59d51831ba 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithSpecialPriceTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithSpecialPriceTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutFillingQuantityAndStockTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutFillingQuantityAndStockTest.xml index f326a047c32b..af9487e3e6a2 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutFillingQuantityAndStockTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutFillingQuantityAndStockTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutTaxClassIdTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutTaxClassIdTest.xml index 8e33a082d0ba..dd7e3331a0ed 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutTaxClassIdTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithoutTaxClassIdTest.xml @@ -20,6 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -27,6 +28,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminDeleteDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminDeleteDownloadableProductTest.xml index d3c2d6e5d71a..07124ea4846b 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminDeleteDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminDeleteDownloadableProductTest.xml @@ -18,6 +18,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="DownloadableProductWithTwoLink" stepKey="createDownloadableProduct"> @@ -31,6 +32,7 @@ </createData> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <actionGroup ref="logout" stepKey="logout"/> </after> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml index 8cb0d5fde986..20c1acaf8d61 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminProductTypeSwitchingOnEditingTest.xml @@ -37,12 +37,16 @@ <group value="catalog"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> <!--Create product--> <comment userInput="Create product" stepKey="commentCreateProduct"/> <createData entity="SimpleProduct2" stepKey="createProduct"/> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <!--Delete product--> <comment userInput="Delete product" stepKey="commentDeleteProduct"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultImageDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultImageDownloadableProductTest.xml index 3ee6cef47738..3597c12e82df 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultImageDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultImageDownloadableProductTest.xml @@ -19,9 +19,11 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com"/> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com"/> <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> </after> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml index d8bbbb2b4d62..0d98862d9a5e 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminRemoveDefaultVideoDownloadableProductTest.xml @@ -18,6 +18,12 @@ <testCaseId value="MC-207"/> <group value="Downloadable"/> </annotations> + <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="enableAdminAccountSharing"/> + </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="setStoreDefaultConfig"/> + </after> <!-- Create a downloadable product --> <!-- Replacing steps in base AdminRemoveDefaultVideoSimpleProductTest --> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml index 66177b6875dd..b5f437996d69 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml @@ -19,6 +19,7 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="product"/> <createData entity="ApiDownloadableProduct" stepKey="product"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="product"/> @@ -27,6 +28,9 @@ <requiredEntity createDataKey="product"/> </createData> </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="delete"/> + </after> </test> <test name="AdvanceCatalogSearchDownloadableBySkuTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> <annotations> @@ -39,7 +43,8 @@ <group value="Downloadable"/> </annotations> <before> - <createData entity="ApiDownloadableProduct" stepKey="product"/> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="product"/> + <createData entity="ApiDownloadableProductUnderscoredSku" stepKey="product"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="product"/> </createData> @@ -47,6 +52,9 @@ <requiredEntity createDataKey="product"/> </createData> </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="delete"/> + </after> </test> <test name="AdvanceCatalogSearchDownloadableByDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> <annotations> @@ -59,6 +67,7 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="product"/> <createData entity="ApiDownloadableProduct" stepKey="product"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="product"/> @@ -67,6 +76,9 @@ <requiredEntity createDataKey="product"/> </createData> </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="delete"/> + </after> </test> <test name="AdvanceCatalogSearchDownloadableByShortDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> <annotations> @@ -79,6 +91,7 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="product"/> <createData entity="ApiDownloadableProduct" stepKey="product"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="product"/> @@ -87,6 +100,9 @@ <requiredEntity createDataKey="product"/> </createData> </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="delete"/> + </after> </test> <test name="AdvanceCatalogSearchDownloadableByPriceTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> <annotations> @@ -99,6 +115,7 @@ <group value="Downloadable"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="product"/> <createData entity="ApiDownloadableProduct" stepKey="product"/> <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> <requiredEntity createDataKey="product"/> @@ -107,5 +124,8 @@ <requiredEntity createDataKey="product"/> </createData> </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="delete"/> + </after> </test> </tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml index 0b905964fd2d..274dd39468a2 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml @@ -18,6 +18,9 @@ <group value="Downloadable"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -61,6 +64,9 @@ <actionGroup ref="saveProductForm" stepKey="saveProduct"/> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/LinkDownloadableProductFromGuestToCustomerTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/LinkDownloadableProductFromGuestToCustomerTest.xml index b960d15b2fdf..b9773415059e 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/LinkDownloadableProductFromGuestToCustomerTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/LinkDownloadableProductFromGuestToCustomerTest.xml @@ -18,6 +18,7 @@ <testCaseId value="MC-16011"/> </annotations> <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> <magentoCLI command="config:set {{EnableGuestCheckoutWithDownloadableItems.path}} {{EnableGuestCheckoutWithDownloadableItems.value}}" stepKey="enableGuestCheckoutWithDownloadableItems" /> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="DownloadableProductWithOneLink" stepKey="createProduct"> @@ -28,6 +29,7 @@ </createData> </before> <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> <magentoCLI command="config:set {{DisableGuestCheckoutWithDownloadableItems.path}} {{DisableGuestCheckoutWithDownloadableItems.value}}" stepKey="disableGuestCheckoutWithDownloadableItems" /> <deleteData stepKey="deleteProduct" createDataKey="createProduct"/> <deleteData stepKey="deleteCategory" createDataKey="createCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/ManualSelectAllDownloadableLinksDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/ManualSelectAllDownloadableLinksDownloadableProductTest.xml new file mode 100644 index 000000000000..a86fd544d24d --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/ManualSelectAllDownloadableLinksDownloadableProductTest.xml @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="ManualSelectAllDownloadableLinksDownloadableProductTest"> + <annotations> + <features value="Catalog"/> + <stories value="Create Downloadable Product"/> + <title value="Manual select all downloadable links downloadable product test"/> + <description value="Manually selecting all downloadable links must change 'Select/Unselect all' button label to 'Unselect all', and 'Select all' otherwise"/> + <severity value="MAJOR"/> + <group value="Downloadable"/> + </annotations> + <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + + <!-- Create category --> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + + <!-- Create downloadable product --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="amOnProductGridPage"/> + <waitForPageLoad stepKey="waitForProductGridPageLoad"/> + <actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="createProduct"> + <argument name="productType" value="downloadable"/> + </actionGroup> + + <!-- Fill downloadable product values --> + <actionGroup ref="fillMainProductFormNoWeight" stepKey="fillDownloadableProductForm"> + <argument name="product" value="DownloadableProduct"/> + </actionGroup> + + <!-- Add downloadable product to category --> + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" + parameterArray="[$$createCategory.name$$]" stepKey="fillCategory"/> + + <!-- Fill downloadable link information before the creation link --> + <actionGroup ref="AdminAddDownloadableLinkInformationActionGroup" stepKey="addDownloadableLinkInformation"/> + + <!-- Links can be purchased separately --> + <checkOption selector="{{AdminProductDownloadableSection.isLinksPurchasedSeparately}}" + stepKey="checkOptionPurchaseSeparately"/> + + <!-- Add first downloadable link --> + <actionGroup ref="addDownloadableProductLinkWithMaxDownloads" stepKey="addFirstDownloadableProductLink"> + <argument name="link" value="downloadableLinkWithMaxDownloads"/> + </actionGroup> + + <!-- Add second downloadable link --> + <actionGroup ref="addDownloadableProductLink" stepKey="addSecondDownloadableProductLink"> + <argument name="link" value="downloadableLink"/> + </actionGroup> + + <!-- Save product --> + <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + </before> + <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + + <!-- Delete category --> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Delete created downloadable product --> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct"> + <argument name="product" value="DownloadableProduct"/> + </actionGroup> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Step 1: Navigate to store front Product page as guest --> + <amOnPage url="/{{DownloadableProduct.sku}}.html" + stepKey="amOnStorefrontProductPage"/> + + <!-- Step 2: Check first downloadable link checkbox --> + <click + selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLinkWithMaxDownloads.title)}}" + stepKey="selectFirstCheckbox"/> + + <!-- Step 3: Check second downloadable link checkbox --> + <click + selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" + stepKey="selectSecondCheckbox"/> + + <!-- Step 4: Grab "Select/Unselect All" button label text --> + <grabTextFrom + selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}" + stepKey="grabUnselectAllButtonText"/> + + <!-- Step 5: Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes --> + <assertEquals + message="Assert that 'Select/Unselect all' button text is 'Unselect all' after manually checking all checkboxes" + stepKey="assertButtonTextOne"> + <expectedResult type="string">Unselect all</expectedResult> + <actualResult type="string">{$grabUnselectAllButtonText}</actualResult> + </assertEquals> + + <!-- Step 6: Uncheck second downloadable link checkbox --> + <click + selector="{{StorefrontDownloadableProductSection.downloadableLinkByTitle(downloadableLink.title)}}" + stepKey="unselectSecondCheckbox"/> + + <!-- Step 7: Grab "Select/Unselect All" button label text --> + <grabTextFrom + selector="{{StorefrontDownloadableProductSection.downloadableLinkSelectAllLabel}}" + stepKey="grabSelectAllButtonText"/> + + <!-- Step 8: Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox --> + <assertEquals + message="Assert that 'Select/Unselect all' button text is 'Select all' after manually unchecking one checkbox" + stepKey="assertButtonTextTwo"> + <expectedResult type="string">Select all</expectedResult> + <actualResult type="string">{$grabSelectAllButtonText}</actualResult> + </assertEquals> + + </test> +</tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/NewProductsListWidgetDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/NewProductsListWidgetDownloadableProductTest.xml index 4864d11c884b..94fca6f50763 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/NewProductsListWidgetDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/NewProductsListWidgetDownloadableProductTest.xml @@ -20,6 +20,13 @@ <group value="WYSIWYGDisabled"/> </annotations> + <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add static.magento.com" before="loginAsAdmin"/> + </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove static.magento.com" before="logout"/> + </after> + <!-- A Cms page containing the New Products Widget gets created here via extends --> <!-- Create a Downloadable product to appear in the widget --> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/SelectAllDownloadableLinksDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/SelectAllDownloadableLinksDownloadableProductTest.xml index 94940f0e0819..f9ca6fea09cf 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/SelectAllDownloadableLinksDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/SelectAllDownloadableLinksDownloadableProductTest.xml @@ -18,6 +18,9 @@ <group value="Downloadable"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + <!-- Create category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> @@ -61,6 +64,9 @@ <actionGroup ref="saveProductForm" stepKey="saveProduct"/> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + <!-- Delete category --> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAdvanceCatalogSearchDownloadableBySkuWithHyphenTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAdvanceCatalogSearchDownloadableBySkuWithHyphenTest.xml new file mode 100644 index 000000000000..7c415a8edccc --- /dev/null +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAdvanceCatalogSearchDownloadableBySkuWithHyphenTest.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + --> + + <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchDownloadableBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="Downloadable"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Downloadable product with product sku that contains hyphen"/> + <description value="Guest customer should be able to advance search Downloadable product with product that contains hyphen"/> + <severity value="MAJOR"/> + <testCaseId value="MC-252"/> + <group value="Downloadable"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + <createData entity="ApiDownloadableProduct" stepKey="product"/> + <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink1"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiDownloadableLink" stepKey="addDownloadableLink2"> + <requiredEntity createDataKey="product"/> + </createData> + </before> + <after> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + </after> + </test> + </tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/VerifyDisableDownloadableProductSamplesAreNotAccessibleTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/VerifyDisableDownloadableProductSamplesAreNotAccessibleTest.xml index f29bbcf925e2..ba2e3453a6d9 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/VerifyDisableDownloadableProductSamplesAreNotAccessibleTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/VerifyDisableDownloadableProductSamplesAreNotAccessibleTest.xml @@ -21,6 +21,9 @@ <group value="catalog"/> </annotations> <before> + <!-- Add downloadable domains --> + <magentoCLI stepKey="addDownloadableDomain" command="downloadable:domains:add example.com static.magento.com"/> + <!-- Create category --> <createData entity="_defaultCategory" stepKey="createCategory"/> @@ -40,6 +43,9 @@ </createData> </before> <after> + <!-- Remove downloadable domains --> + <magentoCLI stepKey="removeDownloadableDomain" command="downloadable:domains:remove example.com static.magento.com"/> + <!-- Delete product --> <deleteData createDataKey="createProduct" stepKey="deleteDownloadableProduct"/> diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php index 25a5d86b0385..55353c16b472 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/DownloadableTest.php @@ -7,6 +7,9 @@ use Magento\Catalog\Api\Data\ProductExtensionInterface; +/** + * Unit tests for \Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable. + */ class DownloadableTest extends \PHPUnit\Framework\TestCase { /** @@ -34,12 +37,20 @@ class DownloadableTest extends \PHPUnit\Framework\TestCase */ private $extensionAttributesMock; + /** + * @var \Magento\Downloadable\Model\Product\Type|\Magento\Catalog\Api\Data\ProductExtensionInterface + */ + private $downloadableProductTypeMock; + + /** + * @inheritdoc + */ protected function setUp() { $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->productMock = $this->createPartialMock( \Magento\Catalog\Model\Product::class, - ['setDownloadableData', 'getExtensionAttributes', '__wakeup'] + ['setDownloadableData', 'getExtensionAttributes', '__wakeup', 'getTypeInstance'] ); $this->subjectMock = $this->createMock( \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper::class @@ -62,6 +73,10 @@ protected function setUp() $sampleBuilderMock = $this->getMockBuilder(\Magento\Downloadable\Model\Sample\Builder::class) ->disableOriginalConstructor() ->getMock(); + $this->downloadableProductTypeMock = $this->createPartialMock( + \Magento\Downloadable\Model\Product\Type::class, + ['getLinks', 'getSamples'] + ); $this->downloadablePlugin = new \Magento\Downloadable\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Downloadable( $this->requestMock, @@ -86,6 +101,11 @@ public function testAfterInitializeWithNoDataToSave($downloadable) $this->productMock->expects($this->once()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); + $this->productMock->expects($this->exactly(2)) + ->method('getTypeInstance') + ->willReturn($this->downloadableProductTypeMock); + $this->downloadableProductTypeMock->expects($this->once())->method('getLinks')->willReturn([]); + $this->downloadableProductTypeMock->expects($this->once())->method('getSamples')->willReturn([]); $this->extensionAttributesMock->expects($this->once()) ->method('setDownloadableProductLinks') ->with([]); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php index 2639c22ff2ca..152e3699f969 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Link/ContentValidatorTest.php @@ -5,8 +5,12 @@ */ namespace Magento\Downloadable\Test\Unit\Model\Link; +use Magento\Downloadable\Helper\File; use Magento\Downloadable\Model\Link\ContentValidator; +/** + * Unit tests for Magento\Downloadable\Model\Link\ContentValidator. + */ class ContentValidatorTest extends \PHPUnit\Framework\TestCase { /** @@ -24,6 +28,11 @@ class ContentValidatorTest extends \PHPUnit\Framework\TestCase */ protected $urlValidatorMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + protected $domainValidatorMock; + /** * @var \PHPUnit_Framework_MockObject_MockObject */ @@ -34,13 +43,34 @@ class ContentValidatorTest extends \PHPUnit\Framework\TestCase */ protected $sampleFileMock; + /** + * @var File|\PHPUnit_Framework_MockObject_MockObject + */ + private $fileMock; + + /** + * @inheritdoc + */ protected function setUp() { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->fileValidatorMock = $this->createMock(\Magento\Downloadable\Model\File\ContentValidator::class); $this->urlValidatorMock = $this->createMock(\Magento\Framework\Url\Validator::class); + $this->domainValidatorMock = $this->createMock(\Magento\Downloadable\Model\Url\DomainValidator::class); $this->linkFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); $this->sampleFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); - $this->validator = new ContentValidator($this->fileValidatorMock, $this->urlValidatorMock); + $this->fileMock = $this->createMock(File::class); + + $this->validator = $objectManager->getObject( + ContentValidator::class, + [ + 'fileContentValidator' => $this->fileValidatorMock, + 'urlValidator' => $this->urlValidatorMock, + 'fileHelper' => $this->fileMock, + 'domainValidator' => $this->domainValidatorMock, + ] + ); } public function testIsValid() @@ -60,6 +90,7 @@ public function testIsValid() ]; $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $linkMock = $this->getLinkMock($linkData); $this->assertTrue($this->validator->isValid($linkMock)); } @@ -80,6 +111,7 @@ public function testIsValidSkipLinkContent() ]; $this->fileValidatorMock->expects($this->once())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->never())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->never())->method('isValid')->will($this->returnValue(true)); $linkMock = $this->getLinkMock($linkData); $this->assertTrue($this->validator->isValid($linkMock, false)); } @@ -100,6 +132,7 @@ public function testIsValidSkipSampleContent() ]; $this->fileValidatorMock->expects($this->never())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->once())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->once())->method('isValid')->will($this->returnValue(true)); $linkMock = $this->getLinkMock($linkData); $this->assertTrue($this->validator->isValid($linkMock, true, false)); } @@ -123,6 +156,7 @@ public function testIsValidThrowsExceptionIfSortOrderIsInvalid($sortOrder) ]; $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $contentMock = $this->getLinkMock($linkContentData); $this->validator->isValid($contentMock); } @@ -158,6 +192,7 @@ public function testIsValidThrowsExceptionIfPriceIsInvalid($price) ]; $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $contentMock = $this->getLinkMock($linkContentData); $this->validator->isValid($contentMock); } @@ -191,6 +226,7 @@ public function testIsValidThrowsExceptionIfNumberOfDownloadsIsInvalid($numberOf 'sample_type' => 'file', ]; $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); + $this->domainValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $contentMock = $this->getLinkMock($linkContentData); $this->validator->isValid($contentMock); @@ -223,45 +259,29 @@ protected function getLinkMock(array $linkData) 'isShareable', 'getNumberOfDownloads', 'getLinkType', - 'getLinkFile' + 'getLinkFile', ] ) ->getMockForAbstractClass(); - $linkMock->expects($this->any())->method('getTitle')->will($this->returnValue( - $linkData['title'] - )); - $linkMock->expects($this->any())->method('getPrice')->will($this->returnValue( - $linkData['price'] - )); - $linkMock->expects($this->any())->method('getSortOrder')->will($this->returnValue( - $linkData['sort_order'] - )); - $linkMock->expects($this->any())->method('isShareable')->will($this->returnValue( - $linkData['shareable'] - )); - $linkMock->expects($this->any())->method('getNumberOfDownloads')->will($this->returnValue( - $linkData['number_of_downloads'] - )); - $linkMock->expects($this->any())->method('getLinkType')->will($this->returnValue( - $linkData['link_type'] - )); - $linkMock->expects($this->any())->method('getLinkFile')->will($this->returnValue( - $this->linkFileMock - )); + $linkMock->expects($this->any())->method('getTitle')->will($this->returnValue($linkData['title'])); + $linkMock->expects($this->any())->method('getPrice')->will($this->returnValue($linkData['price'])); + $linkMock->expects($this->any())->method('getSortOrder')->will($this->returnValue($linkData['sort_order'])); + $linkMock->expects($this->any())->method('isShareable')->will($this->returnValue($linkData['shareable'])); + $linkMock->expects($this->any())->method('getNumberOfDownloads')->will( + $this->returnValue($linkData['number_of_downloads']) + ); + $linkMock->expects($this->any())->method('getLinkType')->will($this->returnValue($linkData['link_type'])); + $linkMock->expects($this->any())->method('getLinkFile')->will($this->returnValue($this->linkFileMock)); if (isset($linkData['link_url'])) { - $linkMock->expects($this->any())->method('getLinkUrl')->will($this->returnValue( - $linkData['link_url'] - )); + $linkMock->expects($this->any())->method('getLinkUrl')->will($this->returnValue($linkData['link_url'])); } if (isset($linkData['sample_url'])) { - $linkMock->expects($this->any())->method('getSampleUrl')->will($this->returnValue( - $linkData['sample_url'] - )); + $linkMock->expects($this->any())->method('getSampleUrl')->will($this->returnValue($linkData['sample_url'])); } if (isset($linkData['sample_type'])) { - $linkMock->expects($this->any())->method('getSampleType')->will($this->returnValue( - $linkData['sample_type'] - )); + $linkMock->expects($this->any())->method('getSampleType')->will( + $this->returnValue($linkData['sample_type']) + ); } if (isset($linkData['link_file_content'])) { $linkMock->expects($this->any())->method('getLinkFileContent')->willReturn($linkData['link_file_content']); @@ -270,9 +290,8 @@ protected function getLinkMock(array $linkData) $linkMock->expects($this->any())->method('getSampleFileContent') ->willReturn($linkData['sample_file_content']); } - $linkMock->expects($this->any())->method('getSampleFile')->will($this->returnValue( - $this->sampleFileMock - )); + $linkMock->expects($this->any())->method('getSampleFile')->will($this->returnValue($this->sampleFileMock)); + return $linkMock; } } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php index 821f251929f8..25f720f27150 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/LinkRepositoryTest.php @@ -98,7 +98,9 @@ protected function setUp() \Magento\Framework\Json\EncoderInterface::class ); $this->linkFactoryMock = $this->createPartialMock(\Magento\Downloadable\Model\LinkFactory::class, ['create']); - $this->productMock = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [ + $this->productMock = $this->createPartialMock( + \Magento\Catalog\Model\Product::class, + [ '__wakeup', 'getTypeId', 'setDownloadableData', @@ -107,8 +109,9 @@ protected function setUp() 'getStoreId', 'getStore', 'getWebsiteIds', - 'getData' - ]); + 'getData', + ] + ); $this->service = new \Magento\Downloadable\Model\LinkRepository( $this->repositoryMock, $this->productTypeMock, @@ -162,7 +165,8 @@ protected function getLinkMock(array $linkData) 'getNumberOfDownloads', 'getIsShareable', 'getLinkUrl', - 'getLinkFile' + 'getLinkFile', + 'hasSampleType', ] ) ->getMockForAbstractClass(); @@ -309,12 +313,15 @@ public function testUpdate() $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->productMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $existingLinkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ + $existingLinkMock = $this->createPartialMock( + \Magento\Downloadable\Model\Link::class, + [ '__wakeup', 'getId', 'load', - 'getProductId' - ]); + 'getProductId', + ] + ); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($existingLinkMock)); $linkMock = $this->getLinkMock($linkData); $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkMock) @@ -371,12 +378,15 @@ public function testUpdateWithExistingFile() $storeMock = $this->createMock(\Magento\Store\Model\Store::class); $storeMock->expects($this->any())->method('getWebsiteId')->will($this->returnValue($websiteId)); $this->productMock->expects($this->any())->method('getStore')->will($this->returnValue($storeMock)); - $existingLinkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ + $existingLinkMock = $this->createPartialMock( + \Magento\Downloadable\Model\Link::class, + [ '__wakeup', 'getId', 'load', - 'getProductId' - ]); + 'getProductId', + ] + ); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($existingLinkMock)); $linkMock = $this->getLinkMock($linkData); $this->contentValidatorMock->expects($this->any())->method('isValid')->with($linkMock) @@ -436,6 +446,8 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() 'price' => 10.1, 'number_of_downloads' => 100, 'is_shareable' => true, + 'link_type' => 'url', + 'link_url' => 'https://google.com', ]; $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); @@ -501,10 +513,12 @@ public function testGetList() 'sample_file' => '/r/o/rock.melody.ogg', 'link_type' => 'url', 'link_url' => 'http://link.url', - 'link_file' => null + 'link_file' => null, ]; - $linkMock = $this->createPartialMock(\Magento\Downloadable\Model\Link::class, [ + $linkMock = $this->createPartialMock( + \Magento\Downloadable\Model\Link::class, + [ 'getId', 'getStoreTitle', 'getTitle', @@ -519,8 +533,9 @@ public function testGetList() 'getSampleUrl', 'getLinkType', 'getLinkFile', - 'getLinkUrl' - ]); + 'getLinkUrl', + ] + ); $linkInterfaceMock = $this->createMock(\Magento\Downloadable\Api\Data\LinkInterface::class); diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php index c863fb7ad62f..4a32a45859ce 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/Sample/ContentValidatorTest.php @@ -6,7 +6,11 @@ namespace Magento\Downloadable\Test\Unit\Model\Sample; use Magento\Downloadable\Model\Sample\ContentValidator; +use Magento\Downloadable\Helper\File; +/** + * Unit tests for Magento\Downloadable\Model\Sample\ContentValidator. + */ class ContentValidatorTest extends \PHPUnit\Framework\TestCase { /** @@ -34,12 +38,31 @@ class ContentValidatorTest extends \PHPUnit\Framework\TestCase */ protected $sampleFileMock; + /** + * @var File|\PHPUnit_Framework_MockObject_MockObject + */ + private $fileMock; + + /** + * @inheritdoc + */ protected function setUp() { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->fileValidatorMock = $this->createMock(\Magento\Downloadable\Model\File\ContentValidator::class); $this->urlValidatorMock = $this->createMock(\Magento\Framework\Url\Validator::class); $this->sampleFileMock = $this->createMock(\Magento\Downloadable\Api\Data\File\ContentInterface::class); - $this->validator = new ContentValidator($this->fileValidatorMock, $this->urlValidatorMock); + $this->fileMock = $this->createMock(File::class); + + $this->validator = $objectManager->getObject( + ContentValidator::class, + [ + 'fileContentValidator' => $this->fileValidatorMock, + 'urlValidator' => $this->urlValidatorMock, + 'fileHelper' => $this->fileMock, + ] + ); } public function testIsValid() @@ -94,28 +117,29 @@ public function getInvalidSortOrder() protected function getSampleContentMock(array $sampleContentData) { $contentMock = $this->createMock(\Magento\Downloadable\Api\Data\SampleInterface::class); - $contentMock->expects($this->any())->method('getTitle')->will($this->returnValue( - $sampleContentData['title'] - )); - - $contentMock->expects($this->any())->method('getSortOrder')->will($this->returnValue( - $sampleContentData['sort_order'] - )); - $contentMock->expects($this->any())->method('getSampleType')->will($this->returnValue( - $sampleContentData['sample_type'] - )); + $contentMock->expects($this->any())->method('getTitle')->will( + $this->returnValue($sampleContentData['title']) + ); + + $contentMock->expects($this->any())->method('getSortOrder')->will( + $this->returnValue($sampleContentData['sort_order']) + ); + $contentMock->expects($this->any())->method('getSampleType')->will( + $this->returnValue($sampleContentData['sample_type']) + ); if (isset($sampleContentData['sample_url'])) { - $contentMock->expects($this->any())->method('getSampleUrl')->will($this->returnValue( - $sampleContentData['sample_url'] - )); + $contentMock->expects($this->any())->method('getSampleUrl')->will( + $this->returnValue($sampleContentData['sample_url']) + ); } if (isset($sampleContentData['sample_file_content'])) { $contentMock->expects($this->any())->method('getSampleFileContent') ->willReturn($sampleContentData['sample_file_content']); } - $contentMock->expects($this->any())->method('getSampleFile')->will($this->returnValue( - $this->sampleFileMock - )); + $contentMock->expects($this->any())->method('getSampleFile')->will( + $this->returnValue($this->sampleFileMock) + ); + return $contentMock; } } diff --git a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php index 8e13bd83b039..f1674c6838a2 100644 --- a/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php +++ b/app/code/Magento/Downloadable/Test/Unit/Model/SampleRepositoryTest.php @@ -149,25 +149,26 @@ protected function getSampleMock(array $sampleData) $sampleMock->expects($this->any())->method('getId')->willReturn($sampleData['id']); } $sampleMock->expects($this->any())->method('getTitle')->will($this->returnValue($sampleData['title'])); - $sampleMock->expects($this->any())->method('getSortOrder')->will($this->returnValue( - $sampleData['sort_order'] - )); + $sampleMock->expects($this->any())->method('getSortOrder')->will( + $this->returnValue($sampleData['sort_order']) + ); if (isset($sampleData['sample_type'])) { - $sampleMock->expects($this->any())->method('getSampleType')->will($this->returnValue( - $sampleData['sample_type'] - )); + $sampleMock->expects($this->any())->method('getSampleType')->will( + $this->returnValue($sampleData['sample_type']) + ); } if (isset($sampleData['sample_url'])) { - $sampleMock->expects($this->any())->method('getSampleUrl')->will($this->returnValue( - $sampleData['sample_url'] - )); + $sampleMock->expects($this->any())->method('getSampleUrl')->will( + $this->returnValue($sampleData['sample_url']) + ); } if (isset($sampleData['sample_file'])) { - $sampleMock->expects($this->any())->method('getSampleFile')->will($this->returnValue( - $sampleData['sample_file'] - )); + $sampleMock->expects($this->any())->method('getSampleFile')->will( + $this->returnValue($sampleData['sample_file']) + ); } + return $sampleMock; } @@ -353,6 +354,8 @@ public function testUpdateThrowsExceptionIfTitleIsEmptyAndScopeIsGlobal() 'id' => $sampleId, 'title' => '', 'sort_order' => 1, + 'sample_type' => 'url', + 'sample_url' => 'https://google.com', ]; $this->repositoryMock->expects($this->any())->method('get')->with($productSku, true) ->will($this->returnValue($this->productMock)); @@ -414,10 +417,12 @@ public function testGetList() 'sort_order' => 21, 'sample_type' => 'file', 'sample_url' => null, - 'sample_file' => '/r/o/rock.melody.ogg' + 'sample_file' => '/r/o/rock.melody.ogg', ]; - $sampleMock = $this->createPartialMock(\Magento\Downloadable\Model\Sample::class, [ + $sampleMock = $this->createPartialMock( + \Magento\Downloadable\Model\Sample::class, + [ 'getId', 'getStoreTitle', 'getTitle', @@ -426,8 +431,9 @@ public function testGetList() 'getSampleUrl', 'getSortOrder', 'getData', - '__wakeup' - ]); + '__wakeup', + ] + ); $sampleInterfaceMock = $this->createMock(\Magento\Downloadable\Api\Data\SampleInterface::class); diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Links.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Links.php index f29708cc9a2c..0a3ea2fc6ba1 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Links.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Links.php @@ -13,6 +13,7 @@ use Magento\Framework\UrlInterface; use Magento\Downloadable\Model\Link as LinkModel; use Magento\Downloadable\Api\Data\LinkInterface; +use Magento\Framework\Exception\ValidatorException; /** * Class Links @@ -155,7 +156,7 @@ protected function addSampleFile(array $linkData, LinkInterface $link) $sampleFile = $link->getSampleFile(); if ($sampleFile) { $file = $this->downloadableFile->getFilePath($this->linkModel->getBaseSamplePath(), $sampleFile); - if ($this->downloadableFile->ensureFileInFilesystem($file)) { + if ($this->isLinkFileValid($file)) { $linkData['sample']['file'][0] = [ 'file' => $sampleFile, 'name' => $this->downloadableFile->getFileFromPathFile($sampleFile), @@ -184,7 +185,7 @@ protected function addLinkFile(array $linkData, LinkInterface $link) $linkFile = $link->getLinkFile(); if ($linkFile) { $file = $this->downloadableFile->getFilePath($this->linkModel->getBasePath(), $linkFile); - if ($this->downloadableFile->ensureFileInFilesystem($file)) { + if ($this->isLinkFileValid($file)) { $linkData['file'][0] = [ 'file' => $linkFile, 'name' => $this->downloadableFile->getFileFromPathFile($linkFile), @@ -201,6 +202,21 @@ protected function addLinkFile(array $linkData, LinkInterface $link) return $linkData; } + /** + * Check that Links File or Sample is valid. + * + * @param string $file + * @return bool + */ + private function isLinkFileValid(string $file): bool + { + try { + return $this->downloadableFile->ensureFileInFilesystem($file); + } catch (ValidatorException $e) { + return false; + } + } + /** * Return formatted price with two digits after decimal point * diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Samples.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Samples.php index b000de487b77..988f429de1d8 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Samples.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Data/Samples.php @@ -11,6 +11,7 @@ use Magento\Catalog\Model\Locator\LocatorInterface; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Downloadable\Helper\File as DownloadableFile; +use Magento\Framework\Exception\ValidatorException; use Magento\Framework\UrlInterface; use Magento\Downloadable\Api\Data\SampleInterface; @@ -136,7 +137,7 @@ protected function addSampleFile(array $sampleData, SampleInterface $sample) $sampleFile = $sample->getSampleFile(); if ($sampleFile) { $file = $this->downloadableFile->getFilePath($this->sampleModel->getBasePath(), $sampleFile); - if ($this->downloadableFile->ensureFileInFilesystem($file)) { + if ($this->isSampleFileValid($file)) { $sampleData['file'][0] = [ 'file' => $sampleFile, 'name' => $this->downloadableFile->getFileFromPathFile($sampleFile), @@ -152,4 +153,19 @@ protected function addSampleFile(array $sampleData, SampleInterface $sample) return $sampleData; } + + /** + * Check that Sample file is valid. + * + * @param string $file + * @return bool + */ + private function isSampleFileValid(string $file): bool + { + try { + return $this->downloadableFile->ensureFileInFilesystem($file); + } catch (ValidatorException $e) { + return false; + } + } } diff --git a/app/code/Magento/Downloadable/etc/db_schema.xml b/app/code/Magento/Downloadable/etc/db_schema.xml index ccbefa4fb399..ee7b3c5683ea 100644 --- a/app/code/Magento/Downloadable/etc/db_schema.xml +++ b/app/code/Magento/Downloadable/etc/db_schema.xml @@ -233,7 +233,7 @@ <column name="website_id"/> </constraint> </table> - <table name="catalog_product_index_price_downlod_tmp" resource="default" engine="memory" + <table name="catalog_product_index_price_downlod_tmp" resource="default" engine="innodb" comment="Temporary Indexer Table for price of downloadable products"> <column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="false" comment="Entity ID"/> diff --git a/app/code/Magento/Downloadable/etc/di.xml b/app/code/Magento/Downloadable/etc/di.xml index 4e9b0b55afb0..a932e5598f8a 100644 --- a/app/code/Magento/Downloadable/etc/di.xml +++ b/app/code/Magento/Downloadable/etc/di.xml @@ -92,6 +92,7 @@ <preference for="Magento\Downloadable\Api\Data\File\ContentUploaderInterface" type="Magento\Downloadable\Model\File\ContentUploader" /> <preference for="Magento\Downloadable\Model\Product\TypeHandler\TypeHandlerInterface" type="Magento\Downloadable\Model\Product\TypeHandler\TypeHandler" /> <preference for="Magento\Downloadable\Api\Data\DownloadableOptionInterface" type="Magento\Downloadable\Model\DownloadableOption" /> + <preference for="Magento\Downloadable\Api\DomainManagerInterface" type="Magento\Downloadable\Model\DomainManager"/> <type name="Magento\Framework\EntityManager\Operation\ExtensionPool"> <arguments> <argument name="extensionActions" xsi:type="array"> @@ -164,4 +165,13 @@ <argument name="connectionName" xsi:type="string">indexer</argument> </arguments> </type> + <type name="Magento\Framework\Console\CommandListInterface"> + <arguments> + <argument name="commands" xsi:type="array"> + <item name="addDomainsCommand" xsi:type="object">Magento\Downloadable\Console\Command\DomainsAddCommand</item> + <item name="removeDomainsCommand" xsi:type="object">Magento\Downloadable\Console\Command\DomainsRemoveCommand</item> + <item name="showDomainsCommand" xsi:type="object">Magento\Downloadable\Console\Command\DomainsShowCommand</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Downloadable/i18n/en_US.csv b/app/code/Magento/Downloadable/i18n/en_US.csv index 87427bf48396..1e96413aa08a 100644 --- a/app/code/Magento/Downloadable/i18n/en_US.csv +++ b/app/code/Magento/Downloadable/i18n/en_US.csv @@ -118,3 +118,5 @@ Downloads,Downloads "Use Content-Disposition","Use Content-Disposition" "Disable Guest Checkout if Cart Contains Downloadable Items","Disable Guest Checkout if Cart Contains Downloadable Items" "Guest checkout will only work with shareable.","Guest checkout will only work with shareable." +"Link URL's domain is not in list of downloadable_domains in env.php.","Link URL's domain is not in list of downloadable_domains in env.php." +"Sample URL's domain is not in list of downloadable_domains in env.php.","Sample URL's domain is not in list of downloadable_domains in env.php." diff --git a/app/code/Magento/Downloadable/view/frontend/web/js/downloadable.js b/app/code/Magento/Downloadable/view/frontend/web/js/downloadable.js index a1e8c785c696..8bdea0b3a70b 100644 --- a/app/code/Magento/Downloadable/view/frontend/web/js/downloadable.js +++ b/app/code/Magento/Downloadable/view/frontend/web/js/downloadable.js @@ -12,12 +12,17 @@ define([ ], function ($) { 'use strict'; + /** + * Downloadable widget + */ $.widget('mage.downloadable', { options: { priceHolderSelector: '.price-box' }, - /** @inheritdoc */ + /** + * @inheritdoc + */ _create: function () { var self = this; @@ -65,6 +70,32 @@ define([ } } }); + + this.reloadAllCheckText(); + }, + + /** + * Reload all-elements-checkbox's label + * @private + */ + reloadAllCheckText: function () { + var allChecked = true, + allElementsCheck = $(this.options.allElements), + allElementsLabel = $('label[for="' + allElementsCheck.attr('id') + '"] > span'); + + $(this.options.linkElement).each(function () { + if (!this.checked) { + allChecked = false; + } + }); + + if (allChecked) { + allElementsLabel.text(allElementsCheck.attr('data-checked')); + allElementsCheck.prop('checked', true); + } else { + allElementsLabel.text(allElementsCheck.attr('data-notchecked')); + allElementsCheck.prop('checked', false); + } } }); diff --git a/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php b/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php index 18f883b61516..5f159971e4a1 100644 --- a/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php +++ b/app/code/Magento/DownloadableGraphQl/Model/Cart/BuyRequest/DownloadableLinksDataProvider.php @@ -40,12 +40,7 @@ public function execute(array $cartItemData): array if (isset($cartItemData['data']) && isset($cartItemData['data']['sku'])) { $sku = $cartItemData['data']['sku']; - - try { - $product = $this->productRepository->get($sku); - } catch (NoSuchEntityException $e) { - throw new GraphQlNoSuchEntityException(__('Could not find specified product.')); - } + $product = $this->productRepository->get($sku); if ($product->getLinksPurchasedSeparately() && isset($cartItemData['downloadable_product_links'])) { $downloadableLinks = $cartItemData['downloadable_product_links']; diff --git a/app/code/Magento/DownloadableGraphQl/etc/schema.graphqls b/app/code/Magento/DownloadableGraphQl/etc/schema.graphqls index db452d1e5ace..ecadd031ab58 100644 --- a/app/code/Magento/DownloadableGraphQl/etc/schema.graphqls +++ b/app/code/Magento/DownloadableGraphQl/etc/schema.graphqls @@ -43,7 +43,7 @@ enum DownloadableFileTypeEnum @deprecated(reason: "`sample_url` serves to get th } type DownloadableProductLinks @doc(description: "DownloadableProductLinks defines characteristics of a downloadable product") { - id: Int @deprecated(reason: "This information shoud not be exposed on frontend") + id: Int @deprecated(reason: "This information should not be exposed on frontend") title: String @doc(description: "The display name of the link") sort_order: Int @doc(description: "A number indicating the sort order") price: Float @doc(description: "The price of the downloadable product") @@ -56,7 +56,7 @@ type DownloadableProductLinks @doc(description: "DownloadableProductLinks define } type DownloadableProductSamples @doc(description: "DownloadableProductSamples defines characteristics of a downloadable product") { - id: Int @deprecated(reason: "This information shoud not be exposed on frontend") + id: Int @deprecated(reason: "This information should not be exposed on frontend") title: String @doc(description: "The display name of the sample") sort_order: Int @doc(description: "A number indicating the sort order") sample_url: String @doc(description: "URL to the downloadable sample") diff --git a/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php b/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php index e03964bd2c38..c9cdf52f55dd 100644 --- a/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php +++ b/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php @@ -8,12 +8,14 @@ namespace Magento\DownloadableImportExport\Model\Import\Product\Type; use Magento\CatalogImportExport\Model\Import\Product as ImportProduct; +use Magento\Downloadable\Model\Url\DomainValidator; use Magento\Framework\EntityManager\MetadataPool; use \Magento\Store\Model\Store; /** * Class Downloadable * + * phpcs:disable Magento2.Commenting.ConstantsPHPDocFormatting * @SuppressWarnings(PHPMD.TooManyFields) */ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType @@ -101,6 +103,10 @@ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Typ const ERROR_COLS_IS_EMPTY = 'emptyOptions'; + private const ERROR_LINK_URL_NOT_IN_DOMAIN_WHITELIST = 'linkUrlNotInDomainWhitelist'; + + private const ERROR_SAMPLE_URL_NOT_IN_DOMAIN_WHITELIST = 'sampleUrlNotInDomainWhitelist'; + /** * Validation failure message template definitions * @@ -111,7 +117,11 @@ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Typ self::ERROR_GROUP_TITLE_NOT_FOUND => 'Group titles not found for downloadable products', self::ERROR_OPTION_NO_TITLE => 'Option no title', self::ERROR_MOVE_FILE => 'Error move file', - self::ERROR_COLS_IS_EMPTY => 'Missing sample and links data for the downloadable product' + self::ERROR_COLS_IS_EMPTY => 'Missing sample and links data for the downloadable product', + self::ERROR_LINK_URL_NOT_IN_DOMAIN_WHITELIST => + 'Link URL\'s domain is not in list of downloadable_domains in env.php.', + self::ERROR_SAMPLE_URL_NOT_IN_DOMAIN_WHITELIST => + 'Sample URL\'s domain is not in list of downloadable_domains in env.php.' ]; /** @@ -244,6 +254,11 @@ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Typ */ protected $downloadableHelper; + /** + * @var DomainValidator + */ + private $domainValidator; + /** * Downloadable constructor * @@ -253,6 +268,7 @@ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Typ * @param array $params * @param \Magento\DownloadableImportExport\Helper\Uploader $uploaderHelper * @param \Magento\DownloadableImportExport\Helper\Data $downloadableHelper + * @param DomainValidator $domainValidator * @param MetadataPool $metadataPool */ public function __construct( @@ -262,12 +278,14 @@ public function __construct( array $params, \Magento\DownloadableImportExport\Helper\Uploader $uploaderHelper, \Magento\DownloadableImportExport\Helper\Data $downloadableHelper, + DomainValidator $domainValidator, MetadataPool $metadataPool = null ) { parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params, $metadataPool); $this->parameters = $this->_entityModel->getParameters(); $this->_resource = $resource; $this->uploaderHelper = $uploaderHelper; + $this->domainValidator = $domainValidator; $this->downloadableHelper = $downloadableHelper; } @@ -336,17 +354,36 @@ public function isRowValid(array $rowData, $rowNum, $isNewProduct = true) */ protected function isRowValidSample(array $rowData) { - $result = false; - if (isset($rowData[self::COL_DOWNLOADABLE_SAMPLES]) - && $rowData[self::COL_DOWNLOADABLE_SAMPLES] != '' - && $this->sampleGroupTitle($rowData) == '') { - $this->_entityModel->addRowError(self::ERROR_GROUP_TITLE_NOT_FOUND, $this->rowNum); + $hasSampleLinkData = ( + isset($rowData[self::COL_DOWNLOADABLE_SAMPLES]) && + $rowData[self::COL_DOWNLOADABLE_SAMPLES] != '' + ); + + if (!$hasSampleLinkData) { + return false; + } + + $sampleData = $this->prepareSampleData($rowData[static::COL_DOWNLOADABLE_SAMPLES]); + + if ($this->sampleGroupTitle($rowData) == '') { $result = true; + $this->_entityModel->addRowError(self::ERROR_GROUP_TITLE_NOT_FOUND, $this->rowNum); } - if (isset($rowData[self::COL_DOWNLOADABLE_SAMPLES]) - && $rowData[self::COL_DOWNLOADABLE_SAMPLES] != '') { - $result = $this->isTitle($this->prepareSampleData($rowData[self::COL_DOWNLOADABLE_SAMPLES])); + + $result = $result ?? $this->isTitle($sampleData); + + foreach ($sampleData as $link) { + if ($this->hasDomainNotInWhitelist($link, 'link_type', 'link_url')) { + $this->_entityModel->addRowError(static::ERROR_LINK_URL_NOT_IN_DOMAIN_WHITELIST, $this->rowNum); + $result = true; + } + + if ($this->hasDomainNotInWhitelist($link, 'sample_type', 'sample_url')) { + $this->_entityModel->addRowError(static::ERROR_SAMPLE_URL_NOT_IN_DOMAIN_WHITELIST, $this->rowNum); + $result = true; + } } + return $result; } @@ -358,19 +395,36 @@ protected function isRowValidSample(array $rowData) */ protected function isRowValidLink(array $rowData) { - $result = false; - if (isset($rowData[self::COL_DOWNLOADABLE_LINKS]) && - $rowData[self::COL_DOWNLOADABLE_LINKS] != '' && - $this->linksAdditionalAttributes($rowData, 'group_title', self::DEFAULT_GROUP_TITLE) == '' - ) { + $hasLinkData = ( + isset($rowData[self::COL_DOWNLOADABLE_LINKS]) && + $rowData[self::COL_DOWNLOADABLE_LINKS] != '' + ); + + if (!$hasLinkData) { + return false; + } + + $linkData = $this->prepareLinkData($rowData[self::COL_DOWNLOADABLE_LINKS]); + + if ($this->linksAdditionalAttributes($rowData, 'group_title', self::DEFAULT_GROUP_TITLE) == '') { $this->_entityModel->addRowError(self::ERROR_GROUP_TITLE_NOT_FOUND, $this->rowNum); $result = true; } - if (isset($rowData[self::COL_DOWNLOADABLE_LINKS]) && - $rowData[self::COL_DOWNLOADABLE_LINKS] != '' - ) { - $result = $this->isTitle($this->prepareLinkData($rowData[self::COL_DOWNLOADABLE_LINKS])); + + $result = $result ?? $this->isTitle($linkData); + + foreach ($linkData as $link) { + if ($this->hasDomainNotInWhitelist($link, 'link_type', 'link_url')) { + $this->_entityModel->addRowError(static::ERROR_LINK_URL_NOT_IN_DOMAIN_WHITELIST, $this->rowNum); + $result = true; + } + + if ($this->hasDomainNotInWhitelist($link, 'sample_type', 'sample_url')) { + $this->_entityModel->addRowError(static::ERROR_SAMPLE_URL_NOT_IN_DOMAIN_WHITELIST, $this->rowNum); + $result = true; + } } + return $result; } @@ -733,6 +787,7 @@ protected function prepareSampleData($rowCol, $entityId = null) $rowCol ); foreach ($options as $option) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $result[] = array_merge( $this->dataSample, ['product_id' => $entityId], @@ -757,6 +812,7 @@ protected function prepareLinkData($rowCol, $entityId = null) $rowCol ); foreach ($options as $option) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $result[] = array_merge( $this->dataLink, ['product_id' => $entityId], @@ -829,6 +885,7 @@ protected function parseSampleOption($values) /** * Uploading files into the "downloadable/files" media folder. + * * Return a new file name if the same file is already exists. * * @param string $fileName @@ -861,4 +918,23 @@ protected function clear() $this->productIds = []; return $this; } + + /** + * Does link contain url not in whitelist? + * + * @param array $link + * @param string $linkTypeKey + * @param string $linkUrlKey + * @return bool + */ + private function hasDomainNotInWhitelist(array $link, string $linkTypeKey, string $linkUrlKey): bool + { + return ( + isset($link[$linkTypeKey]) && + $link[$linkTypeKey] === 'url' && + isset($link[$linkUrlKey]) && + strlen($link[$linkUrlKey]) && + !$this->domainValidator->isValid($link[$linkUrlKey]) + ); + } } diff --git a/app/code/Magento/Eav/Model/AttributeGroupSearchResults.php b/app/code/Magento/Eav/Model/AttributeGroupSearchResults.php new file mode 100644 index 000000000000..100d5638a96d --- /dev/null +++ b/app/code/Magento/Eav/Model/AttributeGroupSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Eav\Model; + +use Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Attribute Group search results. + */ +class AttributeGroupSearchResults extends SearchResults implements AttributeGroupSearchResultsInterface +{ +} diff --git a/app/code/Magento/Eav/Model/AttributeSearchResults.php b/app/code/Magento/Eav/Model/AttributeSearchResults.php new file mode 100644 index 000000000000..b82a27bbfea1 --- /dev/null +++ b/app/code/Magento/Eav/Model/AttributeSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Eav\Model; + +use Magento\Eav\Api\Data\AttributeSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Eav Attribute search results. + */ +class AttributeSearchResults extends SearchResults implements AttributeSearchResultsInterface +{ +} diff --git a/app/code/Magento/Eav/Model/AttributeSetSearchResults.php b/app/code/Magento/Eav/Model/AttributeSetSearchResults.php new file mode 100644 index 000000000000..46592efda5a1 --- /dev/null +++ b/app/code/Magento/Eav/Model/AttributeSetSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Eav\Model; + +use Magento\Eav\Api\Data\AttributeSetSearchResultsInterface; +use Magento\Framework\Api\SearchResults; + +/** + * Service Data Object with Attribute Set search results. + */ +class AttributeSetSearchResults extends SearchResults implements AttributeSetSearchResultsInterface +{ +} diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php index c5077733e10a..dbeb23231a85 100644 --- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php +++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php @@ -11,7 +11,9 @@ use Magento\Eav\Model\Entity\Attribute as EntityAttribute; use Magento\Framework\App\ObjectManager; use Magento\Framework\DB\Select; +use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Model\AbstractModel; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb; /** * EAV attribute resource model @@ -20,7 +22,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 100.0.2 */ -class Attribute extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb +class Attribute extends AbstractDb { /** * Eav Entity attributes cache @@ -189,6 +191,23 @@ protected function _beforeSave(AbstractModel $object) return parent::_beforeSave($object); } + /** + * @inheritdoc + * + * @param AbstractModel $attribute + * @return AbstractDb + * @throws CouldNotDeleteException + */ + protected function _beforeDelete(AbstractModel $attribute) + { + /** @var $attribute \Magento\Eav\Api\Data\AttributeInterface */ + if ($attribute->getId() && !$attribute->getIsUserDefined()) { + throw new CouldNotDeleteException(__("The system attribute can't be deleted.")); + } + + return parent::_beforeDelete($attribute); + } + /** * Save additional attribute data after save attribute * diff --git a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php index cd0d5141154c..15dcea077c88 100644 --- a/app/code/Magento/Eav/Model/Validator/Attribute/Data.php +++ b/app/code/Magento/Eav/Model/Validator/Attribute/Data.php @@ -4,15 +4,15 @@ * See COPYING.txt for license details. */ +namespace Magento\Eav\Model\Validator\Attribute; + +use Magento\Eav\Model\Attribute; + /** * EAV attribute data validator * * @author Magento Core Team <core@magentocommerce.com> */ -namespace Magento\Eav\Model\Validator\Attribute; - -use Magento\Eav\Model\Attribute; - class Data extends \Magento\Framework\Validator\AbstractValidator { /** @@ -126,7 +126,7 @@ public function isValid($entity) $dataModel = $this->_attrDataFactory->create($attribute, $entity); $dataModel->setExtractedData($data); if (!isset($data[$attributeCode])) { - $data[$attributeCode] = null; + $data[$attributeCode] = ''; } $result = $dataModel->validateValue($data[$attributeCode]); if (true !== $result) { diff --git a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php index 07ce6fbfc6a4..acba37cc4578 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php @@ -4,13 +4,54 @@ * See COPYING.txt for license details. */ +declare(strict_types=1); + +namespace Magento\Eav\Test\Unit\Model\Validator\Attribute; + /** * Test for \Magento\Eav\Model\Validator\Attribute\Data */ -namespace Magento\Eav\Test\Unit\Model\Validator\Attribute; - class DataTest extends \PHPUnit\Framework\TestCase { + /** + * @var \Magento\Eav\Model\AttributeDataFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $attrDataFactory; + + /** + * @var \Magento\Eav\Model\Validator\Attribute\Data + */ + private $model; + + /** + * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + */ + private $objectManager; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->attrDataFactory = $this->getMockBuilder(\Magento\Eav\Model\AttributeDataFactory::class) + ->setMethods(['create']) + ->setConstructorArgs( + [ + 'objectManager' => $this->createMock(\Magento\Framework\ObjectManagerInterface::class), + 'string' => $this->createMock(\Magento\Framework\Stdlib\StringUtils::class) + ] + ) + ->getMock(); + + $this->model = $this->objectManager->getObject( + \Magento\Eav\Model\Validator\Attribute\Data::class, + [ + '_attrDataFactory' => $this->attrDataFactory + ] + ); + } + /** * Testing \Magento\Eav\Model\Validator\Attribute\Data::isValid * @@ -381,13 +422,15 @@ public function testAddErrorMessages() protected function _getAttributeMock($attributeData) { $attribute = $this->getMockBuilder(\Magento\Eav\Model\Attribute::class) - ->setMethods([ - 'getAttributeCode', - 'getDataModel', - 'getFrontendInput', - '__wakeup', - 'getIsVisible', - ]) + ->setMethods( + [ + 'getAttributeCode', + 'getDataModel', + 'getFrontendInput', + '__wakeup', + 'getIsVisible', + ] + ) ->disableOriginalConstructor() ->getMock(); @@ -436,7 +479,7 @@ protected function _getDataModelMock($returnValue, $argument = null) $dataModel = $this->getMockBuilder( \Magento\Eav\Model\Attribute\Data\AbstractData::class )->disableOriginalConstructor()->setMethods( - ['validateValue'] + ['setExtractedData', 'validateValue'] )->getMockForAbstractClass(); if ($argument) { $dataModel->expects( @@ -466,4 +509,24 @@ protected function _getEntityMock() )->disableOriginalConstructor()->getMock(); return $entity; } + + /** + * Test for isValid() without data for attribute. + * + * @return void + */ + public function testIsValidWithoutData() : void + { + $attributeData = ['attribute_code' => 'attribute', 'frontend_input' => 'text', 'is_visible' => true]; + $entity = $this->_getEntityMock(); + $attribute = $this->_getAttributeMock($attributeData); + $dataModel = $this->_getDataModelMock(true, $this->logicalAnd($this->isEmpty(), $this->isType('string'))); + $dataModel->expects($this->once())->method('setExtractedData')->with([])->willReturnSelf(); + $this->attrDataFactory->expects($this->once()) + ->method('create') + ->with($attribute, $entity) + ->willReturn($dataModel); + $this->model->setAttributes([$attribute])->setData([]); + $this->assertTrue($this->model->isValid($entity)); + } } diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml index ba1c27c70379..407aa8976d68 100644 --- a/app/code/Magento/Eav/etc/db_schema.xml +++ b/app/code/Magento/Eav/etc/db_schema.xml @@ -458,6 +458,10 @@ <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_STORE_STORE_ID" table="eav_attribute_option_value" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_OPTION_ID"> + <column name="store_id"/> + <column name="option_id"/> + </constraint> <index referenceId="EAV_ATTRIBUTE_OPTION_VALUE_OPTION_ID" indexType="btree"> <column name="option_id"/> </index> @@ -481,6 +485,10 @@ referenceColumn="attribute_id" onDelete="CASCADE"/> <constraint xsi:type="foreign" referenceId="EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID" table="eav_attribute_label" column="store_id" referenceTable="store" referenceColumn="store_id" onDelete="CASCADE"/> + <constraint xsi:type="unique" referenceId="EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_STORE_ID_UNIQUE"> + <column name="store_id"/> + <column name="attribute_id"/> + </constraint> <index referenceId="EAV_ATTRIBUTE_LABEL_STORE_ID" indexType="btree"> <column name="store_id"/> </index> diff --git a/app/code/Magento/Eav/etc/db_schema_whitelist.json b/app/code/Magento/Eav/etc/db_schema_whitelist.json index b3f1aca50df0..1814c7ba2dbc 100644 --- a/app/code/Magento/Eav/etc/db_schema_whitelist.json +++ b/app/code/Magento/Eav/etc/db_schema_whitelist.json @@ -287,7 +287,8 @@ "constraint": { "PRIMARY": true, "EAV_ATTR_OPT_VAL_OPT_ID_EAV_ATTR_OPT_OPT_ID": true, - "EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_STORE_STORE_ID": true + "EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_STORE_STORE_ID": true, + "EAV_ATTRIBUTE_OPTION_VALUE_STORE_ID_OPTION_ID": true } }, "eav_attribute_label": { @@ -304,7 +305,8 @@ "constraint": { "PRIMARY": true, "EAV_ATTRIBUTE_LABEL_ATTRIBUTE_ID_EAV_ATTRIBUTE_ATTRIBUTE_ID": true, - "EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID": true + "EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID": true, + "EAV_ATTRIBUTE_LABEL_STORE_ID_ATTRIBUTE_ID": true } }, "eav_form_type": { diff --git a/app/code/Magento/Eav/etc/di.xml b/app/code/Magento/Eav/etc/di.xml index db6f9b0a64f9..a09dc2839985 100644 --- a/app/code/Magento/Eav/etc/di.xml +++ b/app/code/Magento/Eav/etc/di.xml @@ -22,9 +22,9 @@ <preference for="Magento\Eav\Api\AttributeOptionManagementInterface" type="Magento\Eav\Model\Entity\Attribute\OptionManagement" /> <preference for="Magento\Eav\Api\Data\AttributeOptionLabelInterface" type="Magento\Eav\Model\Entity\Attribute\OptionLabel" /> <preference for="Magento\Eav\Api\Data\AttributeValidationRuleInterface" type="Magento\Eav\Model\Entity\Attribute\ValidationRule" /> - <preference for="Magento\Eav\Api\Data\AttributeSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> - <preference for="Magento\Eav\Api\Data\AttributeSetSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> - <preference for="Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Eav\Api\Data\AttributeSearchResultsInterface" type="Magento\Eav\Model\AttributeSearchResults" /> + <preference for="Magento\Eav\Api\Data\AttributeSetSearchResultsInterface" type="Magento\Eav\Model\AttributeSetSearchResults" /> + <preference for="Magento\Eav\Api\Data\AttributeGroupSearchResultsInterface" type="Magento\Eav\Model\AttributeGroupSearchResults" /> <preference for="Magento\Framework\Webapi\CustomAttributeTypeLocatorInterface" type="Magento\Eav\Model\TypeLocator" /> <type name="Magento\Eav\Model\Entity\Attribute\Config"> diff --git a/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php b/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php index aac396f23835..ad52f81bf8ed 100644 --- a/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php +++ b/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/SearchResultApplier.php @@ -68,7 +68,6 @@ public function apply() foreach ($items as $item) { $ids[] = (int)$item->getId(); } - $this->collection->setPageSize(null); $this->collection->getSelect()->where('e.entity_id IN (?)', $ids); $orderList = join(',', $ids); $this->collection->getSelect()->reset(\Magento\Framework\DB\Select::ORDER); diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php index afd383c13421..ddf75c0a78e2 100644 --- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php +++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php @@ -138,7 +138,12 @@ protected function buildQueries(array $matches, array $queryValue) $transformedTypes = []; foreach ($matches as $match) { - $attributeAdapter = $this->attributeProvider->getByAttributeCode($match['field']); + $resolvedField = $this->fieldMapper->getFieldName( + $match['field'], + ['type' => FieldMapperInterface::TYPE_QUERY] + ); + + $attributeAdapter = $this->attributeProvider->getByAttributeCode($resolvedField); $fieldType = $this->fieldTypeResolver->getFieldType($attributeAdapter); $valueTransformer = $this->valueTransformerPool->get($fieldType ?? 'text'); $valueTransformerHash = \spl_object_hash($valueTransformer); @@ -151,10 +156,6 @@ protected function buildQueries(array $matches, array $queryValue) continue; } - $resolvedField = $this->fieldMapper->getFieldName( - $match['field'], - ['type' => FieldMapperInterface::TYPE_QUERY] - ); $conditions[] = [ 'condition' => $queryValue['condition'], 'body' => [ diff --git a/app/code/Magento/Elasticsearch/etc/di.xml b/app/code/Magento/Elasticsearch/etc/di.xml index 55df6a5a37f4..f42d957276d7 100644 --- a/app/code/Magento/Elasticsearch/etc/di.xml +++ b/app/code/Magento/Elasticsearch/etc/di.xml @@ -267,7 +267,7 @@ </type> <virtualType name="Magento\Elasticsearch\Elasticsearch5\SearchAdapter\ConnectionManager" type="Magento\Elasticsearch\SearchAdapter\ConnectionManager"> <arguments> - <argument name="clientFactory" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Client\ElasticsearchFactory</argument> + <argument name="clientFactory" xsi:type="object">Magento\Elasticsearch\Elasticsearch5\Model\Client\ClientFactoryProxy</argument> <argument name="clientConfig" xsi:type="object">Magento\Elasticsearch\Model\Config</argument> </arguments> </virtualType> diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Data/ConfigData.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/ConfigData.xml new file mode 100644 index 000000000000..f1f2f39f4457 --- /dev/null +++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/ConfigData.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="SearchEngineElasticsearchConfigData"> + <data key="path">catalog/search/engine</data> + <data key="scope_id">1</data> + <data key="label">Elasticsearch 6.0+</data> + <data key="value">elasticsearch6</data> + </entity> +</entities> diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Suite/SearchEngineElasticsearchSuite.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Suite/SearchEngineElasticsearchSuite.xml new file mode 100644 index 000000000000..d612f5bd17a2 --- /dev/null +++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Suite/SearchEngineElasticsearchSuite.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd"> + <suite name="SearchEngineElasticsearchSuite"> + <before> + <magentoCLI stepKey="setSearchEngineToElasticsearch" command="config:set {{SearchEngineElasticsearchConfigData.path}} {{SearchEngineElasticsearchConfigData.value}}"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after></after> + <include> + <group name="SearchEngineElasticsearch" /> + </include> + <exclude> + <group name="skip"/> + </exclude> + </suite> +</suites> diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php index 0ca6615b075b..ec5596e2194a 100644 --- a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php +++ b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php @@ -3,12 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); -/** - * Adminhtml system template preview block - * - * @author Magento Core Team <core@magentocommerce.com> - */ namespace Magento\Email\Block\Adminhtml\Template; /** @@ -55,19 +51,22 @@ public function __construct( * Prepare html output * * @return string + * @throws \Exception */ protected function _toHtml() { + $request = $this->getRequest(); + $storeId = $this->getAnyStoreView()->getId(); /** @var $template \Magento\Email\Model\Template */ $template = $this->_emailFactory->create(); - if ($id = (int)$this->getRequest()->getParam('id')) { + if ($id = (int)$request->getParam('id')) { $template->load($id); } else { - $template->setTemplateType($this->getRequest()->getParam('type')); - $template->setTemplateText($this->getRequest()->getParam('text')); - $template->setTemplateStyles($this->getRequest()->getParam('styles')); + $template->setTemplateType($request->getParam('type')); + $template->setTemplateText($request->getParam('text')); + $template->setTemplateStyles($request->getParam('styles')); } \Magento\Framework\Profiler::start($this->profilerName); diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php index 31d172935da7..4f36eedd09b8 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php @@ -7,12 +7,12 @@ namespace Magento\Email\Controller\Adminhtml\Email\Template; -use Magento\Framework\App\Action\HttpGetActionInterface; +use Magento\Framework\App\Action\HttpPostActionInterface; /** * Rendering popup email template. */ -class Popup extends \Magento\Backend\App\Action implements HttpGetActionInterface +class Popup extends \Magento\Backend\App\Action implements HttpPostActionInterface { /** * @var \Magento\Framework\View\Result\PageFactory diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php index c1a8eec07e46..a92836b2995a 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php @@ -4,19 +4,21 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Email\Controller\Adminhtml\Email\Template; +use Magento\Email\Controller\Adminhtml\Email\Template; use Magento\Framework\App\Action\HttpGetActionInterface; +use Magento\Framework\App\Action\HttpPostActionInterface; /** * Rendering email template preview. */ -class Preview extends \Magento\Email\Controller\Adminhtml\Email\Template implements HttpGetActionInterface +class Preview extends Template implements HttpGetActionInterface, HttpPostActionInterface { /** * Preview transactional email action. - * - * @return void */ public function execute() { @@ -24,7 +26,6 @@ public function execute() $this->_view->loadLayout(); $this->_view->getPage()->getConfig()->getTitle()->prepend(__('Email Preview')); $this->_view->renderLayout(); - $this->getResponse()->setHeader('Content-Security-Policy', "script-src 'self'"); } catch (\Exception $e) { $this->messageManager->addErrorMessage( __('An error occurred. The email template can not be opened for preview.') diff --git a/app/code/Magento/Email/Model/Transport.php b/app/code/Magento/Email/Model/Transport.php index cbce1682cb5f..79ceb56a8834 100644 --- a/app/code/Magento/Email/Model/Transport.php +++ b/app/code/Magento/Email/Model/Transport.php @@ -9,7 +9,6 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Exception\MailException; -use Magento\Framework\Mail\EmailMessageInterface; use Magento\Framework\Mail\MessageInterface; use Magento\Framework\Mail\TransportInterface; use Magento\Framework\Phrase; @@ -62,12 +61,12 @@ class Transport implements TransportInterface private $message; /** - * @param EmailMessageInterface $message Email message object + * @param MessageInterface $message Email message object * @param ScopeConfigInterface $scopeConfig Core store config * @param null|string|array|\Traversable $parameters Config options for sendmail parameters */ public function __construct( - EmailMessageInterface $message, + MessageInterface $message, ScopeConfigInterface $scopeConfig, $parameters = null ) { diff --git a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml index 1155930dd75e..3b99ade32e6c 100644 --- a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml +++ b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml @@ -21,7 +21,7 @@ <amOnPage url="{{AdminEmailTemplateIndexPage.url}}" stepKey="navigateToEmailTemplatePage"/> <!--Click "Add New Template" button--> <click selector="{{AdminMainActionsSection.add}}" stepKey="clickAddNewTemplateButton"/> - <!--Select value for "Template" drop-down menu in "Load default template" tab--> + <!--Select value for "Template" drop-down menu in "Load Default Template" tab--> <selectOption selector="{{AdminEmailTemplateEditSection.templateDropDown}}" userInput="Registry Update" stepKey="selectValueFromTemplateDropDown"/> <!--Fill in required fields in "Template Information" tab and click "Save Template" button--> <click selector="{{AdminEmailTemplateEditSection.loadTemplateButton}}" stepKey="clickLoadTemplateButton"/> diff --git a/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php b/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php index 286e9a989d4d..4d168ffbf2bd 100644 --- a/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php +++ b/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php @@ -18,26 +18,42 @@ class PreviewTest extends \PHPUnit\Framework\TestCase const MALICIOUS_TEXT = 'test malicious'; + /** + * @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject + */ + protected $request; + + /** + * @var \Magento\Email\Block\Adminhtml\Template\Preview + */ + protected $preview; + + /** + * @var \Magento\Framework\Filter\Input\MaliciousCode|\PHPUnit_Framework_MockObject_MockObject + */ + protected $maliciousCode; + + /** + * @var \Magento\Email\Model\Template|\PHPUnit_Framework_MockObject_MockObject + */ + protected $template; + + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $storeManager; + /** * Init data */ protected function setUp() { $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - } - /** - * Check of processing email templates - * - * @param array $requestParamMap - * - * @dataProvider toHtmlDataProvider - * @param $requestParamMap - */ - public function testToHtml($requestParamMap) - { $storeId = 1; - $template = $this->getMockBuilder(\Magento\Email\Model\Template::class) + $designConfigData = []; + + $this->template = $this->getMockBuilder(\Magento\Email\Model\Template::class) ->setMethods( [ 'setDesignConfig', @@ -50,71 +66,106 @@ public function testToHtml($requestParamMap) ) ->disableOriginalConstructor() ->getMock(); - $template->expects($this->once()) + + $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); + + $this->maliciousCode = $this->createPartialMock( + \Magento\Framework\Filter\Input\MaliciousCode::class, + ['filter'] + ); + + $this->template->expects($this->once()) ->method('getProcessedTemplate') ->with($this->equalTo([])) ->willReturn(self::MALICIOUS_TEXT); - $designConfigData = []; - $template->expects($this->atLeastOnce()) - ->method('getDesignConfig') + + $this->template->method('getDesignConfig') ->willReturn(new \Magento\Framework\DataObject($designConfigData)); + $emailFactory = $this->createPartialMock(\Magento\Email\Model\TemplateFactory::class, ['create']); $emailFactory->expects($this->any()) ->method('create') - ->willReturn($template); + ->willReturn($this->template); - $request = $this->createMock(\Magento\Framework\App\RequestInterface::class); - $request->expects($this->any())->method('getParam')->willReturnMap($requestParamMap); $eventManage = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); $scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $design = $this->createMock(\Magento\Framework\View\DesignInterface::class); $store = $this->createPartialMock(\Magento\Store\Model\Store::class, ['getId', '__wakeup']); - $store->expects($this->any())->method('getId')->willReturn($storeId); - $storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) - ->disableOriginalConstructor() - ->getMock(); - $storeManager->expects($this->atLeastOnce()) - ->method('getDefaultStoreView') + + $store->expects($this->any()) + ->method('getId') + ->willReturn($storeId); + + $this->storeManager->method('getDefaultStoreView') ->willReturn($store); - $storeManager->expects($this->any())->method('getDefaultStoreView')->willReturn(null); - $storeManager->expects($this->any())->method('getStores')->willReturn([$store]); + + $this->storeManager->expects($this->any())->method('getDefaultStoreView')->willReturn(null); + $this->storeManager->expects($this->any())->method('getStores')->willReturn([$store]); $appState = $this->getMockBuilder(\Magento\Framework\App\State::class) - ->setConstructorArgs([$scopeConfig]) + ->setConstructorArgs( + [ + $scopeConfig + ] + ) ->setMethods(['emulateAreaCode']) ->disableOriginalConstructor() ->getMock(); $appState->expects($this->any()) ->method('emulateAreaCode') - ->with(\Magento\Email\Model\AbstractTemplate::DEFAULT_DESIGN_AREA, [$template, 'getProcessedTemplate']) - ->willReturn($template->getProcessedTemplate()); + ->with( + \Magento\Email\Model\AbstractTemplate::DEFAULT_DESIGN_AREA, + [$this->template, 'getProcessedTemplate'] + ) + ->willReturn($this->template->getProcessedTemplate()); $context = $this->createPartialMock( \Magento\Backend\Block\Template\Context::class, ['getRequest', 'getEventManager', 'getScopeConfig', 'getDesignPackage', 'getStoreManager', 'getAppState'] ); - $context->expects($this->any())->method('getRequest')->willReturn($request); + $context->expects($this->any())->method('getRequest')->willReturn($this->request); $context->expects($this->any())->method('getEventManager')->willReturn($eventManage); $context->expects($this->any())->method('getScopeConfig')->willReturn($scopeConfig); $context->expects($this->any())->method('getDesignPackage')->willReturn($design); - $context->expects($this->any())->method('getStoreManager')->willReturn($storeManager); + $context->expects($this->any())->method('getStoreManager')->willReturn($this->storeManager); $context->expects($this->once())->method('getAppState')->willReturn($appState); - $maliciousCode = $this->createPartialMock(\Magento\Framework\Filter\Input\MaliciousCode::class, ['filter']); - $maliciousCode->expects($this->once()) - ->method('filter') - ->with($this->equalTo($requestParamMap[1][2])) - ->willReturn(self::MALICIOUS_TEXT); - /** @var \Magento\Email\Block\Adminhtml\Template\Preview $preview */ - $preview = $this->objectManagerHelper->getObject( + $this->preview = $this->objectManagerHelper->getObject( \Magento\Email\Block\Adminhtml\Template\Preview::class, [ 'context' => $context, - 'maliciousCode' => $maliciousCode, + 'maliciousCode' => $this->maliciousCode, 'emailFactory' => $emailFactory ] ); - $this->assertEquals(self::MALICIOUS_TEXT, $preview->toHtml()); + } + + /** + * Check of processing email templates + * + * @param array $requestParamMap + * @dataProvider toHtmlDataProvider + */ + public function testToHtml($requestParamMap) + { + $this->request->expects($this->any()) + ->method('getParam') + ->willReturnMap($requestParamMap); + $this->template + ->expects($this->atLeastOnce()) + ->method('getDesignConfig'); + $this->storeManager->expects($this->atLeastOnce()) + ->method('getDefaultStoreView'); + $this->maliciousCode->expects($this->once()) + ->method('filter') + ->with($this->equalTo($requestParamMap[1][2])) + ->willReturn(self::MALICIOUS_TEXT); + + $this->assertEquals(self::MALICIOUS_TEXT, $this->preview->toHtml()); } /** diff --git a/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php b/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php index 9a67bf59dd4b..d4584ce86dff 100644 --- a/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php +++ b/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php @@ -54,11 +54,6 @@ class PreviewTest extends \PHPUnit\Framework\TestCase */ protected $pageTitleMock; - /** - * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject - */ - protected $responseMock; - protected function setUp() { $objectManager = new ObjectManager($this); @@ -84,16 +79,11 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) - ->setMethods(['setHeader']) - ->getMockForAbstractClass(); - $this->context = $objectManager->getObject( \Magento\Backend\App\Action\Context::class, [ 'request' => $this->requestMock, - 'view' => $this->viewMock, - 'response' => $this->responseMock + 'view' => $this->viewMock ] ); $this->object = $objectManager->getObject( @@ -118,9 +108,6 @@ public function testExecute() $this->pageTitleMock->expects($this->once()) ->method('prepend') ->willReturnSelf(); - $this->responseMock->expects($this->once()) - ->method('setHeader') - ->with('Content-Security-Policy', "script-src 'self'"); $this->assertNull($this->object->execute()); } diff --git a/app/code/Magento/Email/Test/Unit/ViewModel/Template/Preview/FormTest.php b/app/code/Magento/Email/Test/Unit/ViewModel/Template/Preview/FormTest.php new file mode 100644 index 000000000000..88c323c923c4 --- /dev/null +++ b/app/code/Magento/Email/Test/Unit/ViewModel/Template/Preview/FormTest.php @@ -0,0 +1,154 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Email\Test\Unit\ViewModel\Template\Preview; + +use Magento\Email\ViewModel\Template\Preview\Form; +use Magento\Framework\App\Request\Http; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +/** + * Class FormTest + * + * @covers \Magento\Email\ViewModel\Template\Preview\Form + */ +class FormTest extends \PHPUnit\Framework\TestCase +{ + /** @var Form */ + protected $form; + + /** @var Http|\PHPUnit_Framework_MockObject_MockObject */ + protected $requestMock; + + protected function setUp() + { + $this->requestMock = $this->createPartialMock( + Http::class, + ['getParam', 'getMethod'] + ); + + $objectManagerHelper = new ObjectManager($this); + + $this->form = $objectManagerHelper->getObject( + Form::class, + ['request'=> $this->requestMock] + ); + } + + /** + * Tests that the form is created with the expected fields based on the request type. + * + * @dataProvider getFormFieldsDataProvider + * @param string $httpMethod + * @param array $httpParams + * @param array $expectedFields + * @throws LocalizedException + */ + public function testGetFormFields(string $httpMethod, array $httpParams, array $expectedFields) + { + $this->requestMock->expects($this->once()) + ->method('getMethod') + ->willReturn($httpMethod); + + $this->requestMock->expects($this->any()) + ->method('getParam') + ->willReturnMap($httpParams); + + $actualFields = $this->form->getFormFields(); + + $this->assertEquals($expectedFields, $actualFields); + } + + /** + * Tests that an exception is thrown when a required parameter is missing for the request type. + * + * @dataProvider getFormFieldsInvalidDataProvider + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Missing expected parameter + * @param string $httpMethod + * @param array $httpParams + */ + public function testGetFormFieldsMissingParameter(string $httpMethod, array $httpParams) + { + $this->requestMock->expects($this->once()) + ->method('getMethod') + ->willReturn($httpMethod); + + $this->requestMock->expects($this->once()) + ->method('getParam') + ->willReturnMap($httpParams); + + $this->form->getFormFields(); + } + + /** + * @return array + */ + public function getFormFieldsDataProvider() + { + return [ + 'get_request_valid' => [ + 'httpMethod' => 'GET', + 'httpParams' => [ + ['id', null, 1] + ], + 'expectedFields' => [ + 'id' => 1 + ] + ], + 'get_request_valid_ignore_params' => [ + 'httpMethod' => 'GET', + 'httpParams' => [ + ['id', null, 1], + ['text', null, 'Hello World'], + ['type', null, 2], + ['styles', null, ''] + ], + 'expectedFields' => [ + 'id' => 1 + ] + ], + 'post_request_valid' => [ + 'httpMethod' => 'POST', + 'httpParams' => [ + ['text', null, 'Hello World'], + ['type', null, 2], + ['styles', null, ''] + ], + 'expectedFields' => [ + 'text' => 'Hello World', + 'type' => 2, + 'styles' => '' + ] + ] + ]; + } + + /** + * @return array + */ + public function getFormFieldsInvalidDataProvider() + { + return [ + 'get_request_missing_id' => [ + 'httpMethod' => 'GET', + 'httpParams' => [ + ['text', null, 'Hello World'], + ['type', null, 2], + ['styles', null, ''] + ] + ], + 'post_request_missing_text' => [ + 'httpMethod' => 'POST', + 'httpParams' => [ + ['type', null, 2], + ['styles', null, ''] + ] + ] + ]; + } +} diff --git a/app/code/Magento/Email/ViewModel/Template/Preview/Form.php b/app/code/Magento/Email/ViewModel/Template/Preview/Form.php new file mode 100644 index 000000000000..9db93cb94a29 --- /dev/null +++ b/app/code/Magento/Email/ViewModel/Template/Preview/Form.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Email\ViewModel\Template\Preview; + +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\View\Element\Block\ArgumentInterface; + +/** + * Class Form + */ +class Form implements ArgumentInterface +{ + private $expectedParamsGetRequest = [ + 'id' + ]; + + private $expectedParamsPostRequest = [ + 'text', + 'type', + 'styles' + ]; + + /** + * @var RequestInterface + */ + private $request; + + /** + * @param RequestInterface $request + */ + public function __construct(RequestInterface $request) + { + $this->request = $request; + } + + /** + * Gets the fields to be included in the email preview form. + * + * @return array + * @throws LocalizedException + */ + public function getFormFields() + { + $params = $fields = []; + $method = $this->request->getMethod(); + + if ($method === 'GET') { + $params = $this->expectedParamsGetRequest; + } elseif ($method === 'POST') { + $params = $this->expectedParamsPostRequest; + } + + foreach ($params as $paramName) { + $fieldValue = $this->request->getParam($paramName); + if ($fieldValue === null) { + throw new LocalizedException( + __("Missing expected parameter \"$paramName\" while attempting to generate template preview.") + ); + } + $fields[$paramName] = $fieldValue; + } + + return $fields; + } +} diff --git a/app/code/Magento/Email/i18n/en_US.csv b/app/code/Magento/Email/i18n/en_US.csv index 8eed4b5c662b..412660d90d46 100644 --- a/app/code/Magento/Email/i18n/en_US.csv +++ b/app/code/Magento/Email/i18n/en_US.csv @@ -72,7 +72,7 @@ City,City "We're sorry, an error has occurred while generating this content.","We're sorry, an error has occurred while generating this content." "Invalid sender data","Invalid sender data" Title,Title -"Load default template","Load default template" +"Load Default Template","Load Default Template" Template,Template "Are you sure you want to strip tags?","Are you sure you want to strip tags?" "Are you sure you want to delete this template?","Are you sure you want to delete this template?" diff --git a/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml index 97f31c618f9b..e7cbc675ce38 100644 --- a/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml +++ b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml @@ -12,7 +12,11 @@ <referenceContainer name="backend.page" remove="true"/> <referenceContainer name="menu.wrapper" remove="true"/> <referenceContainer name="root"> - <block name="preview.page.content" class="Magento\Backend\Block\Page" template="Magento_Email::preview/iframeswitcher.phtml"/> + <block name="preview.page.content" class="Magento\Backend\Block\Page" template="Magento_Email::preview/iframeswitcher.phtml"> + <arguments> + <argument name="preview_form_view_model" xsi:type="object">Magento\Email\ViewModel\Template\Preview\Form</argument> + </arguments> + </block> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml b/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml index 4d26b59b093e..29ceb71a138e 100644 --- a/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml +++ b/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml @@ -7,13 +7,34 @@ /** @var \Magento\Backend\Block\Page $block */ ?> <div id="preview" class="cms-revision-preview"> - <iframe - name="preview_iframe" + <iframe name="preview_iframe" id="preview_iframe" frameborder="0" title="<?= $block->escapeHtmlAttr(__('Preview')) ?>" width="100%" - sandbox="allow-forms allow-pointer-lock" - src="<?= $block->escapeUrl($block->getUrl('*/*/popup', ['_current' => true])) ?>" - /> + sandbox="allow-same-origin allow-pointer-lock" + ></iframe> + <form id="preview_form" + action="<?= $block->escapeUrl($block->getUrl('*/*/popup')) ?>" + method="post" + target="preview_iframe" + > + <input type="hidden" name="form_key" value="<?= /* @noEscape */ $block->getFormKey() ?>" /> + <?php foreach ($block->getPreviewFormViewModel()->getFormFields() as $name => $value) : ?> + <input type="hidden" name="<?= $block->escapeHtmlAttr($name) ?>" value="<?= $block->escapeHtmlAttr($value) ?>"/> + <?php endforeach; ?> + </form> </div> +<script> +require([ + 'jquery' +], function($) { + $(document).ready(function() { + $('#preview_form').submit(); + }); + + $('#preview_iframe').load(function() { + $(this).height($(this).contents().height()); + }); +}); +</script> diff --git a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml index 1f236a21a730..7378fa4b2e47 100644 --- a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml +++ b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml @@ -12,9 +12,9 @@ use Magento\Framework\App\TemplateTypesInterface; <form action="<?= $block->escapeUrl($block->getLoadUrl()) ?>" method="post" id="email_template_load_form"> <?= $block->getBlockHtml('formkey') ?> <fieldset class="admin__fieldset form-inline"> - <legend class="admin__legend"><span><?= $block->escapeHtml(__('Load default template')) ?></span></legend><br> - <div class="admin__field"> - <label class="admin__field-label" for="template_select"><?= $block->escapeHtml(__('Template')) ?></label> + <legend class="admin__legend"><span><?= $block->escapeHtml(__('Load Default Template')) ?></span></legend><br> + <div class="admin__field required"> + <label class="admin__field-label" for="template_select"><span><?= $block->escapeHtml(__('Template')) ?></span></label> <div class="admin__field-control"> <select id="template_select" name="code" class="admin__control-select required-entry"> <?php foreach ($block->getTemplateOptions() as $group => $options) : ?> @@ -48,7 +48,7 @@ use Magento\Framework\App\TemplateTypesInterface; <?= /* @noEscape */ $block->getFormHtml() ?> </form> -<form action="<?= $block->escapeUrl($block->getPreviewUrl()) ?>" method="get" id="email_template_preview_form" target="_blank"> +<form action="<?= $block->escapeUrl($block->getPreviewUrl()) ?>" method="post" id="email_template_preview_form" target="_blank"> <?= /* @noEscape */ $block->getBlockHtml('formkey') ?> <div class="no-display"> <input type="hidden" id="preview_type" name="type" value="<?= /* @noEscape */ $block->isTextType() ? 1 : 2 ?>" /> @@ -153,6 +153,7 @@ require([ } else { $('preview_type').value = <?= (int) $block->getTemplateType() ?>; } + if (typeof tinyMCE == 'undefined' || !tinyMCE.get('template_text')) { $('preview_text').value = $('template_text').value; } else { diff --git a/app/code/Magento/Fedex/Test/Mftf/Data/FedExConfigData.xml b/app/code/Magento/Fedex/Test/Mftf/Data/FedExConfigData.xml new file mode 100644 index 000000000000..d03403970ae5 --- /dev/null +++ b/app/code/Magento/Fedex/Test/Mftf/Data/FedExConfigData.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminFedexEnableForCheckoutConfigData" type="fedex_config"> + <data key="path">carriers/fedex/active</data> + <data key="value">1</data> + <data key="label">Yes</data> + </entity> + <entity name="AdminFedexEnableSandboxModeConfigData" type="fedex_config"> + <data key="path">carriers/fedex/sandbox_mode</data> + <data key="value">1</data> + <data key="label">Yes</data> + </entity> + <entity name="AdminFedexEnableDebugConfigData" type="fedex_config"> + <data key="path">carriers/fedex/debug</data> + <data key="value">1</data> + <data key="label">Yes</data> + </entity> + <entity name="AdminFedexEnableShowMethodConfigData" type="fedex_config"> + <data key="path">carriers/fedex/showmethod</data> + <data key="value">1</data> + <data key="label">Yes</data> + </entity> + <entity name="AdminFedexDisableShowMethodConfigData" type="fedex_config"> + <data key="path">carriers/fedex/showmethod</data> + <data key="value">0</data> + <data key="label">No</data> + </entity> + <entity name="AdminFedexDisableDebugConfigData" type="fedex_config"> + <data key="path">carriers/fedex/debug</data> + <data key="value">0</data> + <data key="label">No</data> + </entity> + <entity name="AdminFedexDisableSandboxModeConfigData" type="fedex_config"> + <data key="path">carriers/fedex/sandbox_mode</data> + <data key="value">0</data> + <data key="label">No</data> + </entity> + <entity name="AdminFedexDisableForCheckoutConfigData" type="fedex_config"> + <data key="path">carriers/fedex/active</data> + <data key="value">0</data> + <data key="label">No</data> + </entity> +</entities> diff --git a/app/code/Magento/Fedex/Test/Mftf/Section/AdminShippingMethodFedExSection.xml b/app/code/Magento/Fedex/Test/Mftf/Section/AdminShippingMethodFedExSection.xml new file mode 100644 index 000000000000..0f75d475d6b1 --- /dev/null +++ b/app/code/Magento/Fedex/Test/Mftf/Section/AdminShippingMethodFedExSection.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShippingMethodFedExSection"> + <element name="carriersFedExTab" type="button" selector="#carriers_fedex-head"/> + <element name="carriersFedExActive" type="input" selector="#carriers_fedex_active_inherit"/> + <element name="carriersFedExTitle" type="input" selector="#carriers_fedex_title_inherit"/> + <element name="carriersFedExAccountId" type="input" selector="#carriers_fedex_account"/> + <element name="carriersFedExMeterNumber" type="input" selector="#carriers_fedex_meter_number"/> + <element name="carriersFedExKey" type="input" selector="#carriers_fedex_key"/> + <element name="carriersFedExPassword" type="input" selector="#carriers_fedex_password"/> + <element name="carriersFedExSandboxMode" type="input" selector="#carriers_fedex_sandbox_mode_inherit"/> + <element name="carriersFedExShipmentRequestType" type="input" selector="#carriers_fedex_shipment_requesttype_inherit"/> + <element name="carriersFedExPackaging" type="input" selector="#carriers_fedex_packaging_inherit"/> + <element name="carriersFedExDropoff" type="input" selector="#carriers_fedex_dropoff_inherit"/> + <element name="carriersFedExUnitOfMeasure" type="input" selector="#carriers_fedex_unit_of_measure_inherit"/> + <element name="carriersFedExMaxPackageWeight" type="input" selector="#carriers_fedex_max_package_weight_inherit"/> + <element name="carriersFedExHandlingType" type="input" selector="#carriers_fedex_handling_type_inherit"/> + <element name="carriersFedExHandlingAction" type="select" selector="#carriers_fedex_handling_action_inherit"/> + <element name="carriersFedExFreeMethod" type="input" selector="#carriers_fedex_free_method_inherit"/> + <element name="carriersFedExSpecificErrMsg" type="input" selector="#carriers_fedex_specificerrmsg_inherit"/> + <element name="carriersFedExAllowSpecific" type="input" selector="#carriers_fedex_sallowspecific_inherit"/> + <element name="carriersFedExSpecificCountry" type="input" selector="#carriers_fedex_specificcountry"/> + </section> +</sections> diff --git a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml new file mode 100644 index 000000000000..f599d7ca223a --- /dev/null +++ b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"> + <!--Assert configuration are disabled in FedEx section--> + <comment userInput="Assert configuration are disabled in FedEx section" stepKey="commentSeeDisabledFedExConfigs"/> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <conditionalClick selector="{{AdminShippingMethodFedExSection.carriersFedExTab}}" dependentSelector="{{AdminShippingMethodFedExSection.carriersFedExActive}}" visible="false" stepKey="expandFedExTab"/> + <waitForElementVisible selector="{{AdminShippingMethodFedExSection.carriersFedExActive}}" stepKey="waitFedExTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExActive}}" userInput="disabled" stepKey="grabFedExActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExActiveDisabled" stepKey="assertFedExActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExTitle}}" userInput="disabled" stepKey="grabFedExTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExTitleDisabled" stepKey="assertFedExTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExAccountId}}" userInput="disabled" stepKey="grabFedExAccountIdDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExAccountIdDisabled" stepKey="assertFedExAccountIdDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExMeterNumber}}" userInput="disabled" stepKey="grabFedExMeterNumberDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExMeterNumberDisabled" stepKey="assertFedExMeterNumberDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExKey}}" userInput="disabled" stepKey="grabFedExKeyDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExKeyDisabled" stepKey="assertFedExKeyDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExPassword}}" userInput="disabled" stepKey="grabFedExPasswordDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExPasswordDisabled" stepKey="assertFedExPasswordDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExSandboxMode}}" userInput="disabled" stepKey="grabFedExSandboxDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExSandboxDisabled" stepKey="assertFedExSandboxDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExShipmentRequestType}}" userInput="disabled" stepKey="grabFedExShipmentRequestTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExShipmentRequestTypeDisabled" stepKey="assertFedExShipmentRequestTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExPackaging}}" userInput="disabled" stepKey="grabFedExPackagingDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExPackagingDisabled" stepKey="assertFedExPackagingDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExDropoff}}" userInput="disabled" stepKey="grabFedExDropoffDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExDropoffDisabled" stepKey="assertFedExDropoffDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExUnitOfMeasure}}" userInput="disabled" stepKey="grabFedExUnitOfMeasureDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExUnitOfMeasureDisabled" stepKey="assertFedExUnitOfMeasureDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExMaxPackageWeight}}" userInput="disabled" stepKey="grabFedExMaxPackageWeightDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExMaxPackageWeightDisabled" stepKey="assertFedExMaxPackageWeightDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExHandlingType}}" userInput="disabled" stepKey="grabFedExHandlingTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExHandlingTypeDisabled" stepKey="assertFedExHandlingTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExHandlingAction}}" userInput="disabled" stepKey="grabFedExHandlingActionDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExHandlingActionDisabled" stepKey="assertFedExHandlingActionDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExSpecificErrMsg}}" userInput="disabled" stepKey="grabFedExSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExSpecificErrMsgDisabled" stepKey="assertFedExSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExAllowSpecific}}" userInput="disabled" stepKey="grabFedExAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExAllowSpecificDisabled" stepKey="assertFedExAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFedExSection.carriersFedExSpecificCountry}}" userInput="disabled" stepKey="grabFedExSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFedExSpecificCountryDisabled" stepKey="assertFedExSpecificCountryDisabled"/> + </test> +</tests> diff --git a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml new file mode 100644 index 000000000000..91a76383babd --- /dev/null +++ b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml @@ -0,0 +1,130 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreatingShippingLabelTest"> + <annotations> + <features value="Fedex"/> + <stories value="Shipping label"/> + <title value="Creating shipping label"/> + <description value="Creating shipping label"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20287"/> + <useCaseId value="MC-18215"/> + <group value="shipping"/> + <skip> + <issueId value="MQE-1578"/> + </skip> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!-- Create product --> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <!--Set Fedex configs data--> + <magentoCLI command="config:set {{AdminFedexEnableForCheckoutConfigData.path}} {{AdminFedexEnableForCheckoutConfigData.value}}" stepKey="enableCheckout"/> + <magentoCLI command="config:set {{AdminFedexEnableSandboxModeConfigData.path}} {{AdminFedexEnableSandboxModeConfigData.value}}" stepKey="enableSandbox"/> + <magentoCLI command="config:set {{AdminFedexEnableDebugConfigData.path}} {{AdminFedexEnableDebugConfigData.value}}" stepKey="enableDebug"/> + <magentoCLI command="config:set {{AdminFedexEnableShowMethodConfigData.path}} {{AdminFedexEnableShowMethodConfigData.value}}" stepKey="enableShowMethod"/> + <!--TODO: add fedex credentials--> + <!--Set StoreInformation configs data--> + <magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} '{{AdminGeneralSetStoreNameConfigData.value}}'" stepKey="setStoreInformationName"/> + <magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.telephone}}" stepKey="setStoreInformationPhone"/> + <magentoCLI command="config:set {{AdminGeneralSetCountryConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.country_id}}" stepKey="setStoreInformationCountry"/> + <magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.city}}" stepKey="setStoreInformationCity"/> + <magentoCLI command="config:set {{AdminGeneralSetPostcodeConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.postcode}}" stepKey="setStoreInformationPostcode"/> + <magentoCLI command="config:set {{AdminGeneralSetStreetAddressConfigData.path}} '{{DE_Address_Berlin_Not_Default_Address.street[0]}}'" stepKey="setStoreInformationStreetAddress"/> + <magentoCLI command="config:set {{AdminGeneralSetStreetAddress2ConfigData.path}} '{{US_Address_California.street[0]}}'" stepKey="setStoreInformationStreetAddress2"/> + <magentoCLI command="config:set {{AdminGeneralSetVatNumberConfigData.path}} {{AdminGeneralSetVatNumberConfigData.value}}" stepKey="setStoreInformationVatNumber"/> + <!--Set Shipping settings origin data--> + <magentoCLI command="config:set {{AdminShippingSettingsOriginCountryConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.country_id}}" stepKey="setOriginCountry"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginCityConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.city}}" stepKey="setOriginCity"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginZipCodeConfigData.path}} {{DE_Address_Berlin_Not_Default_Address.postcode}}" stepKey="setOriginZipCode"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddressConfigData.path}} '{{DE_Address_Berlin_Not_Default_Address.street[0]}}'" stepKey="setOriginStreetAddress"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddress2ConfigData.path}} '{{US_Address_California.street[0]}}'" stepKey="setOriginStreetAddress2"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <!--Reset configs--> + <magentoCLI command="config:set {{AdminFedexDisableForCheckoutConfigData.path}} {{AdminFedexDisableForCheckoutConfigData.value}}" stepKey="disableCheckout"/> + <magentoCLI command="config:set {{AdminFedexDisableSandboxModeConfigData.path}} {{AdminFedexDisableSandboxModeConfigData.value}}" stepKey="disableSandbox"/> + <magentoCLI command="config:set {{AdminFedexDisableDebugConfigData.path}} {{AdminFedexDisableDebugConfigData.value}}" stepKey="disableDebug"/> + <magentoCLI command="config:set {{AdminFedexDisableShowMethodConfigData.path}} {{AdminFedexDisableShowMethodConfigData.value}}" stepKey="disableShowMethod"/> + <magentoCLI command="config:set {{AdminGeneralSetStoreNameConfigData.path}} ''" stepKey="setStoreInformationName"/> + <magentoCLI command="config:set {{AdminGeneralSetStorePhoneConfigData.path}} ''" stepKey="setStoreInformationPhone"/> + <magentoCLI command="config:set {{AdminGeneralSetCityConfigData.path}} ''" stepKey="setStoreInformationCity"/> + <magentoCLI command="config:set {{AdminGeneralSetPostcodeConfigData.path}} ''" stepKey="setStoreInformationPostcode"/> + <magentoCLI command="config:set {{AdminGeneralSetStreetAddressConfigData.path}} ''" stepKey="setStoreInformationStreetAddress"/> + <magentoCLI command="config:set {{AdminGeneralSetStreetAddress2ConfigData.path}} ''" stepKey="setStoreInformationStreetAddress2"/> + <magentoCLI command="config:set {{AdminGeneralSetVatNumberConfigData.path}} ''" stepKey="setStoreInformationVatNumber"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginCityConfigData.path}} ''" stepKey="setOriginCity"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginZipCodeConfigData.path}} ''" stepKey="setOriginZipCode"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddressConfigData.path}} ''" stepKey="setOriginStreetAddress"/> + <magentoCLI command="config:set {{AdminShippingSettingsOriginStreetAddress2ConfigData.path}} ''" stepKey="setOriginStreetAddress2"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!--Delete created data--> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Add country of manufacture to product--> + <amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="amOnEditPage"/> + <waitForPageLoad stepKey="waitForEditPage"/> + <actionGroup ref="AdminFillProductCountryOfManufactureActionGroup" stepKey="fillCountryOfManufacture"> + <argument name="countryId" value="DE"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveSimpleProduct"/> + <!--Place for order using FedEx shipping method--> + <amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="amOnStorefrontProductPage"/> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addProductToCart"> + <argument name="product" value="$$createProduct$$"/> + <argument name="productCount" value="1"/> + </actionGroup> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/> + <actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="addAddress"> + <argument name="customerVar" value="Simple_US_Utah_Customer"/> + <argument name="customerAddressVar" value="US_Address_California"/> + <argument name="shippingMethod" value="Federal Express"/> + </actionGroup> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectPaymentMethod"/> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="customerPlaceOrder"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage"/> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/> + </actionGroup> + <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber}}" stepKey="grabOrderNumber"/> + <!--Open created order in admin--> + <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/> + <actionGroup ref="searchAdminDataGridByKeyword" stepKey="searchOrder"> + <argument name="keyword" value="$grabOrderNumber"/> + </actionGroup> + <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> + <!--Create Invoice--> + <actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/> + <!--Create shipping label--> + <actionGroup ref="goToShipmentIntoOrder" stepKey="goToShipmentIntoOrder"/> + <checkOption selector="{{AdminShipmentTotalSection.createShippingLabel}}" stepKey="checkCreateShippingLabel"/> + <click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/> + <actionGroup ref="AdminShipmentCreateShippingLabelActionGroup" stepKey="createPackage"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + <actionGroup ref="AdminGoToShipmentTabActionGroup" stepKey="goToShipmentTab"/> + <click selector="{{AdminOrderShipmentsTabSection.viewGridRow('1')}}" stepKey="clickRowToViewShipment"/> + <waitForPageLoad stepKey="waitForShipmentItemsSection"/> + <seeElement selector="{{AdminShipmentTrackingInformationShippingSection.shippingInfoTable}}" stepKey="seeInformationTable"/> + <seeElement selector="{{AdminShipmentTrackingInformationShippingSection.shippingNumber}}" stepKey="seeShippingNumberElement"/> + <grabTextFrom selector="{{AdminShipmentTrackingInformationShippingSection.shippingMethod}}" stepKey="grabShippingMethod"/> + <grabTextFrom selector="{{AdminShipmentTrackingInformationShippingSection.shippingMethodTitle}}" stepKey="grabShippingMethodTitle"/> + <assertEquals actual="$grabShippingMethod" expectedType="string" expected="Federal Express" stepKey="assertShippingMethodIsFedEx"/> + <assertEquals actual="$grabShippingMethodTitle" expectedType="string" expected="Federal Express" stepKey="assertShippingMethodTitleIsFedEx"/> + </test> +</tests> diff --git a/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php b/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php index e02401c1a865..59ad900c491b 100644 --- a/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php +++ b/app/code/Magento/GiftMessage/Block/Message/Multishipping/Plugin/ItemsBox.php @@ -43,6 +43,15 @@ public function __construct(MessageHelper $helper) */ public function afterGetItemsBoxTextAfter(ShippingBlock $subject, $itemsBoxText, DataObject $addressEntity) { + if ($addressEntity->getGiftMessageId() === null) { + $addressEntity->setGiftMessageId($addressEntity->getQuote()->getGiftMessageId()); + } + foreach ($addressEntity->getAllItems() as $item) { + if ($item->getGiftMessageId() === null) { + $item->setGiftMessageId($item->getQuoteItem()->getGiftMessageId()); + } + } + return $itemsBoxText . $this->helper->getInline('multishipping_address', $addressEntity); } } diff --git a/app/code/Magento/GiftMessage/Test/Mftf/Section/AdminOrderGiftSection.xml b/app/code/Magento/GiftMessage/Test/Mftf/Section/AdminOrderGiftSection.xml new file mode 100644 index 000000000000..dc6d0b79a836 --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Mftf/Section/AdminOrderGiftSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminOrderGiftSection"> + <element name="orderItemGiftOptionsLink" type="text" selector="//table[contains(@class, 'edit-order-table')]//tbody[contains(.,'{{productName}}')]//a[contains(@class, 'action-link')]" parameterized="true"/> + <element name="orderItemGiftMessage" type="textarea" selector="#current_item_giftmessage_message" /> + </section> +</sections> diff --git a/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftMessageSection.xml b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftMessageSection.xml new file mode 100644 index 000000000000..b1f6f35ba5d9 --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftMessageSection.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontCheckoutCartGiftMessageSection"> + <element name="giftItemMessage" type="textarea" selector="tbody.cart:nth-of-type({{blockNumber}}) #gift-message-whole-message" parameterized="true"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftSection.xml b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftSection.xml new file mode 100644 index 000000000000..e39279de228f --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontCheckoutCartGiftSection.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontCheckoutCartGiftSection"> + <element name="cartItemGiftMessage" type="text" selector="//tbody[contains(.,'{{productName}}')]//div[@class='gift-message']//textarea" parameterized="true"/> + <element name="orderNumber" type="text" selector="(//div[contains(@class, 'orders-succeed')]//a)[{{blockNumber}}]" parameterized="true"/> + <element name="viewOrder" type="text" selector="//table[@id='my-orders-table']//tr[contains(.,'{{orderNumber}}')]//a[contains(@class, 'action view')]" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontOrderGiftSection.xml b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontOrderGiftSection.xml new file mode 100644 index 000000000000..45e7531f0b4a --- /dev/null +++ b/app/code/Magento/GiftMessage/Test/Mftf/Section/StorefrontOrderGiftSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontOrderGiftSection"> + <element name="giftMessageLink" type="button" selector=".table-wrapper.order-items .options .action.show"/> + <element name="giftMessage" type="text" selector=".order-gift-message .item-message" /> + </section> +</sections> diff --git a/app/code/Magento/GraphQl/etc/schema.graphqls b/app/code/Magento/GraphQl/etc/schema.graphqls index 77bba5ea3a9d..559ccf942892 100644 --- a/app/code/Magento/GraphQl/etc/schema.graphqls +++ b/app/code/Magento/GraphQl/etc/schema.graphqls @@ -36,10 +36,10 @@ directive @resolver(class: String="") on QUERY | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION - + directive @typeResolver(class: String="") on INTERFACE | OBJECT -directive @cache(cacheIdentity: String="" cachable: Boolean=true) on QUERY +directive @cache(cacheIdentity: String="" cacheable: Boolean=true) on QUERY type Query { } diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php index 4777b2bae07a..350edb5b8495 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Plugin.php @@ -6,7 +6,7 @@ */ namespace Magento\GroupedProduct\Model\Product\Type; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; /** * Plugin. @@ -14,14 +14,14 @@ class Plugin { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Type/Grouped/AssociatedProductsCollection.php b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Type/Grouped/AssociatedProductsCollection.php index 519da2051081..c492939232b1 100644 --- a/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Type/Grouped/AssociatedProductsCollection.php +++ b/app/code/Magento/GroupedProduct/Model/ResourceModel/Product/Type/Grouped/AssociatedProductsCollection.php @@ -41,7 +41,7 @@ class AssociatedProductsCollection extends \Magento\Catalog\Model\ResourceModel\ * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -67,7 +67,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Data/GroupedProductData.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Data/GroupedProductData.xml index ba3703e7b0ed..e6d7588289c3 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Data/GroupedProductData.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Data/GroupedProductData.xml @@ -28,6 +28,17 @@ <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> </entity> + <entity name="ApiGroupedProductAndUnderscoredSku" type="product3"> + <data key="sku" unique="suffix">api_grouped_product</data> + <data key="type_id">grouped</data> + <data key="attribute_set_id">4</data> + <data key="name" unique="suffix">Api Grouped Product</data> + <data key="status">1</data> + <data key="urlKey" unique="suffix">api-grouped-product</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductDescription</requiredEntity> + <requiredEntity type="custom_attribute_array">ApiProductShortDescription</requiredEntity> + </entity> <entity name="ApiGroupedProduct2" type="product3"> <data key="sku" unique="suffix">apiGroupedProduct</data> <data key="type_id">grouped</data> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultImageGroupedProductTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultImageGroupedProductTest.xml index 5d65f8269023..f2cb2cc993a5 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultImageGroupedProductTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultImageGroupedProductTest.xml @@ -29,6 +29,9 @@ </createData> </before> <after> + <actionGroup ref="deleteProductBySku" stepKey="deleteGroupedProduct"> + <argument name="sku" value="{{GroupedProduct.sku}}"/> + </actionGroup> <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> <deleteData createDataKey="createProductOne" stepKey="deleteProductOne"/> <deleteData createDataKey="createProductTwo" stepKey="deleteProductTwo"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml index 2a600d38250f..4fd06ccaa27e 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml @@ -17,6 +17,42 @@ <severity value="MAJOR"/> <testCaseId value="MC-141"/> <group value="GroupedProduct"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="OneSimpleProductLink" stepKey="addProductOne"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addProductOne" stepKey="addProductTwo"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple2"/> + </updateData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchGroupedProductByNameMysqlTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> + <annotations> + <features value="GroupedProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Grouped product with product name using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Grouped product with product name using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20464"/> + <group value="GroupedProduct"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -51,7 +87,7 @@ <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="ApiGroupedProductAndUnderscoredSku" stepKey="product"/> <createData entity="OneSimpleProductLink" stepKey="addProductOne"> <requiredEntity createDataKey="product"/> <requiredEntity createDataKey="simple1"/> @@ -77,6 +113,42 @@ <severity value="MAJOR"/> <testCaseId value="MC-282"/> <group value="GroupedProduct"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="OneSimpleProductLink" stepKey="addProductOne"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addProductOne" stepKey="addProductTwo"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple2"/> + </updateData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchGroupedProductByDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> + <annotations> + <features value="GroupedProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Grouped product with product description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Grouped product with product description using the MYSQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20468"/> + <group value="GroupedProduct"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -107,6 +179,42 @@ <severity value="MAJOR"/> <testCaseId value="MC-283"/> <group value="GroupedProduct"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="OneSimpleProductLink" stepKey="addProductOne"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addProductOne" stepKey="addProductTwo"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple2"/> + </updateData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchGroupedProductByShortDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> + <annotations> + <features value="GroupedProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Grouped product with product short description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Grouped product with product short description using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20469"/> + <group value="GroupedProduct"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> @@ -137,6 +245,51 @@ <severity value="MAJOR"/> <testCaseId value="MC-284"/> <group value="GroupedProduct"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="OneSimpleProductLink" stepKey="addProductOne"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addProductOne" stepKey="addProductTwo"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple2"/> + </updateData> + <getData entity="GetProduct3" stepKey="arg1"> + <requiredEntity createDataKey="product"/> + </getData> + <getData entity="GetProduct" stepKey="arg2"> + <requiredEntity createDataKey="simple1"/> + </getData> + <getData entity="GetProduct" stepKey="arg3"> + <requiredEntity createDataKey="simple2"/> + </getData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> + <test name="AdvanceCatalogSearchGroupedProductByPriceMysqlTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> + <annotations> + <features value="GroupedProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Grouped product with product price using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Grouped product with product price using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20470"/> + <group value="GroupedProduct"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchGroupedProductBySkuWithHyphenTest b/app/code/Magento/GroupedProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchGroupedProductBySkuWithHyphenTest new file mode 100644 index 000000000000..5220349a4aac --- /dev/null +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/StorefrontAdvanceCatalogSearchGroupedProductBySkuWithHyphenTest @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontAdvanceCatalogSearchGroupedProductBySkuWithHyphenTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="GroupedProduct"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Grouped product with product sku that in camelCase format"/> + <description value="Guest customer should be able to advance search Grouped product with product sku that in camelCase format"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20519"/> + <group value="GroupedProduct"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiGroupedProduct" stepKey="product"/> + <createData entity="OneSimpleProductLink" stepKey="addProductOne"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addProductOne" stepKey="addProductTwo"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="simple2"/> + </updateData> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php index cec7931c1c61..78fa2445ff58 100644 --- a/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/GroupedProduct/Test/Unit/Model/ProductTest.php @@ -30,7 +30,7 @@ class ProductTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; @@ -159,14 +159,9 @@ class ProductTest extends \PHPUnit\Framework\TestCase */ protected function setUp() { - $this->categoryIndexerMock = $this->getMockForAbstractClass( - \Magento\Framework\Indexer\IndexerInterface::class - ); + $this->categoryIndexerMock = $this->getMockForAbstractClass(\Magento\Framework\Indexer\IndexerInterface::class); - $this->moduleManager = $this->createPartialMock( - \Magento\Framework\Module\ModuleManagerInterface::class, - ['isEnabled'] - ); + $this->moduleManager = $this->createPartialMock(\Magento\Framework\Module\Manager::class, ['isEnabled']); $this->stockItemFactoryMock = $this->createPartialMock( \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory::class, ['create'] diff --git a/app/code/Magento/GroupedProductGraphQl/Model/Resolver/Product/Price/Provider.php b/app/code/Magento/GroupedProductGraphQl/Model/Resolver/Product/Price/Provider.php new file mode 100644 index 000000000000..b2336a074129 --- /dev/null +++ b/app/code/Magento/GroupedProductGraphQl/Model/Resolver/Product/Price/Provider.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GroupedProductGraphQl\Model\Resolver\Product\Price; + +use Magento\Catalog\Pricing\Price\FinalPrice; +use Magento\Catalog\Pricing\Price\RegularPrice; +use Magento\Framework\Pricing\PriceInfoInterface; +use Magento\Framework\Pricing\Amount\AmountInterface; +use Magento\Framework\Pricing\SaleableInterface; +use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface; + +/** + * Provides product prices for configurable products + */ +class Provider implements ProviderInterface +{ + /** + * Cache product prices so only fetch once + * + * @var AmountInterface[] + */ + private $minimalProductAmounts; + + /** + * @inheritdoc + */ + public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface + { + return $this->getMinimalProductAmount($product, FinalPrice::PRICE_CODE); + } + + /** + * @inheritdoc + */ + public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface + { + return $this->getMinimalProductAmount($product, RegularPrice::PRICE_CODE); + } + + /** + * @inheritdoc + */ + public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface + { + //Use minimal for maximal since maximal price in infinite + return $this->getMinimalProductAmount($product, FinalPrice::PRICE_CODE); + } + + /** + * @inheritdoc + */ + public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface + { + //Use minimal for maximal since maximal price in infinite + return $this->getMinimalProductAmount($product, RegularPrice::PRICE_CODE); + } + + /** + * @inheritdoc + */ + public function getRegularPrice(SaleableInterface $product): AmountInterface + { + return $product->getPriceInfo()->getPrice(RegularPrice::PRICE_CODE)->getAmount(); + } + + /** + * Get minimal amount for cheapest product in group + * + * @param SaleableInterface $product + * @param string $priceType + * @return AmountInterface + */ + private function getMinimalProductAmount(SaleableInterface $product, string $priceType): AmountInterface + { + if (empty($this->minimalProductAmounts[$product->getId()][$priceType])) { + $products = $product->getTypeInstance()->getAssociatedProducts($product); + $minPrice = null; + foreach ($products as $item) { + $item->setQty(PriceInfoInterface::PRODUCT_QUANTITY_DEFAULT); + $price = $item->getPriceInfo()->getPrice($priceType); + $priceValue = $price->getValue(); + if (($priceValue !== false) && ($priceValue <= ($minPrice === null ? $priceValue : $minPrice))) { + $minPrice = $price->getValue(); + $this->minimalProductAmounts[$product->getId()][$priceType] = $price->getAmount(); + } + } + } + + return $this->minimalProductAmounts[$product->getId()][$priceType]; + } +} diff --git a/app/code/Magento/GroupedProductGraphQl/composer.json b/app/code/Magento/GroupedProductGraphQl/composer.json index cd22c6066eb4..9578aa27ba18 100644 --- a/app/code/Magento/GroupedProductGraphQl/composer.json +++ b/app/code/Magento/GroupedProductGraphQl/composer.json @@ -5,6 +5,7 @@ "require": { "php": "~7.1.3||~7.2.0||~7.3.0", "magento/module-grouped-product": "*", + "magento/module-catalog": "*", "magento/module-catalog-graph-ql": "*", "magento/framework": "*" }, diff --git a/app/code/Magento/GroupedProductGraphQl/etc/graphql/di.xml b/app/code/Magento/GroupedProductGraphQl/etc/graphql/di.xml index 5c41fc26e615..4c408b38b5ec 100644 --- a/app/code/Magento/GroupedProductGraphQl/etc/graphql/di.xml +++ b/app/code/Magento/GroupedProductGraphQl/etc/graphql/di.xml @@ -29,4 +29,12 @@ </argument> </arguments> </type> + + <type name="Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool"> + <arguments> + <argument name="providers" xsi:type="array"> + <item name="grouped" xsi:type="object">Magento\GroupedProductGraphQl\Model\Resolver\Product\Price\Provider</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php index d6b96a28afcc..af5377a6227c 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php @@ -5,6 +5,7 @@ */ namespace Magento\ImportExport\Block\Adminhtml\Import\Edit; +use Magento\Framework\App\ObjectManager; use Magento\ImportExport\Model\Import; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; @@ -32,6 +33,11 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic */ protected $_behaviorFactory; + /** + * @var Import\ImageDirectoryBaseProvider + */ + private $imagesDirectoryProvider; + /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Framework\Registry $registry @@ -40,6 +46,7 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic * @param \Magento\ImportExport\Model\Source\Import\EntityFactory $entityFactory * @param \Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory * @param array $data + * @param Import\ImageDirectoryBaseProvider|null $imageDirProvider */ public function __construct( \Magento\Backend\Block\Template\Context $context, @@ -48,12 +55,15 @@ public function __construct( \Magento\ImportExport\Model\Import $importModel, \Magento\ImportExport\Model\Source\Import\EntityFactory $entityFactory, \Magento\ImportExport\Model\Source\Import\Behavior\Factory $behaviorFactory, - array $data = [] + array $data = [], + ?Import\ImageDirectoryBaseProvider $imageDirProvider = null ) { $this->_entityFactory = $entityFactory; $this->_behaviorFactory = $behaviorFactory; parent::__construct($context, $registry, $formFactory, $data); $this->_importModel = $importModel; + $this->imagesDirectoryProvider = $imageDirProvider + ?? ObjectManager::getInstance()->get(Import\ImageDirectoryBaseProvider::class); } /** @@ -231,8 +241,11 @@ protected function _prepareForm() 'required' => false, 'class' => 'input-text', 'note' => __( - 'For Type "Local Server" use relative path to Magento installation, - e.g. var/export, var/import, var/export/some/dir' + $this->escapeHtml( + 'For Type "Local Server" use relative path to <Magento installation>/' + .$this->imagesDirectoryProvider->getDirectoryRelativePath() + .', e.g. product_images, import_images/batch1' + ) ), ] ); diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php index 10ae2dc5e58e..1e9d194653c9 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php @@ -67,6 +67,11 @@ public function execute() } $directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR); $path = $directory->getAbsolutePath() . 'export/' . $fileName; + + if (!$directory->isFile($path)) { + throw new LocalizedException(__('Sorry, but the data is invalid or the file is not uploaded.')); + } + $this->file->deleteFile($path); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php index e850f6af86cf..5f036e51f66c 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Start.php @@ -6,12 +6,15 @@ namespace Magento\ImportExport\Controller\Adminhtml\Import; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +use Magento\Framework\App\ObjectManager; use Magento\ImportExport\Controller\Adminhtml\ImportResult as ImportResultController; use Magento\Framework\Controller\ResultFactory; use Magento\ImportExport\Model\Import; /** - * Controller responsible for initiating the import process + * Controller responsible for initiating the import process. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Start extends ImportResultController implements HttpPostActionInterface { @@ -25,25 +28,35 @@ class Start extends ImportResultController implements HttpPostActionInterface */ private $exceptionMessageFactory; + /** + * @var Import\ImageDirectoryBaseProvider + */ + private $imagesDirProvider; + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\ImportExport\Model\Report\ReportProcessorInterface $reportProcessor * @param \Magento\ImportExport\Model\History $historyModel * @param \Magento\ImportExport\Helper\Report $reportHelper - * @param \Magento\ImportExport\Model\Import $importModel + * @param Import $importModel * @param \Magento\Framework\Message\ExceptionMessageFactoryInterface $exceptionMessageFactory + * @param Import\ImageDirectoryBaseProvider|null $imageDirectoryBaseProvider */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\ImportExport\Model\Report\ReportProcessorInterface $reportProcessor, \Magento\ImportExport\Model\History $historyModel, \Magento\ImportExport\Helper\Report $reportHelper, - \Magento\ImportExport\Model\Import $importModel, - \Magento\Framework\Message\ExceptionMessageFactoryInterface $exceptionMessageFactory + Import $importModel, + \Magento\Framework\Message\ExceptionMessageFactoryInterface $exceptionMessageFactory, + ?Import\ImageDirectoryBaseProvider $imageDirectoryBaseProvider = null ) { parent::__construct($context, $reportProcessor, $historyModel, $reportHelper); + $this->importModel = $importModel; $this->exceptionMessageFactory = $exceptionMessageFactory; + $this->imagesDirProvider = $imageDirectoryBaseProvider + ?? ObjectManager::getInstance()->get(Import\ImageDirectoryBaseProvider::class); } /** @@ -66,6 +79,8 @@ public function execute() ->addAction('hide', ['edit_form', 'upload_button', 'messages']); $this->importModel->setData($data); + //Images can be read only from given directory. + $this->importModel->setData('images_base_directory', $this->imagesDirProvider->getDirectory()); $errorAggregator = $this->importModel->getErrorAggregator(); $errorAggregator->initValidationStrategy( $this->importModel->getData(Import::FIELD_NAME_VALIDATION_STRATEGY), diff --git a/app/code/Magento/ImportExport/Model/Export/Config/Converter.php b/app/code/Magento/ImportExport/Model/Export/Config/Converter.php index 20ab81ec1cd5..298f63d18f88 100644 --- a/app/code/Magento/ImportExport/Model/Export/Config/Converter.php +++ b/app/code/Magento/ImportExport/Model/Export/Config/Converter.php @@ -5,7 +5,7 @@ */ namespace Magento\ImportExport\Model\Export\Config; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\App\Utility\Classes; /** @@ -14,14 +14,14 @@ class Converter implements \Magento\Framework\Config\ConverterInterface { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php index 04f4111d3a0a..cf20001882c0 100644 --- a/app/code/Magento/ImportExport/Model/Import.php +++ b/app/code/Magento/ImportExport/Model/Import.php @@ -13,6 +13,7 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\ValidatorException; use Magento\Framework\Filesystem; use Magento\Framework\HTTP\Adapter\FileTransferFactory; use Magento\Framework\Indexer\IndexerRegistry; @@ -107,7 +108,7 @@ class Import extends AbstractModel const DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR = ','; /** - * default empty attribute value constant + * Import empty attribute default value */ const DEFAULT_EMPTY_ATTRIBUTE_VALUE_CONSTANT = '__EMPTY__VALUE__'; const DEFAULT_SIZE = 50; @@ -464,8 +465,28 @@ public function importSource() { $this->setData('entity', $this->getDataSourceModel()->getEntityTypeCode()); $this->setData('behavior', $this->getDataSourceModel()->getBehavior()); - $this->importHistoryModel->updateReport($this); + //Validating images temporary directory path if the constraint has been provided + if ($this->hasData('images_base_directory') + && $this->getData('images_base_directory') instanceof Filesystem\Directory\ReadInterface + ) { + /** @var Filesystem\Directory\ReadInterface $imagesDirectory */ + $imagesDirectory = $this->getData('images_base_directory'); + if (!$imagesDirectory->isReadable()) { + $rootWrite = $this->_filesystem->getDirectoryWrite(DirectoryList::ROOT); + $rootWrite->create($imagesDirectory->getAbsolutePath()); + } + try { + $this->setData( + self::FIELD_NAME_IMG_FILE_DIR, + $imagesDirectory->getAbsolutePath($this->getData(self::FIELD_NAME_IMG_FILE_DIR)) + ); + $this->_getEntityAdapter()->setParameters($this->getData()); + } catch (ValidatorException $exception) { + throw new LocalizedException(__('Images file directory is outside required directory'), $exception); + } + } + $this->importHistoryModel->updateReport($this); $this->addLogComment(__('Begin import of "%1" with "%2" behavior', $this->getEntity(), $this->getBehavior())); $result = $this->processImport(); @@ -547,9 +568,15 @@ public function uploadSource() $entity = $this->getEntity(); /** @var $uploader Uploader */ $uploader = $this->_uploaderFactory->create(['fileId' => self::FIELD_NAME_SOURCE_FILE]); + $uploader->setAllowedExtensions(['csv', 'zip']); $uploader->skipDbProcessing(true); $fileName = $this->random->getRandomString(32) . '.' . $uploader->getFileExtension(); - $result = $uploader->save($this->getWorkingDir(), $fileName); + try { + $result = $uploader->save($this->getWorkingDir(), $fileName); + } catch (\Exception $e) { + throw new LocalizedException(__('The file cannot be uploaded.')); + } + // phpcs:disable Magento2.Functions.DiscouragedFunction.Discouraged $extension = pathinfo($result['file'], PATHINFO_EXTENSION); diff --git a/app/code/Magento/ImportExport/Model/Import/Config/Converter.php b/app/code/Magento/ImportExport/Model/Import/Config/Converter.php index f2d1596ec3d9..a1eb8470b4dd 100644 --- a/app/code/Magento/ImportExport/Model/Import/Config/Converter.php +++ b/app/code/Magento/ImportExport/Model/Import/Config/Converter.php @@ -5,7 +5,7 @@ */ namespace Magento\ImportExport\Model\Import\Config; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\App\Utility\Classes; /** @@ -14,14 +14,14 @@ class Converter implements \Magento\Framework\Config\ConverterInterface { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/ImportExport/Model/Import/ImageDirectoryBaseProvider.php b/app/code/Magento/ImportExport/Model/Import/ImageDirectoryBaseProvider.php new file mode 100644 index 000000000000..9c90b57c30ea --- /dev/null +++ b/app/code/Magento/ImportExport/Model/Import/ImageDirectoryBaseProvider.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\ImportExport\Model\Import; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Filesystem\Directory\ReadInterface; +use Magento\Framework\Filesystem; +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * Provides base directory to use for images when user imports entities. + */ +class ImageDirectoryBaseProvider +{ + /** + * @var ScopeConfigInterface + */ + private $config; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * @param ScopeConfigInterface $config + * @param Filesystem $filesystem + */ + public function __construct(ScopeConfigInterface $config, Filesystem $filesystem) + { + $this->config = $config; + $this->filesystem = $filesystem; + } + + /** + * Directory that users are allowed to place images for importing. + * + * @return ReadInterface + */ + public function getDirectory(): ReadInterface + { + $path = $this->getDirectoryRelativePath(); + + return $this->filesystem->getDirectoryReadByPath( + $this->filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath($path) + ); + } + + /** + * The directory's path relative to Magento root. + * + * @return string + */ + public function getDirectoryRelativePath(): string + { + return $this->config->getValue('general/file/import_images_base_dir'); + } +} diff --git a/app/code/Magento/ImportExport/Model/Import/Source/Zip.php b/app/code/Magento/ImportExport/Model/Import/Source/Zip.php index 6fa87ab5d5c4..7e69d837d652 100644 --- a/app/code/Magento/ImportExport/Model/Import/Source/Zip.php +++ b/app/code/Magento/ImportExport/Model/Import/Source/Zip.php @@ -33,6 +33,12 @@ public function __construct( throw new ValidatorException(__('Sorry, but the data is invalid or the file is not uploaded.')); } $directory->delete($directory->getRelativePath($file)); - parent::__construct($csvFile, $directory, $options); + + try { + parent::__construct($csvFile, $directory, $options); + } catch (\LogicException $e) { + $directory->delete($directory->getRelativePath($csvFile)); + throw $e; + } } } diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminAssertVisiblePagerActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminAssertVisiblePagerActionGroup.xml new file mode 100644 index 000000000000..298be79a6ac9 --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminAssertVisiblePagerActionGroup.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAssertVisiblePagerActionGroup"> + <seeElement selector="{{AdminExportGridPagerSection.pager}}" stepKey="seeGridPager"/> + <seeElement selector="{{AdminGridRowsPerPage.count}}" stepKey="seeCountPerPageElement"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminNavigateToExportPageActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminNavigateToExportPageActionGroup.xml new file mode 100644 index 000000000000..1c3c241c7b0f --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminNavigateToExportPageActionGroup.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminNavigateToExportPageActionGroup"> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="navigateToExportPage"/> + <waitForPageLoad stepKey="waitForExportPageOpened"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Page/AdminExportIndexPage.xml b/app/code/Magento/ImportExport/Test/Mftf/Page/AdminExportIndexPage.xml index 55ed3edd9bc7..3d0aff2e113a 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Page/AdminExportIndexPage.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Page/AdminExportIndexPage.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> <page name="AdminExportIndexPage" url="admin/export/" area="admin" module="Magento_ImportExport"> <section name="AdminExportMainSection"/> + <section name="AdminExportGridPagerSection"/> </page> </pages> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportGridPagerSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportGridPagerSection.xml new file mode 100644 index 000000000000..8c4615c5926f --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportGridPagerSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminExportGridPagerSection"> + <element name="pager" type="text" selector=".admin__data-grid-header div.admin__data-grid-pager-wrap"/> + <element name="recordsLabel" type="text" selector=".admin__data-grid-header .admin__control-support-text"/> + </section> +</sections> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminExportPagerGridTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminExportPagerGridTest.xml new file mode 100644 index 000000000000..b203a4d11a2d --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminExportPagerGridTest.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminExportPagerGridTest"> + <annotations> + <features value="ImportExport"/> + <stories value="Export Grid"/> + <title value="Testing if the grid is present on export page"/> + <description value="Admin should be able to see the grid onn export page"/> + <severity value="CRITICAL"/> + <group value="importExport"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="AdminNavigateToExportPageActionGroup" stepKey="navigateToExportPage"/> + <actionGroup ref="AdminAssertVisiblePagerActionGroup" stepKey="seeGridPager"/> + </test> +</tests> diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php index c888c6b44734..e08f382d9400 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Export/Config/ConverterTest.php @@ -21,7 +21,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase protected $filePath; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php index b29a04322ce4..69118d2e2a31 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/Import/Config/ConverterTest.php @@ -21,7 +21,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase protected $filePath; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManager; diff --git a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php index 50e71512c3d2..04a15179477d 100644 --- a/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php +++ b/app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php @@ -640,6 +640,9 @@ public function testGetUnknownEntity($entity) $import->getEntity(); } + /** + * @return array + */ public function unknownEntitiesProvider() { return [ diff --git a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php index e64a6df430ea..f9f5f446ba42 100644 --- a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php +++ b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php @@ -7,16 +7,23 @@ namespace Magento\ImportExport\Ui\DataProvider; +use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider; use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Io\File; /** * Data provider for export grid. */ class ExportFileDataProvider extends DataProvider { + /** + * @var File|null + */ + private $fileIO; + /** * @var DriverInterface */ @@ -37,6 +44,7 @@ class ExportFileDataProvider extends DataProvider * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param DriverInterface $file * @param Filesystem $filesystem + * @param File|null $fileIO * @param array $meta * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -51,6 +59,7 @@ public function __construct( \Magento\Framework\Api\FilterBuilder $filterBuilder, DriverInterface $file, Filesystem $filesystem, + File $fileIO = null, array $meta = [], array $data = [] ) { @@ -67,6 +76,8 @@ public function __construct( $meta, $data ); + + $this->fileIO = $fileIO ?: ObjectManager::getInstance()->get(File::class); } /** @@ -89,10 +100,14 @@ public function getData() } $result = []; foreach ($files as $file) { - $result['items'][]['file_name'] = basename($file); + $result['items'][]['file_name'] = $this->fileIO->getPathInfo($file)['basename']; } + $pageSize = (int) $this->request->getParam('paging')['pageSize']; + $pageCurrent = (int) $this->request->getParam('paging')['current']; + $pageOffset = ($pageCurrent - 1) * $pageSize; $result['totalRecords'] = count($result['items']); + $result['items'] = array_slice($result['items'], $pageOffset, $pageSize); return $result; } diff --git a/app/code/Magento/ImportExport/etc/config.xml b/app/code/Magento/ImportExport/etc/config.xml index 7aee9bdd2fd6..b8ce1c70ee16 100644 --- a/app/code/Magento/ImportExport/etc/config.xml +++ b/app/code/Magento/ImportExport/etc/config.xml @@ -18,6 +18,7 @@ </available> </importexport_local_valid_paths> <bunch_size>100</bunch_size> + <import_images_base_dir>var/import/images</import_images_base_dir> </file> </general> <import> diff --git a/app/code/Magento/ImportExport/view/adminhtml/ui_component/export_grid.xml b/app/code/Magento/ImportExport/view/adminhtml/ui_component/export_grid.xml index 2b160bc9f6f4..1922f58ed47a 100644 --- a/app/code/Magento/ImportExport/view/adminhtml/ui_component/export_grid.xml +++ b/app/code/Magento/ImportExport/view/adminhtml/ui_component/export_grid.xml @@ -34,6 +34,9 @@ </settings> </dataProvider> </dataSource> + <listingToolbar name="listing_top"> + <paging name="listing_paging"/> + </listingToolbar> <columns name="export_grid_columns"> <column name="file_name"> <settings> diff --git a/app/code/Magento/Integration/Helper/Oauth/Data.php b/app/code/Magento/Integration/Helper/Oauth/Data.php index de074055efa2..107583a9e70a 100644 --- a/app/code/Magento/Integration/Helper/Oauth/Data.php +++ b/app/code/Magento/Integration/Helper/Oauth/Data.php @@ -116,22 +116,22 @@ public function getConsumerPostTimeout() /** * Get customer token lifetime from config. * - * @return int hours + * @return float hours */ public function getCustomerTokenLifetime() { - $hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); - return $hours > 0 ? $hours : 0; + $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); + return is_numeric($hours) && $hours > 0 ? $hours : 0; } /** * Get customer token lifetime from config. * - * @return int hours + * @return float hours */ public function getAdminTokenLifetime() { - $hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/admin'); - return $hours > 0 ? $hours : 0; + $hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/admin'); + return is_numeric($hours) && $hours > 0 ? $hours : 0; } } diff --git a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php index 0b9cb377d1d0..ce618f97883b 100644 --- a/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php +++ b/app/code/Magento/LayeredNavigation/Observer/Edit/Tab/Front/ProductAttributeFormBuildFrontTabObserver.php @@ -8,7 +8,7 @@ namespace Magento\LayeredNavigation\Observer\Edit\Tab\Front; use Magento\Config\Model\Config\Source; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Event\ObserverInterface; /** @@ -22,15 +22,15 @@ class ProductAttributeFormBuildFrontTabObserver implements ObserverInterface protected $optionList; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Source\Yesno $optionList */ - public function __construct(ModuleManagerInterface $moduleManager, Source\Yesno $optionList) + public function __construct(Manager $moduleManager, Source\Yesno $optionList) { $this->optionList = $optionList; $this->moduleManager = $moduleManager; diff --git a/app/code/Magento/LayeredNavigation/Observer/Grid/ProductAttributeGridBuildObserver.php b/app/code/Magento/LayeredNavigation/Observer/Grid/ProductAttributeGridBuildObserver.php index b98230c1ebe3..57a20cf17371 100644 --- a/app/code/Magento/LayeredNavigation/Observer/Grid/ProductAttributeGridBuildObserver.php +++ b/app/code/Magento/LayeredNavigation/Observer/Grid/ProductAttributeGridBuildObserver.php @@ -7,7 +7,7 @@ */ namespace Magento\LayeredNavigation\Observer\Grid; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Event\ObserverInterface; /** @@ -16,16 +16,16 @@ class ProductAttributeGridBuildObserver implements ObserverInterface { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** * Construct. * - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobile.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobile.xml index 721942f58f7c..6d182d0b7a5e 100644 --- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobile.xml +++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/ShopByButtonInMobile.xml @@ -17,6 +17,7 @@ <severity value="CRITICAL"/> <testCaseId value="MC-6092"/> <group value="LayeredNavigation"/> + <group value="SearchEngineMysql"/> </annotations> <before> <createData entity="productDropDownAttribute" stepKey="attribute"/> diff --git a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php index f0243784dd61..34627fbb286e 100644 --- a/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php +++ b/app/code/Magento/LayeredNavigation/Test/Unit/Block/NavigationTest.php @@ -100,7 +100,7 @@ public function testCanShowBlock() ->method('isEnabled') ->with($this->catalogLayerMock, $filters) ->will($this->returnValue($enabled)); - + $category = $this->createMock(Category::class); $this->catalogLayerMock->expects($this->atLeastOnce())->method('getCurrentCategory')->willReturn($category); $category->expects($this->once())->method('getDisplayMode')->willReturn(Category::DM_PRODUCT); @@ -119,12 +119,12 @@ public function testCanShowBlock() public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $result) { $filters = ['To' => 'be', 'or' => 'not', 'to' => 'be']; - + $this->filterListMock->expects($this->atLeastOnce())->method('getFilters') ->with($this->catalogLayerMock) ->will($this->returnValue($filters)); $this->assertEquals($filters, $this->model->getFilters()); - + $this->visibilityFlagMock ->expects($this->any()) ->method('isEnabled') @@ -137,6 +137,9 @@ public function testCanShowBlockWithDifferentDisplayModes(string $mode, bool $re $this->assertEquals($result, $this->model->canShowBlock()); } + /** + * @return array + */ public function canShowBlockDataProvider() { return [ diff --git a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/File.php b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/File.php index 8dfce40419b4..8c9fe7b848fa 100644 --- a/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/File.php +++ b/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/File.php @@ -6,12 +6,20 @@ namespace Magento\MediaStorage\Model\ResourceModel\File\Storage; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem\Io\File as FileIo; +use Magento\Framework\App\ObjectManager; /** * Class File */ class File { + /** + * @var FileIo + */ + private $fileIo; + /** * @var \Magento\Framework\Filesystem */ @@ -25,11 +33,16 @@ class File /** * @param \Magento\Framework\Filesystem $filesystem * @param \Psr\Log\LoggerInterface $log + * @param FileIo $fileIo */ - public function __construct(\Magento\Framework\Filesystem $filesystem, \Psr\Log\LoggerInterface $log) - { + public function __construct( + \Magento\Framework\Filesystem $filesystem, + \Psr\Log\LoggerInterface $log, + FileIo $fileIo = null + ) { $this->_logger = $log; $this->_filesystem = $filesystem; + $this->fileIo = $fileIo ?? ObjectManager::getInstance()->get(FileIo::class); } /** @@ -45,14 +58,15 @@ public function getStorageData($dir = '/') $directoryInstance = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA); if ($directoryInstance->isDirectory($dir)) { foreach ($directoryInstance->readRecursively($dir) as $path) { - $itemName = basename($path); + $pathInfo = $this->fileIo->getPathInfo($path); + $itemName = $pathInfo['basename']; if ($itemName == '.svn' || $itemName == '.htaccess') { continue; } if ($directoryInstance->isDirectory($path)) { $directories[] = [ 'name' => $itemName, - 'path' => dirname($path) == '.' ? '/' : dirname($path), + 'path' => $pathInfo['dirname'] === '.' ? '/' : $pathInfo['dirname'], ]; } else { $files[] = $path; @@ -64,7 +78,7 @@ public function getStorageData($dir = '/') } /** - * Clear files and directories in storage + * Clear all files in storage $dir * * @param string $dir * @return $this @@ -73,8 +87,17 @@ public function clear($dir = '') { $directoryInstance = $this->_filesystem->getDirectoryWrite(DirectoryList::MEDIA); if ($directoryInstance->isDirectory($dir)) { - foreach ($directoryInstance->read($dir) as $path) { - $directoryInstance->delete($path); + $paths = $directoryInstance->readRecursively($dir); + foreach ($paths as $path) { + if ($directoryInstance->isDirectory($path)) { + continue; + } + + $pathInfo = $this->fileIo->getPathInfo($path); + + if ($pathInfo['basename'] !== '.htaccess') { + $directoryInstance->delete($path); + } } } @@ -127,7 +150,7 @@ public function saveFile($filePath, $content, $overwrite = false) } } catch (\Magento\Framework\Exception\FileSystemException $e) { $this->_logger->info($e->getMessage()); - throw new \Magento\Framework\Exception\LocalizedException(__('Unable to save file: %1', $filePath)); + throw new LocalizedException(__('Unable to save file: %1', $filePath)); } return false; diff --git a/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php b/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php index 97dffbe0e39a..adc045cd0bed 100644 --- a/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php +++ b/app/code/Magento/MediaStorage/Test/Unit/Model/ResourceModel/File/Storage/FileTest.php @@ -6,12 +6,18 @@ namespace Magento\MediaStorage\Test\Unit\Model\ResourceModel\File\Storage; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; /** * Class FileTest */ class FileTest extends \PHPUnit\Framework\TestCase { + /** + * @var \Magento\Framework\Filesystem\Io\File + */ + private $fileIoMock; + /** * @var \Magento\MediaStorage\Model\ResourceModel\File\Storage\File */ @@ -44,9 +50,17 @@ protected function setUp() ['isDirectory', 'readRecursively'] ); - $this->storageFile = new \Magento\MediaStorage\Model\ResourceModel\File\Storage\File( - $this->filesystemMock, - $this->loggerMock + $this->fileIoMock = $this->createPartialMock(\Magento\Framework\Filesystem\Io\File::class, ['getPathInfo']); + + $objectManager = new ObjectManager($this); + + $this->storageFile = $objectManager->getObject( + \Magento\MediaStorage\Model\ResourceModel\File\Storage\File::class, + [ + 'filesystem' => $this->filesystemMock, + 'log' => $this->loggerMock, + 'fileIo' => $this->fileIoMock + ] ); } @@ -98,6 +112,20 @@ public function testGetStorageData() 'folder_one/folder_two/.htaccess', 'folder_one/folder_two/file_two.txt', ]; + + $pathInfos = array_map( + function ($path) { + return [$path, pathinfo($path)]; + }, + $paths + ); + + $this->fileIoMock->expects( + $this->any() + )->method( + 'getPathInfo' + )->will($this->returnValueMap($pathInfos)); + sort($paths); $this->directoryReadMock->expects( $this->once() diff --git a/app/code/Magento/Multishipping/Block/Checkout/Shipping.php b/app/code/Magento/Multishipping/Block/Checkout/Shipping.php index 77981c736b9e..99450fc53807 100644 --- a/app/code/Magento/Multishipping/Block/Checkout/Shipping.php +++ b/app/code/Magento/Multishipping/Block/Checkout/Shipping.php @@ -3,10 +3,13 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Multishipping\Block\Checkout; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Quote\Model\Quote\Address; +use Magento\Store\Model\ScopeInterface; /** * Mustishipping checkout shipping @@ -67,6 +70,8 @@ public function getCheckout() } /** + * Add page title and prepare layout + * * @return $this */ protected function _prepareLayout() @@ -78,6 +83,8 @@ protected function _prepareLayout() } /** + * Retrieves addresses + * * @return Address[] */ public function getAddresses() @@ -86,6 +93,8 @@ public function getAddresses() } /** + * Returns count of addresses + * * @return mixed */ public function getAddressCount() @@ -99,6 +108,8 @@ public function getAddressCount() } /** + * Retrieves the address items + * * @param Address $address * @return \Magento\Framework\DataObject[] */ @@ -106,7 +117,7 @@ public function getAddressItems($address) { $items = []; foreach ($address->getAllItems() as $item) { - if ($item->getParentItemId()) { + if ($item->getParentItemId() || !$item->getQuoteItemId()) { continue; } $item->setQuoteItem($this->getCheckout()->getQuote()->getItemById($item->getQuoteItemId())); @@ -118,6 +129,8 @@ public function getAddressItems($address) } /** + * Retrieves the address shipping method + * * @param Address $address * @return mixed */ @@ -127,6 +140,8 @@ public function getAddressShippingMethod($address) } /** + * Retrieves address shipping rates + * * @param Address $address * @return mixed */ @@ -137,22 +152,20 @@ public function getShippingRates($address) } /** + * Retrieves the carrier name by the code + * * @param string $carrierCode * @return string */ public function getCarrierName($carrierCode) { - if ($name = $this->_scopeConfig->getValue( - 'carriers/' . $carrierCode . '/title', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ) { - return $name; - } - return $carrierCode; + $name = $this->_scopeConfig->getValue('carriers/' . $carrierCode . '/title', ScopeInterface::SCOPE_STORE); + return $name ?: $carrierCode; } /** + * Retrieves the address edit url + * * @param Address $address * @return string */ @@ -162,6 +175,8 @@ public function getAddressEditUrl($address) } /** + * Retrieves the url for items edition + * * @return string */ public function getItemsEditUrl() @@ -170,6 +185,8 @@ public function getItemsEditUrl() } /** + * Retrieves the url for the post action + * * @return string */ public function getPostActionUrl() @@ -178,6 +195,8 @@ public function getPostActionUrl() } /** + * Retrieves the back url + * * @return string */ public function getBackUrl() @@ -186,6 +205,8 @@ public function getBackUrl() } /** + * Returns converted and formatted price + * * @param Address $address * @param float $price * @param bool $flag @@ -202,7 +223,7 @@ public function getShippingPrice($address, $price, $flag) } /** - * Retrieve text for items box + * Retrieves text for items box * * @param \Magento\Framework\DataObject $addressEntity * @return string diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php index c86caec733a1..38a30c1ee49e 100644 --- a/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php +++ b/app/code/Magento/Multishipping/Controller/Checkout/Address/NewShipping.php @@ -1,12 +1,19 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Multishipping\Controller\Checkout\Address; -class NewShipping extends \Magento\Multishipping\Controller\Checkout\Address +use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; +use Magento\Multishipping\Controller\Checkout\Address; + +/** + * Class NewShipping + * + * @package Address + */ +class NewShipping extends Address implements HttpGetActionInterface { /** * Create New Shipping address Form @@ -35,7 +42,7 @@ public function execute() if ($this->_getCheckout()->getCustomerDefaultShippingAddress()) { $addressForm->setBackUrl($this->_url->getUrl('*/checkout/addresses')); } else { - $addressForm->setBackUrl($this->_url->getUrl('*/cart/')); + $addressForm->setBackUrl($this->_url->getUrl('checkout/cart/')); } } $this->_view->renderLayout(); diff --git a/app/code/Magento/Multishipping/Controller/Checkout/Plugin.php b/app/code/Magento/Multishipping/Controller/Checkout/Plugin.php deleted file mode 100644 index f88cdfc26fa9..000000000000 --- a/app/code/Magento/Multishipping/Controller/Checkout/Plugin.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Multishipping\Controller\Checkout; - -/** - * Turns Off Multishipping mode for Quote. - */ -class Plugin -{ - /** - * @var \Magento\Checkout\Model\Cart - */ - protected $cart; - - /** - * @param \Magento\Checkout\Model\Cart $cart - */ - public function __construct(\Magento\Checkout\Model\Cart $cart) - { - $this->cart = $cart; - } - - /** - * Disable multishipping - * - * @param \Magento\Framework\App\Action\Action $subject - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - */ - public function beforeExecute(\Magento\Framework\App\Action\Action $subject) - { - $quote = $this->cart->getQuote(); - if ($quote->getIsMultiShipping()) { - $quote->setIsMultiShipping(0); - $this->cart->saveQuote(); - } - } -} diff --git a/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php b/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php index 4ef36a7c8b6f..b450232395b8 100644 --- a/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php +++ b/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php @@ -3,34 +3,48 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Multishipping\Model\Cart\Controller; +use Magento\Checkout\Controller\Cart; +use Magento\Checkout\Model\Session; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Multishipping\Model\Checkout\Type\Multishipping\State; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; + +/** + * Cleans shipping addresses and item assignments after MultiShipping flow + */ class CartPlugin { /** - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ private $cartRepository; /** - * @var \Magento\Checkout\Model\Session + * @var Session */ private $checkoutSession; /** - * @var \Magento\Customer\Api\AddressRepositoryInterface + * @var AddressRepositoryInterface */ private $addressRepository; /** - * @param \Magento\Quote\Api\CartRepositoryInterface $cartRepository - * @param \Magento\Checkout\Model\Session $checkoutSession - * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository + * @param CartRepositoryInterface $cartRepository + * @param Session $checkoutSession + * @param AddressRepositoryInterface $addressRepository */ public function __construct( - \Magento\Quote\Api\CartRepositoryInterface $cartRepository, - \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Customer\Api\AddressRepositoryInterface $addressRepository + CartRepositoryInterface $cartRepository, + Session $checkoutSession, + AddressRepositoryInterface $addressRepository ) { $this->cartRepository = $cartRepository; $this->checkoutSession = $checkoutSession; @@ -38,20 +52,19 @@ public function __construct( } /** - * @param \Magento\Checkout\Controller\Cart $subject - * @param \Magento\Framework\App\RequestInterface $request + * Cleans shipping addresses and item assignments after MultiShipping flow + * + * @param Cart $subject + * @param RequestInterface $request * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @throws LocalizedException */ - public function beforeDispatch( - \Magento\Checkout\Controller\Cart $subject, - \Magento\Framework\App\RequestInterface $request - ) { - /** @var \Magento\Quote\Model\Quote $quote */ + public function beforeDispatch(Cart $subject, RequestInterface $request) + { + /** @var Quote $quote */ $quote = $this->checkoutSession->getQuote(); - - // Clear shipping addresses and item assignments after MultiShipping flow - if ($quote->isMultipleShippingAddresses()) { + if ($quote->isMultipleShippingAddresses() && $this->isCheckoutComplete()) { foreach ($quote->getAllShippingAddresses() as $address) { $quote->removeAddress($address->getId()); } @@ -59,12 +72,20 @@ public function beforeDispatch( $shippingAddress = $quote->getShippingAddress(); $defaultShipping = $quote->getCustomer()->getDefaultShipping(); if ($defaultShipping) { - $defaultCustomerAddress = $this->addressRepository->getById( - $defaultShipping - ); + $defaultCustomerAddress = $this->addressRepository->getById($defaultShipping); $shippingAddress->importCustomerAddressData($defaultCustomerAddress); } $this->cartRepository->save($quote); } } + + /** + * Checks whether the checkout flow is complete + * + * @return bool + */ + private function isCheckoutComplete() : bool + { + return (bool) ($this->checkoutSession->getStepData(State::STEP_SHIPPING)['is_complete'] ?? true); + } } diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php index 7105fd4e9d26..d1103abfbb94 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping.php @@ -691,6 +691,19 @@ protected function _prepareOrder(\Magento\Quote\Model\Quote\Address $address) $this->quoteAddressToOrder->convert($address) ); + $shippingMethodCode = $address->getShippingMethod(); + if (isset($shippingMethodCode) && !empty($shippingMethodCode)) { + $rate = $address->getShippingRateByCode($shippingMethodCode); + $shippingPrice = $rate->getPrice(); + } else { + $shippingPrice = $order->getShippingAmount(); + } + $store = $order->getStore(); + $amountPrice = $store->getBaseCurrency() + ->convert($shippingPrice, $store->getCurrentCurrencyCode()); + $order->setBaseShippingAmount($shippingPrice); + $order->setShippingAmount($amountPrice); + $order->setQuote($quote); $order->setBillingAddress($this->quoteAddressToOrderAddress->convert($quote->getBillingAddress())); diff --git a/app/code/Magento/Multishipping/Plugin/DisableMultishippingMode.php b/app/code/Magento/Multishipping/Plugin/DisableMultishippingMode.php new file mode 100644 index 000000000000..fff2346d7624 --- /dev/null +++ b/app/code/Magento/Multishipping/Plugin/DisableMultishippingMode.php @@ -0,0 +1,51 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Multishipping\Plugin; + +use Magento\Checkout\Model\Cart; +use Magento\Framework\App\Action\Action; + +/** + * Turns Off Multishipping mode for Quote. + */ +class DisableMultishippingMode +{ + /** + * @var Cart + */ + private $cart; + + /** + * @param Cart $cart + */ + public function __construct( + Cart $cart + ) { + $this->cart = $cart; + } + + /** + * Disable multishipping + * + * @param Action $subject + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeExecute(Action $subject) + { + $quote = $this->cart->getQuote(); + if ($quote->getIsMultiShipping()) { + $quote->setIsMultiShipping(0); + $extensionAttributes = $quote->getExtensionAttributes(); + if ($extensionAttributes && $extensionAttributes->getShippingAssignments()) { + $extensionAttributes->setShippingAssignments([]); + } + $this->cart->saveQuote(); + } + } +} diff --git a/app/code/Magento/Multishipping/Plugin/MultishippingQuoteRepository.php b/app/code/Magento/Multishipping/Plugin/MultishippingQuoteRepository.php new file mode 100644 index 000000000000..af19e4bc91f5 --- /dev/null +++ b/app/code/Magento/Multishipping/Plugin/MultishippingQuoteRepository.php @@ -0,0 +1,159 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Multishipping\Plugin; + +use Magento\Framework\Api\SearchResultsInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\ShippingAssignment\ShippingProcessor; +use Magento\Quote\Model\ShippingAssignmentFactory; + +/** + * Plugin for multishipping quote processing. + */ +class MultishippingQuoteRepository +{ + /** + * @var ShippingAssignmentFactory + */ + private $shippingAssignmentFactory; + + /** + * @var ShippingProcessor + */ + private $shippingProcessor; + + /** + * @param ShippingAssignmentFactory $shippingAssignmentFactory + * @param ShippingProcessor $shippingProcessor + */ + public function __construct( + ShippingAssignmentFactory $shippingAssignmentFactory, + ShippingProcessor $shippingProcessor + ) { + $this->shippingAssignmentFactory = $shippingAssignmentFactory; + $this->shippingProcessor = $shippingProcessor; + } + + /** + * Process multishipping quote for get. + * + * @param CartRepositoryInterface $subject + * @param CartInterface $result + * @return CartInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGet( + CartRepositoryInterface $subject, + CartInterface $result + ) { + return $this->processQuote($result); + } + + /** + * Process multishipping quote for get list. + * + * @param CartRepositoryInterface $subject + * @param SearchResultsInterface $result + * + * @return SearchResultsInterface + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetList( + CartRepositoryInterface $subject, + SearchResultsInterface $result + ) { + $items = []; + foreach ($result->getItems() as $item) { + $items[] = $this->processQuote($item); + } + $result->setItems($items); + + return $result; + } + + /** + * Remove shipping assignments for multishipping quote. + * + * @param CartRepositoryInterface $subject + * @param CartInterface $quote + * @return array + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeSave(CartRepositoryInterface $subject, CartInterface $quote) + { + $extensionAttributes = $quote->getExtensionAttributes(); + if ($quote->getIsMultiShipping() && $extensionAttributes && $extensionAttributes->getShippingAssignments()) { + $quote->getExtensionAttributes()->setShippingAssignments([]); + } + + return [$quote]; + } + + /** + * Set shipping assignments for multishipping quote according to customer selection. + * + * @param CartInterface $quote + * @return CartInterface + */ + private function processQuote(CartInterface $quote): CartInterface + { + if (!$quote->getIsMultiShipping() || !$quote instanceof Quote) { + return $quote; + } + + if ($quote->getExtensionAttributes() && $quote->getExtensionAttributes()->getShippingAssignments()) { + $shippingAssignments = []; + $addresses = $quote->getAllAddresses(); + + foreach ($addresses as $address) { + $quoteItems = $this->getQuoteItems($quote, $address); + if (!empty($quoteItems)) { + $shippingAssignment = $this->shippingAssignmentFactory->create(); + $shippingAssignment->setItems($quoteItems); + $shippingAssignment->setShipping($this->shippingProcessor->create($address)); + $shippingAssignments[] = $shippingAssignment; + } + } + + if (!empty($shippingAssignments)) { + $quote->getExtensionAttributes()->setShippingAssignments($shippingAssignments); + } + } + + return $quote; + } + + /** + * Returns quote items assigned to address. + * + * @param Quote $quote + * @param Quote\Address $address + * @return Quote\Item[] + */ + private function getQuoteItems(Quote $quote, Quote\Address $address): array + { + $quoteItems = []; + foreach ($address->getItemsCollection() as $addressItem) { + $quoteItem = $quote->getItemById($addressItem->getQuoteItemId()); + if ($quoteItem) { + $multishippingQuoteItem = clone $quoteItem; + $qty = $addressItem->getQty(); + $sku = $multishippingQuoteItem->getSku(); + if (isset($quoteItems[$sku])) { + $qty += $quoteItems[$sku]->getQty(); + } + $multishippingQuoteItem->setQty($qty); + $quoteItems[$sku] = $multishippingQuoteItem; + } + } + + return array_values($quoteItems); + } +} diff --git a/app/code/Magento/Multishipping/Plugin/ResetShippingAssigment.php b/app/code/Magento/Multishipping/Plugin/ResetShippingAssigment.php new file mode 100644 index 000000000000..deac19e23a23 --- /dev/null +++ b/app/code/Magento/Multishipping/Plugin/ResetShippingAssigment.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Multishipping\Plugin; + +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\ShippingAssignment\ShippingAssignmentProcessor; + +/** + * Resets quote shipping assignments when item is removed from multishipping quote. + */ +class ResetShippingAssigment +{ + /** + * @var ShippingAssignmentProcessor + */ + private $shippingAssignmentProcessor; + + /** + * @param ShippingAssignmentProcessor $shippingAssignmentProcessor + */ + public function __construct( + ShippingAssignmentProcessor $shippingAssignmentProcessor + ) { + $this->shippingAssignmentProcessor = $shippingAssignmentProcessor; + } + + /** + * Resets quote shipping assignments when item is removed from multishipping quote. + * + * @param Quote $subject + * @param mixed $itemId + * + * @return array + */ + public function beforeRemoveItem(Quote $subject, $itemId): array + { + if ($subject->getIsMultiShipping()) { + $extensionAttributes = $subject->getExtensionAttributes(); + if ($extensionAttributes && $extensionAttributes->getShippingAssignments()) { + $shippingAssignment = $this->shippingAssignmentProcessor->create($subject); + $extensionAttributes->setShippingAssignments([$shippingAssignment]); + } + } + + return [$itemId]; + } +} diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/AdminSalesOrderActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/AdminSalesOrderActionGroup.xml new file mode 100644 index 000000000000..67ba256f50ea --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/AdminSalesOrderActionGroup.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <actionGroup name="AdminSalesOrderActionGroup"> + <waitForPageLoad stepKey="waitForAdminSalesPageToLoad"/> + <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRowLink"/> + <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <waitForPageLoad stepKey="waitForCheckTotalActionGroup"/> + <scrollTo selector="{{AdminOrderTotalSection.subTotal}}" stepKey="scrollToOrderTotalSection"/> + <grabTextFrom selector="{{AdminOrderTotalSection.subTotal}}" stepKey="grabvalueForSubtotal"/> + <grabTextFrom selector="{{AdminOrderTotalSection.shippingAndHandling}}" stepKey="grabvalueForShippingHandling"/> + <grabTextFrom selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="grabvalueForGrandTotal"/> + <executeJS stepKey="sum_TotalValue" function=" + var subtotal = '{$grabvalueForSubtotal}'.substr(1); + var handling = '{$grabvalueForShippingHandling}'.substr(1); + var subtotal_handling = (parseFloat(subtotal) + parseFloat(handling)).toFixed(2); + return ('$' + subtotal_handling);"/> + <assertEquals stepKey="assertSubTotalPrice"> + <expectedResult type="string">$sum_TotalValue</expectedResult> + <actualResult type="string">$grabvalueForGrandTotal</actualResult> + </assertEquals> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMultipleAddressesActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMultipleAddressesActionGroup.xml index 333c2aec6c28..861b97427b44 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMultipleAddressesActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMultipleAddressesActionGroup.xml @@ -23,5 +23,22 @@ <click stepKey="clickOnUpdateAddress" selector="{{SingleShippingSection.updateAddress}}" after="selectSecondShippingMethod" /> <waitForPageLoad stepKey="waitForShippingInformation" after="clickOnUpdateAddress" /> </actionGroup> + <actionGroup name="StorefrontCheckoutWithMultipleAddressesActionGroup"> + <click selector="{{SingleShippingSection.checkoutWithMultipleAddresses}}" stepKey="clickOnCheckoutWithMultipleAddresses"/> + <waitForPageLoad stepKey="waitForMultipleAddressPageLoad"/> + </actionGroup> + <actionGroup name="StorefrontSelectAddressActionGroup"> + <arguments> + <argument name="sequenceNumber" type="string" defaultValue="1"/> + <argument name="option" type="string" defaultValue="1"/> + </arguments> + <selectOption selector="{{MultishippingSection.selectShippingAddress(sequenceNumber)}}" userInput="{{option}}" stepKey="selectShippingAddress"/> + </actionGroup> + <actionGroup name="StorefrontSaveAddressActionGroup"> + <click stepKey="clickOnUpdateAddress" selector="{{SingleShippingSection.updateAddress}}"/> + <waitForPageLoad stepKey="waitForShippingInformationAfterUpdated" time="90"/> + <click stepKey="goToShippingInformation" selector="{{SingleShippingSection.goToShippingInfo}}"/> + <waitForPageLoad stepKey="waitForShippingPageLoad"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/PlaceOrderActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/PlaceOrderActionGroup.xml index efb860e31478..349d31ef1da5 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/PlaceOrderActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/PlaceOrderActionGroup.xml @@ -16,5 +16,4 @@ <see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage"/> </actionGroup> -</actionGroups> - +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/ReviewOrderActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/ReviewOrderActionGroup.xml index af7d897910ca..bbd0e9ebad7a 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/ReviewOrderActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/ReviewOrderActionGroup.xml @@ -35,5 +35,4 @@ </assertEquals> </actionGroup> -</actionGroups> - +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SalesOrderActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SalesOrderActionGroup.xml new file mode 100644 index 000000000000..47cc3ffa455a --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SalesOrderActionGroup.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <actionGroup name="SalesOrderForMultiShipmentActionGroup"> + <arguments> + <argument name="shippingPrice" defaultValue="$5.00" type="string" /> + <argument name="subtotalPrice" defaultValue="$123.00" type="string" /> + <argument name="totalPrice" defaultValue="$128.00" type="string" /> + </arguments> + <waitForPageLoad stepKey="waitForSalesOrderHistoryPageToLoad" /> + <!--Click on View Order Link--> + <click stepKey="viewOrderAction" selector="{{SalesOrderSection.viewOrderLink}}"/> + <waitForPageLoad stepKey="waitForViewOrderPageToLoad" /> + <!--Check Shipping Method, Subtotal and Total Price--> + <grabTextFrom selector="{{SalesOrderSection.salesOrderPrice('subtotal')}}" stepKey="salesOrderSubtotalPrice"/> + <grabTextFrom selector="{{SalesOrderSection.salesOrderPrice('shipping')}}" stepKey="salesOrderShippingPrice"/> + <grabTextFrom selector="{{SalesOrderSection.salesOrderPrice('grand_total')}}" stepKey="salesOrderGrandTotalPrice"/> + <assertEquals stepKey="assertSubtotalPrice"> + <expectedResult type="string">{{subtotalPrice}}</expectedResult> + <actualResult type="string">$salesOrderSubtotalPrice</actualResult> + </assertEquals> + <assertEquals stepKey="assertShippingMethodPrice"> + <expectedResult type="string">{{shippingPrice}}</expectedResult> + <actualResult type="string">$salesOrderShippingPrice</actualResult> + </assertEquals> + <assertEquals stepKey="assertTotalPrice"> + <expectedResult type="string">{{totalPrice}}</expectedResult> + <actualResult type="string">$salesOrderGrandTotalPrice</actualResult> + </assertEquals> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectBillingInfoActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectBillingInfoActionGroup.xml index 3f7578953df7..c5dd97cadcc2 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectBillingInfoActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectBillingInfoActionGroup.xml @@ -12,5 +12,4 @@ <waitForPageLoad stepKey="waitForBillingInfoPageLoad"/> <click stepKey="goToReviewOrder" selector="{{PaymentMethodSection.goToReviewOrder}}"/> </actionGroup> -</actionGroups> - +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectShippingInfoActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectShippingInfoActionGroup.xml index af0b2467862b..bcaeb8ba4800 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectShippingInfoActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/SelectShippingInfoActionGroup.xml @@ -29,5 +29,9 @@ <waitForPageLoad stepKey="waitForRadioOptions"/> <click stepKey="goToBillingInformation" selector="{{ShippingMethodSection.goToBillingInfo}}"/> </actionGroup> + <actionGroup name="StorefrontLeaveDefaultShippingMethodsAndGoToBillingInfoActionGroup"> + <waitForPageLoad stepKey="waitForShippingInfo"/> + <click stepKey="goToBillingInformation" selector="{{ShippingMethodSection.goToBillingInfo}}"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontMultishippingCheckoutActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontMultishippingCheckoutActionGroup.xml new file mode 100644 index 000000000000..c5dee010239d --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontMultishippingCheckoutActionGroup.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <actionGroup name="StorefrontCheckoutShippingSelectMultipleAddressesActionGroup"> + <arguments> + <argument name="firstAddress" type="string" defaultValue="{{CustomerAddressSimple.street[0]}}"/> + <argument name="secondAddress" type="string" defaultValue="{{CustomerAddressSimple.street[1]}}"/> + </arguments> + <selectOption selector="{{StorefrontCheckoutShippingMultipleAddressesSection.selectedMultipleShippingAddress('1')}}" userInput="{{firstAddress}}" stepKey="selectShippingAddressForTheFirstItem"/> + <selectOption selector="{{StorefrontCheckoutShippingMultipleAddressesSection.selectedMultipleShippingAddress('2')}}" userInput="{{secondAddress}}" stepKey="selectShippingAddressForTheSecondItem"/> + <click selector="{{CheckoutSuccessMainSection.continueShoppingButton}}" stepKey="clickToGoToInformationButton"/> + </actionGroup> + <actionGroup name="StorefrontGoCheckoutWithMultipleAddresses"> + <click selector="{{MultishippingSection.shippingMultipleCheckout}}" stepKey="clickToMultipleAddressShippingButton"/> + </actionGroup> + <actionGroup name="StorefrontGoToBillingInformationActionGroup"> + <click selector="{{StorefrontMultipleShippingMethodSection.continueToBillingInformationButton}}" stepKey="clickToContinueToBillingInformationButton"/> + <waitForPageLoad stepKey="waitForBillingPage"/> + </actionGroup> +</actionGroups> + diff --git a/app/code/Magento/Multishipping/Test/Mftf/Page/MultishippingCheckoutPage.xml b/app/code/Magento/Multishipping/Test/Mftf/Page/MultishippingCheckoutPage.xml index 001002e98271..beee76a632b2 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Page/MultishippingCheckoutPage.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Page/MultishippingCheckoutPage.xml @@ -15,4 +15,4 @@ <section name="PaymentMethodSection"/> <section name="ReviewOrderSection"/> </page> -</pages> +</pages> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection.xml index 45fafc3105c3..e6f328249371 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection.xml @@ -16,9 +16,17 @@ </section> <section name="MultishippingSection"> <element name="checkoutWithMultipleAddresses" type="button" selector="//span[text()='Check Out with Multiple Addresses']"/> + <element name="shippingMultipleCheckout" type="button" selector=".action.multicheckout"/> <element name="firstShippingAddressValue" type="select" selector="//table//tbody//tr[position()=1]//td[position()=3]//div//select//option[2]"/> <element name="firstShippingAddressOption" type="select" selector="//table//tbody//tr[position()=1]//td[position()=3]//div//select"/> <element name="secondShippingAddressValue" type="select" selector="//table//tbody//tr[position()=2]//td[position()=3]//div//select//option[1]"/> <element name="secondShippingAddressOption" type="select" selector="//table//tbody//tr[position()=2]//td[position()=3]//div//select"/> + <element name="selectShippingAddress" type="select" selector="(//table[@id='multiship-addresses-table'] //div[@class='field address'] //select)[{{sequenceNumber}}]" parameterized="true"/> + </section> + <section name="StorefrontMultipleShippingMethodSection"> + <element name="orderId" type="text" selector=".shipping-list:nth-child({{rowNum}}) .order-id" parameterized="true"/> + <element name="goToReviewYourOrderButton" type="button" selector="#payment-continue"/> + <element name="continueToBillingInformationButton" type="button" selector=".action.primary.continue"/> + <element name="successMessage" type="text" selector=".multicheckout.success"/> </section> </sections> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/PaymentMethodSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/PaymentMethodSection.xml index 4e7f4a497ad4..8113ed3aa0c0 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Section/PaymentMethodSection.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/PaymentMethodSection.xml @@ -11,4 +11,4 @@ <section name="PaymentMethodSection"> <element name="goToReviewOrder" type="button" selector="//span[text()='Go to Review Your Order']"/> </section> -</sections> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/ReviewOrderSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/ReviewOrderSection.xml index e13f28929dcc..7961a0f811f6 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Section/ReviewOrderSection.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/ReviewOrderSection.xml @@ -23,5 +23,4 @@ <element name="secondOrderTotalPrice" type="text" selector="//div[@class='block-content'][position()=2]//table[position()=1]//tr[@class='grand totals'][position()=1]//td//span[@class='price']"/> <element name="grandTotalPrice" type="text" selector="//div[@class='checkout-review']//div[@class='grand totals']//span[@class='price']"/> </section> -</sections> - +</sections> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/SalesOrderSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/SalesOrderSection.xml new file mode 100644 index 000000000000..c788ef5978ad --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/SalesOrderSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <section name="SalesOrderSection"> + <element name="viewOrderLink" type="text" selector="//span[text()='View Order']"/> + <element name="salesOrderPrice" type="text" selector="//div[@class='order-details-items ordered']//tr[@class='{{price_type}}']//td[@class='amount']//span[@class='price']" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/ShippingMethodSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/ShippingMethodSection.xml index 6a2290bcf1a4..311b3ae95906 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Section/ShippingMethodSection.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/ShippingMethodSection.xml @@ -14,5 +14,4 @@ <element name="secondShippingMethodRadioButton" type="select" selector="//div[@class='block block-shipping'][position()=2]//div[@class='block-content']//div[@class='box box-shipping-method']//div[@class='box-content']//dl//dd[position()=2]//fieldset//div//div//input[@class='radio']"/> <element name="goToBillingInfo" type="button" selector="//span[text()='Continue to Billing Information']"/> </section> -</sections> - +</sections> \ No newline at end of file diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/StorefrontCheckoutShippingMultipleAddressesSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/StorefrontCheckoutShippingMultipleAddressesSection.xml new file mode 100644 index 000000000000..34427bda9334 --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/StorefrontCheckoutShippingMultipleAddressesSection.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontCheckoutShippingMultipleAddressesSection"> + <element name="selectedMultipleShippingAddress" type="select" selector=".table tr:nth-of-type({{selectNumber}}) select" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml new file mode 100644 index 000000000000..a81d24e99563 --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StoreFrontMyAccountWithMultishipmentTest"> + <annotations> + <features value="Multishipping"/> + <stories value="Shipping price shows 0 on Order view page after multiple address checkout"/> + <title value="Verify Shipping price for Storefront after multiple address checkout"/> + <description value="Verify that shipping price on My account matches with shipping method prices after multiple addresses checkout (Order view page)"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-19303"/> + <group value="multishipping"/> + </annotations> + + <before> + <createData stepKey="category" entity="SimpleSubCategory"/> + <createData stepKey="product1" entity="SimpleProduct"> + <requiredEntity createDataKey="category"/> + </createData> + <createData stepKey="product2" entity="SimpleProduct"> + <requiredEntity createDataKey="category"/> + </createData> + <createData entity="Simple_US_Customer_Two_Addresses" stepKey="customer"/> + <createData entity="FreeShippinMethodConfig" stepKey="enableFreeShipping"/> + <createData entity="FlatRateShippingMethodDefault" stepKey="enableFlatRateShipping"/> + <magentoCLI command="config:set payment/checkmo/active 1" stepKey="enableCheckMoneyOrderPaymentMethod"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> + <argument name="Customer" value="$$customer$$"/> + </actionGroup> + </before> + + <amOnPage url="$$product1.name$$.html" stepKey="goToProduct1"/> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProduct1"> + <argument name="productName" value="$$product1.name$$"/> + </actionGroup> + <amOnPage url="$$product2.name$$.html" stepKey="goToProduct2"/> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProduct2"> + <argument name="productName" value="$$product2.name$$"/> + </actionGroup> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/> + <actionGroup ref="CheckingWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/> + <actionGroup ref="SelectMultiShippingInfoActionGroup" stepKey="checkoutWithMultipleShipping"/> + <actionGroup ref="SelectBillingInfoActionGroup" stepKey="checkoutWithPaymentMethod"/> + <actionGroup ref="ReviewOrderForMultiShipmentActionGroup" stepKey="reviewOrderForMultiShipment"/> + <actionGroup ref="PlaceOrderActionGroup" stepKey="placeOrder"/> + <amOnPage url="{{StorefrontCustomerOrdersHistoryPage.url}}" stepKey="goToSalesOrder"/> + <actionGroup ref="SalesOrderForMultiShipmentActionGroup" stepKey="salesOrderForMultiShipment"/> + <waitForPageLoad stepKey="waitForAdminPageToLoad"/> + <!-- Go to Stores > Configuration > Sales > Orders --> + <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onAdminOrdersPage"/> + <actionGroup ref="AdminSalesOrderActionGroup" stepKey="ValidateOrderTotals"/> + <after> + <deleteData stepKey="deleteCategory" createDataKey="category"/> + <deleteData stepKey="deleteProduct1" createDataKey="product1"/> + <deleteData stepKey="deleteProduct2" createDataKey="product2"/> + <deleteData stepKey="deleteCustomer" createDataKey="customer"/> + <createData entity="FreeShippinMethodDefault" stepKey="disableFreeShipping"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontCheckoutWithMultipleAddressesTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontCheckoutWithMultipleAddressesTest.xml new file mode 100644 index 000000000000..138ab5df26ab --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontCheckoutWithMultipleAddressesTest.xml @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontCheckoutWithMultipleAddressesTest"> + <annotations> + <features value="Multishipping"/> + <stories value="Multiple Shipping"/> + <title value="Place an order with three different addresses"/> + <description value="Place an order with three different addresses"/> + <severity value="MAJOR"/> + <testCaseId value="MC-17461"/> + <useCaseId value="MAGETWO-99490"/> + <group value="Multishipment"/> + </annotations> + <before> + <!-- Login as Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + <!-- Set configurations --> + <magentoCLI command="config:set multishipping/options/checkout_multiple 1" stepKey="allowShippingToMultipleAddresses"/> + <!-- Create simple products --> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="firstProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="SimpleProduct" stepKey="secondProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Customer_US_UK_DE" stepKey="createCustomerWithMultipleAddresses"/> + </before> + <after> + <!-- Delete created data --> + <actionGroup ref="logout" stepKey="logout"/> + <deleteData createDataKey="firstProduct" stepKey="deleteFirstProduct"/> + <deleteData createDataKey="secondProduct" stepKey="deleteSecondProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/> + </after> + <!-- Login to the Storefront as created customer --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomerWithMultipleAddresses$$"/> + </actionGroup> + <!-- Open the first product page --> + <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToFirstProductPage"> + <argument name="productUrl" value="$$firstProduct.custom_attributes[url_key]$$"/> + </actionGroup> + <!-- Add the first product to the Shopping Cart --> + <actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addFirstProductToCart"> + <argument name="productName" value="$$firstProduct.name$$"/> + <argument name="productQty" value="1"/> + </actionGroup> + <!-- Open the second product page --> + <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToSecondProductPage"> + <argument name="productUrl" value="$$secondProduct.custom_attributes[url_key]$$"/> + </actionGroup> + <!-- Add the second product to the Shopping Cart --> + <actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addSecondProductToCart"> + <argument name="productName" value="$$secondProduct.name$$"/> + <argument name="productQty" value="1"/> + </actionGroup> + <!--Go to Cart --> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/> + <!--Check Out with Multiple Addresses --> + <actionGroup ref="StorefrontCheckoutWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/> + <!-- Select different addresses and click 'Go to Shipping Information' --> + <actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectFirstAddress"> + <argument name="sequenceNumber" value="1"/> + <argument name="option" value="John Doe, 368 Broadway St. 113, New York, New York 10001, United States"/> + </actionGroup> + <actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectSecondAddress"> + <argument name="sequenceNumber" value="2"/> + <argument name="option" value="John Doe, Augsburger Strabe 41, Berlin, 10789, Germany"/> + </actionGroup> + <actionGroup ref="StorefrontSaveAddressActionGroup" stepKey="saveAddresses"/> + <!-- Click 'Continue to Billing Information' --> + <actionGroup ref="StorefrontLeaveDefaultShippingMethodsAndGoToBillingInfoActionGroup" stepKey="useDefaultShippingMethod"/> + <!-- Click 'Go to Review Your Order' --> + <actionGroup ref="SelectBillingInfoActionGroup" stepKey="useDefaultBillingMethod"/> + <!-- Click 'Place Order' --> + <actionGroup ref="PlaceOrderActionGroup" stepKey="placeOrder"/> + <!-- Open the first product page --> + <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="goToFirstProductPageSecondTime"> + <argument name="productUrl" value="$$firstProduct.custom_attributes[url_key]$$"/> + </actionGroup> + <!-- Add three identical products to the Shopping Cart --> + <actionGroup ref="AddProductWithQtyToCartFromStorefrontProductPage" stepKey="addIdenticalProductsToCart"> + <argument name="productName" value="$$firstProduct.name$$"/> + <argument name="productQty" value="3"/> + </actionGroup> + <!--Go to Cart --> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCartWithIdenticalProducts"/> + <!--Check Out with Multiple Addresses --> + <actionGroup ref="StorefrontCheckoutWithMultipleAddressesActionGroup" stepKey="checkoutWithThreeDifferentAddresses"/> + <!-- Select different addresses and click 'Go to Shipping Information' --> + <actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectFirstAddressFromThree"> + <argument name="sequenceNumber" value="1"/> + <argument name="option" value="John Doe, 368 Broadway St. 113, New York, New York 10001, United States"/> + </actionGroup> + <actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectSecondAddressFromThree"> + <argument name="sequenceNumber" value="2"/> + <argument name="option" value="John Doe, Augsburger Strabe 41, Berlin, 10789, Germany"/> + </actionGroup> + <actionGroup ref="StorefrontSelectAddressActionGroup" stepKey="selectThirdAddressFromThree"> + <argument name="sequenceNumber" value="3"/> + <argument name="option" value="Jane Doe, 172, Westminster Bridge Rd, London, SE1 7RW, United Kingdom"/> + </actionGroup> + <actionGroup ref="StorefrontSaveAddressActionGroup" stepKey="saveThreeDifferentAddresses"/> + <!-- Click 'Continue to Billing Information' --> + <actionGroup ref="StorefrontLeaveDefaultShippingMethodsAndGoToBillingInfoActionGroup" stepKey="useDefaultShippingMethodForIdenticalProducts"/> + <!-- Click 'Go to Review Your Order' --> + <actionGroup ref="SelectBillingInfoActionGroup" stepKey="UseDefaultBillingMethodForIdenticalProducts"/> + <!-- Click 'Place Order' --> + <actionGroup ref="PlaceOrderActionGroup" stepKey="placeOrderWithIdenticalProducts"/> + </test> +</tests> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml new file mode 100644 index 000000000000..fd79d4d954cd --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest"> + <annotations> + <features value="Multishipping"/> + <stories value="Multishipping"/> + <title value="Process multishipping checkout when Cart page is opened in another tab"/> + <description value="Process multishipping checkout when Cart page is opened in another tab"/> + <severity value="MAJOR"/> + <testCaseId value="MC-17871"/> + <useCaseId value="MC-17469"/> + <group value="multishipping"/> + </annotations> + <before> + <!-- Login as Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + <!-- Set configurations --> + <magentoCLI command="config:set multishipping/options/checkout_multiple 1" stepKey="allowShippingToMultipleAddresses"/> + <!-- Create two simple products --> + <createData entity="ApiCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createFirstProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="_defaultProduct" stepKey="createSecondProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomerWithMultipleAddresses"/> + </before> + <after> + <!-- Delete created data --> + <actionGroup ref="logout" stepKey="logout"/> + <deleteData createDataKey="createFirstProduct" stepKey="deleteFirstProduct"/> + <deleteData createDataKey="createSecondProduct" stepKey="deleteSecondProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/> + </after> + <!-- Login to the Storefront as created customer --> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomerWithMultipleAddresses$$"/> + </actionGroup> + <!-- Add two products to the Shopping Cart --> + <amOnPage url="{{StorefrontProductPage.url($$createFirstProduct.name$$)}}" stepKey="amOnStorefrontProductFirstPage"/> + <waitForPageLoad stepKey="waitForTheFirstProduct"/> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddProductToCart"> + <argument name="product" value="$$createFirstProduct$$"/> + <argument name="productCount" value="1"/> + </actionGroup> + <amOnPage url="{{StorefrontProductPage.url($$createSecondProduct.name$$)}}" stepKey="amOnStorefrontSecondProductPage"/> + <waitForPageLoad stepKey="waitForPageLoadForTheSecondProduct"/> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="cartAddSecondProductToCart"> + <argument name="product" value="$$createSecondProduct$$"/> + <argument name="productCount" value="2"/> + </actionGroup> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> + <!-- Click 'Check Out with Multiple Addresses' --> + <waitForPageLoad stepKey="waitForSecondPageLoad"/> + <actionGroup ref="StorefrontGoCheckoutWithMultipleAddresses" stepKey="goCheckoutWithMultipleAddresses"/> + <!-- Select different addresses and click 'Go to Shipping Information' --> + <actionGroup ref="StorefrontCheckoutShippingSelectMultipleAddressesActionGroup" stepKey="selectMultipleAddresses"> + <argument name="firstAddress" value="{{UK_Not_Default_Address.street[0]}}"/> + <argument name="secondAddress" value="{{US_Address_NY.street[1]}}"/> + </actionGroup> + <waitForPageLoad stepKey="waitPageLoad"/> + <!-- Open the Cart page in another browser window and go back --> + <openNewTab stepKey="openNewTab"/> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPageNewTab"/> + <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertFirstProductItemInCheckOutCart"> + <argument name="productName" value="$$createFirstProduct.name$$"/> + <argument name="productSku" value="$$createFirstProduct.sku$$"/> + <argument name="productPrice" value="$$createFirstProduct.price$$"/> + <argument name="subtotal" value="$$createFirstProduct.price$$" /> + <argument name="qty" value="1"/> + </actionGroup> + <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertSecondProductItemInCheckOutCart"> + <argument name="productName" value="$$createSecondProduct.name$$"/> + <argument name="productSku" value="$$createSecondProduct.sku$$"/> + <argument name="productPrice" value="$$createSecondProduct.price$$"/> + <argument name="subtotal" value="$$createSecondProduct.price$$" /> + <argument name="qty" value="1"/> + </actionGroup> + <switchToNextTab stepKey="switchToNextTab"/> + <!-- Click 'Continue to Billing Information' and 'Go to Review Your Order' --> + <actionGroup ref="StorefrontGoToBillingInformationActionGroup" stepKey="goToBillingInformation"/> + <see selector="{{ShipmentFormSection.shippingAddress}}" userInput="{{US_Address_NY.city}}" stepKey="seeBillingAddress"/> + <waitForElementVisible selector="{{StorefrontMultipleShippingMethodSection.goToReviewYourOrderButton}}" stepKey="waitForGoToReviewYourOrderVisible" /> + <click selector="{{StorefrontMultipleShippingMethodSection.goToReviewYourOrderButton}}" stepKey="clickToGoToReviewYourOrderButton"/> + <!-- Click 'Place Order' --> + <actionGroup ref="PlaceOrderActionGroup" stepKey="placeOrder"/> + <see selector="{{StorefrontMultipleShippingMethodSection.successMessage}}" userInput="Successfully ordered" stepKey="seeSuccessMessage"/> + <grabTextFrom selector="{{StorefrontMultipleShippingMethodSection.orderId('1')}}" stepKey="grabFirstOrderId"/> + <grabTextFrom selector="{{StorefrontMultipleShippingMethodSection.orderId('2')}}" stepKey="grabSecondOrderId"/> + <!-- Go to My Account > My Orders --> + <amOnPage url="{{StorefrontCustomerOrdersHistoryPage.url}}" stepKey="goToMyOrdersPage"/> + <waitForPageLoad stepKey="waitForMyOrdersPageLoad"/> + <seeElement selector="{{StorefrontCustomerOrdersGridSection.orderView({$grabFirstOrderId})}}" stepKey="seeFirstOrder"/> + <seeElement selector="{{StorefrontCustomerOrdersGridSection.orderView({$grabSecondOrderId})}}" stepKey="seeSecondOrder"/> + <waitForPageLoad stepKey="waitForOrderPageLoad"/> + <!-- Go to Admin > Sales > Orders --> + <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage"/> + <actionGroup ref="searchAdminDataGridByKeyword" stepKey="searchFirstOrder"> + <argument name="keyword" value="$grabFirstOrderId"/> + </actionGroup> + <seeElement selector="{{AdminOrdersGridSection.orderId({$grabFirstOrderId})}}" stepKey="seeAdminFirstOrder"/> + <actionGroup ref="searchAdminDataGridByKeyword" stepKey="searchSecondOrder"> + <argument name="keyword" value="$grabSecondOrderId"/> + </actionGroup> + <seeElement selector="{{AdminOrdersGridSection.orderId({$grabSecondOrderId})}}" stepKey="seeAdminSecondOrder"/> + </test> +</tests> diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php index 9ffef2832a6b..42715d026e9e 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/Address/NewShippingTest.php @@ -170,7 +170,7 @@ public function executeDataProvider() { return [ 'shipping_address_exists' => ['*/checkout/addresses', 'shipping_address', 'back/address'], - 'shipping_address_not_exist' => ['*/cart/', null, 'back/cart'] + 'shipping_address_not_exist' => ['checkout/cart/', null, 'back/cart'] ]; } diff --git a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php deleted file mode 100644 index a26f2661ebab..000000000000 --- a/app/code/Magento/Multishipping/Test/Unit/Controller/Checkout/PluginTest.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php -/** - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -declare(strict_types=1); - -namespace Magento\Multishipping\Test\Unit\Controller\Checkout; - -use Magento\Multishipping\Controller\Checkout\Plugin; - -class PluginTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $cartMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteMock; - - /** - * @var Plugin - */ - protected $object; - - protected function setUp() - { - $this->cartMock = $this->createMock(\Magento\Checkout\Model\Cart::class); - $this->quoteMock = $this->createPartialMock( - \Magento\Quote\Model\Quote::class, - ['__wakeUp', 'setIsMultiShipping', 'getIsMultiShipping'] - ); - $this->cartMock->expects($this->once())->method('getQuote')->will($this->returnValue($this->quoteMock)); - $this->object = new \Magento\Multishipping\Controller\Checkout\Plugin($this->cartMock); - } - - public function testExecuteTurnsOffMultishippingModeOnMultishippingQuote(): void - { - $subject = $this->createMock(\Magento\Checkout\Controller\Index\Index::class); - $this->quoteMock->expects($this->once())->method('getIsMultiShipping')->willReturn(1); - $this->quoteMock->expects($this->once())->method('setIsMultiShipping')->with(0); - $this->cartMock->expects($this->once())->method('saveQuote'); - $this->object->beforeExecute($subject); - } - - public function testExecuteTurnsOffMultishippingModeOnNotMultishippingQuote(): void - { - $subject = $this->createMock(\Magento\Checkout\Controller\Index\Index::class); - $this->quoteMock->expects($this->once())->method('getIsMultiShipping')->willReturn(0); - $this->quoteMock->expects($this->never())->method('setIsMultiShipping'); - $this->cartMock->expects($this->never())->method('saveQuote'); - $this->object->beforeExecute($subject); - } -} diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php index 02bc96687377..731365974c23 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/MultishippingTest.php @@ -11,6 +11,7 @@ use Magento\Customer\Api\Data\AddressInterface; use Magento\Customer\Api\Data\AddressSearchResultsInterface; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Directory\Model\Currency; use Magento\Multishipping\Model\Checkout\Type\Multishipping\PlaceOrderDefault; use Magento\Multishipping\Model\Checkout\Type\Multishipping\PlaceOrderFactory; use Magento\Quote\Model\Quote\Address; @@ -44,6 +45,7 @@ use Magento\Quote\Model\ShippingAssignment; use Magento\Sales\Model\Order\Email\Sender\OrderSender; use Magento\Sales\Model\OrderFactory; +use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use PHPUnit_Framework_MockObject_MockObject; use \PHPUnit\Framework\TestCase; @@ -453,7 +455,8 @@ public function testCreateOrders(): void ]; $quoteItemId = 1; $paymentProviderCode = 'checkmo'; - + $shippingPrice = '0.00'; + $currencyCode = 'USD'; $simpleProductTypeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Type\Simple::class) ->disableOriginalConstructor() ->setMethods(['getOrderOptions']) @@ -467,6 +470,17 @@ public function testCreateOrders(): void $this->getQuoteAddressesMock($quoteAddressItemMock, $addressTotal); $this->setQuoteMockData($paymentProviderCode, $shippingAddressMock, $billingAddressMock); + $currencyMock = $this->getMockBuilder(Currency::class) + ->disableOriginalConstructor() + ->setMethods([ 'convert' ]) + ->getMock(); + $currencyMock->method('convert')->willReturn($shippingPrice); + $storeMock = $this->getMockBuilder(Store::class) + ->disableOriginalConstructor() + ->setMethods(['getBaseCurrency','getCurrentCurrencyCode' ]) + ->getMock(); + $storeMock->method('getBaseCurrency')->willReturn($currencyMock); + $storeMock->method('getCurrentCurrencyCode')->willReturn($currencyCode); $orderAddressMock = $this->createSimpleMock(\Magento\Sales\Api\Data\OrderAddressInterface::class); $orderPaymentMock = $this->createSimpleMock(\Magento\Sales\Api\Data\OrderPaymentInterface::class); $orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class) @@ -476,6 +490,9 @@ public function testCreateOrders(): void $orderItemMock->method('getQuoteItemId')->willReturn($quoteItemId); $orderMock = $this->getOrderMock($orderAddressMock, $orderPaymentMock, $orderItemMock); + $orderMock->expects($this->once())->method('getStore')->willReturn($storeMock); + $orderMock->expects($this->once())->method('setBaseShippingAmount')->with($shippingPrice)->willReturnSelf(); + $orderMock->expects($this->once())->method('setShippingAmount')->with($shippingPrice)->willReturnSelf(); $this->orderFactoryMock->expects($this->once())->method('create')->willReturn($orderMock); $this->dataObjectHelperMock->expects($this->once())->method('mergeDataObjects') ->with( @@ -608,12 +625,18 @@ private function getQuoteAddressesMock($quoteAddressItemMock, int $addressTotal) )->getMock(); $shippingAddressMock->method('validate')->willReturn(true); $shippingAddressMock->method('getShippingMethod')->willReturn('carrier'); - $shippingAddressMock->method('getShippingRateByCode')->willReturn('code'); $shippingAddressMock->method('getCountryId')->willReturn('EN'); $shippingAddressMock->method('getAllItems')->willReturn([$quoteAddressItemMock]); $shippingAddressMock->method('getAddressType')->willReturn('shipping'); $shippingAddressMock->method('getGrandTotal')->willReturn($addressTotal); + $shippingRateMock = $this->getMockBuilder(Address\Rate::class) + ->disableOriginalConstructor() + ->setMethods([ 'getPrice' ]) + ->getMock(); + $shippingRateMock->method('getPrice')->willReturn('0.00'); + $shippingAddressMock->method('getShippingRateByCode')->willReturn($shippingRateMock); + $billingAddressMock = $this->getMockBuilder(Address::class) ->disableOriginalConstructor() ->setMethods(['validate']) @@ -673,6 +696,9 @@ private function getOrderMock( 'getCanSendNewEmailFlag', 'getItems', 'setShippingMethod', + 'getStore', + 'setShippingAmount', + 'setBaseShippingAmount' ] )->getMock(); $orderMock->method('setQuote')->with($this->quoteMock); diff --git a/app/code/Magento/Multishipping/Test/Unit/Plugin/DisableMultishippingModeTest.php b/app/code/Magento/Multishipping/Test/Unit/Plugin/DisableMultishippingModeTest.php new file mode 100644 index 000000000000..02ae1a70ce80 --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Unit/Plugin/DisableMultishippingModeTest.php @@ -0,0 +1,99 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Multishipping\Test\Unit\Plugin; + +use Magento\Checkout\Controller\Index\Index; +use Magento\Checkout\Model\Cart; +use Magento\Multishipping\Plugin\DisableMultishippingMode; +use Magento\Quote\Api\Data\CartExtensionInterface; +use Magento\Quote\Api\Data\ShippingAssignmentInterface; +use Magento\Quote\Model\Quote; + +/** + * Class DisableMultishippingModeTest + */ +class DisableMultishippingModeTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $cartMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $quoteMock; + + /** + * @var DisableMultishippingMode + */ + private $object; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->cartMock = $this->createMock(Cart::class); + $this->quoteMock = $this->createPartialMock( + Quote::class, + ['__wakeUp', 'setIsMultiShipping', 'getIsMultiShipping', 'getExtensionAttributes'] + ); + $this->cartMock->expects($this->once()) + ->method('getQuote') + ->will($this->returnValue($this->quoteMock)); + $this->object = new DisableMultishippingMode($this->cartMock); + } + + /** + * Tests turn off multishipping on multishipping quote. + * + * @return void + */ + public function testExecuteTurnsOffMultishippingModeOnMultishippingQuote(): void + { + $subject = $this->createMock(Index::class); + $extensionAttributes = $this->createPartialMock( + CartExtensionInterface::class, + ['setShippingAssignments', 'getShippingAssignments'] + ); + $extensionAttributes->method('getShippingAssignments') + ->willReturn( + $this->createMock(ShippingAssignmentInterface::class) + ); + $extensionAttributes->expects($this->once()) + ->method('setShippingAssignments') + ->with([]); + $this->quoteMock->method('getExtensionAttributes') + ->willReturn($extensionAttributes); + $this->quoteMock->expects($this->once()) + ->method('getIsMultiShipping')->willReturn(1); + $this->quoteMock->expects($this->once()) + ->method('setIsMultiShipping') + ->with(0); + $this->cartMock->expects($this->once()) + ->method('saveQuote'); + + $this->object->beforeExecute($subject); + } + + /** + * Tests turn off multishipping on non-multishipping quote. + * + * @return void + */ + public function testExecuteTurnsOffMultishippingModeOnNotMultishippingQuote(): void + { + $subject = $this->createMock(Index::class); + $this->quoteMock->expects($this->once())->method('getIsMultiShipping')->willReturn(0); + $this->quoteMock->expects($this->never())->method('setIsMultiShipping'); + $this->cartMock->expects($this->never())->method('saveQuote'); + $this->object->beforeExecute($subject); + } +} diff --git a/app/code/Magento/Multishipping/etc/di.xml b/app/code/Magento/Multishipping/etc/di.xml index 3bccf0b74bcd..ad0d341d6b2e 100644 --- a/app/code/Magento/Multishipping/etc/di.xml +++ b/app/code/Magento/Multishipping/etc/di.xml @@ -9,4 +9,7 @@ <type name="Magento\Quote\Model\Cart\CartTotalRepository"> <plugin name="multishipping_shipping_addresses" type="Magento\Multishipping\Model\Cart\CartTotalRepositoryPlugin" /> </type> + <type name="Magento\Quote\Model\QuoteRepository"> + <plugin name="multishipping_quote_repository" type="Magento\Multishipping\Plugin\MultishippingQuoteRepository" /> + </type> </config> diff --git a/app/code/Magento/Multishipping/etc/frontend/di.xml b/app/code/Magento/Multishipping/etc/frontend/di.xml index 0c2daaf45043..481b95280a4a 100644 --- a/app/code/Magento/Multishipping/etc/frontend/di.xml +++ b/app/code/Magento/Multishipping/etc/frontend/di.xml @@ -31,13 +31,13 @@ </arguments> </type> <type name="Magento\Checkout\Controller\Cart\Add"> - <plugin name="multishipping_disabler" type="Magento\Multishipping\Controller\Checkout\Plugin" sortOrder="50" /> + <plugin name="multishipping_disabler" type="Magento\Multishipping\Plugin\DisableMultishippingMode" sortOrder="50" /> </type> <type name="Magento\Checkout\Controller\Cart\UpdatePost"> - <plugin name="multishipping_disabler" type="Magento\Multishipping\Controller\Checkout\Plugin" sortOrder="50" /> + <plugin name="multishipping_disabler" type="Magento\Multishipping\Plugin\DisableMultishippingMode" sortOrder="50" /> </type> <type name="Magento\Checkout\Controller\Index\Index"> - <plugin name="multishipping_disabler" type="Magento\Multishipping\Controller\Checkout\Plugin" sortOrder="50" /> + <plugin name="multishipping_disabler" type="Magento\Multishipping\Plugin\DisableMultishippingMode" sortOrder="50" /> </type> <type name="Magento\Checkout\Model\Cart"> <plugin name="multishipping_session_mapper" type="Magento\Multishipping\Model\Checkout\Type\Multishipping\Plugin" sortOrder="50" /> @@ -45,4 +45,7 @@ <type name="Magento\Checkout\Controller\Cart"> <plugin name="multishipping_clear_addresses" type="Magento\Multishipping\Model\Cart\Controller\CartPlugin" sortOrder="50" /> </type> + <type name="Magento\Quote\Model\Quote"> + <plugin name="multishipping_reset_shipping_assigment" type="Magento\Multishipping\Plugin\ResetShippingAssigment"/> + </type> </config> diff --git a/app/code/Magento/MysqlMq/Model/ResourceModel/Queue.php b/app/code/Magento/MysqlMq/Model/ResourceModel/Queue.php index d50ed851b64a..2a45eafc63f2 100644 --- a/app/code/Magento/MysqlMq/Model/ResourceModel/Queue.php +++ b/app/code/Magento/MysqlMq/Model/ResourceModel/Queue.php @@ -151,7 +151,7 @@ public function getMessages($queueName, $limit = null) 'queue_message_status.status IN (?)', [QueueManagement::MESSAGE_STATUS_NEW, QueueManagement::MESSAGE_STATUS_RETRY_REQUIRED] )->where('queue.name = ?', $queueName) - ->order('queue_message_status.updated_at ASC'); + ->order(['queue_message_status.updated_at ASC', 'queue_message_status.id ASC']); if ($limit) { $select->limit($limit); diff --git a/app/code/Magento/MysqlMq/Test/Unit/Model/ResourceModel/QueueTest.php b/app/code/Magento/MysqlMq/Test/Unit/Model/ResourceModel/QueueTest.php index d3fe09a71294..e3c6e6d9aee2 100644 --- a/app/code/Magento/MysqlMq/Test/Unit/Model/ResourceModel/QueueTest.php +++ b/app/code/Magento/MysqlMq/Test/Unit/Model/ResourceModel/QueueTest.php @@ -206,7 +206,9 @@ public function testGetMessages() ] )->willReturnSelf(); $select->expects($this->once()) - ->method('order')->with('queue_message_status.updated_at ASC')->willReturnSelf(); + ->method('order') + ->with(['queue_message_status.updated_at ASC', 'queue_message_status.id ASC']) + ->willReturnSelf(); $select->expects($this->once())->method('limit')->with($limit)->willReturnSelf(); $connection->expects($this->once())->method('fetchAll')->with($select)->willReturn($messages); $this->assertEquals($messages, $this->queue->getMessages($queueName, $limit)); diff --git a/app/code/Magento/NewRelicReporting/Model/Apm/Deployments.php b/app/code/Magento/NewRelicReporting/Model/Apm/Deployments.php index bacdd3e4a81f..99d3f4d406ad 100644 --- a/app/code/Magento/NewRelicReporting/Model/Apm/Deployments.php +++ b/app/code/Magento/NewRelicReporting/Model/Apm/Deployments.php @@ -7,6 +7,9 @@ use \Magento\Framework\HTTP\ZendClient; +/** + * Performs the request to make the deployment + */ class Deployments { /** @@ -88,7 +91,7 @@ public function setDeployment($description, $change = false, $user = false) return false; } - if (($response->getStatus() < 200 || $response->getStatus() > 210)) { + if ($response->getStatus() < 200 || $response->getStatus() > 210) { $this->logger->warning('Deployment marker request did not send a 200 status code.'); return false; } diff --git a/app/code/Magento/NewRelicReporting/Model/Module/Collect.php b/app/code/Magento/NewRelicReporting/Model/Module/Collect.php index 0d8a94fbed94..fe5389e258aa 100644 --- a/app/code/Magento/NewRelicReporting/Model/Module/Collect.php +++ b/app/code/Magento/NewRelicReporting/Model/Module/Collect.php @@ -6,7 +6,7 @@ namespace Magento\NewRelicReporting\Model\Module; use Magento\Framework\Module\FullModuleList; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Module\ModuleListInterface; use Magento\NewRelicReporting\Model\Config; use Magento\NewRelicReporting\Model\Module; @@ -22,7 +22,7 @@ class Collect protected $moduleList; /** - * @var ModuleManagerInterface + * @var Manager */ protected $moduleManager; @@ -46,14 +46,14 @@ class Collect * * @param ModuleListInterface $moduleList * @param FullModuleList $fullModuleList - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param \Magento\NewRelicReporting\Model\ModuleFactory $moduleFactory * @param \Magento\NewRelicReporting\Model\ResourceModel\Module\CollectionFactory $moduleCollectionFactory */ public function __construct( ModuleListInterface $moduleList, FullModuleList $fullModuleList, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, \Magento\NewRelicReporting\Model\ModuleFactory $moduleFactory, \Magento\NewRelicReporting\Model\ResourceModel\Module\CollectionFactory $moduleCollectionFactory ) { diff --git a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php index 3c30d95b77de..4286406d6e9a 100644 --- a/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php +++ b/app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php @@ -8,6 +8,7 @@ use Magento\NewRelicReporting\Model\Module\Collect; use Magento\Framework\Module\FullModuleList; use Magento\Framework\Module\ModuleListInterface; +use Magento\Framework\Module\Manager; use Magento\NewRelicReporting\Model\Module; /** diff --git a/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml b/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml index 1df1cd5f8dae..02657340bf34 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Data/AdminMenuData.xml @@ -19,8 +19,8 @@ <data key="dataUiId">magento-newsletter-newsletter-subscriber</data> </entity> <entity name="AdminMenuMarketingCommunicationsNewsletterTemplate"> - <data key="pageTitle">Newsletter Template</data> - <data key="title">Newsletter Template</data> + <data key="pageTitle">Newsletter Templates</data> + <data key="title">Newsletter Templates</data> <data key="dataUiId">magento-newsletter-newsletter-template</data> </entity> <entity name="AdminMenuReportsMarketingNewsletterProblemReports"> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminAddWidgetToWYSIWYGNewsletterTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminAddWidgetToWYSIWYGNewsletterTest.xml index a7ac9e38d4b0..273a39a31213 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminAddWidgetToWYSIWYGNewsletterTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminAddWidgetToWYSIWYGNewsletterTest.xml @@ -15,10 +15,7 @@ <title value="Admin should be able to add widget to WYSIWYG Editor of Newsletter"/> <description value="Admin should be able to add widget to WYSIWYG Editor Newsletter"/> <severity value="CRITICAL"/> - <testCaseId value="MAGETWO-84682"/> - <skip> - <issueId value="MC-17140"/> - </skip> + <testCaseId value="MC-6070"/> </annotations> <before> <actionGroup ref="LoginActionGroup" stepKey="login"/> @@ -26,13 +23,14 @@ <actionGroup ref="SwitchToVersion4ActionGroup" stepKey="switchToTinyMCE4" /> </before> <amOnPage url="{{NewsletterTemplateForm.url}}" stepKey="amOnNewsletterTemplatePage"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> + <waitForElementVisible selector="{{BasicFieldNewsletterSection.templateName}}" stepKey="waitForTemplateName"/> <fillField selector="{{BasicFieldNewsletterSection.templateName}}" userInput="{{_defaultNewsletter.name}}" stepKey="fillTemplateName" /> <fillField selector="{{BasicFieldNewsletterSection.templateSubject}}" userInput="{{_defaultNewsletter.subject}}" stepKey="fillTemplateSubject" /> <fillField selector="{{BasicFieldNewsletterSection.senderName}}" userInput="{{_defaultNewsletter.senderName}}" stepKey="fillSenderName" /> <fillField selector="{{BasicFieldNewsletterSection.senderEmail}}" userInput="{{_defaultNewsletter.senderEmail}}" stepKey="fillSenderEmail" /> <conditionalClick selector="{{NewsletterWYSIWYGSection.ShowHideBtn}}" dependentSelector="{{NewsletterWYSIWYGSection.TinyMCE4}}" visible="false" stepKey="toggleEditorIfHidden"/> <waitForElementVisible selector="{{TinyMCESection.TinyMCE4}}" stepKey="waitForTinyMCE" /> + <waitForElementVisible selector="{{NewsletterWYSIWYGSection.InsertWidgetIcon}}" stepKey="waitForInsertWidgerIconButton"/> <click selector="{{NewsletterWYSIWYGSection.InsertWidgetIcon}}" stepKey="clickInsertWidgetIcon" /> <wait time="10" stepKey="waitForPageLoad" /> <see userInput="Inserting a widget does not create a widget instance." stepKey="seeMessage" /> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml index 22ca214c94ae..4d60b7676605 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml @@ -49,7 +49,7 @@ </actionGroup> <magentoCLI command="indexer:reindex" stepKey="reindex"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Go to store front (default) and click Create an Account.--> diff --git a/app/code/Magento/Newsletter/etc/adminhtml/menu.xml b/app/code/Magento/Newsletter/etc/adminhtml/menu.xml index a9cedf1c7a1e..8fc21494b5de 100644 --- a/app/code/Magento/Newsletter/etc/adminhtml/menu.xml +++ b/app/code/Magento/Newsletter/etc/adminhtml/menu.xml @@ -7,7 +7,7 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd"> <menu> - <add id="Magento_Newsletter::newsletter_template" title="Newsletter Template" translate="title" module="Magento_Newsletter" parent="Magento_Backend::marketing_communications" sortOrder="30" action="newsletter/template/" resource="Magento_Newsletter::template"/> + <add id="Magento_Newsletter::newsletter_template" title="Newsletter Templates" translate="title" module="Magento_Newsletter" parent="Magento_Backend::marketing_communications" sortOrder="30" action="newsletter/template/" resource="Magento_Newsletter::template"/> <add id="Magento_Newsletter::newsletter_queue" title="Newsletter Queue" translate="title" module="Magento_Newsletter" sortOrder="40" parent="Magento_Backend::marketing_communications" action="newsletter/queue/" resource="Magento_Newsletter::queue"/> <add id="Magento_Newsletter::newsletter_subscriber" title="Newsletter Subscribers" translate="title" module="Magento_Newsletter" sortOrder="50" parent="Magento_Backend::marketing_communications" action="newsletter/subscriber/" resource="Magento_Newsletter::subscriber"/> <add id="Magento_Newsletter::newsletter_problem" title="Newsletter Problem Reports" translate="title" module="Magento_Newsletter" sortOrder="50" parent="Magento_Reports::report_marketing" action="newsletter/problem/" resource="Magento_Newsletter::problem"/> diff --git a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml index aef84c068100..5d54dab99e75 100644 --- a/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml +++ b/app/code/Magento/Newsletter/view/adminhtml/layout/newsletter_subscriber_block.xml @@ -91,7 +91,6 @@ <arguments> <argument name="header" xsi:type="string" translate="true">Customer First Name</argument> <argument name="index" xsi:type="string">firstname</argument> - <argument name="default" xsi:type="string">----</argument> <argument name="header_css_class" xsi:type="string">col-first-name</argument> <argument name="column_css_class" xsi:type="string">col-first-name</argument> </arguments> @@ -100,7 +99,6 @@ <arguments> <argument name="header" xsi:type="string" translate="true">Customer Last Name</argument> <argument name="index" xsi:type="string">lastname</argument> - <argument name="default" xsi:type="string">----</argument> <argument name="header_css_class" xsi:type="string">col-last-name</argument> <argument name="column_css_class" xsi:type="string">col-last-name</argument> </arguments> diff --git a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/checkmo.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/checkmo.phtml index 36f9d35327fc..28395f8eeb84 100644 --- a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/checkmo.phtml +++ b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/checkmo.phtml @@ -7,8 +7,9 @@ /** * @var $block \Magento\OfflinePayments\Block\Info\Checkmo */ +$paymentTitle = $block->getMethod()->getConfigData('title', $block->getInfo()->getOrder()->getStoreId()); ?> -<?= $block->escapeHtml($block->getMethod()->getTitle()) ?> +<?= $block->escapeHtml($paymentTitle) ?> <?php if ($block->getInfo()->getAdditionalInformation()) : ?> <?php if ($block->getPayableTo()) : ?> <br /><?= $block->escapeHtml(__('Make Check payable to: %1', $block->getPayableTo())) ?> diff --git a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/pdf/checkmo.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/pdf/checkmo.phtml index d8d952526e67..f85a8f8357dd 100644 --- a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/pdf/checkmo.phtml +++ b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/pdf/checkmo.phtml @@ -7,8 +7,9 @@ /** * @var $block \Magento\OfflinePayments\Block\Info\Checkmo */ +$paymentTitle = $block->getMethod()->getConfigData('title', $block->getInfo()->getOrder()->getStoreId()); ?> -<?= $block->escapeHtml($block->getMethod()->getTitle()) ?> +<?= $block->escapeHtml($paymentTitle) ?> {{pdf_row_separator}} <?php if ($block->getInfo()->getAdditionalInformation()) : ?> {{pdf_row_separator}} diff --git a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/purchaseorder.phtml b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/purchaseorder.phtml index 2a6de7f0cc35..ae7f654a1350 100644 --- a/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/purchaseorder.phtml +++ b/app/code/Magento/OfflinePayments/view/adminhtml/templates/info/purchaseorder.phtml @@ -6,8 +6,9 @@ /** * @var $block \Magento\OfflinePayments\Block\Info\Purchaseorder */ +$paymentTitle = $block->getMethod()->getConfigData('title', $block->getInfo()->getOrder()->getStoreId()); ?> -<div class="order-payment-method-name"><?= $block->escapeHtml($block->getMethod()->getTitle()) ?></div> +<div class="order-payment-method-name"><?= $block->escapeHtml($paymentTitle) ?></div> <table class="data-table admin__table-secondary"> <tr> <th><?= $block->escapeHtml(__('Purchase Order Number')) ?>:</th> diff --git a/app/code/Magento/PageCache/Model/DepersonalizeChecker.php b/app/code/Magento/PageCache/Model/DepersonalizeChecker.php index 4012499d5da5..3023efb7a71a 100644 --- a/app/code/Magento/PageCache/Model/DepersonalizeChecker.php +++ b/app/code/Magento/PageCache/Model/DepersonalizeChecker.php @@ -20,7 +20,7 @@ class DepersonalizeChecker /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManager; @@ -33,12 +33,12 @@ class DepersonalizeChecker /** * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param Config $cacheConfig */ public function __construct( \Magento\Framework\App\RequestInterface $request, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, Config $cacheConfig ) { $this->request = $request; diff --git a/app/code/Magento/PageCache/Plugin/RegisterFormKeyFromCookie.php b/app/code/Magento/PageCache/Plugin/RegisterFormKeyFromCookie.php index 6cdc500aaf33..36a20ec658b6 100644 --- a/app/code/Magento/PageCache/Plugin/RegisterFormKeyFromCookie.php +++ b/app/code/Magento/PageCache/Plugin/RegisterFormKeyFromCookie.php @@ -10,10 +10,10 @@ namespace Magento\PageCache\Plugin; use Magento\Framework\App\PageCache\FormKey as CacheFormKey; -use Magento\Framework\Escaper; use Magento\Framework\Data\Form\FormKey; -use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; +use Magento\Framework\Escaper; use Magento\Framework\Session\Config\ConfigInterface; +use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; /** * Allow for registration of a form key through cookies. @@ -46,7 +46,7 @@ class RegisterFormKeyFromCookie private $sessionConfig; /** - * @param CacheFormKey $formKey + * @param CacheFormKey $cacheFormKey * @param Escaper $escaper * @param FormKey $formKey * @param CookieMetadataFactory $cookieMetadataFactory @@ -70,7 +70,6 @@ public function __construct( * Set form key from the cookie. * * @return void - * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeDispatch(): void @@ -85,6 +84,8 @@ public function beforeDispatch(): void } /** + * Set form key cookie + * * @param string $formKey * @return void */ @@ -94,6 +95,7 @@ private function updateCookieFormKey(string $formKey): void ->createPublicCookieMetadata(); $cookieMetadata->setDomain($this->sessionConfig->getCookieDomain()); $cookieMetadata->setPath($this->sessionConfig->getCookiePath()); + $cookieMetadata->setSecure($this->sessionConfig->getCookieSecure()); $lifetime = $this->sessionConfig->getCookieLifetime(); if ($lifetime !== 0) { $cookieMetadata->setDuration($lifetime); diff --git a/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php b/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php index 6857c637bab8..8cc933853a49 100644 --- a/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php +++ b/app/code/Magento/PageCache/Test/Unit/Model/DepersonalizeCheckerTest.php @@ -18,7 +18,7 @@ class DepersonalizeCheckerTest extends \PHPUnit\Framework\TestCase private $requestMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ private $moduleManagerMock; @@ -30,7 +30,7 @@ class DepersonalizeCheckerTest extends \PHPUnit\Framework\TestCase public function setup() { $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\ModuleManagerInterface::class); + $this->moduleManagerMock = $this->createMock(\Magento\Framework\Module\Manager::class); $this->cacheConfigMock = $this->createMock(\Magento\PageCache\Model\Config::class); } diff --git a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php index fbf80de519f9..71e0384c72f7 100644 --- a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php +++ b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Payment\Ui\Component\Listing\Column\Method; /** @@ -41,6 +42,14 @@ public function toOptionArray() if ($this->options === null) { $this->options = $this->paymentHelper->getPaymentMethodList(true, true); } + + array_walk( + $this->options, + function (&$item) { + $item['__disableTmpl'] = true; + } + ); + return $this->options; } } 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 8b9c37f11256..3cd88bddbfb1 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/info/default.phtml @@ -9,8 +9,9 @@ * @see \Magento\Payment\Block\Info */ $specificInfo = $block->getSpecificInformation(); +$paymentTitle = $block->getMethod()->getConfigData('title', $block->getInfo()->getOrder()->getStoreId()); ?> -<?= $block->escapeHtml($block->getMethod()->getTitle()) ?> +<?= $block->escapeHtml($paymentTitle) ?> <?php if ($specificInfo) : ?> <table class="data-table admin__table-secondary"> diff --git a/app/code/Magento/Payment/view/adminhtml/templates/info/pdf/default.phtml b/app/code/Magento/Payment/view/adminhtml/templates/info/pdf/default.phtml index a8583ea5549f..54b9e48d07a9 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/info/pdf/default.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/info/pdf/default.phtml @@ -8,8 +8,9 @@ * @see \Magento\Payment\Block\Info * @var \Magento\Payment\Block\Info $block */ +$paymentTitle = $block->getMethod()->getConfigData('title', $block->getInfo()->getOrder()->getStoreId()); ?> -<?= $block->escapeHtml($block->getMethod()->getTitle()) ?>{{pdf_row_separator}} +<?= $block->escapeHtml($paymentTitle) ?>{{pdf_row_separator}} <?php if ($specificInfo = $block->getSpecificInformation()) : ?> <?php foreach ($specificInfo as $label => $value) : ?> diff --git a/app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js b/app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js index c41be40cba14..746a4bd2cf33 100644 --- a/app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js +++ b/app/code/Magento/Payment/view/base/web/js/model/credit-card-validation/validator.js @@ -4,23 +4,15 @@ */ /* @api */ -(function (factory) { - 'use strict'; - - if (typeof define === 'function' && define.amd) { - define([ - 'jquery', - 'Magento_Payment/js/model/credit-card-validation/cvv-validator', - 'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator', - 'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator', - 'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator', - 'Magento_Payment/js/model/credit-card-validation/credit-card-data', - 'mage/translate' - ], factory); - } else { - factory(jQuery); - } -}(function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) { +define([ + 'jquery', + 'Magento_Payment/js/model/credit-card-validation/cvv-validator', + 'Magento_Payment/js/model/credit-card-validation/credit-card-number-validator', + 'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-year-validator', + 'Magento_Payment/js/model/credit-card-validation/expiration-date-validator/expiration-month-validator', + 'Magento_Payment/js/model/credit-card-validation/credit-card-data', + 'mage/translate' +], function ($, cvvValidator, creditCardNumberValidator, yearValidator, monthValidator, creditCardData) { 'use strict'; $('.payment-method-content input[type="number"]').on('keyup', function () { @@ -111,4 +103,4 @@ rule.unshift(i); $.validator.addMethod.apply($.validator, rule); }); -})); +}); diff --git a/app/code/Magento/Paypal/Test/Mftf/ActionGroup/PayPalExpressCheckoutConfigurationActionGroup.xml b/app/code/Magento/Paypal/Test/Mftf/ActionGroup/PayPalExpressCheckoutConfigurationActionGroup.xml index c047633e5227..4d752d837764 100644 --- a/app/code/Magento/Paypal/Test/Mftf/ActionGroup/PayPalExpressCheckoutConfigurationActionGroup.xml +++ b/app/code/Magento/Paypal/Test/Mftf/ActionGroup/PayPalExpressCheckoutConfigurationActionGroup.xml @@ -16,7 +16,31 @@ <argument name="credentials" defaultValue="_CREDS"/> <argument name="countryCode" type="string" defaultValue="us"/> </arguments> - + + <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <click selector="{{PayPalExpressCheckoutConfigSection.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/> + <waitForElementVisible selector="{{PayPalAdvancedSettingConfigSection.advancedSettingTab(countryCode)}}" stepKey="waitForAdvancedSettingTab"/> + <fillField selector ="{{PayPalExpressCheckoutConfigSection.email(countryCode)}}" userInput="{{credentials.magento/paypal_express_checkout_us_business_account}}" stepKey="inputEmailAssociatedWithPayPalMerchantAccount"/> + <selectOption selector ="{{PayPalExpressCheckoutConfigSection.apiMethod(countryCode)}}" userInput="API Signature" stepKey="inputAPIAuthenticationMethods"/> + <fillField selector ="{{PayPalExpressCheckoutConfigSection.username(countryCode)}}" userInput="{{credentials.magento/paypal_express_checkout_us_api_username}}" stepKey="inputAPIUsername"/> + <fillField selector ="{{PayPalExpressCheckoutConfigSection.password(countryCode)}}" userInput="{{credentials.magento/paypal_express_checkout_us_api_password}}" stepKey="inputAPIPassword"/> + <fillField selector ="{{PayPalExpressCheckoutConfigSection.signature(countryCode)}}" userInput="{{credentials.magento/paypal_express_checkout_us_api_signature}}" stepKey="inputAPISignature"/> + <selectOption selector ="{{PayPalExpressCheckoutConfigSection.sandboxMode(countryCode)}}" userInput="Yes" stepKey="enableSandboxMode"/> + <selectOption selector="{{PayPalExpressCheckoutConfigSection.enableSolution(countryCode)}}" userInput="Yes" stepKey="enableSolution"/> + <fillField selector ="{{PayPalExpressCheckoutConfigSection.merchantID(countryCode)}}" userInput="{{credentials.magento/paypal_express_checkout_us_merchant_id}}" stepKey="inputMerchantID"/> + <!--Save configuration--> + <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig"/> + </actionGroup> + + <actionGroup name="SampleConfigPayPalExpressCheckout"> + <annotations> + <description>Goes to the 'Configuration' page for 'Payment Methods'. Fills in the provided Sample PayPal credentials and other details. Clicks on Save.</description> + </annotations> + <arguments> + <argument name="credentials" defaultValue="SamplePaypalExpressConfig"/> + <argument name="countryCode" type="string" defaultValue="us"/> + </arguments> <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> <waitForPageLoad stepKey="waitForPageLoad1"/> <click selector="{{PayPalExpressCheckoutConfigSection.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/> @@ -29,42 +53,44 @@ <selectOption selector ="{{PayPalExpressCheckoutConfigSection.sandboxMode(countryCode)}}" userInput="Yes" stepKey="enableSandboxMode"/> <selectOption selector="{{PayPalExpressCheckoutConfigSection.enableSolution(countryCode)}}" userInput="Yes" stepKey="enableSolution"/> <fillField selector ="{{PayPalExpressCheckoutConfigSection.merchantID(countryCode)}}" userInput="{{credentials.paypal_express_merchantID}}" stepKey="inputMerchantID"/> - <!--Save configuration--> <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig"/> </actionGroup> - + <actionGroup name="CreatePayPalOrderWithSelectedPaymentMethodActionGroup" extends="CreateOrderToPrintPageActionGroup"> <annotations> <description>EXTENDS: CreateOrderToPrintPageActionGroup. Clicks on PayPal. Fills the PayPay details in the modal. PLEASE NOTE: The PayPal Payment credentials are Hardcoded using 'Payer'.</description> </annotations> - + <arguments> + <argument name="payerName" defaultValue="MPI" type="string"/> + <argument name="credentials" defaultValue="_CREDS"/> + </arguments> + + <!-- click on PayPal payment radio button --> <waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" stepKey="waitForPlaceOrderButton"/> <click selector="{{CheckoutPaymentSection.PayPalPaymentRadio}}" stepKey="clickPlaceOrder"/> - + <!--set ID for iframe of PayPal group button--> <executeJS function="jQuery('.zoid-component-frame.zoid-visible').attr('id', 'myIframe')" stepKey="clickOrderLink"/> - + <!--switch to iframe of PayPal group button--> - <comment userInput="switch to iframe of PayPal group button" stepKey="commentSwitchToIframe"/> <switchToIFrame userInput="myIframe" stepKey="clickPrintOrderLink"/> <waitForElementVisible selector="{{CheckoutPaymentSection.PayPalBtn}}" stepKey="waitForPayPalBtn"/> <click selector="{{CheckoutPaymentSection.PayPalBtn}}" stepKey="clickPayPalBtn"/> <switchToIFrame stepKey="switchBack1"/> - + <!--Check in-context--> - <comment userInput="Check in-context" stepKey="commentVerifyInContext"/> <switchToNextTab stepKey="switchToInContentTab"/> <waitForPageLoad stepKey="waitForPageLoad"/> <seeCurrentUrlMatches regex="~\//www.sandbox.paypal.com/~" stepKey="seeCurrentUrlMatchesConfigPath1"/> - <waitForElement selector="{{PayPalPaymentSection.email}}" stepKey="waitForLoginForm"/> - <fillField selector="{{PayPalPaymentSection.email}}" userInput="{{Payer.buyerEmail}}" stepKey="fillEmail"/> - <fillField selector="{{PayPalPaymentSection.password}}" userInput="{{Payer.buyerPassword}}" stepKey="fillPassword"/> + <waitForElement selector="{{PayPalPaymentSection.email}}" stepKey="waitForLoginForm" /> + <fillField selector="{{PayPalPaymentSection.email}}" userInput="{{credentials.magento/paypal_sandbox_login_email}}" stepKey="fillEmail"/> + <fillField selector="{{PayPalPaymentSection.password}}" userInput="{{credentials.magento/paypal_sandbox_login_password}}" stepKey="fillPassword"/> <click selector="{{PayPalPaymentSection.loginBtn}}" stepKey="login"/> <waitForPageLoad stepKey="wait"/> - <seeElement selector="{{PayPalPaymentSection.reviewUserInfo}}" stepKey="seePayerName"/> + <see userInput="{{payerName}}" selector="{{PayPalPaymentSection.reviewUserInfo}}" stepKey="seePayerName"/> </actionGroup> - + <actionGroup name="addProductToCheckoutPage"> <annotations> <description>Goes to the provided Category page on the Storefront. Adds the 1st Product to the Cart. Goes to Checkout. Select the Shipping Method. Selects PayPal as the Payment Method.</description> @@ -72,7 +98,7 @@ <arguments> <argument name="Category"/> </arguments> - + <amOnPage url="{{StorefrontCategoryPage.url(Category.name)}}" stepKey="onCategoryPage"/> <waitForPageLoad stepKey="waitForPageLoad1"/> <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> diff --git a/app/code/Magento/Paypal/Test/Mftf/ActionGroup/StorefrontPayOrderOnPayPalCheckoutActionGroup.xml b/app/code/Magento/Paypal/Test/Mftf/ActionGroup/StorefrontPayOrderOnPayPalCheckoutActionGroup.xml new file mode 100644 index 000000000000..392014d876e4 --- /dev/null +++ b/app/code/Magento/Paypal/Test/Mftf/ActionGroup/StorefrontPayOrderOnPayPalCheckoutActionGroup.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontPayOrderOnPayPalCheckoutActionGroup"> + <annotations> + <description>Verifies product name on Paypal cart and clicks 'Pay Now' on PayPal payment checkout page.</description> + </annotations> + <arguments> + <argument name="productName" type="string"/> + </arguments> + <click selector="{{PayPalPaymentSection.cartIcon}}" stepKey="openCart"/> + <seeElement selector="{{PayPalPaymentSection.itemName(productName)}}" stepKey="seeProductName"/> + <click selector="{{PayPalPaymentSection.PayPalSubmitBtn}}" stepKey="clickPayPalSubmitBtn"/> + <switchToPreviousTab stepKey="switchToPreviousTab"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Paypal/Test/Mftf/Data/PaypalConfigData.xml b/app/code/Magento/Paypal/Test/Mftf/Data/PaypalConfigData.xml new file mode 100644 index 000000000000..074420749410 --- /dev/null +++ b/app/code/Magento/Paypal/Test/Mftf/Data/PaypalConfigData.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="StorefrontPaypalEnableConfigData"> + <data key="path">payment/paypal_express/active</data> + <data key="scope_id">1</data> + <data key="label">Yes</data> + <data key="value">1</data> + </entity> + <entity name="StorefrontPaypalDisableConfigData"> + <data key="path">payment/paypal_express/active</data> + <data key="scope_id">1</data> + <data key="label">No</data> + <data key="value">0</data> + </entity> + <entity name="StorefrontPaypalMerchantAccountIdConfigData"> + <data key="path">payment/paypal_express/merchant_id</data> + <data key="scope_id">1</data> + <data key="value">''</data> + </entity> + <entity name="StorefrontPaypalEnableSkipOrderReviewStepConfigData"> + <data key="path">payment/paypal_express/skip_order_review_step</data> + <data key="scope_id">1</data> + <data key="label">Yes</data> + <data key="value">1</data> + </entity> + <entity name="StorefrontPaypalDisableSkipOrderReviewStepConfigData"> + <data key="path">payment/paypal_express/skip_order_review_step</data> + <data key="scope_id">1</data> + <data key="label">No</data> + <data key="value">0</data> + </entity> + <entity name="StorefrontPaypalEnableInContextCheckoutConfigData"> + <data key="path">payment/paypal_express/in_context</data> + <data key="scope_id">1</data> + <data key="label">Yes</data> + <data key="value">1</data> + </entity> + <entity name="StorefrontPaypalDisableInContextCheckoutConfigData"> + <data key="path">payment/paypal_express/active</data> + <data key="scope_id">1</data> + <data key="label">No</data> + <data key="value">0</data> + </entity> +</entities> diff --git a/app/code/Magento/Paypal/Test/Mftf/Data/PaypalData.xml b/app/code/Magento/Paypal/Test/Mftf/Data/PaypalData.xml index ae34476e9ac0..ba56243fdb39 100644 --- a/app/code/Magento/Paypal/Test/Mftf/Data/PaypalData.xml +++ b/app/code/Magento/Paypal/Test/Mftf/Data/PaypalData.xml @@ -99,4 +99,37 @@ <data key="paypal_express_api_signature">someApiSignature</data> <data key="paypal_express_merchantID">someMerchantId</data> </entity> + <entity name="PaypalConfig" type="paypal_config_state"> + <requiredEntity type="business_account">BusinessAccount</requiredEntity> + <requiredEntity type="api_username">ApiUsername</requiredEntity> + <requiredEntity type="api_password">ApiPassword</requiredEntity> + <requiredEntity type="api_signature">ApiSignature</requiredEntity> + <requiredEntity type="api_authentication">ApiAuthentication</requiredEntity> + <requiredEntity type="sandbox_flag">SandboxFlag</requiredEntity> + <requiredEntity type="use_proxy">UseProxy</requiredEntity> + </entity> + <entity name="BusinessAccount" type="business_account"> + <data key="value">{{_CREDS.magento/paypal_express_checkout_us_business_account}}</data> + </entity> + <entity name="ApiUsername" type="api_username"> + <data key="value">{{_CREDS.magento/paypal_express_checkout_us_api_username}}</data> + </entity> + <entity name="ApiPassword" type="api_password"> + <data key="value">{{_CREDS.magento/paypal_express_checkout_us_api_password}}</data> + </entity> + <entity name="ApiSignature" type="api_signature"> + <data key="value">{{_CREDS.magento/paypal_express_checkout_us_api_signature}}</data> + </entity> + <entity name="ApiAuthentication" type="api_authentication"> + <data key="value">0</data> + </entity> + <entity name="SandboxFlag" type="sandbox_flag"> + <data key="value">1</data> + </entity> + <entity name="UseProxy" type="use_proxy"> + <data key="value">0</data> + </entity> + <entity name="Payer"> + <data key="firstName">Alex</data> + </entity> </entities> diff --git a/app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml b/app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml index 8d1b594d44e6..af68a7611cd1 100644 --- a/app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml +++ b/app/code/Magento/Paypal/Test/Mftf/Section/PayPalExpressCheckoutConfigSection.xml @@ -57,7 +57,7 @@ <element name="email" type="input" selector="//input[contains(@name, 'email') and not(contains(@style, 'display:none'))]"/> <element name="password" type="input" selector="//input[contains(@name, 'password') and not(contains(@style, 'display:none'))]"/> <element name="loginBtn" type="input" selector="button#btnLogin"/> - <element name="reviewUserInfo" type="text" selector="//p[@id='reviewUserInfo' and contains(text(),'Hi, MPI!')]"/> + <element name="reviewUserInfo" type="text" selector="#reviewUserInfo"/> <element name="cartIcon" type="text" selector="#transactionCart"/> <element name="itemName" type="text" selector="//span[@title='{{productName}}']" parameterized="true"/> <element name="PayPalSubmitBtn" type="text" selector="//input[@type='submit']"/> diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/AdminCheckDefaultValueOfPayPalCustomizeButtonTest.xml b/app/code/Magento/Paypal/Test/Mftf/Test/AdminCheckDefaultValueOfPayPalCustomizeButtonTest.xml new file mode 100644 index 000000000000..5c10bc9536fc --- /dev/null +++ b/app/code/Magento/Paypal/Test/Mftf/Test/AdminCheckDefaultValueOfPayPalCustomizeButtonTest.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckDefaultValueOfPayPalCustomizeButtonTest"> + <annotations> + <features value="Paypal"/> + <stories value="Button Configuration"/> + <title value="Check Default Value Of Paypal Customize Button"/> + <description value="Default value of Paypal Customize Button should be NO"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-10904"/> + <group value="paypal"/> + <skip> + <issueId value="DEVOPS-3311"/> + </skip> + </annotations> + <before> + <actionGroup ref="LoginActionGroup" stepKey="login"/> + <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpressCheckout"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + </after> + <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <actionGroup ref="OpenPayPalButtonCheckoutPage" stepKey= "openPayPalButtonCheckoutPage"/> + <seeElement selector="{{ButtonCustomization.customizeDrpDown}}" stepKey="seeCustomizeDropDown"/> + <seeOptionIsSelected selector="{{ButtonCustomization.customizeDrpDown}}" userInput="No" stepKey="seeNoIsDefaultValue"/> + <selectOption selector="{{ButtonCustomization.customizeDrpDown}}" userInput="Yes" stepKey="enableButtonCustomization"/> + <!--Verify default value--> + <comment userInput="Verify default value" stepKey="commentVerifyDefaultValue1"/> + <seeElement selector="{{ButtonCustomization.label}}" stepKey="seeLabel"/> + <seeElement selector="{{ButtonCustomization.layout}}" stepKey="seeLayout"/> + <seeElement selector="{{ButtonCustomization.size}}" stepKey="seeSize1"/> + <seeElement selector="{{ButtonCustomization.shape}}" stepKey="seeShape1"/> + <seeElement selector="{{ButtonCustomization.color}}" stepKey="seeColor"/> + </test> +</tests> diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/AdminConfigPaymentsConflictResolutionForPayPal.xml b/app/code/Magento/Paypal/Test/Mftf/Test/AdminConfigPaymentsConflictResolutionForPayPal.xml index a6e741f0151e..cfc7d66ba23c 100644 --- a/app/code/Magento/Paypal/Test/Mftf/Test/AdminConfigPaymentsConflictResolutionForPayPal.xml +++ b/app/code/Magento/Paypal/Test/Mftf/Test/AdminConfigPaymentsConflictResolutionForPayPal.xml @@ -20,7 +20,7 @@ </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpress"> + <actionGroup ref="SampleConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpress"> <argument name="credentials" value="SamplePaypalExpressConfig"/> </actionGroup> </before> diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/PayPalSmartButtonInCheckoutPage.xml b/app/code/Magento/Paypal/Test/Mftf/Test/PayPalSmartButtonInCheckoutPage.xml deleted file mode 100644 index 079b46dc1b0c..000000000000 --- a/app/code/Magento/Paypal/Test/Mftf/Test/PayPalSmartButtonInCheckoutPage.xml +++ /dev/null @@ -1,170 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="CheckDefaultValueOfPayPalCustomizeButtonTest"> - <annotations> - <features value="PayPal"/> - <stories value="Button Configuration"/> - <title value="Check Default Value Of PayPal Customize Button"/> - <description value="Default value of PayPal Customize Button should be NO"/> - <severity value="AVERAGE"/> - <testCaseId value="MC-10904"/> - <skip> - <issueId value="DEVOPS-3311"/> - </skip> - </annotations> - <before> - <actionGroup ref="LoginActionGroup" stepKey="login"/> - <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpressCheckout"/> - </before> - <after> - <actionGroup ref="logout" stepKey="logoutFromAdmin"/> - </after> - <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> - <actionGroup ref="OpenPayPalButtonCheckoutPage" stepKey="openPayPalButtonCheckoutPage"/> - <seeElement selector="{{ButtonCustomization.customizeDrpDown}}" stepKey="seeCustomizeDropDown"/> - <seeOptionIsSelected selector="{{ButtonCustomization.customizeDrpDown}}" userInput="No" stepKey="seeNoIsDefaultValue"/> - <selectOption selector="{{ButtonCustomization.customizeDrpDown}}" userInput="Yes" stepKey="enableButtonCustomization"/> - <!--Verify default value--> - <comment userInput="Verify default value" stepKey="commentVerifyDefaultValue1"/> - <seeElement selector="{{ButtonCustomization.label}}" stepKey="seeLabel"/> - <seeElement selector="{{ButtonCustomization.layout}}" stepKey="seeLayout"/> - <seeElement selector="{{ButtonCustomization.size}}" stepKey="seeSize1"/> - <seeElement selector="{{ButtonCustomization.shape}}" stepKey="seeShape1"/> - <seeElement selector="{{ButtonCustomization.color}}" stepKey="seeColor"/> - </test> - <test name="CheckCreditButtonConfiguration"> - <annotations> - <features value="PayPal"/> - <stories value="Button Configuration"/> - <title value="Check Credit Button Configuration"/> - <description value="Admin is able to customize Credit button"/> - <severity value="AVERAGE"/> - <testCaseId value="MC-10900"/> - <skip> - <issueId value="DEVOPS-3311"/> - </skip> - </annotations> - <before> - <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> - <createData entity="_defaultProduct" stepKey="createPreReqProduct"> - <requiredEntity createDataKey="createPreReqCategory"/> - </createData> - <!-- Create Customer --> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - <actionGroup ref="LoginActionGroup" stepKey="login"/> - <!--Config PayPal Express Checkout--> - <comment userInput="config PayPal Express Checkout" stepKey="commemtConfigPayPalExpressCheckout"/> - <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpressCheckout"/> - </before> - <after> - <deleteData stepKey="deleteCategory" createDataKey="createPreReqCategory"/> - <deleteData stepKey="deleteProduct" createDataKey="createPreReqProduct"/> - <deleteData stepKey="deleteCustomer" createDataKey="createCustomer"/> - <actionGroup ref="logout" stepKey="logoutFromAdmin"/> - </after> - <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> - <!--Navigate to button configuration setting--> - <comment userInput="Navigate to button configuration setting in Admin site" stepKey="commentNavigateToButtonConfigurationInAdmin"/> - <actionGroup ref="OpenPayPalButtonCheckoutPage" stepKey="openPayPalButtonCheckoutPage"/> - <waitForElement selector="{{ButtonCustomization.customizeDrpDown}}" stepKey="seeCustomizeDropDown"/> - <selectOption selector="{{ButtonCustomization.customizeDrpDown}}" userInput="Yes" stepKey="enableButtonCustomization"/> - <!--Verify Credit Button value--> - <comment userInput="Verify Credit Button value" stepKey="commentVerifyDefaultValue2"/> - <selectOption selector="{{ButtonCustomization.label}}" userInput="{{PayPalLabel.credit}}" stepKey="selectCreditAsLabel"/> - <seeElement selector="{{ButtonCustomization.size}}" stepKey="seeSize2"/> - <seeElement selector="{{ButtonCustomization.shape}}" stepKey="seeShape2"/> - <dontSeeElement selector="{{ButtonCustomization.layout}}" stepKey="dontSeeLayout"/> - <dontSeeElement selector="{{ButtonCustomization.color}}" stepKey="dontSeeColor"/> - <!--Customize Credit Button--> - <selectOption selector="{{ButtonCustomization.size}}" userInput="{{PayPalSize.medium}}" stepKey="selectSize"/> - <selectOption selector="{{ButtonCustomization.shape}}" userInput="{{PayPalShape.pill}}" stepKey="selectShape"/> - <!--Save configuration--> - <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig"/> - <waitForPageLoad stepKey="waitForConfigSave"/> - <openNewTab stepKey="openNewTab"/> - <amOnPage url="/" stepKey="openStorefront"/> - <!--Login to storefront as previously created customer--> - <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> - <argument name="Customer" value="$$createCustomer$$"/> - </actionGroup> - <actionGroup ref="addProductToCheckoutPage" stepKey="addProductToCheckoutPage"> - <argument name="Category" value="$$createPreReqCategory$$"/> - </actionGroup> - <!--set ID for iframe of PayPal group button--> - <executeJS function="jQuery('.zoid-component-frame.zoid-visible').attr('id', 'myIframe')" stepKey="clickOrderLink"/> - <!--switch to iframe of PayPal group button--> - <comment userInput="switch to iframe of PayPal group button" stepKey="commentSwitchToIframe"/> - <switchToIFrame userInput="myIframe" stepKey="clickPrintOrderLink"/> - <waitForElementVisible selector="{{CheckoutPaymentSection.PayPalBtn}}" stepKey="waitForPayPalBtn"/> - <seeElement selector="{{PayPalButtonOnStorefront.label(PayPalLabel.credit)}}{{PayPalButtonOnStorefront.size(PayPalSize.medium)}}" stepKey="seeButtonInMediumSize"/> - <seeElement selector="{{PayPalButtonOnStorefront.label(PayPalLabel.credit)}}{{PayPalButtonOnStorefront.shape(PayPalShape.pill)}}" stepKey="seeButtonInPillShape"/> - </test> - <test name="PayPalSmartButtonInCheckoutPage"> - <annotations> - <features value="PayPal"/> - <stories value="Generic checkout skeleton flow"/> - <title value="Mainflow of PayPal Smart Button"/> - <description value="Users are able to place order using PayPal Smart Button"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-13690"/> - <skip> - <issueId value="DEVOPS-3311"/> - </skip> - </annotations> - <before> - <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> - <createData entity="_defaultProduct" stepKey="createPreReqProduct"> - <requiredEntity createDataKey="createPreReqCategory"/> - </createData> - <!-- Create Customer --> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - <actionGroup ref="LoginActionGroup" stepKey="login"/> - <!--Config PayPal Express Checkout--> - <comment userInput="config PayPal Express Checkout" stepKey="commemtConfigPayPalExpressCheckout"/> - <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpressCheckout"/> - <magentoCLI command="config:set payment/paypal_express/in_context 1" stepKey="disableInContextPayPal"/> - </before> - <after> - <deleteData stepKey="deleteCategory" createDataKey="createPreReqCategory"/> - <deleteData stepKey="deleteProduct" createDataKey="createPreReqProduct"/> - <deleteData stepKey="deleteCustomer" createDataKey="createCustomer"/> - <magentoCLI command="config:set payment/paypal_express/in_context 0" stepKey="enableInContextPayPal"/> - <actionGroup ref="logout" stepKey="logoutFromAdmin"/> - </after> - <magentoCLI command="config:set payment/paypal_express/payment_action Authorization" stepKey="inputPaymentAction"/> - <magentoCLI command="config:set payment/paypal_express/solution_type Sole" stepKey="enablePayPalGuestCheckout"/> - <magentoCLI command="config:set payment/paypal_express/line_items_enabled 1" stepKey="enableTransferCartLine"/> - <magentoCLI command="config:set payment/paypal_express/skip_order_review_step 1" stepKey="enableSkipOrderReview"/> - <!--Login to storefront as previously created customer--> - <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> - <argument name="Customer" value="$$createCustomer$$"/> - </actionGroup> - <!--Place an order using PayPal method--> - <comment userInput="Place an order using PayPal method" stepKey="commentPayPalPlaceOrder"/> - <actionGroup ref="CreatePayPalOrderWithSelectedPaymentMethodActionGroup" stepKey="createPayPalOrder"> - <argument name="Category" value="$$createPreReqCategory$$"/> - </actionGroup> - <!--Open Cart on PayPal--> - <comment userInput="Open Cart on PayPal" stepKey="commentOpenCart"/> - <click selector="{{PayPalPaymentSection.cartIcon}}" stepKey="openCart"/> - <seeElement selector="{{PayPalPaymentSection.itemName($$createPreReqProduct.name$$)}}" stepKey="seeProductname"/> - <click selector="{{PayPalPaymentSection.PayPalSubmitBtn}}" stepKey="clickPayPalSubmitBtn"/> - <switchToPreviousTab stepKey="switchToPreviousTab"/> - <waitForPageLoad stepKey="waitForPageLoad"/> - <!--I see order successful Page instead of Order Review Page--> - <comment userInput="I see order successful Page instead of Order Review Page" stepKey="commentVerifyOrderReviewPage"/> - <waitForElement selector="{{CheckoutSuccessMainSection.successTitle}}" stepKey="waitForLoadSuccessPageTitle"/> - <waitForElement selector="{{CheckoutSuccessMainSection.success}}" time="30" stepKey="waitForLoadSuccessPage"/> - <seeElement selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="seeOrderLink"/> - </test> -</tests> \ No newline at end of file diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontCheckCreditButtonConfigurationTest.xml b/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontCheckCreditButtonConfigurationTest.xml new file mode 100644 index 000000000000..d8cea82bcc2f --- /dev/null +++ b/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontCheckCreditButtonConfigurationTest.xml @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontCheckCreditButtonConfigurationTest"> + <annotations> + <features value="Paypal"/> + <stories value="Button Configuration"/> + <title value="Check Credit Button Configuration"/> + <description value="Admin is able to customize Credit button"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-10900"/> + <group value="paypal"/> + <skip> + <issueId value="DEVOPS-3311"/> + </skip> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createPreReqCategory"/> + <createData entity="_defaultProduct" stepKey="createPreReqProduct"> + <requiredEntity createDataKey="createPreReqCategory"/> + </createData> + <!-- Create Customer --> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <actionGroup ref="LoginActionGroup" stepKey="login"/> + <!--Config PayPal Express Checkout--> + <comment userInput="config PayPal Express Checkout" stepKey="commemtConfigPayPalExpressCheckout"/> + <actionGroup ref="ConfigPayPalExpressCheckout" stepKey="ConfigPayPalExpressCheckout"/> + </before> + <after> + <deleteData stepKey="deleteCategory" createDataKey="createPreReqCategory"/> + <deleteData stepKey="deleteProduct" createDataKey="createPreReqProduct"/> + <deleteData stepKey="deleteCustomer" createDataKey="createCustomer"/> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + </after> + <amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <!--Navigate to button configuration setting--> + <comment userInput="Navigate to button configuration setting in Admin site" stepKey="commentNavigateToButtonConfigurationInAdmin"/> + <actionGroup ref="OpenPayPalButtonCheckoutPage" stepKey="openPayPalButtonCheckoutPage"/> + <waitForElement selector="{{ButtonCustomization.customizeDrpDown}}" stepKey="seeCustomizeDropDown"/> + <selectOption selector="{{ButtonCustomization.customizeDrpDown}}" userInput="Yes" stepKey="enableButtonCustomization"/> + <!--Verify Credit Button value--> + <comment userInput="Verify Credit Button value" stepKey="commentVerifyDefaultValue2"/> + <selectOption selector="{{ButtonCustomization.label}}" userInput="{{PayPalLabel.credit}}" stepKey="selectCreditAsLabel"/> + <seeElement selector="{{ButtonCustomization.size}}" stepKey="seeSize"/> + <seeElement selector="{{ButtonCustomization.shape}}" stepKey="seeShape"/> + <dontSeeElement selector="{{ButtonCustomization.layout}}" stepKey="dontSeeLayout"/> + <dontSeeElement selector="{{ButtonCustomization.color}}" stepKey="dontSeeColor"/> + <!--Customize Credit Button--> + <selectOption selector="{{ButtonCustomization.size}}" userInput="{{PayPalSize.medium}}" stepKey="selectSize"/> + <selectOption selector="{{ButtonCustomization.shape}}" userInput="{{PayPalShape.pill}}" stepKey="selectShape"/> + <!--Save configuration--> + <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig"/> + <waitForPageLoad stepKey="waitForConfigSave"/> + <openNewTab stepKey="openNewTab"/> + <amOnPage url="/" stepKey="openStorefront"/> + <!--Login to storefront as previously created customer--> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + <actionGroup ref="addProductToCheckoutPage" stepKey="addProductToCheckoutPage"> + <argument name="Category" value="$$createPreReqCategory$$"/> + </actionGroup> + <!--set ID for iframe of PayPal group button--> + <executeJS function="jQuery('.zoid-component-frame.zoid-visible').attr('id', 'myIframe')" stepKey="clickOrderLink"/> + <!--switch to iframe of PayPal group button--> + <comment userInput="switch to iframe of PayPal group button" stepKey="commentSwitchToIframe"/> + <switchToIFrame userInput="myIframe" stepKey="clickPrintOrderLink"/> + <waitForElementVisible selector="{{CheckoutPaymentSection.PayPalBtn}}" stepKey="waitForPayPalBtn"/> + <seeElement selector="{{PayPalButtonOnStorefront.label(PayPalLabel.credit)}}{{PayPalButtonOnStorefront.size(PayPalSize.medium)}}" stepKey="seeButtonInMediumSize"/> + <seeElement selector="{{PayPalButtonOnStorefront.label(PayPalLabel.credit)}}{{PayPalButtonOnStorefront.shape(PayPalShape.pill)}}" stepKey="seeButtonInPillShape"/> + </test> +</tests> diff --git a/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml b/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml new file mode 100644 index 000000000000..6adba94e9689 --- /dev/null +++ b/app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontPaypalSmartButtonInCheckoutPageTest"> + <annotations> + <features value="Paypal"/> + <stories value="Generic checkout skeleton flow"/> + <title value="Mainflow of Paypal Smart Button"/> + <description value="Users are able to place order using Paypal Smart Button"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-13690"/> + <skip> + <issueId value="DEVOPS-3311"/> + </skip> + <group value="paypal"/> + </annotations> + <before> + + <!-- Create Product --> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Create Customer --> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + + <!-- Set Paypal express config --> + <magentoCLI command="config:set {{StorefrontPaypalEnableConfigData.path}} {{StorefrontPaypalEnableConfigData.value}}" stepKey="enablePaypal"/> + <magentoCLI command="config:set {{StorefrontPaypalEnableInContextCheckoutConfigData.path}} {{StorefrontPaypalEnableInContextCheckoutConfigData.value}}" stepKey="enableInContextPayPal"/> + <magentoCLI command="config:set {{StorefrontPaypalEnableSkipOrderReviewStepConfigData.path}} {{StorefrontPaypalEnableSkipOrderReviewStepConfigData.value}}" stepKey="enableSkipOrderReview"/> + <magentoCLI command="config:set {{StorefrontPaypalMerchantAccountIdConfigData.path}} {{_CREDS.magento/paypal_express_checkout_us_merchant_id}}" stepKey="setMerchantId"/> + <createData entity="PaypalConfig" stepKey="createPaypalExpressConfig"/> + + <!-- Login --> + <actionGroup ref="LoginActionGroup" stepKey="login"/> + </before> + <after> + <!-- Cleanup Paypal configurations --> + <magentoCLI command="config:set {{StorefrontPaypalMerchantAccountIdConfigData.path}} {{StorefrontPaypalMerchantAccountIdConfigData.value}}" stepKey="deleteMerchantId"/> + <magentoCLI command="config:set {{StorefrontPaypalDisableSkipOrderReviewStepConfigData.path}} {{StorefrontPaypalDisableSkipOrderReviewStepConfigData.value}}" stepKey="disableSkipOrderReview"/> + <magentoCLI command="config:set {{StorefrontPaypalDisableInContextCheckoutConfigData.path}} {{StorefrontPaypalDisableInContextCheckoutConfigData.value}}" stepKey="disableInContextPayPal"/> + <magentoCLI command="config:set {{StorefrontPaypalDisableConfigData.path}} {{StorefrontPaypalDisableConfigData.value}}" stepKey="disablePaypal"/> + <createData entity="SamplePaypalConfig" stepKey="setDefaultPaypalConfig"/> + + <!-- Delete product --> + <deleteData stepKey="deleteCategory" createDataKey="createCategory"/> + <deleteData stepKey="deleteProduct" createDataKey="createProduct"/> + + <!--Delete customer --> + <deleteData stepKey="deleteCustomer" createDataKey="createCustomer"/> + + <!-- Logout --> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + </after> + + <!--Login to storefront as previously created customer--> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + + <!-- Place an order using PayPal payment method --> + <actionGroup ref="CreatePayPalOrderWithSelectedPaymentMethodActionGroup" stepKey="createPayPalOrder"> + <argument name="Category" value="$$createCategory$$"/> + <argument name="payerName" value="{{Payer.firstName}}"/> + </actionGroup> + + <!-- PayPal checkout --> + <actionGroup ref="StorefrontPayOrderOnPayPalCheckoutActionGroup" stepKey="payOrderOnPayPalCheckout"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + + <!-- I see order successful Page instead of Order Review Page --> + <actionGroup ref="AssertStorefrontCheckoutSuccessActionGroup" stepKey="assertCheckoutSuccess"/> + </test> +</tests> diff --git a/app/code/Magento/Paypal/etc/config.xml b/app/code/Magento/Paypal/etc/config.xml index 4619fc853944..6c0601f80137 100644 --- a/app/code/Magento/Paypal/etc/config.xml +++ b/app/code/Magento/Paypal/etc/config.xml @@ -164,7 +164,6 @@ <title>Credit Card (Payflow Advanced) PayPal PayPal - PayPal 1 1 GET diff --git a/app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js b/app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js index 60172f696e9e..8abd57cc6913 100644 --- a/app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js +++ b/app/code/Magento/PaypalCaptcha/view/frontend/web/js/view/payment/list-mixin.js @@ -34,14 +34,16 @@ define([ /** * Overrides default window.clearTimeout() to catch errors from iframe and reload Captcha. + * + * @param {Number} timeoutID */ - clearTimeout: function () { + clearTimeout: function (timeoutID) { var captcha = captchaList.getCaptchaByFormId(this.formId); if (captcha !== null) { captcha.refresh(); } - clearTimeout(); + clearTimeout(timeoutID); } }; diff --git a/app/code/Magento/PaypalGraphQl/etc/schema.graphqls b/app/code/Magento/PaypalGraphQl/etc/schema.graphqls index 78335e089cdc..b8f14eec70d1 100644 --- a/app/code/Magento/PaypalGraphQl/etc/schema.graphqls +++ b/app/code/Magento/PaypalGraphQl/etc/schema.graphqls @@ -7,7 +7,7 @@ type Query { } type Mutation { - createPaypalExpressToken(input: PaypalExpressTokenInput!): PaypalExpressToken @resolver(class: "\\Magento\\PaypalGraphQl\\Model\\Resolver\\PaypalExpressToken") @doc(description:"Initiates an Express Checkout transaction and receives a token. Use this mutation for Express Checkout and Payments Standard payment methods.") + createPaypalExpressToken(input: PaypalExpressTokenInput!): PaypalExpressTokenOutput @resolver(class: "\\Magento\\PaypalGraphQl\\Model\\Resolver\\PaypalExpressToken") @doc(description:"Initiates an Express Checkout transaction and receives a token. Use this mutation for Express Checkout and Payments Standard payment methods.") createPayflowProToken(input: PayflowProTokenInput!): CreatePayflowProTokenOutput @resolver(class: "\\Magento\\PaypalGraphQl\\Model\\Resolver\\PayflowProToken") @doc(description: "Initiates a transaction and receives a token. Use this mutation for Payflow Pro and Payments Pro payment methods") handlePayflowProResponse(input: PayflowProResponseInput!): PayflowProResponseOutput @resolver(class: "\\Magento\\PaypalGraphQl\\Model\\Resolver\\PayflowProResponse") @doc(description: "Handles payment response and saves payment in Quote. Use this mutations for Payflow Pro and Payments Pro payment methods.") } @@ -20,7 +20,12 @@ input PaypalExpressTokenInput @doc(description: "Defines the attributes required express_button: Boolean @doc(description: "Indicates whether the buyer selected the quick checkout button. The default value is false") } -type PaypalExpressToken @doc(description: "Contains the token returned by PayPal and a set of URLs that allow the buyer to authorize payment and adjust checkout details. Applies to Express Checkout and Payments Standard payment methods.") { +type PaypalExpressToken @doc(description: "Deprecated: use type `PaypalExpressTokenOutput` instead") { + token: String @deprecated(reason: "Use field `token` of type `PaypalExpressTokenOutput` instead") @doc(description:"The token returned by PayPal") + paypal_urls: PaypalExpressUrlList @deprecated(reason: "Use field `paypal_urls` of type `PaypalExpressTokenOutput` instead") @doc(description:"A set of URLs that allow the buyer to authorize payment and adjust checkout details") +} + +type PaypalExpressTokenOutput @doc(description: "Contains the token returned by PayPal and a set of URLs that allow the buyer to authorize payment and adjust checkout details. Applies to Express Checkout and Payments Standard payment methods.") { token: String @doc(description:"The token returned by PayPal") paypal_urls: PaypalExpressUrlList @doc(description:"A set of URLs that allow the buyer to authorize payment and adjust checkout details") } diff --git a/app/code/Magento/Persistent/Model/QuoteManager.php b/app/code/Magento/Persistent/Model/QuoteManager.php index 8ae22e4c26c6..c7e22a05eb3b 100644 --- a/app/code/Magento/Persistent/Model/QuoteManager.php +++ b/app/code/Magento/Persistent/Model/QuoteManager.php @@ -121,7 +121,6 @@ public function convertCustomerCartToGuest() ->setCustomerEmail(null) ->setCustomerFirstname(null) ->setCustomerLastname(null) - ->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID) ->setIsPersistent(false); $quote->getAddressesCollection()->walk('setCustomerAddressId', ['customerAddressId' => null]); $quote->getAddressesCollection()->walk('setCustomerId', ['customerId' => null]); diff --git a/app/code/Magento/Persistent/Observer/CheckExpirePersistentQuoteObserver.php b/app/code/Magento/Persistent/Observer/CheckExpirePersistentQuoteObserver.php index 6a8772358f01..036f17fb3c1b 100644 --- a/app/code/Magento/Persistent/Observer/CheckExpirePersistentQuoteObserver.php +++ b/app/code/Magento/Persistent/Observer/CheckExpirePersistentQuoteObserver.php @@ -6,6 +6,9 @@ namespace Magento\Persistent\Observer; use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; use Magento\Quote\Model\Quote; /** @@ -74,6 +77,11 @@ class CheckExpirePersistentQuoteObserver implements ObserverInterface */ private $quote; + /** + * @var CartRepositoryInterface + */ + private $quoteRepository; + /** * @param \Magento\Persistent\Helper\Session $persistentSession * @param \Magento\Persistent\Helper\Data $persistentData @@ -82,6 +90,7 @@ class CheckExpirePersistentQuoteObserver implements ObserverInterface * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Checkout\Model\Session $checkoutSession * @param \Magento\Framework\App\RequestInterface $request + * @param CartRepositoryInterface $quoteRepository */ public function __construct( \Magento\Persistent\Helper\Session $persistentSession, @@ -90,7 +99,8 @@ public function __construct( \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, - \Magento\Framework\App\RequestInterface $request + \Magento\Framework\App\RequestInterface $request, + CartRepositoryInterface $quoteRepository ) { $this->_persistentSession = $persistentSession; $this->quoteManager = $quoteManager; @@ -99,6 +109,7 @@ public function __construct( $this->_eventManager = $eventManager; $this->_persistentData = $persistentData; $this->request = $request; + $this->quoteRepository = $quoteRepository; } /** @@ -147,9 +158,11 @@ public function execute(\Magento\Framework\Event\Observer $observer) */ private function isPersistentQuoteOutdated(): bool { - if ((!$this->_persistentData->isEnabled() || !$this->_persistentData->isShoppingCartPersist()) + if (!($this->_persistentData->isEnabled() && $this->_persistentData->isShoppingCartPersist()) && !$this->_customerSession->isLoggedIn() - && $this->_checkoutSession->getQuoteId()) { + && $this->_checkoutSession->getQuoteId() + && $this->isActiveQuote() + ) { return (bool)$this->getQuote()->getIsPersistent(); } return false; @@ -182,6 +195,21 @@ private function getQuote(): Quote return $this->quote; } + /** + * Check if quote is active. + * + * @return bool + */ + private function isActiveQuote(): bool + { + try { + $this->quoteRepository->getActive($this->_checkoutSession->getQuoteId()); + return true; + } catch (NoSuchEntityException $e) { + return false; + } + } + /** * Check current request is coming from onepage checkout page. * diff --git a/app/code/Magento/Persistent/Observer/MakePersistentQuoteGuestObserver.php b/app/code/Magento/Persistent/Observer/MakePersistentQuoteGuestObserver.php index 94726bc9b1d0..f2f9b96fa82e 100644 --- a/app/code/Magento/Persistent/Observer/MakePersistentQuoteGuestObserver.php +++ b/app/code/Magento/Persistent/Observer/MakePersistentQuoteGuestObserver.php @@ -4,10 +4,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Persistent\Observer; use Magento\Framework\Event\ObserverInterface; +/** + * Make persistent quote to be guest + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) + */ class MakePersistentQuoteGuestObserver implements ObserverInterface { /** @@ -65,8 +71,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) /** @var $action \Magento\Persistent\Controller\Index */ $action = $observer->getEvent()->getControllerAction(); if ($action instanceof \Magento\Persistent\Controller\Index) { - if ((($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) - || $this->_persistentData->isShoppingCartPersist()) + if (($this->_persistentSession->isPersistent() && !$this->_customerSession->isLoggedIn()) + || $this->_persistentData->isShoppingCartPersist() ) { $this->quoteManager->setGuest(true); } diff --git a/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php index 5ba0182ecc57..9731811ea8a9 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/Layout/DepersonalizePluginTest.php @@ -46,17 +46,9 @@ protected function setUp() $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->moduleManagerMock = $this->createPartialMock( - \Magento\Framework\Module\ModuleManagerInterface::class, - ['isEnabled'] - ); - $this->cacheConfigMock = $this->createPartialMock( - \Magento\PageCache\Model\Config::class, - ['isEnabled'] - ); - $this->depersonalizeCheckerMock = $this->createMock( - \Magento\PageCache\Model\DepersonalizeChecker::class - ); + $this->moduleManagerMock = $this->createPartialMock(\Magento\Framework\Module\Manager::class, ['isEnabled']); + $this->cacheConfigMock = $this->createPartialMock(\Magento\PageCache\Model\Config::class, ['isEnabled']); + $this->depersonalizeCheckerMock = $this->createMock(\Magento\PageCache\Model\DepersonalizeChecker::class); $this->plugin = $this->objectManager->getObject( \Magento\Persistent\Model\Layout\DepersonalizePlugin::class, diff --git a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php index e5de8e7d4aad..afabf18079fb 100644 --- a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php @@ -55,7 +55,9 @@ protected function setUp() { $this->persistentSessionMock = $this->createMock(\Magento\Persistent\Helper\Session::class); $this->sessionMock = - $this->createPartialMock(\Magento\Persistent\Model\Session::class, [ + $this->createPartialMock( + \Magento\Persistent\Model\Session::class, + [ 'setLoadInactive', 'setCustomerData', 'clearQuote', @@ -63,7 +65,8 @@ protected function setUp() 'getQuote', 'removePersistentCookie', '__wakeup', - ]); + ] + ); $this->persistentDataMock = $this->createMock(\Magento\Persistent\Helper\Data::class); $this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class); @@ -71,7 +74,9 @@ protected function setUp() $this->createMock(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class); $this->quoteRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [ + $this->quoteMock = $this->createPartialMock( + \Magento\Quote\Model\Quote::class, + [ 'getId', 'getIsPersistent', 'getPaymentsCollection', @@ -90,7 +95,8 @@ protected function setUp() 'getIsActive', 'getCustomerId', '__wakeup' - ]); + ] + ); $this->model = new QuoteManager( $this->persistentSessionMock, @@ -258,21 +264,22 @@ public function testConvertCustomerCartToGuest() ->method('setCustomerFirstname')->with(null)->willReturn($this->quoteMock); $this->quoteMock->expects($this->once()) ->method('setCustomerLastname')->with(null)->willReturn($this->quoteMock); - $this->quoteMock->expects($this->once())->method('setCustomerGroupId') - ->with(\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID) + $this->quoteMock->expects($this->never())->method('setCustomerGroupId') ->willReturn($this->quoteMock); $this->quoteMock->expects($this->once()) ->method('setIsPersistent')->with(false)->willReturn($this->quoteMock); $this->quoteMock->expects($this->exactly(3)) ->method('getAddressesCollection')->willReturn($this->abstractCollectionMock); - $this->abstractCollectionMock->expects($this->exactly(3))->method('walk')->with($this->logicalOr( - $this->equalTo('setCustomerAddressId'), - $this->equalTo($addressArgs), - $this->equalTo('setCustomerId'), - $this->equalTo($customerIdArgs), - $this->equalTo('setEmail'), - $this->equalTo($emailArgs) - )); + $this->abstractCollectionMock->expects($this->exactly(3))->method('walk')->with( + $this->logicalOr( + $this->equalTo('setCustomerAddressId'), + $this->equalTo($addressArgs), + $this->equalTo('setCustomerId'), + $this->equalTo($customerIdArgs), + $this->equalTo('setEmail'), + $this->equalTo($emailArgs) + ) + ); $this->quoteMock->expects($this->once())->method('collectTotals')->willReturn($this->quoteMock); $this->persistentSessionMock->expects($this->once()) ->method('getSession')->willReturn($this->sessionMock); diff --git a/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php index 2c5b9dad48eb..31a6ba9f10e7 100644 --- a/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php +++ b/app/code/Magento/Persistent/Test/Unit/Observer/CheckExpirePersistentQuoteObserverTest.php @@ -6,6 +6,8 @@ namespace Magento\Persistent\Test\Unit\Observer; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Model\Quote; /** @@ -63,6 +65,11 @@ class CheckExpirePersistentQuoteObserverTest extends \PHPUnit\Framework\TestCase */ private $quoteMock; + /** + * @var \PHPUnit_Framework_MockObject_MockObject|CartRepositoryInterface + */ + private $quoteRepositoryMock; + /** * @inheritdoc */ @@ -82,6 +89,7 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getRequestUri', 'getServer']) ->getMockForAbstractClass(); + $this->quoteRepositoryMock = $this->createMock(CartRepositoryInterface::class); $this->model = new \Magento\Persistent\Observer\CheckExpirePersistentQuoteObserver( $this->sessionMock, @@ -90,7 +98,8 @@ protected function setUp() $this->eventManagerMock, $this->customerSessionMock, $this->checkoutSessionMock, - $this->requestMock + $this->requestMock, + $this->quoteRepositoryMock ); $this->quoteMock = $this->getMockBuilder(Quote::class) ->setMethods(['getCustomerIsGuest', 'getIsPersistent']) @@ -111,12 +120,19 @@ public function testExecuteWhenCanNotApplyPersistentData() public function testExecuteWhenPersistentIsNotEnabled() { + $quoteId = 'quote_id_1'; + $this->persistentHelperMock ->expects($this->once()) ->method('canProcess') ->with($this->observerMock) ->willReturn(true); $this->persistentHelperMock->expects($this->exactly(2))->method('isEnabled')->willReturn(false); + $this->checkoutSessionMock->expects($this->exactly(2))->method('getQuoteId')->willReturn($quoteId); + $this->quoteRepositoryMock->expects($this->once()) + ->method('getActive') + ->with($quoteId) + ->willThrowException(new NoSuchEntityException()); $this->eventManagerMock->expects($this->never())->method('dispatch'); $this->model->execute($this->observerMock); } diff --git a/app/code/Magento/ProductAlert/Controller/Add/Price.php b/app/code/Magento/ProductAlert/Controller/Add/Price.php index 973db8c3bf5d..2dbcc27cd57d 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Price.php @@ -6,16 +6,17 @@ namespace Magento\ProductAlert\Controller\Add; -use Magento\Framework\App\Action\HttpGetActionInterface; -use Magento\ProductAlert\Controller\Add as AddController; -use Magento\Framework\App\Action\Context; -use Magento\Customer\Model\Session as CustomerSession; -use Magento\Store\Model\StoreManagerInterface; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\UrlInterface; +use Magento\Customer\Model\Session as CustomerSession; use Magento\Framework\App\Action\Action; +use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\UrlInterface; +use Magento\ProductAlert\Controller\Add as AddController; +use Magento\Store\Model\StoreManagerInterface; /** * Controller for notifying about price. @@ -28,15 +29,17 @@ class Price extends AddController implements HttpGetActionInterface protected $storeManager; /** - * @var \Magento\Catalog\Api\ProductRepositoryInterface + * @var \Magento\Catalog\Api\ProductRepositoryInterface */ protected $productRepository; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository + * Price constructor. + * + * @param Context $context + * @param CustomerSession $customerSession + * @param StoreManagerInterface $storeManager + * @param ProductRepositoryInterface $productRepository */ public function __construct( Context $context, @@ -54,6 +57,7 @@ public function __construct( * * @param string $url * @return bool + * @throws NoSuchEntityException */ protected function isInternal($url) { @@ -68,13 +72,14 @@ protected function isInternal($url) /** * Method for adding info about product alert price. * - * @return \Magento\Framework\Controller\Result\Redirect + * @return \Magento\Framework\Controller\ResultInterface + * @throws NoSuchEntityException */ public function execute() { $backUrl = $this->getRequest()->getParam(Action::PARAM_NAME_URL_ENCODED); $productId = (int)$this->getRequest()->getParam('product_id'); - /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ + /** @var Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if (!$backUrl || !$productId) { $resultRedirect->setPath('/'); @@ -93,9 +98,9 @@ public function execute() ->setWebsiteId($store->getWebsiteId()) ->setStoreId($store->getId()); $model->save(); - $this->messageManager->addSuccess(__('You saved the alert subscription.')); + $this->messageManager->addSuccessMessage(__('You saved the alert subscription.')); } catch (NoSuchEntityException $noEntityException) { - $this->messageManager->addError(__('There are not enough parameters.')); + $this->messageManager->addErrorMessage(__('There are not enough parameters.')); if ($this->isInternal($backUrl)) { $resultRedirect->setUrl($backUrl); } else { @@ -103,7 +108,7 @@ public function execute() } return $resultRedirect; } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __("The alert subscription couldn't update at this time. Please try again later.") ); diff --git a/app/code/Magento/ProductAlert/Controller/Add/Stock.php b/app/code/Magento/ProductAlert/Controller/Add/Stock.php index f36fdf5fb715..38b22d1efb85 100644 --- a/app/code/Magento/ProductAlert/Controller/Add/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Add/Stock.php @@ -76,13 +76,13 @@ public function execute() ->setWebsiteId($store->getWebsiteId()) ->setStoreId($store->getId()); $model->save(); - $this->messageManager->addSuccess(__('Alert subscription has been saved.')); + $this->messageManager->addSuccessMessage(__('Alert subscription has been saved.')); } catch (NoSuchEntityException $noEntityException) { - $this->messageManager->addError(__('There are not enough parameters.')); + $this->messageManager->addErrorMessage(__('There are not enough parameters.')); $resultRedirect->setUrl($backUrl); return $resultRedirect; } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __("The alert subscription couldn't update at this time. Please try again later.") ); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php index 2077b1ff2794..0aabf5d96e1e 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php @@ -6,6 +6,7 @@ namespace Magento\ProductAlert\Controller\Unsubscribe; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\ProductAlert\Controller\Unsubscribe as UnsubscribeController; use Magento\Framework\App\Action\Context; use Magento\Customer\Model\Session as CustomerSession; @@ -13,7 +14,10 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Framework\Exception\NoSuchEntityException; -class Price extends UnsubscribeController +/** + * Class Price + */ +class Price extends UnsubscribeController implements HttpGetActionInterface { /** * @var \Magento\Catalog\Api\ProductRepositoryInterface @@ -35,6 +39,8 @@ public function __construct( } /** + * Unsubscribe action + * * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() @@ -51,8 +57,13 @@ public function execute() /* @var $product \Magento\Catalog\Model\Product */ $product = $this->productRepository->getById($productId); if (!$product->isVisibleInCatalog()) { - throw new NoSuchEntityException(); + $this->messageManager->addErrorMessage( + __("The product wasn't found. Verify the product and try again.") + ); + $resultRedirect->setPath('customer/account/'); + return $resultRedirect; } + /** @var \Magento\ProductAlert\Model\Price $model */ $model = $this->_objectManager->create(\Magento\ProductAlert\Model\Price::class) ->setCustomerId($this->customerSession->getCustomerId()) @@ -67,13 +78,13 @@ public function execute() $model->delete(); } - $this->messageManager->addSuccess(__('You deleted the alert subscription.')); + $this->messageManager->addSuccessMessage(__('You deleted the alert subscription.')); } catch (NoSuchEntityException $noEntityException) { - $this->messageManager->addError(__("The product wasn't found. Verify the product and try again.")); + $this->messageManager->addErrorMessage(__("The product wasn't found. Verify the product and try again.")); $resultRedirect->setPath('customer/account/'); return $resultRedirect; } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __("The alert subscription couldn't update at this time. Please try again later.") ); diff --git a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php index 1b729f988e4a..f8df6ae6af38 100644 --- a/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php +++ b/app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php @@ -94,13 +94,13 @@ public function execute() if ($model->getId()) { $model->delete(); } - $this->messageManager->addSuccess(__('You will no longer receive stock alerts for this product.')); + $this->messageManager->addSuccessMessage(__('You will no longer receive stock alerts for this product.')); } catch (NoSuchEntityException $noEntityException) { - $this->messageManager->addError(__('The product was not found.')); + $this->messageManager->addErrorMessage(__('The product was not found.')); $resultRedirect->setPath('customer/account/'); return $resultRedirect; } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __("The alert subscription couldn't update at this time. Please try again later.") ); diff --git a/app/code/Magento/ProductAlert/Test/Unit/Controller/Unsubscribe/PriceTest.php b/app/code/Magento/ProductAlert/Test/Unit/Controller/Unsubscribe/PriceTest.php new file mode 100644 index 000000000000..a07c93337c04 --- /dev/null +++ b/app/code/Magento/ProductAlert/Test/Unit/Controller/Unsubscribe/PriceTest.php @@ -0,0 +1,125 @@ +objectManager = new ObjectManager($this); + $this->requestMock = $this->createMock(Http::class); + $this->resultFactoryMock = $this->createMock(ResultFactory::class); + $this->resultRedirectMock = $this->createMock(Redirect::class); + $this->messageManagerMock = $this->createMock(Manager::class); + $this->productMock = $this->createMock(Product::class); + $this->contextMock = $this->createMock(Context::class); + $this->customerSessionMock = $this->createMock(Session::class); + $this->productRepositoryMock = $this->createMock(ProductRepositoryInterface::class); + $this->resultFactoryMock->expects($this->any()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($this->resultRedirectMock); + $this->contextMock->expects($this->any())->method('getRequest')->willReturn($this->requestMock); + $this->contextMock->expects($this->any())->method('getResultFactory')->willReturn($this->resultFactoryMock); + $this->contextMock->expects($this->any())->method('getMessageManager')->willReturn($this->messageManagerMock); + + $this->priceController = $this->objectManager->getObject( + Price::class, + [ + 'context' => $this->contextMock, + 'customerSession' => $this->customerSessionMock, + 'productRepository' => $this->productRepositoryMock, + ] + ); + } + + public function testProductIsNotVisibleInCatalog() + { + $productId = 123; + $this->requestMock->expects($this->any())->method('getParam')->with('product')->willReturn($productId); + $this->productRepositoryMock->expects($this->any()) + ->method('getById') + ->with($productId) + ->willReturn($this->productMock); + $this->productMock->expects($this->any())->method('isVisibleInCatalog')->willReturn(false); + $this->messageManagerMock->expects($this->once())->method('addErrorMessage')->with(__("The product wasn't found. Verify the product and try again.")); + $this->resultRedirectMock->expects($this->once())->method('setPath')->with('customer/account/'); + + $this->assertEquals( + $this->resultRedirectMock, + $this->priceController->execute() + ); + } +} diff --git a/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminAssertVideoNoValidationErrorActionGroup.xml b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminAssertVideoNoValidationErrorActionGroup.xml new file mode 100644 index 000000000000..676974a577cb --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminAssertVideoNoValidationErrorActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminFillProductVideoFieldActionGroup.xml b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminFillProductVideoFieldActionGroup.xml new file mode 100644 index 000000000000..c4448dee84cd --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminFillProductVideoFieldActionGroup.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminGetVideoInformationActionGroup.xml b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminGetVideoInformationActionGroup.xml new file mode 100644 index 000000000000..c786a77de97f --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminGetVideoInformationActionGroup.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminOpenProductVideoModalActionGroup.xml b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminOpenProductVideoModalActionGroup.xml new file mode 100644 index 000000000000..569200efa737 --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AdminOpenProductVideoModalActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AssertAdminVideoValidationErrorActionGroup.xml b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AssertAdminVideoValidationErrorActionGroup.xml new file mode 100644 index 000000000000..60e2391712f1 --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/ActionGroup/AssertAdminVideoValidationErrorActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Section/AdminProductNewVideoSection.xml b/app/code/Magento/ProductVideo/Test/Mftf/Section/AdminProductNewVideoSection.xml index 71dad6a24f14..58a1c40a4e47 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Section/AdminProductNewVideoSection.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Section/AdminProductNewVideoSection.xml @@ -12,6 +12,7 @@ + @@ -20,5 +21,6 @@ + \ No newline at end of file diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminValidateUrlOnGetVideoInformationTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminValidateUrlOnGetVideoInformationTest.xml new file mode 100644 index 000000000000..0db15276e8c6 --- /dev/null +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminValidateUrlOnGetVideoInformationTest.xml @@ -0,0 +1,45 @@ + + + + + + + + + <description value="Testing for a required video url when getting video information"/> + <severity value="CRITICAL"/> + <group value="ProductVideo"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <createData entity="ProductVideoYoutubeApiKeyConfig" stepKey="setStoreConfig"/> + </before> + <after> + <createData entity="DefaultProductVideoConfig" stepKey="setStoreDefaultConfig"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndexPage"/> + <actionGroup ref="goToCreateProductPage" stepKey="goToCreateProduct"> + <argument name="product" value="SimpleProduct"/> + </actionGroup> + <actionGroup ref="AdminOpenProductVideoModalActionGroup" stepKey="openAddProductVideoModal"/> + <actionGroup ref="AdminGetVideoInformationActionGroup" stepKey="clickOnGetVideoInformation"/> + <actionGroup ref="AssertAdminVideoValidationErrorActionGroup" stepKey="seeUrlValidationMessage"> + <argument name="inputName" value="video_url"/> + </actionGroup> + <actionGroup ref="AdminFillProductVideoFieldActionGroup" stepKey="fillVideoUrlField"> + <argument name="input" value="{{AdminProductNewVideoSection.videoUrlTextField}}"/> + <argument name="value" value="{{mftfTestProductVideo.videoUrl}}"/> + </actionGroup> + <actionGroup ref="AdminGetVideoInformationActionGroup" stepKey="clickOnGetVideoInformation2"/> + <actionGroup ref="AdminAssertVideoNoValidationErrorActionGroup" stepKey="dontSeeUrlValidationMessage"> + <argument name="inputName" value="video_url"/> + </actionGroup> + </test> +</tests> 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 e9b234c5f116..9cc731dde4b0 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 @@ -282,9 +282,15 @@ define([ * @private */ _onGetVideoInformationClick: function () { - this._onlyVideoPlayer = false; - this._isEditPage = false; - this._videoUrlWidget.trigger('update_video_information'); + var videoForm = this.element.find(this._videoFormSelector); + + videoForm.validation(); + + if (this.element.find(this._videoUrlSelector).valid()) { + this._onlyVideoPlayer = false; + this._isEditPage = false; + this._videoUrlWidget.trigger('update_video_information'); + } }, /** @@ -299,6 +305,14 @@ define([ * @private */ _onGetVideoInformationStartRequest: function () { + var videoForm = this.element.find(this._videoFormSelector); + + try { + videoForm.validation('clearError'); + } catch (e) { + // Do nothing + } + this._videoRequestComplete = false; }, diff --git a/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php index 5da776091f7f..48818e5d253e 100644 --- a/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php +++ b/app/code/Magento/Quote/Api/Data/CartSearchResultsInterface.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Quote\Api\Data; /** diff --git a/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php index 266a6e67528e..678c92250f53 100644 --- a/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php +++ b/app/code/Magento/Quote/Model/Cart/Totals/ItemConverter.php @@ -71,7 +71,7 @@ public function __construct( * Converts a specified rate model to a shipping method data object. * * @param \Magento\Quote\Model\Quote\Item $item - * @return array + * @return \Magento\Quote\Api\Data\TotalsItemInterface * @throws \Exception */ public function modelToDataObject($item) diff --git a/app/code/Magento/Quote/Model/CartSearchResults.php b/app/code/Magento/Quote/Model/CartSearchResults.php new file mode 100644 index 000000000000..5c505bec121f --- /dev/null +++ b/app/code/Magento/Quote/Model/CartSearchResults.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Quote\Model; + +use Magento\Framework\Api\AbstractSimpleObject; +use Magento\Quote\Api\Data\CartSearchResultsInterface; + +/** + * Service Data Object with Cart search results. + */ +class CartSearchResults extends AbstractSimpleObject implements CartSearchResultsInterface +{ + /** + * @inheritdoc + */ + public function setItems(array $items = null) + { + return $this->setData(self::KEY_ITEMS, $items); + } + + /** + * @inheritdoc + */ + public function getItems() + { + return $this->_get(self::KEY_ITEMS) === null ? [] : $this->_get(self::KEY_ITEMS); + } + + /** + * @inheritdoc + */ + public function getSearchCriteria() + { + return $this->_get(self::KEY_SEARCH_CRITERIA); + } + + /** + * @inheritdoc + */ + public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) + { + return $this->setData(self::KEY_SEARCH_CRITERIA, $searchCriteria); + } + + /** + * @inheritdoc + */ + public function getTotalCount() + { + return $this->_get(self::KEY_TOTAL_COUNT); + } + + /** + * @inheritdoc + */ + public function setTotalCount($count) + { + return $this->setData(self::KEY_TOTAL_COUNT, $count); + } +} diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 3ecbc69b8078..0e2bf1ce48ec 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -425,9 +425,11 @@ protected function _populateBeforeSaveData() */ protected function _isSameAsBilling() { + $quoteSameAsBilling = $this->getSameAsBilling(); + return $this->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING && - ($this->_isNotRegisteredCustomer() || - $this->_isDefaultShippingNullOrSameAsBillingAddress()); + ($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()) && + ($quoteSameAsBilling || $quoteSameAsBilling === 0 || $quoteSameAsBilling === null); } /** @@ -471,7 +473,7 @@ protected function _isDefaultShippingNullOrSameAsBillingAddress() /** * Declare address quote model object * - * @param \Magento\Quote\Model\Quote $quote + * @param \Magento\Quote\Model\Quote $quote * @return $this */ public function setQuote(\Magento\Quote\Model\Quote $quote) @@ -691,7 +693,7 @@ public function getItemQty($itemId = 0) */ public function hasItems() { - return sizeof($this->getAllItems()) > 0; + return count($this->getAllItems()) > 0; } /** @@ -1225,8 +1227,8 @@ public function setBaseShippingAmount($value, $alreadyExclTax = false) /** * Set total amount value * - * @param string $code - * @param float $amount + * @param string $code + * @param float $amount * @return $this */ public function setTotalAmount($code, $amount) @@ -1243,8 +1245,8 @@ public function setTotalAmount($code, $amount) /** * Set total amount value in base store currency * - * @param string $code - * @param float $amount + * @param string $code + * @param float $amount * @return $this */ public function setBaseTotalAmount($code, $amount) @@ -1261,8 +1263,8 @@ public function setBaseTotalAmount($code, $amount) /** * Add amount total amount value * - * @param string $code - * @param float $amount + * @param string $code + * @param float $amount * @return $this */ public function addTotalAmount($code, $amount) @@ -1276,8 +1278,8 @@ public function addTotalAmount($code, $amount) /** * Add amount total amount value in base store currency * - * @param string $code - * @param float $amount + * @param string $code + * @param float $amount * @return $this */ public function addBaseTotalAmount($code, $amount) diff --git a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php index 77dfec9603a5..a1228903e232 100644 --- a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php +++ b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php @@ -113,6 +113,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) $customerCountryCode = $customerAddress->getCountryId(); $customerVatNumber = $customerAddress->getVatId(); + $address->setCountryId($customerCountryCode); + $address->setVatId($customerVatNumber); } $groupId = null; diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index 4ea067c9be8f..a590c8aa891a 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -314,6 +314,43 @@ public function testDispatchWithCustomerCountryInEU() $this->model->execute($this->observerMock); } + public function testDispatchWithAddressCustomerVatIdAndCountryId() + { + $customerCountryCode = "BE"; + $customerVat = "123123123"; + $defaultShipping = 1; + + $customerAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class); + $customerAddress->expects($this->any()) + ->method("getVatId") + ->willReturn($customerVat); + + $customerAddress->expects($this->any()) + ->method("getCountryId") + ->willReturn($customerCountryCode); + + $this->addressRepository->expects($this->once()) + ->method("getById") + ->with($defaultShipping) + ->willReturn($customerAddress); + + $this->customerMock->expects($this->atLeastOnce()) + ->method("getDefaultShipping") + ->willReturn($defaultShipping); + + $this->vatValidatorMock->expects($this->once()) + ->method('isEnabled') + ->with($this->quoteAddressMock, $this->storeId) + ->will($this->returnValue(true)); + + $this->customerVatMock->expects($this->once()) + ->method('isCountryInEU') + ->with($customerCountryCode) + ->willReturn(true); + + $this->model->execute($this->observerMock); + } + public function testDispatchWithEmptyShippingAddress() { $customerCountryCode = "DE"; diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml index cd5e62307fdc..f66001e7789c 100644 --- a/app/code/Magento/Quote/etc/di.xml +++ b/app/code/Magento/Quote/etc/di.xml @@ -18,7 +18,7 @@ <preference for="Magento\Quote\Api\Data\CartInterface" type="Magento\Quote\Model\Quote" /> <preference for="Magento\Quote\Api\CartItemRepositoryInterface" type="Magento\Quote\Model\Quote\Item\Repository" /> <preference for="Magento\Quote\Api\CartRepositoryInterface" type="Magento\Quote\Model\QuoteRepository" /> - <preference for="Magento\Quote\Api\Data\CartSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Quote\Api\Data\CartSearchResultsInterface" type="Magento\Quote\Model\CartSearchResults" /> <preference for="Magento\Quote\Api\PaymentMethodManagementInterface" type="Magento\Quote\Model\PaymentMethodManagement" /> <preference for="Magento\Quote\Api\Data\PaymentInterface" type="Magento\Quote\Model\Quote\Payment" /> <preference for="Magento\Quote\Api\CouponManagementInterface" type="Magento\Quote\Model\CouponManagement" /> diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/Address/SaveQuoteAddressToCustomerAddressBook.php b/app/code/Magento/QuoteGraphQl/Model/Cart/Address/SaveQuoteAddressToCustomerAddressBook.php new file mode 100644 index 000000000000..5c773d44e6a1 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/Address/SaveQuoteAddressToCustomerAddressBook.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\QuoteGraphQl\Model\Cart\Address; + +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\Data\AddressInterface; +use Magento\Customer\Api\Data\AddressInterfaceFactory; +use Magento\Customer\Api\Data\RegionInterface; +use Magento\Customer\Api\Data\RegionInterfaceFactory; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Quote\Model\Quote\Address as QuoteAddress; + +/** + * Save Address to Customer Address Book. + */ +class SaveQuoteAddressToCustomerAddressBook +{ + /** + * @var AddressInterfaceFactory + */ + private $addressFactory; + + /** + * @var AddressRepositoryInterface + */ + private $addressRepository; + + /** + * @var RegionInterfaceFactory + */ + private $regionFactory; + + /** + * @param AddressInterfaceFactory $addressFactory + * @param AddressRepositoryInterface $addressRepository + * @param RegionInterfaceFactory $regionFactory + */ + public function __construct( + AddressInterfaceFactory $addressFactory, + AddressRepositoryInterface $addressRepository, + RegionInterfaceFactory $regionFactory + ) { + $this->addressFactory = $addressFactory; + $this->addressRepository = $addressRepository; + $this->regionFactory = $regionFactory; + } + + /** + * Save Address to Customer Address Book. + * + * @param QuoteAddress $quoteAddress + * @param int $customerId + * + * @return void + * @throws GraphQlInputException + */ + public function execute(QuoteAddress $quoteAddress, int $customerId): void + { + try { + /** @var AddressInterface $customerAddress */ + $customerAddress = $this->addressFactory->create(); + $customerAddress->setFirstname($quoteAddress->getFirstname()) + ->setLastname($quoteAddress->getLastname()) + ->setMiddlename($quoteAddress->getMiddlename()) + ->setPrefix($quoteAddress->getPrefix()) + ->setSuffix($quoteAddress->getSuffix()) + ->setVatId($quoteAddress->getVatId()) + ->setCountryId($quoteAddress->getCountryId()) + ->setCompany($quoteAddress->getCompany()) + ->setRegionId($quoteAddress->getRegionId()) + ->setFax($quoteAddress->getFax()) + ->setCity($quoteAddress->getCity()) + ->setPostcode($quoteAddress->getPostcode()) + ->setStreet($quoteAddress->getStreet()) + ->setTelephone($quoteAddress->getTelephone()) + ->setCustomerId($customerId); + + /** @var RegionInterface $region */ + $region = $this->regionFactory->create(); + $region->setRegionCode($quoteAddress->getRegionCode()) + ->setRegion($quoteAddress->getRegion()) + ->setRegionId($quoteAddress->getRegionId()); + $customerAddress->setRegion($region); + + $this->addressRepository->save($customerAddress); + } catch (LocalizedException $e) { + throw new GraphQlInputException(__($e->getMessage()), $e); + } + } +} diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php index dd6478b4873c..95c46cdcca5d 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php @@ -7,7 +7,7 @@ namespace Magento\QuoteGraphQl\Model\Cart; -use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; @@ -52,7 +52,7 @@ public function execute( $this->billingAddressManagement->assign($cart->getId(), $billingAddress, $useForShipping); } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); - } catch (LocalizedException $e) { + } catch (InputException $e) { throw new GraphQlInputException(__($e->getMessage()), $e); } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php index 527999b245a4..4dbcfad31e84 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php @@ -7,7 +7,7 @@ namespace Magento\QuoteGraphQl\Model\Cart; -use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; @@ -50,7 +50,7 @@ public function execute( $this->shippingAddressManagement->assign($cart->getId(), $shippingAddress); } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); - } catch (LocalizedException $e) { + } catch (InputException $e) { throw new GraphQlInputException(__($e->getMessage()), $e); } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php index c4d795293220..27dd1959cb5d 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php @@ -7,7 +7,6 @@ namespace Magento\QuoteGraphQl\Model\Cart; -use Magento\Customer\Model\Address\AbstractAddress; use Magento\Framework\Api\ExtensibleDataObjectConverter; use Magento\Quote\Api\Data\AddressInterface; use Magento\Quote\Model\Quote\Address as QuoteAddress; @@ -41,19 +40,22 @@ public function execute(QuoteAddress $address): array $addressData = $this->dataObjectConverter->toFlatArray($address, [], AddressInterface::class); $addressData['model'] = $address; - $addressData = array_merge($addressData, [ - 'country' => [ - 'code' => $address->getCountryId(), - 'label' => $address->getCountry() - ], - 'region' => [ - 'code' => $address->getRegionCode(), - 'label' => $address->getRegion() - ], - 'street' => $address->getStreet(), - 'items_weight' => $address->getWeight(), - 'customer_notes' => $address->getCustomerNotes() - ]); + $addressData = array_merge( + $addressData, + [ + 'country' => [ + 'code' => $address->getCountryId(), + 'label' => $address->getCountry() + ], + 'region' => [ + 'code' => $address->getRegionCode(), + 'label' => $address->getRegion() + ], + 'street' => $address->getStreet(), + 'items_weight' => $address->getWeight(), + 'customer_notes' => $address->getCustomerNotes() + ] + ); if (!$address->hasItems()) { return $addressData; @@ -61,8 +63,14 @@ public function execute(QuoteAddress $address): array $addressItemsData = []; foreach ($address->getAllItems() as $addressItem) { + if ($addressItem instanceof \Magento\Quote\Model\Quote\Item) { + $itemId = $addressItem->getItemId(); + } else { + $itemId = $addressItem->getQuoteItemId(); + } + $addressItemsData[] = [ - 'cart_item_id' => $addressItem->getQuoteItemId(), + 'cart_item_id' => $itemId, 'quantity' => $addressItem->getQty() ]; } diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/GetShippingAddress.php b/app/code/Magento/QuoteGraphQl/Model/Cart/GetShippingAddress.php new file mode 100644 index 000000000000..2a57c281de18 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/GetShippingAddress.php @@ -0,0 +1,120 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\QuoteGraphQl\Model\Cart; + +use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; +use Magento\GraphQl\Model\Query\ContextInterface; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException; +use Magento\Quote\Model\Quote\Address; +use Magento\QuoteGraphQl\Model\Cart\Address\SaveQuoteAddressToCustomerAddressBook; + +/** + * Get shipping address + */ +class GetShippingAddress +{ + /** + * @var QuoteAddressFactory + */ + private $quoteAddressFactory; + + /** + * @var SaveQuoteAddressToCustomerAddressBook + */ + private $saveQuoteAddressToCustomerAddressBook; + + /** + * @param QuoteAddressFactory $quoteAddressFactory + * @param SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook + */ + public function __construct( + QuoteAddressFactory $quoteAddressFactory, + SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook + ) { + $this->quoteAddressFactory = $quoteAddressFactory; + $this->saveQuoteAddressToCustomerAddressBook = $saveQuoteAddressToCustomerAddressBook; + } + + /** + * Get Shipping Address based on the input. + * + * @param ContextInterface $context + * @param array $shippingAddressInput + * @return Address + * @throws GraphQlAuthorizationException + * @throws GraphQlInputException + * @throws GraphQlNoSuchEntityException + */ + public function execute(ContextInterface $context, array $shippingAddressInput): Address + { + $customerAddressId = $shippingAddressInput['customer_address_id'] ?? null; + $addressInput = $shippingAddressInput['address'] ?? null; + + if ($addressInput) { + $addressInput['customer_notes'] = $shippingAddressInput['customer_notes'] ?? ''; + } + + if (null === $customerAddressId && null === $addressInput) { + throw new GraphQlInputException( + __('The shipping address must contain either "customer_address_id" or "address".') + ); + } + + if ($customerAddressId && $addressInput) { + throw new GraphQlInputException( + __('The shipping address cannot contain "customer_address_id" and "address" at the same time.') + ); + } + + $shippingAddress = $this->createShippingAddress($context, $customerAddressId, $addressInput); + + return $shippingAddress; + } + + /** + * Create shipping address. + * + * @param ContextInterface $context + * @param int|null $customerAddressId + * @param array|null $addressInput + * + * @return \Magento\Quote\Model\Quote\Address + * @throws GraphQlAuthorizationException + */ + private function createShippingAddress( + ContextInterface $context, + ?int $customerAddressId, + ?array $addressInput + ) { + $customerId = $context->getUserId(); + + if (null === $customerAddressId) { + $shippingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput); + + // need to save address only for registered user and if save_in_address_book = true + if (0 !== $customerId + && isset($addressInput['save_in_address_book']) + && (bool)$addressInput['save_in_address_book'] === true + ) { + $this->saveQuoteAddressToCustomerAddressBook->execute($shippingAddress, $customerId); + } + } else { + if (false === $context->getExtensionAttributes()->getIsCustomer()) { + throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.')); + } + + $shippingAddress = $this->quoteAddressFactory->createBasedOnCustomerAddress( + (int)$customerAddressId, + $customerId + ); + } + + return $shippingAddress; + } +} diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php index 673debefd087..f3b96a1454fb 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php @@ -13,6 +13,7 @@ use Magento\GraphQl\Model\Query\ContextInterface; use Magento\Quote\Api\Data\CartInterface; use Magento\Quote\Model\Quote\Address; +use Magento\QuoteGraphQl\Model\Cart\Address\SaveQuoteAddressToCustomerAddressBook; /** * Set billing address for a specified shopping cart @@ -29,16 +30,24 @@ class SetBillingAddressOnCart */ private $assignBillingAddressToCart; + /** + * @var SaveQuoteAddressToCustomerAddressBook + */ + private $saveQuoteAddressToCustomerAddressBook; + /** * @param QuoteAddressFactory $quoteAddressFactory * @param AssignBillingAddressToCart $assignBillingAddressToCart + * @param SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook */ public function __construct( QuoteAddressFactory $quoteAddressFactory, - AssignBillingAddressToCart $assignBillingAddressToCart + AssignBillingAddressToCart $assignBillingAddressToCart, + SaveQuoteAddressToCustomerAddressBook $saveQuoteAddressToCustomerAddressBook ) { $this->quoteAddressFactory = $quoteAddressFactory; $this->assignBillingAddressToCart = $assignBillingAddressToCart; + $this->saveQuoteAddressToCustomerAddressBook = $saveQuoteAddressToCustomerAddressBook; } /** @@ -101,6 +110,15 @@ private function createBillingAddress( ): Address { if (null === $customerAddressId) { $billingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput); + + $customerId = $context->getUserId(); + // need to save address only for registered user and if save_in_address_book = true + if (0 !== $customerId + && isset($addressInput['save_in_address_book']) + && (bool)$addressInput['save_in_address_book'] === true + ) { + $this->saveQuoteAddressToCustomerAddressBook->execute($billingAddress, $customerId); + } } else { if (false === $context->getExtensionAttributes()->getIsCustomer()) { throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.')); @@ -111,6 +129,7 @@ private function createBillingAddress( (int)$context->getUserId() ); } + return $billingAddress; } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php index 260f1343556f..6b1296eaf375 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php @@ -7,7 +7,6 @@ namespace Magento\QuoteGraphQl\Model\Cart; -use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException; use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\GraphQl\Model\Query\ContextInterface; use Magento\Quote\Api\Data\CartInterface; @@ -18,25 +17,25 @@ class SetShippingAddressesOnCart implements SetShippingAddressesOnCartInterface { /** - * @var QuoteAddressFactory + * @var AssignShippingAddressToCart */ - private $quoteAddressFactory; + private $assignShippingAddressToCart; /** - * @var AssignShippingAddressToCart + * @var GetShippingAddress */ - private $assignShippingAddressToCart; + private $getShippingAddress; /** - * @param QuoteAddressFactory $quoteAddressFactory * @param AssignShippingAddressToCart $assignShippingAddressToCart + * @param GetShippingAddress $getShippingAddress */ public function __construct( - QuoteAddressFactory $quoteAddressFactory, - AssignShippingAddressToCart $assignShippingAddressToCart + AssignShippingAddressToCart $assignShippingAddressToCart, + GetShippingAddress $getShippingAddress ) { - $this->quoteAddressFactory = $quoteAddressFactory; $this->assignShippingAddressToCart = $assignShippingAddressToCart; + $this->getShippingAddress = $getShippingAddress; } /** @@ -50,37 +49,8 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s ); } $shippingAddressInput = current($shippingAddressesInput); - $customerAddressId = $shippingAddressInput['customer_address_id'] ?? null; - $addressInput = $shippingAddressInput['address'] ?? null; - if ($addressInput) { - $addressInput['customer_notes'] = $shippingAddressInput['customer_notes'] ?? ''; - } - - if (null === $customerAddressId && null === $addressInput) { - throw new GraphQlInputException( - __('The shipping address must contain either "customer_address_id" or "address".') - ); - } - - if ($customerAddressId && $addressInput) { - throw new GraphQlInputException( - __('The shipping address cannot contain "customer_address_id" and "address" at the same time.') - ); - } - - if (null === $customerAddressId) { - $shippingAddress = $this->quoteAddressFactory->createBasedOnInputData($addressInput); - } else { - if (false === $context->getExtensionAttributes()->getIsCustomer()) { - throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.')); - } - - $shippingAddress = $this->quoteAddressFactory->createBasedOnCustomerAddress( - (int)$customerAddressId, - $context->getUserId() - ); - } + $shippingAddress = $this->getShippingAddress->execute($context, $shippingAddressInput); $this->assignShippingAddressToCart->execute($cart, $shippingAddress); } diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php index 81a7779eb98b..7b5c9a57a7be 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php @@ -93,8 +93,6 @@ public function execute(Quote $cart, int $cartItemId, float $quantity, array $cu ) ); } - - $this->quoteRepository->save($cart); } /** @@ -105,7 +103,7 @@ public function execute(Quote $cart, int $cartItemId, float $quantity, array $cu * @param float $quantity * @throws GraphQlNoSuchEntityException * @throws NoSuchEntityException - * @throws GraphQlNoSuchEntityException + * @throws GraphQlInputException */ private function updateItemQuantity(int $itemId, Quote $cart, float $quantity) { diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ValidateAddressFromSchema.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ValidateAddressFromSchema.php new file mode 100644 index 000000000000..69fb7d3c2fe2 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ValidateAddressFromSchema.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\QuoteGraphQl\Model\Cart; + +use Magento\Framework\GraphQl\Schema\Type\TypeRegistry; + +/** + * Validates address against required fields from schema + */ +class ValidateAddressFromSchema +{ + /** + * @var TypeRegistry + */ + private $typeRegistry; + + /** + * @param TypeRegistry $typeRegistry + */ + public function __construct( + TypeRegistry $typeRegistry + ) { + $this->typeRegistry = $typeRegistry; + } + + /** + * Validate data from address against mandatory fields from graphql schema for address + * + * @param array $address + * @return bool + */ + public function execute(array $address = []) : bool + { + /** @var \Magento\Framework\GraphQL\Schema\Type\Input\InputObjectType $cartAddressInput */ + $cartAddressInput = $this->typeRegistry->get('CartAddressInput'); + $fields = $cartAddressInput->getFields(); + + foreach ($fields as $field) { + if ($field->getType() instanceof \Magento\Framework\GraphQL\Schema\Type\NonNull) { + // an array key has to exist but it's value should not be null + if (array_key_exists($field->name, $address) + && !is_array($address[$field->name]) + && !isset($address[$field->name])) { + return false; + } + } + } + return true; + } +} diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/BillingAddress.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/BillingAddress.php index a6bb0b0d04df..b0e621789ebd 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/BillingAddress.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/BillingAddress.php @@ -13,6 +13,7 @@ use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Quote\Api\Data\CartInterface; use Magento\QuoteGraphQl\Model\Cart\ExtractQuoteAddressData; +use Magento\QuoteGraphQl\Model\Cart\ValidateAddressFromSchema; /** * @inheritdoc @@ -24,12 +25,21 @@ class BillingAddress implements ResolverInterface */ private $extractQuoteAddressData; + /** + * @var ValidateAddressFromSchema + */ + private $validateAddressFromSchema; + /** * @param ExtractQuoteAddressData $extractQuoteAddressData + * @param ValidateAddressFromSchema $validateAddressFromSchema */ - public function __construct(ExtractQuoteAddressData $extractQuoteAddressData) - { + public function __construct( + ExtractQuoteAddressData $extractQuoteAddressData, + ValidateAddressFromSchema $validateAddressFromSchema + ) { $this->extractQuoteAddressData = $extractQuoteAddressData; + $this->validateAddressFromSchema = $validateAddressFromSchema; } /** @@ -44,11 +54,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value $cart = $value['model']; $billingAddress = $cart->getBillingAddress(); - if (null === $billingAddress) { + $addressData = $this->extractQuoteAddressData->execute($billingAddress); + if (!$this->validateAddressFromSchema->execute($addressData)) { return null; } - - $addressData = $this->extractQuoteAddressData->execute($billingAddress); return $addressData; } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php index 1a0740a75c8f..3a10c773c5f2 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/PlaceOrder.php @@ -89,6 +89,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value return [ 'order' => [ + 'order_number' => $order->getIncrementId(), + // @deprecated The order_id field is deprecated, use order_number instead 'order_id' => $order->getIncrementId(), ], ]; diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentAndPlaceOrder.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentAndPlaceOrder.php index 03e1e6ffe822..dd4ce8fe7f7a 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentAndPlaceOrder.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetPaymentAndPlaceOrder.php @@ -99,6 +99,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value return [ 'order' => [ + 'order_number' => $order->getIncrementId(), + // @deprecated The order_id field is deprecated, use order_number instead 'order_id' => $order->getIncrementId(), ], ]; diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddresses.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddresses.php index ae97f7efda45..ac0bfe36627c 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddresses.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddresses.php @@ -13,8 +13,7 @@ use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Quote\Model\Quote; use Magento\QuoteGraphQl\Model\Cart\ExtractQuoteAddressData; -use Magento\Framework\GraphQl\Schema\Type\TypeRegistry; -use Magento\Framework\App\ObjectManager; +use Magento\QuoteGraphQl\Model\Cart\ValidateAddressFromSchema; /** * @inheritdoc @@ -27,20 +26,20 @@ class ShippingAddresses implements ResolverInterface private $extractQuoteAddressData; /** - * @var TypeRegistry + * @var ValidateAddressFromSchema */ - private $typeRegistry; + private $validateAddressFromSchema; /** * @param ExtractQuoteAddressData $extractQuoteAddressData - * @param TypeRegistry|null $typeRegistry + * @param ValidateAddressFromSchema $validateAddressFromSchema */ public function __construct( ExtractQuoteAddressData $extractQuoteAddressData, - TypeRegistry $typeRegistry = null + ValidateAddressFromSchema $validateAddressFromSchema ) { $this->extractQuoteAddressData = $extractQuoteAddressData; - $this->typeRegistry = $typeRegistry ?: ObjectManager::getInstance()->get(TypeRegistry::class); + $this->validateAddressFromSchema = $validateAddressFromSchema; } /** @@ -61,36 +60,11 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value foreach ($shippingAddresses as $shippingAddress) { $address = $this->extractQuoteAddressData->execute($shippingAddress); - if ($this->validateAddressFromSchema($address)) { + if ($this->validateAddressFromSchema->execute($address)) { $addressesData[] = $address; } } } return $addressesData; } - - /** - * Validate data from address against mandatory fields from graphql schema for address - * - * @param array $address - * @return bool - */ - private function validateAddressFromSchema(array $address) : bool - { - /** @var \Magento\Framework\GraphQL\Schema\Type\Input\InputObjectType $cartAddressInput */ - $cartAddressInput = $this->typeRegistry->get('CartAddressInput'); - $fields = $cartAddressInput->getFields(); - - foreach ($fields as $field) { - if ($field->getType() instanceof \Magento\Framework\GraphQL\Schema\Type\NonNull) { - // an array key has to exist but it's value should not be null - if (array_key_exists($field->name, $address) - && !is_array($address[$field->name]) - && !isset($address[$field->name])) { - return false; - } - } - } - return true; - } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php index 8066c28e9e48..241237613b94 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php @@ -15,6 +15,7 @@ use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Quote\Api\CartItemRepositoryInterface; +use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Model\Quote; use Magento\QuoteGraphQl\Model\Cart\GetCartForUser; use Magento\QuoteGraphQl\Model\Cart\UpdateCartItem; @@ -39,19 +40,27 @@ class UpdateCartItems implements ResolverInterface */ private $cartItemRepository; + /** + * @var CartRepositoryInterface + */ + private $cartRepository; + /** * @param GetCartForUser $getCartForUser * @param CartItemRepositoryInterface $cartItemRepository * @param UpdateCartItem $updateCartItem + * @param CartRepositoryInterface $cartRepository */ public function __construct( GetCartForUser $getCartForUser, CartItemRepositoryInterface $cartItemRepository, - UpdateCartItem $updateCartItem + UpdateCartItem $updateCartItem, + CartRepositoryInterface $cartRepository ) { $this->getCartForUser = $getCartForUser; $this->cartItemRepository = $cartItemRepository; $this->updateCartItem = $updateCartItem; + $this->cartRepository = $cartRepository; } /** @@ -76,6 +85,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value try { $this->processCartItems($cart, $cartItems); + $this->cartRepository->save($cart); } catch (NoSuchEntityException $e) { throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e); } catch (LocalizedException $e) { diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls index 494af6c633ef..7074be249fbc 100644 --- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls +++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls @@ -109,7 +109,7 @@ input CartAddressInput { postcode: String country_code: String! telephone: String! - save_in_address_book: Boolean! + save_in_address_book: Boolean } input SetShippingMethodsOnCartInput { @@ -196,7 +196,7 @@ type Cart { applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code") email: String @resolver (class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartEmail") shipping_addresses: [ShippingCartAddress]! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddresses") - billing_address: BillingCartAddress! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\BillingAddress") + billing_address: BillingCartAddress @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\BillingAddress") available_payment_methods: [AvailablePaymentMethod] @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AvailablePaymentMethods") @doc(description: "Available payment methods") selected_payment_method: SelectedPaymentMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SelectedPaymentMethod") prices: CartPrices @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartPrices") @@ -205,15 +205,15 @@ type Cart { } interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartAddressTypeResolver") { - firstname: String - lastname: String + firstname: String! + lastname: String! company: String - street: [String] - city: String + street: [String!]! + city: String! region: CartAddressRegion postcode: String - country: CartAddressCountry - telephone: String + country: CartAddressCountry! + telephone: String! } type ShippingCartAddress implements CartAddressInterface { @@ -234,13 +234,13 @@ type CartItemQuantity @doc(description:"Deprecated: `cart_items` field of `Shipp } type CartAddressRegion { - code: String - label: String + code: String! + label: String! } type CartAddressCountry { - code: String - label: String + code: String! + label: String! } type SelectedShippingMethod { @@ -358,5 +358,6 @@ type CartItemSelectedOptionValuePrice { } type Order { - order_id: String + order_number: String! + order_id: String @deprecated(reason: "The order_id field is deprecated, use order_number instead.") } diff --git a/app/code/Magento/Reports/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Product/Collection.php index 8c985238efe4..ab76cad8da5c 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Product/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Product/Collection.php @@ -77,7 +77,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -111,7 +111,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Reports/Model/ResourceModel/Product/Index/Collection/AbstractCollection.php b/app/code/Magento/Reports/Model/ResourceModel/Product/Index/Collection/AbstractCollection.php index ec514f45ff65..5b4cf39d65de 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Product/Index/Collection/AbstractCollection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Product/Index/Collection/AbstractCollection.php @@ -44,7 +44,7 @@ abstract class AbstractCollection extends \Magento\Catalog\Model\ResourceModel\P * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -69,7 +69,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Reports/Model/ResourceModel/Product/Lowstock/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Product/Lowstock/Collection.php index c02de01117a7..39d673911111 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Product/Lowstock/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Product/Lowstock/Collection.php @@ -63,7 +63,7 @@ class Collection extends \Magento\Reports\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -94,7 +94,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Reports/Test/Mftf/Page/ReportsSearchTermsPage.xml b/app/code/Magento/Reports/Test/Mftf/Page/ReportsSearchTermsPage.xml new file mode 100644 index 000000000000..e9e60c6d6dcc --- /dev/null +++ b/app/code/Magento/Reports/Test/Mftf/Page/ReportsSearchTermsPage.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="ReportsSearchTermPage" url="search/term/report/" area="admin" module="Magento_Reports"> + <section name="ReportsSearchTermSection"/> + </page> +</pages> diff --git a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Product/CollectionTest.php b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Product/CollectionTest.php index 3f1857b352db..23067457081a 100644 --- a/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Product/CollectionTest.php +++ b/app/code/Magento/Reports/Test/Unit/Model/ResourceModel/Product/CollectionTest.php @@ -29,7 +29,7 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Select; use Magento\Framework\Event\ManagerInterface; -use Magento\Framework\Module\ModuleManagerInterface as Manager; +use Magento\Framework\Module\Manager as Manager; use Magento\Framework\Stdlib\DateTime; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; diff --git a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_customer_accounts_grid.xml b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_customer_accounts_grid.xml index 55ca286ad3d4..2d33ca3c6a87 100644 --- a/app/code/Magento/Reports/view/adminhtml/layout/reports_report_customer_accounts_grid.xml +++ b/app/code/Magento/Reports/view/adminhtml/layout/reports_report_customer_accounts_grid.xml @@ -40,6 +40,7 @@ <argument name="id" xsi:type="string">accounts</argument> <argument name="column_css_class" xsi:type="string">col-qty</argument> <argument name="header_css_class" xsi:type="string">col-qty</argument> + <argument name="sortable" xsi:type="string">0</argument> </arguments> </block> </referenceBlock> diff --git a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php index 509e826e6f7d..d3bbdf9a7eb4 100644 --- a/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Review/Block/Adminhtml/Product/Grid.php @@ -29,7 +29,7 @@ class Grid extends \Magento\Catalog\Block\Adminhtml\Product\Grid * @param \Magento\Catalog\Model\Product\Type $type * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $status * @param \Magento\Catalog\Model\Product\Visibility $visibility - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websitesFactory * @param array $data * @@ -44,7 +44,7 @@ public function __construct( \Magento\Catalog\Model\Product\Type $type, \Magento\Catalog\Model\Product\Attribute\Source\Status $status, \Magento\Catalog\Model\Product\Visibility $visibility, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Store\Model\ResourceModel\Website\CollectionFactory $websitesFactory, array $data = [] ) { diff --git a/app/code/Magento/Review/Model/ResourceModel/Rating.php b/app/code/Magento/Review/Model/ResourceModel/Rating.php index 42c14e16a50e..37a93d40b110 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Rating.php +++ b/app/code/Magento/Review/Model/ResourceModel/Rating.php @@ -29,7 +29,7 @@ class Rating extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb protected $_storeManager; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -46,7 +46,7 @@ class Rating extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param Review\Summary $reviewSummary * @param string $connectionName @@ -55,7 +55,7 @@ class Rating extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb public function __construct( \Magento\Framework\Model\ResourceModel\Db\Context $context, \Psr\Log\LoggerInterface $logger, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Review\Model\ResourceModel\Review\Summary $reviewSummary, $connectionName = null, diff --git a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php index 7175baa92a2f..ab264ef1b617 100644 --- a/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php +++ b/app/code/Magento/Review/Model/ResourceModel/Review/Product/Collection.php @@ -75,7 +75,7 @@ class Collection extends \Magento\Catalog\Model\ResourceModel\Product\Collection * @param \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Framework\Validator\UniversalFactory $universalFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory @@ -103,7 +103,7 @@ public function __construct( \Magento\Catalog\Model\ResourceModel\Helper $resourceHelper, \Magento\Framework\Validator\UniversalFactory $universalFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Catalog\Model\Indexer\Product\Flat\State $catalogProductFlatState, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Catalog\Model\Product\OptionFactory $productOptionFactory, diff --git a/app/code/Magento/Review/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ReviewTest.php b/app/code/Magento/Review/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ReviewTest.php index e1e5503ad475..1000821dd189 100644 --- a/app/code/Magento/Review/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ReviewTest.php +++ b/app/code/Magento/Review/Test/Unit/Ui/DataProvider/Product/Form/Modifier/ReviewTest.php @@ -8,7 +8,7 @@ use Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier\AbstractModifierTest; use Magento\Framework\UrlInterface; use Magento\Review\Ui\DataProvider\Product\Form\Modifier\Review; -use \Magento\Framework\Module\Manager as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Ui\DataProvider\Modifier\ModifierInterface; /** diff --git a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php index 433be1c86098..5f1401a201e3 100644 --- a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php +++ b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php @@ -12,7 +12,7 @@ use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier; use Magento\Ui\Component\Form; use Magento\Framework\UrlInterface; -use \Magento\Framework\Module\ModuleManagerInterface as ModuleManager; +use Magento\Framework\Module\Manager as ModuleManager; use Magento\Framework\App\ObjectManager; /** diff --git a/app/code/Magento/Review/view/frontend/web/js/process-reviews.js b/app/code/Magento/Review/view/frontend/web/js/process-reviews.js index 9d1083d662d5..999161d45b58 100644 --- a/app/code/Magento/Review/view/frontend/web/js/process-reviews.js +++ b/app/code/Magento/Review/view/frontend/web/js/process-reviews.js @@ -54,7 +54,7 @@ define([ event.preventDefault(); anchor = $(this).attr('href').replace(/^.*?(#|$)/, ''); - addReviewBlock = $('.block.review-add .block-content #' + anchor); + addReviewBlock = $('#' + anchor); if (addReviewBlock.length) { $('.product.data.items [data-role="content"]').each(function (index) { //eslint-disable-line diff --git a/app/code/Magento/Rss/Controller/Feed.php b/app/code/Magento/Rss/Controller/Feed.php index 8fbe7addb560..4c5acf97bde8 100644 --- a/app/code/Magento/Rss/Controller/Feed.php +++ b/app/code/Magento/Rss/Controller/Feed.php @@ -76,6 +76,8 @@ public function __construct( } /** + * Authenticate not logged in customer. + * * @return bool */ protected function auth() @@ -85,7 +87,6 @@ protected function auth() try { $customer = $this->customerAccountManagement->authenticate($login, $password); $this->customerSession->setCustomerDataAsLoggedIn($customer); - $this->customerSession->regenerateId(); } catch (\Exception $e) { $this->logger->critical($e); } diff --git a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php index 6729fe722de5..d58af06da94c 100644 --- a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php +++ b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Rule\Model\Condition; @@ -17,6 +18,7 @@ * @method setFormName() * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) + * phpcs:disable Magento2.Classes.AbstractApi * @api * @since 100.0.2 */ @@ -390,7 +392,7 @@ public function getValueParsed() $value = reset($value); } if (!is_array($value) && $this->isArrayOperatorType() && $value) { - $value = preg_split('#\s*[,;]\s*#', $value, null, PREG_SPLIT_NO_EMPTY); + $value = preg_split('#\s*[,;]\s*#', (string) $value, -1, PREG_SPLIT_NO_EMPTY); } $this->setValueParsed($value); } @@ -419,8 +421,11 @@ public function getValue() { if ($this->getInputType() == 'date' && !$this->getIsValueParsed()) { // date format intentionally hard-coded + $date = $this->getData('value'); + $date = (\is_numeric($date) ? '@' : '') . $date; $this->setValue( - (new \DateTime($this->getData('value')))->format('Y-m-d H:i:s') + (new \DateTime($date, new \DateTimeZone((string) $this->_localeDate->getConfigTimezone()))) + ->format('Y-m-d H:i:s') ); $this->setIsValueParsed(true); } @@ -432,6 +437,7 @@ public function getValue() * * @return array|string * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * phpcs:disable Generic.Metrics.NestingLevel */ public function getValueName() { @@ -469,6 +475,7 @@ public function getValueName() } return $value; } + //phpcs:enable Generic.Metrics.NestingLevel /** * Get inherited conditions selectors @@ -674,6 +681,9 @@ public function getValueElement() $elementParams['placeholder'] = \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT; $elementParams['autocomplete'] = 'off'; $elementParams['readonly'] = 'true'; + $elementParams['value_name'] = + (new \DateTime($elementParams['value'], new \DateTimeZone($this->_localeDate->getConfigTimezone()))) + ->format('Y-m-d'); } return $this->getForm()->addField( $this->getPrefix() . '__' . $this->getId() . '__value', @@ -879,7 +889,7 @@ protected function _compareValues($validatedValue, $value, $strict = true) return $validatedValue == $value; } - $validatePattern = preg_quote($validatedValue, '~'); + $validatePattern = preg_quote((string) $validatedValue, '~'); if ($strict) { $validatePattern = '^' . $validatePattern . '$'; } diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php index 33e1bf97c347..f44b78835410 100644 --- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php +++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php @@ -152,9 +152,11 @@ protected function _getMappedSqlCondition( ): string { $argument = $condition->getMappedSqlField(); - // If rule hasn't valid argument - create negative expression to prevent incorrect rule behavior. + // If rule hasn't valid argument - prevent incorrect rule behavior. if (empty($argument)) { return $this->_expressionFactory->create(['expression' => '1 = -1']); + } elseif (preg_match('/[^a-z0-9\-_\.\`]/i', $argument) > 0) { + throw new \Magento\Framework\Exception\LocalizedException(__('Invalid field')); } $conditionOperator = $condition->getOperatorForValidate(); @@ -195,7 +197,6 @@ protected function _getMappedSqlCondition( ); } } - return $this->_expressionFactory->create( ['expression' => $expression] ); @@ -241,6 +242,7 @@ protected function _getMappedSqlCombination( * @param AbstractCollection $collection * @param Combine $combine * @return void + * @throws \Magento\Framework\Exception\LocalizedException */ public function attachConditionToCollection( AbstractCollection $collection, @@ -250,29 +252,45 @@ public function attachConditionToCollection( $this->_joinTablesToCollection($collection, $combine); $whereExpression = (string)$this->_getMappedSqlCombination($combine); if (!empty($whereExpression)) { - if (!empty($combine->getConditions())) { - $conditions = ''; - $attributeField = ''; - foreach ($combine->getConditions() as $condition) { - if ($condition->getData('attribute') === \Magento\Catalog\Api\Data\ProductInterface::SKU) { - $conditions = $condition->getData('value'); - $attributeField = $condition->getMappedSqlField(); - } - } + $collection->getSelect()->where($whereExpression); + $this->buildConditions($collection, $combine); + } + } - $collection->getSelect()->where($whereExpression); + /** + * Build sql conditions from combination. + * + * @param AbstractCollection $collection + * @param Combine $combine + * @return void + */ + private function buildConditions(AbstractCollection $collection, Combine $combine) : void + { + if (!empty($combine->getConditions())) { + $conditions = ''; + $attributeField = ''; + foreach ($combine->getConditions() as $condition) { + if ($condition->getData('attribute') === \Magento\Catalog\Api\Data\ProductInterface::SKU) { + $conditions = $condition->getData('value'); + $attributeField = $condition->getMappedSqlField(); + } + } - if (!empty($conditions) && !empty($attributeField)) { - $conditions = explode(',', $conditions); - foreach ($conditions as &$condition) { - $condition = "'" . trim($condition) . "'"; - } - $conditions = implode(', ', $conditions); - $collection->getSelect()->order("FIELD($attributeField, $conditions)"); + if (!empty($conditions) && !empty($attributeField)) { + $conditions = explode(',', $conditions); + foreach ($conditions as &$condition) { + $condition = trim($condition); } - } else { - // Select ::where method adds braces even on empty expression - $collection->getSelect()->where($whereExpression); + $conditions = implode(', ', $conditions); + $collection->getSelect()->order( + $this->_connection->quoteInto( + "FIELD(?, ?)", + [ + $attributeField, + $conditions + ] + ) + ); } } } diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php index 52653197e398..0ba41af04a1b 100644 --- a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php +++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php @@ -55,14 +55,14 @@ public function validateAttributeDataProvider() ['0', '==', 1, false], ['1', '==', 1, true], ['x', '==', 'x', true], - ['x', '==', 0, false], + ['x', '==', '0', false], [1, '!=', 1, false], [0, '!=', 1, true], ['0', '!=', 1, true], ['1', '!=', 1, false], ['x', '!=', 'x', false], - ['x', '!=', 0, true], + ['x', '!=', '0', true], [1, '==', [1], true], [1, '!=', [1], false], @@ -164,15 +164,15 @@ public function validateAttributeArrayInputTypeDataProvider() [[1, 2, 3], '{}', '1', true, 'grid'], [[1, 2, 3], '{}', '8', false, 'grid'], - [[1, 2, 3], '{}', 5, false, 'grid'], + [[1, 2, 3], '{}', '5', false, 'grid'], [[1, 2, 3], '{}', [2, 3, 4], true, 'grid'], [[1, 2, 3], '{}', [4], false, 'grid'], [[3], '{}', [], false, 'grid'], [1, '{}', 1, false, 'grid'], [1, '!{}', [1, 2, 3], false, 'grid'], [[1], '{}', null, false, 'grid'], - [null, '{}', null, true, 'input'], - [null, '!{}', null, false, 'input'], + ['null', '{}', 'null', true, 'input'], + ['null', '!{}', 'null', false, 'input'], [null, '{}', [1], false, 'input'], [[1, 2, 3], '()', 1, true, 'select'], diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php index 12e59e63f6f7..1efa149b390e 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Address/Form.php @@ -136,4 +136,12 @@ public function getFormValues() { return $this->_getAddress()->getData(); } + + /** + * @inheritDoc + */ + protected function getAddressStoreId() + { + return $this->_getAddress()->getOrder()->getStoreId(); + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php index e4b9dd4c63b9..3fe943c1b194 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Form/Address.php @@ -271,21 +271,24 @@ protected function _prepareForm() $this->_form->setValues($this->getFormValues()); - if ($this->_form->getElement('country_id')->getValue()) { - $countryId = $this->_form->getElement('country_id')->getValue(); - $this->_form->getElement('country_id')->setValue(null); - foreach ($this->_form->getElement('country_id')->getValues() as $country) { + $countryElement = $this->_form->getElement('country_id'); + + $this->processCountryOptions($countryElement); + + if ($countryElement->getValue()) { + $countryId = $countryElement->getValue(); + $countryElement->setValue(null); + foreach ($countryElement->getValues() as $country) { if ($country['value'] == $countryId) { - $this->_form->getElement('country_id')->setValue($countryId); + $countryElement->setValue($countryId); } } } - if ($this->_form->getElement('country_id')->getValue() === null) { - $this->_form->getElement('country_id')->setValue( + if ($countryElement->getValue() === null) { + $countryElement->setValue( $this->directoryHelper->getDefaultCountry($this->getStore()) ); } - $this->processCountryOptions($this->_form->getElement('country_id')); // Set custom renderer for VAT field if needed $vatIdElement = $this->_form->getElement('vat_id'); if ($vatIdElement && $this->getDisplayVatValidationButton() !== false) { @@ -309,7 +312,7 @@ protected function _prepareForm() */ private function processCountryOptions(\Magento\Framework\Data\Form\Element\AbstractElement $countryElement) { - $storeId = $this->getBackendQuoteSession()->getStoreId(); + $storeId = $this->getAddressStoreId(); $options = $this->getCountriesCollection() ->loadByStore($storeId) ->toOptionArray(); @@ -388,4 +391,14 @@ public function getAddressAsString(\Magento\Customer\Api\Data\AddressInterface $ return $this->escapeHtml($result); } + + /** + * Return address store id. + * + * @return int + */ + protected function getAddressStoreId() + { + return $this->getBackendQuoteSession()->getStoreId(); + } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php index 9a271f741edd..001c581dc0da 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Search/Grid.php @@ -5,8 +5,7 @@ */ namespace Magento\Sales\Block\Adminhtml\Order\Create\Search; -use Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\DataProvider\ProductCollection - as ProductCollectionDataProvider; +use Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\DataProvider\ProductCollection; use Magento\Framework\App\ObjectManager; /** @@ -48,7 +47,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended protected $_productFactory; /** - * @var ProductCollectionDataProvider $productCollectionProvider + * @var ProductCollection $productCollectionProvider */ private $productCollectionProvider; @@ -60,7 +59,7 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended * @param \Magento\Backend\Model\Session\Quote $sessionQuote * @param \Magento\Sales\Model\Config $salesConfig * @param array $data - * @param ProductCollectionDataProvider|null $productCollectionProvider + * @param ProductCollection|null $productCollectionProvider */ public function __construct( \Magento\Backend\Block\Template\Context $context, @@ -70,14 +69,14 @@ public function __construct( \Magento\Backend\Model\Session\Quote $sessionQuote, \Magento\Sales\Model\Config $salesConfig, array $data = [], - ProductCollectionDataProvider $productCollectionProvider = null + ProductCollection $productCollectionProvider = null ) { $this->_productFactory = $productFactory; $this->_catalogConfig = $catalogConfig; $this->_sessionQuote = $sessionQuote; $this->_salesConfig = $salesConfig; $this->productCollectionProvider = $productCollectionProvider - ?: ObjectManager::getInstance()->get(ProductCollectionDataProvider::class); + ?: ObjectManager::getInstance()->get(ProductCollection::class); parent::__construct($context, $backendHelper, $data); } @@ -94,6 +93,7 @@ protected function _construct() $this->setCheckboxCheckCallback('order.productGridCheckboxCheck.bind(order)'); $this->setRowInitCallback('order.productGridRowInit.bind(order)'); $this->setDefaultSort('entity_id'); + $this->setFilterKeyPressCallback('order.productGridFilterKeyPress'); $this->setUseAjax(true); if ($this->getRequest()->getParam('collapse')) { $this->setIsCollapsed(true); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php index 1210391f70dd..50d29c195968 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Adjustments.php @@ -111,20 +111,4 @@ public function getShippingLabel() } return $label; } - - /** - * Get update totals url. - * - * @return string - */ - public function getUpdateTotalsUrl(): string - { - return $this->getUrl( - 'sales/*/updateQty', - [ - 'order_id' => $this->getSource()->getOrderId(), - 'invoice_id' => $this->getRequest()->getParam('invoice_id', null), - ] - ); - } } diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php index 389c29bedf4c..65163f9ed5d8 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Creditmemo/Create/Items.php @@ -56,12 +56,7 @@ protected function _prepareLayout() $this->addChild( 'update_button', \Magento\Backend\Block\Widget\Button::class, - ['label' => __('Update Qty\'s'), 'class' => 'update-button secondary', 'onclick' => $onclick] - ); - $this->addChild( - 'update_totals_button', - \Magento\Backend\Block\Widget\Button::class, - ['label' => __('Update Totals'), 'class' => 'update-totals-button secondary', 'onclick' => $onclick] + ['label' => __('Update Qty\'s'), 'class' => 'update-button', 'onclick' => $onclick] ); if ($this->getCreditmemo()->canRefund()) { @@ -181,16 +176,6 @@ public function getUpdateButtonHtml() return $this->getChildHtml('update_button'); } - /** - * Get update totals button html - * - * @return string - */ - public function getUpdateTotalsButtonHtml(): string - { - return $this->getChildHtml('update_totals_button'); - } - /** * Get update url * diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php index 341ee16ae910..45cd504be201 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create.php @@ -188,7 +188,7 @@ protected function _processActionData($action = null) && $this->_getOrderCreateModel()->getShippingAddress()->getSameAsBilling() && empty($shippingMethod) ) { $this->_getOrderCreateModel()->setShippingAsBilling(1); - } else { + } elseif ($syncFlag !== null) { $this->_getOrderCreateModel()->setShippingAsBilling((int)$syncFlag); } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php index 67a0dc469163..b4fa6fed6cdf 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php @@ -89,13 +89,18 @@ public function __construct( protected function _prepareShipment($invoice) { $invoiceData = $this->getRequest()->getParam('invoice'); - + $itemArr = []; + if (!isset($invoiceData['items']) || empty($invoiceData['items'])) { + $orderItems = $invoice->getOrder()->getItems(); + foreach ($orderItems as $item) { + $itemArr[$item->getId()] = (int)$item->getQtyOrdered(); + } + } $shipment = $this->shipmentFactory->create( $invoice->getOrder(), - isset($invoiceData['items']) ? $invoiceData['items'] : [], + isset($invoiceData['items']) ? $invoiceData['items'] : $itemArr, $this->getRequest()->getPost('tracking') ); - if (!$shipment->getTotalQty()) { return false; } diff --git a/app/code/Magento/Sales/Cron/CleanExpiredQuotes.php b/app/code/Magento/Sales/Cron/CleanExpiredQuotes.php index a5c7f71df66c..a3242228b28e 100644 --- a/app/code/Magento/Sales/Cron/CleanExpiredQuotes.php +++ b/app/code/Magento/Sales/Cron/CleanExpiredQuotes.php @@ -5,40 +5,35 @@ */ namespace Magento\Sales\Cron; -use Magento\Store\Model\StoresConfig; +use Magento\Quote\Model\ResourceModel\Quote\Collection; +use Magento\Sales\Model\ResourceModel\Collection\ExpiredQuotesCollection; +use Magento\Store\Model\StoreManagerInterface; /** * Class CleanExpiredQuotes */ class CleanExpiredQuotes { - const LIFETIME = 86400; - - /** - * @var StoresConfig - */ - protected $storesConfig; - /** - * @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory + * @var ExpiredQuotesCollection */ - protected $quoteCollectionFactory; + private $expiredQuotesCollection; /** - * @var array + * @var StoreManagerInterface */ - protected $expireQuotesFilterFields = []; + private $storeManager; /** - * @param StoresConfig $storesConfig - * @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $collectionFactory + * @param StoreManagerInterface $storeManager + * @param ExpiredQuotesCollection $expiredQuotesCollection */ public function __construct( - StoresConfig $storesConfig, - \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory $collectionFactory + StoreManagerInterface $storeManager, + ExpiredQuotesCollection $expiredQuotesCollection ) { - $this->storesConfig = $storesConfig; - $this->quoteCollectionFactory = $collectionFactory; + $this->storeManager = $storeManager; + $this->expiredQuotesCollection = $expiredQuotesCollection; } /** @@ -48,42 +43,11 @@ public function __construct( */ public function execute() { - $lifetimes = $this->storesConfig->getStoresConfigByPath('checkout/cart/delete_quote_after'); - foreach ($lifetimes as $storeId => $lifetime) { - $lifetime *= self::LIFETIME; - - /** @var $quotes \Magento\Quote\Model\ResourceModel\Quote\Collection */ - $quotes = $this->quoteCollectionFactory->create(); - - $quotes->addFieldToFilter('store_id', $storeId); - $quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]); - - foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) { - $quotes->addFieldToFilter($field, $condition); - } - + $stores = $this->storeManager->getStores(true); + foreach ($stores as $store) { + /** @var $quotes Collection */ + $quotes = $this->expiredQuotesCollection->getExpiredQuotes($store); $quotes->walk('delete'); } } - - /** - * Retrieve expire quotes additional fields to filter - * - * @return array - */ - protected function getExpireQuotesAdditionalFilterFields() - { - return $this->expireQuotesFilterFields; - } - - /** - * Set expire quotes additional fields to filter - * - * @param array $fields - * @return void - */ - public function setExpireQuotesAdditionalFilterFields(array $fields) - { - $this->expireQuotesFilterFields = $fields; - } } diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 48deddb2fe5a..89564f97ccf1 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -5,8 +5,11 @@ */ namespace Magento\Sales\Model; +use Magento\Config\Model\Config\Source\Nooptreq; use Magento\Directory\Model\Currency; use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Locale\ResolverInterface; @@ -14,6 +17,7 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\Data\OrderItemInterface; use Magento\Sales\Api\Data\OrderStatusHistoryInterface; +use Magento\Sales\Api\OrderItemRepositoryInterface; use Magento\Sales\Model\Order\Payment; use Magento\Sales\Model\Order\ProductOption; use Magento\Sales\Model\ResourceModel\Order\Address\Collection; @@ -24,8 +28,7 @@ use Magento\Sales\Model\ResourceModel\Order\Shipment\Collection as ShipmentCollection; use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection as TrackCollection; use Magento\Sales\Model\ResourceModel\Order\Status\History\Collection as HistoryCollection; -use Magento\Sales\Api\OrderItemRepositoryInterface; -use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Store\Model\ScopeInterface; /** * Order model @@ -299,6 +302,11 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface */ private $searchCriteriaBuilder; + /** + * @var ScopeConfigInterface; + */ + private $scopeConfig; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -331,6 +339,7 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface * @param ProductOption|null $productOption * @param OrderItemRepositoryInterface $itemRepository * @param SearchCriteriaBuilder $searchCriteriaBuilder + * @param ScopeConfigInterface $scopeConfig * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -364,7 +373,8 @@ public function __construct( ResolverInterface $localeResolver = null, ProductOption $productOption = null, OrderItemRepositoryInterface $itemRepository = null, - SearchCriteriaBuilder $searchCriteriaBuilder = null + SearchCriteriaBuilder $searchCriteriaBuilder = null, + ScopeConfigInterface $scopeConfig = null ) { $this->_storeManager = $storeManager; $this->_orderConfig = $orderConfig; @@ -392,6 +402,7 @@ public function __construct( ->get(OrderItemRepositoryInterface::class); $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance() ->get(SearchCriteriaBuilder::class); + $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class); parent::__construct( $context, @@ -1111,7 +1122,7 @@ public function addStatusHistoryComment($comment, $status = false) { return $this->addCommentToStatusHistory($comment, $status, false); } - + /** * Add a comment to order status history. * @@ -1503,7 +1514,7 @@ public function getItemById($itemId) * Get item by quote item id * * @param mixed $quoteItemId - * @return \Magento\Framework\DataObject|null + * @return \Magento\Framework\DataObject|null */ public function getItemByQuoteItemId($quoteItemId) { @@ -1967,11 +1978,23 @@ public function getRelatedObjects() */ public function getCustomerName() { - if ($this->getCustomerFirstname()) { - $customerName = $this->getCustomerFirstname() . ' ' . $this->getCustomerLastname(); - } else { - $customerName = (string)__('Guest'); + if (null === $this->getCustomerFirstname()) { + return (string)__('Guest'); } + + $customerName = ''; + if ($this->isVisibleCustomerPrefix() && strlen($this->getCustomerPrefix())) { + $customerName .= $this->getCustomerPrefix() . ' '; + } + $customerName .= $this->getCustomerFirstname(); + if ($this->isVisibleCustomerMiddlename() && strlen($this->getCustomerMiddlename())) { + $customerName .= ' ' . $this->getCustomerMiddlename(); + } + $customerName .= ' ' . $this->getCustomerLastname(); + if ($this->isVisibleCustomerSuffix() && strlen($this->getCustomerSuffix())) { + $customerName .= ' ' . $this->getCustomerSuffix(); + } + return $customerName; } @@ -4534,5 +4557,48 @@ public function setShippingMethod($shippingMethod) return $this->setData('shipping_method', $shippingMethod); } + /** + * Is visible customer middlename + * + * @return bool + */ + private function isVisibleCustomerMiddlename(): bool + { + return $this->scopeConfig->isSetFlag( + 'customer/address/middlename_show', + ScopeInterface::SCOPE_STORE + ); + } + + /** + * Is visible customer prefix + * + * @return bool + */ + private function isVisibleCustomerPrefix(): bool + { + $prefixShowValue = $this->scopeConfig->getValue( + 'customer/address/prefix_show', + ScopeInterface::SCOPE_STORE + ); + + return $prefixShowValue !== Nooptreq::VALUE_NO; + } + + /** + * Is visible customer suffix + * + * @return bool + */ + private function isVisibleCustomerSuffix(): bool + { + $prefixShowValue = $this->scopeConfig->getValue( + 'customer/address/suffix_show', + ScopeInterface::SCOPE_STORE + ); + + return $prefixShowValue !== Nooptreq::VALUE_NO; + } + //@codeCoverageIgnoreEnd } diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php index dc920ab62e0b..f9efb9f56f50 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoCommentIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\CreditmemoCommentIdentity + */ class CreditmemoCommentIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo_comment/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo_comment/copy_to'; const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo_comment/identity'; @@ -15,6 +23,8 @@ class CreditmemoCommentIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo_comment/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return email copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php index f60ef03800cf..4c1fcfb501e3 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/CreditmemoIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\CreditmemoIdentity + */ class CreditmemoIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/creditmemo/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/creditmemo/copy_to'; const XML_PATH_EMAIL_IDENTITY = 'sales_email/creditmemo/identity'; @@ -15,6 +23,8 @@ class CreditmemoIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/creditmemo/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return email copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php index 81584a61b745..fd0a384a4bc6 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceCommentIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\InvoiceCommentIdentity + */ class InvoiceCommentIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice_comment/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice_comment/copy_to'; const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/invoice_comment/guest_template'; @@ -15,6 +23,8 @@ class InvoiceCommentIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice_comment/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return email copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php index db063b87271f..6bb4eb0f0fd7 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/InvoiceIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\InvoiceIdentity + */ class InvoiceIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/invoice/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/invoice/copy_to'; const XML_PATH_EMAIL_IDENTITY = 'sales_email/invoice/identity'; @@ -15,6 +23,8 @@ class InvoiceIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/invoice/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return email copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php index 3a79402913cc..f43cd71ddd39 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderCommentIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\OrderCommentIdentity + */ class OrderCommentIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/order_comment/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/order_comment/copy_to'; const XML_PATH_EMAIL_GUEST_TEMPLATE = 'sales_email/order_comment/guest_template'; @@ -15,6 +23,8 @@ class OrderCommentIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/order_comment/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return email copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php index 68d269b4b4fc..168869c67fb2 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/OrderIdentity.php @@ -3,8 +3,13 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\OrderIdentity + */ class OrderIdentity extends Container implements IdentityInterface { /** @@ -18,6 +23,8 @@ class OrderIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/order/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -38,7 +45,7 @@ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php index 0c2f1d592dd1..db408ceecb4c 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentCommentIdentity.php @@ -3,10 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\ShipmentCommentIdentity + */ class ShipmentCommentIdentity extends Container implements IdentityInterface { + /** + * Configuration paths + */ const XML_PATH_EMAIL_COPY_METHOD = 'sales_email/shipment_comment/copy_method'; const XML_PATH_EMAIL_COPY_TO = 'sales_email/shipment_comment/copy_to'; const XML_PATH_EMAIL_IDENTITY = 'sales_email/shipment_comment/identity'; @@ -15,6 +23,8 @@ class ShipmentCommentIdentity extends Container implements IdentityInterface const XML_PATH_EMAIL_ENABLED = 'sales_email/shipment_comment/enabled'; /** + * Is email enabled + * * @return bool */ public function isEnabled() @@ -27,18 +37,22 @@ public function isEnabled() } /** + * Return email copy_to list + * * @return array|bool */ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } /** + * Return copy method + * * @return mixed */ public function getCopyMethod() @@ -47,6 +61,8 @@ public function getCopyMethod() } /** + * Return guest template id + * * @return mixed */ public function getGuestTemplateId() @@ -55,6 +71,8 @@ public function getGuestTemplateId() } /** + * Return template id + * * @return mixed */ public function getTemplateId() @@ -63,6 +81,8 @@ public function getTemplateId() } /** + * Return email identity + * * @return mixed */ public function getEmailIdentity() diff --git a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php index ddf682d92fc8..d2f4c03f95b1 100644 --- a/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php +++ b/app/code/Magento/Sales/Model/Order/Email/Container/ShipmentIdentity.php @@ -3,9 +3,13 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Sales\Model\Order\Email\Container; +/** + * Class \Magento\Sales\Model\Order\Email\Container\ShipmentIdentity + */ class ShipmentIdentity extends Container implements IdentityInterface { /** @@ -41,7 +45,7 @@ public function getEmailCopyTo() { $data = $this->getConfigValue(self::XML_PATH_EMAIL_COPY_TO, $this->getStore()->getStoreId()); if (!empty($data)) { - return explode(',', $data); + return array_map('trim', explode(',', $data)); } return false; } diff --git a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php index c4523981ac72..ae188309ea64 100644 --- a/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php +++ b/app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php @@ -85,8 +85,8 @@ public function sendCopyTo() $copyTo = $this->identityContainer->getEmailCopyTo(); if (!empty($copyTo)) { - $this->configureEmailTemplate(); foreach ($copyTo as $email) { + $this->configureEmailTemplate(); $this->transportBuilder->addTo($email); $transport = $this->transportBuilder->getTransport(); $transport->sendMessage(); diff --git a/app/code/Magento/Sales/Model/ResourceModel/Collection/ExpiredQuotesCollection.php b/app/code/Magento/Sales/Model/ResourceModel/Collection/ExpiredQuotesCollection.php new file mode 100644 index 000000000000..895d73cc4cff --- /dev/null +++ b/app/code/Magento/Sales/Model/ResourceModel/Collection/ExpiredQuotesCollection.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Model\ResourceModel\Collection; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; +use Magento\Quote\Model\ResourceModel\Quote\Collection; +use Magento\Quote\Model\ResourceModel\Quote\CollectionFactory; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\ScopeInterface; + +/** + * Class ExpiredQuotesCollection + */ +class ExpiredQuotesCollection +{ + /** + * @var int + */ + private $secondsInDay = 86400; + + /** + * @var string + */ + private $quoteLifetime = 'checkout/cart/delete_quote_after'; + + /** + * @var CollectionFactory + */ + private $quoteCollectionFactory; + + /** + * @var ScopeConfigInterface + */ + private $config; + + /** + * @param ScopeConfigInterface $config + * @param CollectionFactory $collectionFactory + */ + public function __construct( + ScopeConfigInterface $config, + CollectionFactory $collectionFactory + ) { + $this->config = $config; + $this->quoteCollectionFactory = $collectionFactory; + } + + /** + * Gets expired quotes + * + * Quote is considered expired if the latest update date + * of the quote is greater than lifetime threshold + * + * @param StoreInterface $store + * @return AbstractCollection + */ + public function getExpiredQuotes(StoreInterface $store): AbstractCollection + { + $lifetime = $this->config->getValue( + $this->quoteLifetime, + ScopeInterface::SCOPE_STORE, + $store->getCode() + ); + $lifetime *= $this->secondsInDay; + + /** @var $quotes Collection */ + $quotes = $this->quoteCollectionFactory->create(); + $quotes->addFieldToFilter('store_id', $store->getId()); + $quotes->addFieldToFilter('updated_at', ['to' => date("Y-m-d", time() - $lifetime)]); + + return $quotes; + } +} diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenAndFillCreditMemoRefundActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenAndFillCreditMemoRefundActionGroup.xml index 60134ee7e039..78717e9c2f96 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenAndFillCreditMemoRefundActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenAndFillCreditMemoRefundActionGroup.xml @@ -35,7 +35,6 @@ <fillField userInput="{{adjustmentRefund}}" selector="{{AdminCreditMemoTotalSection.adjustmentRefund}}" stepKey="fillAdjustmentRefund"/> <fillField userInput="{{adjustmentFee}}" selector="{{AdminCreditMemoTotalSection.adjustmentFee}}" stepKey="fillAdjustmentFee"/> <checkOption selector="{{AdminCreditMemoTotalSection.emailCopy}}" stepKey="checkSendEmailCopy"/> - <conditionalClick selector="{{AdminCreditMemoTotalSection.updateTotals}}" dependentSelector="{{AdminCreditMemoTotalSection.disabledUpdateTotals}}" visible="false" stepKey="clickUpdateTotalsButton"/> </actionGroup> <!-- Open and fill CreditMemo refund with back to stock --> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml index 3f178ae02102..90e2aa8e1252 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml @@ -92,7 +92,7 @@ <annotations> <description>Clears the Email, First Name, Last Name, Street Line 1, City, Postal Code and Phone fields when adding an Order and then verifies that they are required after attempting to Save.</description> </annotations> - + <seeElement selector="{{AdminOrderFormAccountSection.requiredGroup}}" stepKey="seeCustomerGroupRequired"/> <seeElement selector="{{AdminOrderFormAccountSection.requiredEmail}}" stepKey="seeEmailRequired"/> <clearField selector="{{AdminOrderFormAccountSection.email}}" stepKey="clearEmailField"/> @@ -181,7 +181,7 @@ <annotations> <description>EXTENDS: addConfigurableProductToOrder. Selects the provided Option to the Configurable Product.</description> </annotations> - + <waitForElementVisible selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" stepKey="waitForConfigurablePopover"/> <selectOption selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" userInput="{{option.label}}" stepKey="selectionConfigurableOption"/> </actionGroup> @@ -195,7 +195,7 @@ <argument name="option"/> <argument name="quantity" type="string"/> </arguments> - + <click selector="{{AdminOrderFormItemsSection.configure}}" stepKey="clickConfigure"/> <waitForElementVisible selector="{{AdminOrderFormConfigureProductSection.optionSelect(attribute.default_frontend_label)}}" stepKey="waitForConfigurablePopover"/> <wait time="2" stepKey="waitForOptionsToLoad"/> @@ -213,7 +213,7 @@ <argument name="product"/> <argument name="quantity" type="string" defaultValue="1"/> </arguments> - + <click selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="clickAddProducts"/> <fillField selector="{{AdminOrderFormItemsSection.skuFilter}}" userInput="{{product.sku}}" stepKey="fillSkuFilterBundle"/> <click selector="{{AdminOrderFormItemsSection.search}}" stepKey="clickSearchBundle"/> @@ -235,7 +235,7 @@ <arguments> <argument name="price" type="string"/> </arguments> - + <grabTextFrom selector="{{AdminOrderFormItemsSection.rowPrice('1')}}" stepKey="grabProductPriceFromGrid" after="clickOk"/> <assertEquals stepKey="assertProductPriceInGrid" message="Bundle product price in grid should be equal {{price}}" after="grabProductPriceFromGrid"> <expectedResult type="string">{{price}}</expectedResult> @@ -320,6 +320,22 @@ <selectOption selector="{{AdminOrderFormPaymentSection.flatRateOption}}" userInput="flatrate_flatrate" stepKey="checkFlatRate"/> </actionGroup> + <actionGroup name="changeShippingMethod"> + <annotations> + <description>Change Shipping Method on the Admin 'Create New Order for' page.</description> + </annotations> + <arguments> + <argument name="shippingMethod" defaultValue="flatrate_flatrate" type="string"/> + </arguments> + <click selector="{{AdminOrderFormPaymentSection.header}}" stepKey="unfocus"/> + <waitForPageLoad stepKey="waitForJavascriptToFinish"/> + <click selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="clickShippingMethods1"/> + <waitForElementVisible selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="waitForChangeShippingMethod"/> + <click selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="clickShippingMethods2"/> + <waitForElementVisible selector="{{AdminOrderFormPaymentSection.shippingMethod}}" stepKey="waitForShippingOptions2"/> + <selectOption selector="{{AdminOrderFormPaymentSection.shippingMethod}}" userInput="{{shippingMethod}}" stepKey="checkFlatRate"/> + </actionGroup> + <!--Select free shipping method--> <actionGroup name="orderSelectFreeShipping"> <annotations> @@ -516,7 +532,7 @@ <argument name="product"/> <argument name="customer"/> </arguments> - + <amOnPage stepKey="navigateToNewOrderPage" url="{{AdminOrderCreatePage.url}}"/> <waitForPageLoad stepKey="waitForNewOrderPageOpened"/> <click stepKey="chooseCustomer" selector="{{AdminOrdersGridSection.customerInOrdersSection(customer.firstname)}}"/> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderSelectShippingMethodActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderSelectShippingMethodActionGroup.xml new file mode 100644 index 000000000000..b8493bf28837 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderSelectShippingMethodActionGroup.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminOrderSelectShippingMethodActionGroup"> + <annotations> + <description>Select Shipping method from admin order page.</description> + </annotations> + <arguments> + <argument name="methodTitle" type="string" defaultValue="flatrate"/> + <argument name="methodName" type="string" defaultValue="fixed"/> + </arguments> + <waitForElementVisible selector="{{AdminInvoicePaymentShippingSection.getShippingMethod}}" stepKey="waitForShippingMethodsOpen"/> + <click selector="{{AdminInvoicePaymentShippingSection.getShippingMethod}}" stepKey="openShippingMethod"/> + <conditionalClick selector="{{AdminInvoicePaymentShippingSection.getShippingMethod}}" dependentSelector="{{AdminInvoicePaymentShippingSection.fixedPriceShippingMethod(methodTitle, methodName)}}" visible="false" stepKey="openShippingMethodSecondTime"/> + <waitForElementVisible selector="{{AdminInvoicePaymentShippingSection.fixedPriceShippingMethod(methodName, methodTitle)}}" stepKey="waitForShippingMethod"/> + <click selector="{{AdminInvoicePaymentShippingSection.fixedPriceShippingMethod(methodName, methodTitle)}}" stepKey="chooseShippingMethod"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/CreateOrderToPrintPageActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/CreateOrderToPrintPageActionGroup.xml index aaeb9ffb30bd..7388eaa96f21 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/CreateOrderToPrintPageActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/CreateOrderToPrintPageActionGroup.xml @@ -15,7 +15,7 @@ <arguments> <argument name="Category"/> </arguments> - + <amOnPage url="{{StorefrontCategoryPage.url(Category.name)}}" stepKey="onCategoryPage"/> <waitForPageLoad stepKey="waitForPageLoad1"/> <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoicePaymentShippingSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoicePaymentShippingSection.xml index fda886a83980..32e987bea919 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoicePaymentShippingSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoicePaymentShippingSection.xml @@ -17,5 +17,7 @@ <element name="CreateShipment" type="checkbox" selector=".order-shipping-address input[name='invoice[do_shipment]']"/> <element name="getShippingMethodAndRates" type="button" selector="//span[text()='Get shipping methods and rates']" timeout="60"/> <element name="shippingMethod" type="button" selector="//label[contains(text(), 'Fixed')]" timeout="60"/> + <element name="fixedPriceShippingMethod" type="button" selector="#s_method_{{methodName}}_{{methodTitle}}" parameterized="true"/> + <element name="getShippingMethod" type="button" selector="#order-shipping-method-summary a"/> </section> -</sections> \ No newline at end of file +</sections> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsInformationSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsInformationSection.xml index 71a96dc10938..653b1d48686e 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsInformationSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsInformationSection.xml @@ -13,6 +13,8 @@ <element name="orderStatus" type="text" selector=".order-information table.order-information-table #order_status"/> <element name="purchasedFrom" type="text" selector=".order-information table.order-information-table tr:last-of-type > td"/> <element name="accountInformation" type="text" selector=".order-account-information-table"/> + <element name="orderInformationTable" type="block" selector=".order-information-table"/> + <element name="rate" type="text" selector="//table[contains(@class, 'order-information-table')]//th[contains(text(), 'rate:')]"/> <element name="customerName" type="text" selector=".order-account-information table tr:first-of-type > td span"/> <element name="customerEmail" type="text" selector=".order-account-information table tr:nth-of-type(2) > td a"/> <element name="customerGroup" type="text" selector=".order-account-information table tr:nth-of-type(3) > td"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormBillingAddressSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormBillingAddressSection.xml index 2d1a4d5a4cba..4fde9db1d21d 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormBillingAddressSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormBillingAddressSection.xml @@ -9,6 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminOrderFormBillingAddressSection"> + <element name="selectAddress" type="select" selector="//select[@id='order-billing_address_customer_address_id']"/> <element name="NamePrefix" type="input" selector="#order-billing_address_prefix" timeout="30"/> <element name="FirstName" type="input" selector="#order-billing_address_firstname" timeout="30"/> <element name="MiddleName" type="input" selector="#order-billing_address_middlename" timeout="30"/> @@ -38,4 +39,4 @@ <element name="postalCodeError" type="text" selector="#order-billing_address_postcode-error"/> <element name="phoneError" type="text" selector="#order-billing_address_telephone-error"/> </section> -</sections> \ No newline at end of file +</sections> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormPaymentSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormPaymentSection.xml index b31582552ccc..a478d79d8553 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormPaymentSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormPaymentSection.xml @@ -9,6 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminOrderFormPaymentSection"> + <element name="shippingMethod" type="radio" selector="//input[@name='order[shipping_method]']"/> <element name="header" type="text" selector="#order-methods span.title"/> <element name="getShippingMethods" type="text" selector="#order-shipping_method a.action-default" timeout="30"/> <element name="flatRateOption" type="radio" selector="#s_method_flatrate_flatrate" timeout="30"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrdersGridSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrdersGridSection.xml index ace64cdaa103..a18ca0c41556 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrdersGridSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrdersGridSection.xml @@ -39,5 +39,6 @@ <element name="changeOrderStatus" type="button" selector="//div[contains(concat(' ',normalize-space(@class),' '),' row-gutter ')]//span[text()='{{status}}']" parameterized="true" timeout="30"/> <element name="viewLink" type="text" selector="//td/div[contains(.,'{{orderID}}')]/../..//a[@class='action-menu-item']" parameterized="true"/> <element name="selectOrderID" type="checkbox" selector="//td/div[text()='{{orderId}}']/../preceding-sibling::td//input" parameterized="true" timeout="60"/> + <element name="orderId" type="text" selector="//table[contains(@class, 'data-grid')]//div[contains(text(), '{{orderId}}')]" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml index 8cd2b8ee60ed..45ea09a06ed2 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml @@ -18,6 +18,9 @@ <testCaseId value="MC-18159"/> <useCaseId value="MC-17003"/> <group value="sales"/> + <skip> + <issueId value="MC-17003"/> + </skip> </annotations> <before> <!--Create product--> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml index 1ad736ade37f..4310d412d1c9 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml @@ -55,6 +55,9 @@ <amOnPage url="{{AdminProductEditPage.url($$createBundleProduct.id$$)}}" stepKey="goToProductEditPage"/> <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!--Go to bundle product page--> <amOnPage url="{{StorefrontProductPage.url($$createCategory.name$$)}}" stepKey="navigateToBundleProductPage"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index 800517236cb3..a90fe5c49f03 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -25,7 +25,7 @@ </createData> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteProduct1"/> <deleteData createDataKey="createProduct" stepKey="deleteCategory1"/> </after> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAddProductCheckboxTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAddProductCheckboxTest.xml new file mode 100644 index 000000000000..bd13f7c847c3 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAddProductCheckboxTest.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateOrderAddProductCheckboxTest"> + <annotations> + <title value="Create Order in Admin and Add Product"/> + <stories value="Create order and add product using checkbox"/> + <description value="Create order in Admin panel, add product by clicking checkbox, and verify it is checked"/> + <features value="Sales"/> + <severity value="AVERAGE"/> + <group value="Sales"/> + </annotations> + + <before> + <!-- Create simple customer --> + <createData entity="Simple_US_Customer_CA" stepKey="createSimpleCustomer"/> + + <!-- Create simple product --> + <createData entity="ApiProductWithDescription" stepKey="createSimpleProduct"/> + + <!-- Login to Admin Panel --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + + <!-- Initiate create new order --> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer"> + <argument name="customer" value="$$createSimpleCustomer$$"/> + </actionGroup> + + <click selector="{{AdminOrderFormItemsSection.addProducts}}" stepKey="clickAddProducts"/> + <fillField selector="{{AdminOrderFormItemsSection.skuFilter}}" userInput="$$createSimpleProduct.sku$$" stepKey="fillSkuFilterBundle"/> + <click selector="{{AdminOrderFormItemsSection.search}}" stepKey="clickSearchBundle"/> + <scrollTo selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" x="0" y="-100" stepKey="scrollToCheckColumn"/> + <checkOption selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" stepKey="selectProduct"/> + <seeCheckboxIsChecked selector="{{AdminOrderFormItemsSection.rowCheck('1')}}" stepKey="verifyProductChecked"/> + + <after> + <actionGroup ref="logout" stepKey="logout"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <deleteData createDataKey="createSimpleCustomer" stepKey="deleteSimpleCustomer"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest.xml new file mode 100644 index 000000000000..d6bf0eec301d --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateOrderForCustomerWithTwoAddressesTaxableAndNonTaxableTest"> + <annotations> + <title value="Tax should not be displayed for non taxable address"/> + <stories value="MC-21699: Tax does not change when changing the billing address from Admin Panel"/> + <description value="Tax should not be displayed for non taxable address when switching from taxable address"/> + <testCaseId value="MC-21721"/> + <features value="Sales"/> + <severity value="MAJOR"/> + <group value="Sales"/> + </annotations> + <before> + <!--Enable flat rate shipping--> + <magentoCLI command="config:set {{EnableFlatRateConfigData.path}} {{EnableFlatRateConfigData.value}}" stepKey="enableFlatRate"/> + <!--Enable free shipping method --> + <magentoCLI command="config:set {{EnableFreeShippingConfigData.path}} {{EnableFreeShippingConfigData.value}}" stepKey="enableFreeShipping"/> + <!--Create customer--> + <createData entity="Customer_With_Different_Default_Billing_Shipping_Addresses" stepKey="simpleCustomer"/> + <!--Create category--> + <createData entity="_defaultCategory" stepKey="category1"/> + <!--Create product1--> + <createData entity="_defaultProduct" stepKey="product1"> + <requiredEntity createDataKey="category1"/> + </createData> + <!--Create tax rule for US-CA--> + <createData entity="defaultTaxRule" stepKey="createTaxRule"/> + <!--Login as admin--> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <!--Step 1: Create new order for customer--> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer"> + <argument name="customer" value="$$simpleCustomer$$"/> + </actionGroup> + <!--Step 2: Add product1 to the order--> + <actionGroup ref="addSimpleProductToOrder" stepKey="addSimpleProductToOrder"> + <argument name="product" value="$$product1$$"/> + </actionGroup> + <!--Step 2: Select taxable address as billing address--> + <selectOption selector="{{AdminOrderFormBillingAddressSection.selectAddress}}" userInput="{{US_Address_CA.state}}" stepKey="selectTaxableAddress" /> + <!--Step 3: Select FlatRate shipping method--> + <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShippingMethod"/> + <!--Step 4: Verify that tax is applied to the order--> + <seeElement selector="{{AdminOrderFormTotalSection.total('Tax')}}" stepKey="seeTax" /> + <!--Step 5: Select non taxable address as billing address--> + <selectOption selector="{{AdminOrderFormBillingAddressSection.selectAddress}}" userInput="{{US_Address_TX.state}}" stepKey="selectNonTaxableAddress" /> + <!--Step 6: Change shipping method to Free--> + <actionGroup ref="changeShippingMethod" stepKey="changeShippingMethod"> + <argument name="shippingMethod" value="freeshipping_freeshipping"/> + </actionGroup> + <!--Step 7: Verify that tax is not applied to the order--> + <dontSeeElement selector="{{AdminOrderFormTotalSection.total('Tax')}}" stepKey="dontSeeTax" /> + <after> + <!--Delete product1--> + <deleteData createDataKey="product1" stepKey="deleteProduct1"/> + <!--Delete category--> + <deleteData createDataKey="category1" stepKey="deleteCategory1"/> + <!--Delete customer--> + <deleteData createDataKey="simpleCustomer" stepKey="deleteSimpleCustomer"/> + <!--Delete tax rule--> + <deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/> + <!--Logout--> + <actionGroup ref="logout" stepKey="logout"/> + <!--Disable free shipping method --> + <magentoCLI command="config:set {{DisableFreeShippingConfigData.path}} {{DisableFreeShippingConfigData.value}}" stepKey="disableFreeShipping"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderPaymentMethodValidationTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderPaymentMethodValidationTest.xml index e487c62b9672..255a7a91f9b1 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderPaymentMethodValidationTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderPaymentMethodValidationTest.xml @@ -29,7 +29,7 @@ <magentoCLI stepKey="allowSpecificValue" command="config:set payment/cashondelivery/active 0" /> <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Create order via Admin--> <comment userInput="Admin creates order" stepKey="adminCreateOrderComment"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutEmailTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutEmailTest.xml index ed536bd3351f..01021ad745f7 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutEmailTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutEmailTest.xml @@ -26,7 +26,7 @@ <after> <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Create order via Admin--> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutFieldsValidationTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutFieldsValidationTest.xml index 1490fc1a1a38..9268e9e72865 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutFieldsValidationTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitsOrderWithAndWithoutFieldsValidationTest.xml @@ -25,7 +25,7 @@ <after> <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!--Create order via Admin--> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 93f4233af90e..ec0f97e418c8 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -33,7 +33,7 @@ <argument name="ruleName" value="{{ApiSalesRule.name}}"/> </actionGroup> <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <deleteData createDataKey="createCategory" stepKey="deleteProduct1"/> <deleteData createDataKey="createProduct" stepKey="deleteCategory1"/> </after> @@ -58,7 +58,7 @@ <click selector="{{AdminCartPriceRulesFormSection.save}}" stepKey="clickSaveButton"/> <see selector="{{AdminCartPriceRulesSection.messages}}" userInput="You saved the rule." stepKey="seeSuccessMessage"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <!-- Place an order from Storefront as a Guest --> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml index 5c0d40510246..0bd8ab4855e9 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontPrintOrderGuestTest.xml @@ -19,6 +19,7 @@ <group value="mtf_migrated"/> </annotations> <before> + <magentoCLI command="downloadable:domains:add" arguments="example.com static.magento.com" stepKey="addDownloadableDomain"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <createData entity="ApiCategory" stepKey="createCategory"/> @@ -207,6 +208,7 @@ <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRate"/> </before> <after> + <magentoCLI command="downloadable:domains:remove" arguments="example.com static.magento.com" stepKey="removeDownloadableDomain"/> <deleteData createDataKey="downloadableProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createConfigChildProduct1" stepKey="deleteConfigChildProduct1"/> @@ -275,4 +277,4 @@ <see userInput="Flat Rate - Fixed" selector="{{StorefrontOrderDetailsSection.shippingMethod}}" stepKey="assertShippingMethodOnPrintOrder"/> <switchToPreviousTab stepKey="switchToPreviousTab"/> </test> -</tests> \ No newline at end of file +</tests> diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php index 94148cc51538..2b08daf02134 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Address/FormTest.php @@ -95,6 +95,11 @@ protected function setUp() '_orderCreate' => $this->orderCreate ] ); + + // Do not display VAT validation button on edit order address form + // Emulate fix done in controller + /** @see \Magento\Sales\Controller\Adminhtml\Order\Address::execute */ + $this->addressBlock->setDisplayVatValidationButton(false); } public function testGetForm() diff --git a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php b/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php deleted file mode 100644 index ad6a3e03ba67..000000000000 --- a/app/code/Magento/Sales/Test/Unit/Cron/CleanExpiredQuotesTest.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Sales\Test\Unit\Cron; - -use \Magento\Sales\Cron\CleanExpiredQuotes; - -/** - * Tests Magento\Sales\Cron\CleanExpiredQuotes - */ -class CleanExpiredQuotesTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Store\Model\StoresConfig|\PHPUnit_Framework_MockObject_MockObject - */ - protected $storesConfigMock; - - /** - * @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $quoteFactoryMock; - - /** - * @var \Magento\Sales\Cron\CleanExpiredQuotes - */ - protected $observer; - - protected function setUp() - { - $this->storesConfigMock = $this->createMock(\Magento\Store\Model\StoresConfig::class); - - $this->quoteFactoryMock = $this->getMockBuilder( - \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory::class - ) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - - $this->observer = new CleanExpiredQuotes($this->storesConfigMock, $this->quoteFactoryMock); - } - - /** - * @param array $lifetimes - * @param array $additionalFilterFields - * @dataProvider cleanExpiredQuotesDataProvider - */ - public function testExecute($lifetimes, $additionalFilterFields) - { - $this->storesConfigMock->expects($this->once()) - ->method('getStoresConfigByPath') - ->with($this->equalTo('checkout/cart/delete_quote_after')) - ->will($this->returnValue($lifetimes)); - - $quotesMock = $this->getMockBuilder(\Magento\Quote\Model\ResourceModel\Quote\Collection::class) - ->disableOriginalConstructor() - ->getMock(); - $this->quoteFactoryMock->expects($this->exactly(count($lifetimes))) - ->method('create') - ->will($this->returnValue($quotesMock)); - $quotesMock->expects($this->exactly((2 + count($additionalFilterFields)) * count($lifetimes))) - ->method('addFieldToFilter'); - if (!empty($lifetimes)) { - $quotesMock->expects($this->exactly(count($lifetimes))) - ->method('walk') - ->with('delete'); - } - $this->observer->setExpireQuotesAdditionalFilterFields($additionalFilterFields); - $this->observer->execute(); - } - - /** - * @return array - */ - public function cleanExpiredQuotesDataProvider() - { - return [ - [[], []], - [[1 => 100, 2 => 200], []], - [[1 => 100, 2 => 200], ['field1' => 'condition1', 'field2' => 'condition2']], - ]; - } -} diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php index 68e1c7c17cd1..d255f88dea35 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoCommentIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php index 3da6dfe78eb4..1e3ff11ea73c 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/CreditmemoIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(CreditmemoIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php index b7ec91121225..5eeaa12a736f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceCommentIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php index 4a63541bc05f..3328d2f35b2b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/InvoiceIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(InvoiceIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php index 1dc53b97711a..0892ba34114b 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderCommentIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php index f554c2aeef16..54d1ab872fb1 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/OrderIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(OrderIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php index a8d676be2a2f..ff62b46e0cac 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentCommentIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentCommentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php index 503646a5eac6..bccf10978391 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/Container/ShipmentIdentityTest.php @@ -78,6 +78,21 @@ public function testGetEmailCopyTo() $this->assertEquals(['test_value', 'test_value2'], $result); } + public function testGetEmailCopyToWithSpaceEmail() + { + $this->scopeConfigInterfaceMock->expects($this->once()) + ->method('getValue') + ->with( + $this->equalTo(ShipmentIdentity::XML_PATH_EMAIL_COPY_TO), + $this->equalTo(\Magento\Store\Model\ScopeInterface::SCOPE_STORE), + $this->equalTo($this->storeId) + ) + ->will($this->returnValue('test_value, test_value2')); + $this->identity->setStore($this->storeMock); + $result = $this->identity->getEmailCopyTo(); + $this->assertEquals(['test_value', 'test_value2'], $result); + } + public function testGetEmailCopyToEmptyResult() { $this->scopeConfigInterfaceMock->expects($this->once()) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php index adfb697e7033..756048d287e4 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Email/SenderBuilderTest.php @@ -37,11 +37,6 @@ class SenderBuilderTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $templateId = 'test_template_id'; - $templateOptions = ['option1', 'option2']; - $templateVars = ['var1', 'var2']; - $emailIdentity = 'email_identity_test'; - $emailCopyTo = ['example@mail.com']; $this->templateContainerMock = $this->createPartialMock( \Magento\Sales\Model\Order\Email\Container\Template::class, @@ -83,36 +78,6 @@ protected function setUp() ] ); - $this->templateContainerMock->expects($this->once()) - ->method('getTemplateId') - ->will($this->returnValue($templateId)); - $this->transportBuilder->expects($this->once()) - ->method('setTemplateIdentifier') - ->with($this->equalTo($templateId)); - $this->templateContainerMock->expects($this->once()) - ->method('getTemplateOptions') - ->will($this->returnValue($templateOptions)); - $this->transportBuilder->expects($this->once()) - ->method('setTemplateOptions') - ->with($this->equalTo($templateOptions)); - $this->templateContainerMock->expects($this->once()) - ->method('getTemplateVars') - ->will($this->returnValue($templateVars)); - $this->transportBuilder->expects($this->once()) - ->method('setTemplateVars') - ->with($this->equalTo($templateVars)); - - $this->identityContainerMock->expects($this->once()) - ->method('getEmailIdentity') - ->will($this->returnValue($emailIdentity)); - $this->transportBuilder->expects($this->once()) - ->method('setFromByScope') - ->with($this->equalTo($emailIdentity), 1); - - $this->identityContainerMock->expects($this->once()) - ->method('getEmailCopyTo') - ->will($this->returnValue($emailCopyTo)); - $this->senderBuilder = new SenderBuilder( $this->templateContainerMock, $this->identityContainerMock, @@ -122,6 +87,7 @@ protected function setUp() public function testSend() { + $this->setExpectedCount(1); $customerName = 'test_name'; $customerEmail = 'test_email'; $identity = 'email_identity_test'; @@ -142,20 +108,20 @@ public function testSend() $this->identityContainerMock->expects($this->once()) ->method('getCustomerName') ->will($this->returnValue($customerName)); - $this->identityContainerMock->expects($this->once()) + $this->identityContainerMock->expects($this->exactly(1)) ->method('getStore') ->willReturn($this->storeMock); $this->storeMock->expects($this->once()) ->method('getId') ->willReturn(1); - $this->transportBuilder->expects($this->once()) + $this->transportBuilder->expects($this->exactly(1)) ->method('setFromByScope') ->with($identity, 1); - $this->transportBuilder->expects($this->once()) + $this->transportBuilder->expects($this->exactly(1)) ->method('addTo') ->with($this->equalTo($customerEmail), $this->equalTo($customerName)); - $this->transportBuilder->expects($this->once()) + $this->transportBuilder->expects($this->exactly(1)) ->method('getTransport') ->will($this->returnValue($transportMock)); @@ -164,6 +130,7 @@ public function testSend() public function testSendCopyTo() { + $this->setExpectedCount(2); $identity = 'email_identity_test'; $transportMock = $this->createMock( \Magento\Sales\Test\Unit\Model\Order\Email\Stub\TransportInterfaceMock::class @@ -172,22 +139,66 @@ public function testSendCopyTo() ->method('getCustomerEmail'); $this->identityContainerMock->expects($this->never()) ->method('getCustomerName'); - $this->transportBuilder->expects($this->once()) - ->method('addTo') - ->with($this->equalTo('example@mail.com')); - $this->transportBuilder->expects($this->once()) + $this->transportBuilder->expects($this->exactly(2)) + ->method('addTo'); + $this->transportBuilder->expects($this->exactly(2)) ->method('setFromByScope') ->with($identity, 1); - $this->identityContainerMock->expects($this->once()) + $this->identityContainerMock->expects($this->exactly(2)) ->method('getStore') ->willReturn($this->storeMock); - $this->storeMock->expects($this->once()) + $this->storeMock->expects($this->exactly(2)) ->method('getId') ->willReturn(1); - $this->transportBuilder->expects($this->once()) + $this->transportBuilder->expects($this->exactly(2)) ->method('getTransport') ->will($this->returnValue($transportMock)); $this->senderBuilder->sendCopyTo(); } + + /** + * Sets expected count invocation. + * + * @param int $count + */ + private function setExpectedCount(int $count = 1) + { + + $templateId = 'test_template_id'; + $templateOptions = ['option1', 'option2']; + $templateVars = ['var1', 'var2']; + $emailIdentity = 'email_identity_test'; + $emailCopyTo = ['example@mail.com', 'example2@mail.com']; + + $this->templateContainerMock->expects($this->exactly($count)) + ->method('getTemplateId') + ->will($this->returnValue($templateId)); + $this->transportBuilder->expects($this->exactly($count)) + ->method('setTemplateIdentifier') + ->with($this->equalTo($templateId)); + $this->templateContainerMock->expects($this->exactly($count)) + ->method('getTemplateOptions') + ->will($this->returnValue($templateOptions)); + $this->transportBuilder->expects($this->exactly($count)) + ->method('setTemplateOptions') + ->with($this->equalTo($templateOptions)); + $this->templateContainerMock->expects($this->exactly($count)) + ->method('getTemplateVars') + ->will($this->returnValue($templateVars)); + $this->transportBuilder->expects($this->exactly($count)) + ->method('setTemplateVars') + ->with($this->equalTo($templateVars)); + + $this->identityContainerMock->expects($this->exactly($count)) + ->method('getEmailIdentity') + ->will($this->returnValue($emailIdentity)); + $this->transportBuilder->expects($this->exactly($count)) + ->method('setFromByScope') + ->with($this->equalTo($emailIdentity), 1); + + $this->identityContainerMock->expects($this->once()) + ->method('getEmailCopyTo') + ->will($this->returnValue($emailCopyTo)); + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index 705d2face230..bd6487caff7d 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Sales\Test\Unit\Model; use Magento\Catalog\Api\Data\ProductInterface; @@ -17,6 +18,8 @@ use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\Api\SearchCriteria; use Magento\Sales\Api\Data\OrderItemSearchResultInterface; +use Magento\Framework\App\Config\ScopeConfigInterface; +use PHPUnit\Framework\MockObject\MockObject; /** * Test class for \Magento\Sales\Model\Order @@ -24,6 +27,7 @@ * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessivePublicCount) + * @SuppressWarnings(PHPMD.TooManyFields) */ class OrderTest extends \PHPUnit\Framework\TestCase { @@ -102,6 +106,11 @@ class OrderTest extends \PHPUnit\Framework\TestCase */ private $searchCriteriaBuilder; + /** + * @var MockObject|ScopeConfigInterface $scopeConfigMock + */ + private $scopeConfigMock; + protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -125,14 +134,17 @@ protected function setUp() \Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class, ['create'] ); - $this->item = $this->createPartialMock(\Magento\Sales\Model\ResourceModel\Order\Item::class, [ + $this->item = $this->createPartialMock( + \Magento\Sales\Model\ResourceModel\Order\Item::class, + [ 'isDeleted', 'getQtyToInvoice', 'getParentItemId', 'getQuoteItemId', 'getLockedDoInvoice', 'getProductId', - ]); + ] + ); $this->salesOrderCollectionMock = $this->getMockBuilder( \Magento\Sales\Model\ResourceModel\Order\Collection::class )->disableOriginalConstructor() @@ -168,6 +180,7 @@ protected function setUp() ->setMethods(['addFilter', 'create']) ->disableOriginalConstructor()->getMockForAbstractClass(); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); $this->order = $helper->getObject( \Magento\Sales\Model\Order::class, [ @@ -182,7 +195,8 @@ protected function setUp() 'localeResolver' => $this->localeResolver, 'timezone' => $this->timezone, 'itemRepository' => $this->itemRepository, - 'searchCriteriaBuilder' => $this->searchCriteriaBuilder + 'searchCriteriaBuilder' => $this->searchCriteriaBuilder, + 'scopeConfig' => $this->scopeConfigMock ] ); } @@ -354,6 +368,51 @@ public function testCanInvoice() $this->assertTrue($this->order->canInvoice()); } + /** + * Ensure customer name returned correctly. + * + * @dataProvider customerNameProvider + * @param array $expectedData + */ + public function testGetCustomerName(array $expectedData) + { + $this->order->setCustomerFirstname($expectedData['first_name']); + $this->order->setCustomerSuffix($expectedData['customer_suffix']); + $this->order->setCustomerPrefix($expectedData['customer_prefix']); + $this->scopeConfigMock->expects($this->exactly($expectedData['invocation'])) + ->method('isSetFlag') + ->willReturn(true); + $this->assertEquals($expectedData['expected_name'], $this->order->getCustomerName()); + } + + /** + * Customer name data provider + */ + public function customerNameProvider() + { + return + [ + [ + [ + 'first_name' => null, + 'invocation' => 0, + 'expected_name' => 'Guest', + 'customer_suffix' => 'smith', + 'customer_prefix' => 'mr.' + ] + ], + [ + [ + 'first_name' => 'Smith', + 'invocation' => 1, + 'expected_name' => 'mr. Smith Carl', + 'customer_suffix' => 'Carl', + 'customer_prefix' => 'mr.' + ] + ] + ]; + } + /** * @param string $status * @@ -819,9 +878,10 @@ public function testCanVoidPayment($actionFlags, $orderState) if ($orderState == \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW) { $canVoidOrder = false; } - if ($orderState == \Magento\Sales\Model\Order::STATE_HOLDED && (!isset( - $actionFlags[\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD] - ) || $actionFlags[\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD] !== false) + if ($orderState == \Magento\Sales\Model\Order::STATE_HOLDED && + (!isset($actionFlags[\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD]) || + $actionFlags[\Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD] !== false + ) ) { $canVoidOrder = false; } @@ -1193,6 +1253,9 @@ public function testGetCreatedAtFormattedUsesCorrectLocale() $this->order->getCreatedAtFormatted(\IntlDateFormatter::SHORT); } + /** + * @return array + */ public function notInvoicingStatesProvider() { return [ @@ -1202,6 +1265,9 @@ public function notInvoicingStatesProvider() ]; } + /** + * @return array + */ public function canNotCreditMemoStatesProvider() { return [ diff --git a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php index 99a411c43c24..30513571fb71 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/ResourceModel/Order/Handler/StateTest.php @@ -103,6 +103,9 @@ public function testCheck( $this->assertEquals($expectedState, $this->orderMock->getState()); } + /** + * @return array + */ public function stateCheckDataProvider() { return [ diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml index 31aefd8d2ca5..9e0d203cd56b 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml @@ -34,11 +34,11 @@ <?php if ($block->canEditQty()) : ?> <tfoot> <tr> - <td colspan="3"> </td> - <td colspan="3"> + <td colspan="4"> </td> + <td> <?= $block->getUpdateButtonHtml() ?> </td> - <td colspan="3" class="last"> </td> + <td colspan="4" class="last"> </td> </tr> </tfoot> <?php endif; ?> @@ -100,7 +100,6 @@ <span class="title"><?= $block->escapeHtml(__('Refund Totals')) ?></span> </div> <?= $block->getChildHtml('creditmemo_totals') ?> - <div class="totals-actions"><?= $block->getUpdateTotalsButtonHtml() ?></div> <div class="order-totals-actions"> <div class="field choice admin__field admin__field-option field-append-comments"> <input id="notify_customer" @@ -140,9 +139,8 @@ require(['jquery'], function(jQuery){ //<![CDATA[ var submitButtons = jQuery('.submit-button'); -var updateButtons = jQuery('.update-button,.update-totals-button'); -var fields = jQuery('.qty-input,.order-subtotal-table input[type="text"]'); - +var updateButtons = jQuery('.update-button'); +var fields = jQuery('.qty-input'); function enableButtons(buttons) { buttons.removeClass('disabled').prop('disabled', false); } diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/details.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/details.phtml index b700f1b3a65a..70373f177d8b 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/details.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/details.phtml @@ -81,8 +81,8 @@ $_order = $block->getOrder() ?> </tr> <?php endif; ?> <tr bgcolor="#DEE5E8"> - <td colspan="2" align="right" style="padding:3px 9px"><strong><big><?= $block->escapeHtml(__('Grand Total')) ?></big></strong></td> - <td align="right" style="padding:6px 9px"><strong><big><?= /* @noEscape */ $_order->formatPrice($_order->getGrandTotal()) ?></big></strong></td> + <td colspan="2" align="right" style="padding:3px 9px"><strong style="font-size: larger"><?= $block->escapeHtml(__('Grand Total')) ?></strong></td> + <td align="right" style="padding:6px 9px"><strong style="font-size: larger"><?= /* @noEscape */ $_order->formatPrice($_order->getGrandTotal()) ?></strong></td> </tr> </tfoot> </table> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/totals/due.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/totals/due.phtml index 87d7c85c2d9e..f8e914a2c9b2 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/totals/due.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/totals/due.phtml @@ -6,7 +6,7 @@ ?> <?php if ($block->getCanDisplayTotalDue()) : ?> <tr> - <td class="label"><big><strong><?= $block->escapeHtml(__('Total Due')) ?></strong></big></td> - <td class="emph"><big><?= /* @noEscape */ $block->displayPriceAttribute('total_due', true) ?></big></td> + <td class="label"><strong style="font-size: larger"><?= $block->escapeHtml(__('Total Due')) ?></strong></td> + <td class="emph" style="font-size: larger"><?= /* @noEscape */ $block->displayPriceAttribute('total_due', true) ?></td> </tr> <?php endif; ?> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/totals/grand.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/totals/grand.phtml index dc76799251c7..af5d58d47fce 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/totals/grand.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/totals/grand.phtml @@ -9,13 +9,13 @@ <tr> <td class="label"> - <strong><big> + <strong style="font-size: larger"> <?php if ($block->getGrandTotalTitle()) : ?> <?= $block->escapeHtml($block->getGrandTotalTitle()) ?> <?php else : ?> <?= $block->escapeHtml(__('Grand Total')) ?> <?php endif; ?> - </big></strong> + </strong> </td> - <td class="emph"><big><?= /* @noEscape */ $block->displayPriceAttribute('grand_total', true) ?></big></td> + <td class="emph" style="font-size: larger"><?= /* @noEscape */ $block->displayPriceAttribute('grand_total', true) ?></td> </tr> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml index ab5cd49449ec..825ac8205772 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/view/info.phtml @@ -9,6 +9,10 @@ */ $order = $block->getOrder(); +$baseCurrencyCode = (string)$order->getBaseCurrencyCode(); +$globalCurrencyCode = (string)$order->getGlobalCurrencyCode(); +$orderCurrencyCode = (string)$order->getOrderCurrencyCode(); + $orderAdminDate = $block->formatDate( $block->getOrderAdminDate($order->getCreatedAt()), \IntlDateFormatter::MEDIUM, @@ -23,6 +27,7 @@ $orderStoreDate = $block->formatDate( ); $customerUrl = $block->getCustomerViewUrl(); + $allowedAddressHtmlTags = ['b', 'br', 'em', 'i', 'li', 'ol', 'p', 'strong', 'sub', 'sup', 'ul']; ?> @@ -93,15 +98,15 @@ $allowedAddressHtmlTags = ['b', 'br', 'em', 'i', 'li', 'ol', 'p', 'strong', 'sub <td><?= $block->escapeHtml($order->getRemoteIp()); ?><?= $order->getXForwardedFor() ? ' (' . $block->escapeHtml($order->getXForwardedFor()) . ')' : ''; ?></td> </tr> <?php endif; ?> - <?php if ($order->getGlobalCurrencyCode() != $order->getBaseCurrencyCode()) : ?> + <?php if ($globalCurrencyCode !== $baseCurrencyCode) : ?> <tr> - <th><?= $block->escapeHtml(__('%1 / %2 rate:', $order->getGlobalCurrencyCode(), $order->getBaseCurrencyCode())) ?></th> + <th><?= $block->escapeHtml(__('%1 / %2 rate:', $globalCurrencyCode, $baseCurrencyCode)) ?></th> <td><?= $block->escapeHtml($order->getBaseToGlobalRate()) ?></td> </tr> <?php endif; ?> - <?php if ($order->getBaseCurrencyCode() != $order->getOrderCurrencyCode()) : ?> + <?php if ($baseCurrencyCode !== $orderCurrencyCode && $globalCurrencyCode !== $orderCurrencyCode) : ?> <tr> - <th><?= $block->escapeHtml(__('%1 / %2 rate:', $order->getOrderCurrencyCode(), $order->getBaseCurrencyCode())) ?></th> + <th><?= $block->escapeHtml(__('%1 / %2 rate:', $orderCurrencyCode, $baseCurrencyCode)) ?></th> <td><?= $block->escapeHtml($order->getBaseToOrderRate()) ?></td> </tr> <?php endif; ?> diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js index 3fe9d0878288..4e0741451074 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js @@ -795,6 +795,20 @@ define([ grid.reloadParams = {'products[]':this.gridProducts.keys()}; }, + productGridFilterKeyPress: function (grid, event) { + var returnKey = parseInt(Event.KEY_RETURN || 13, 10); + + if (event.keyCode === returnKey) { + if (typeof event.stopPropagation === 'function') { + event.stopPropagation(); + } + + if (typeof event.preventDefault === 'function') { + event.preventDefault(); + } + } + }, + /** * Submit configured products to quote */ diff --git a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml index 019baeea54e2..cb84dcc3fae8 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items.phtml @@ -7,8 +7,9 @@ <?php $_order = $block->getOrder() ?> <div class="actions-toolbar"> <a href="<?= $block->escapeUrl($block->getPrintAllCreditmemosUrl($_order)) ?>" - onclick="this.target='_blank'" - class="action print"> + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print All Refunds')) ?></span> </a> </div> @@ -16,8 +17,9 @@ <div class="order-title"> <strong><?= $block->escapeHtml(__('Refund #')) ?><?= $block->escapeHtml($_creditmemo->getIncrementId()) ?> </strong> <a href="<?= $block->escapeUrl($block->getPrintCreditmemoUrl($_creditmemo)) ?>" - onclick="this.target='_blank'" - class="action print"> + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print Refund')) ?></span> </a> </div> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml b/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml index 6b87d3c22331..2872291a0eaa 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/info/buttons.phtml @@ -16,9 +16,10 @@ <span><?= $block->escapeHtml(__('Reorder')) ?></span> </a> <?php endif ?> - <a class="action print" - href="<?= $block->escapeUrl($block->getPrintUrl($_order)) ?>" - onclick="this.target='_blank';"> + <a href="<?= $block->escapeUrl($block->getPrintUrl($_order)) ?>" + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print Order')) ?></span> </a> <?= $block->getChildHtml() ?> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml index 419060bfba71..ba3440f03c00 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items.phtml @@ -7,8 +7,9 @@ <?php $_order = $block->getOrder() ?> <div class="actions-toolbar"> <a href="<?= $block->escapeUrl($block->getPrintAllInvoicesUrl($_order)) ?>" + class="action print" target="_blank" - class="action print"> + rel="noopener"> <span><?= $block->escapeHtml(__('Print All Invoices')) ?></span> </a> </div> @@ -16,8 +17,9 @@ <div class="order-title"> <strong><?= $block->escapeHtml(__('Invoice #')) ?><?= $block->escapeHtml($_invoice->getIncrementId()) ?></strong> <a href="<?= $block->escapeUrl($block->getPrintInvoiceUrl($_invoice)) ?>" - onclick="this.target='_blank'" - class="action print"> + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print Invoice')) ?></span> </a> </div> diff --git a/app/code/Magento/SalesGraphQl/etc/schema.graphqls b/app/code/Magento/SalesGraphQl/etc/schema.graphqls index a7c30f582e75..a687ee59031e 100644 --- a/app/code/Magento/SalesGraphQl/etc/schema.graphqls +++ b/app/code/Magento/SalesGraphQl/etc/schema.graphqls @@ -7,7 +7,7 @@ type Query { type CustomerOrder @doc(description: "Order mapping fields") { id: Int - increment_id: String @deprecated(reason: "Use the order_number instaed.") + increment_id: String @deprecated(reason: "Use the order_number instead.") order_number: String! @doc(description: "The order number") created_at: String grand_total: Float diff --git a/app/code/Magento/SalesRule/Api/Data/RuleInterface.php b/app/code/Magento/SalesRule/Api/Data/RuleInterface.php index 34341e16cfb6..94e6ed8b4584 100644 --- a/app/code/Magento/SalesRule/Api/Data/RuleInterface.php +++ b/app/code/Magento/SalesRule/Api/Data/RuleInterface.php @@ -5,13 +5,15 @@ */ namespace Magento\SalesRule\Api\Data; +use Magento\Framework\Api\ExtensibleDataInterface; + /** * Interface RuleInterface * * @api * @since 100.0.2 */ -interface RuleInterface extends \Magento\Framework\Api\ExtensibleDataInterface +interface RuleInterface extends ExtensibleDataInterface { const FREE_SHIPPING_NONE = 'NONE'; const FREE_SHIPPING_MATCHING_ITEMS_ONLY = 'MATCHING_ITEMS_ONLY'; @@ -173,7 +175,7 @@ public function getIsActive(); * Set whether the coupon is active * * @param bool $isActive - * @return bool + * @return $this */ public function setIsActive($isActive); @@ -232,6 +234,8 @@ public function setStopRulesProcessing($stopRulesProcessing); public function getIsAdvanced(); /** + * Set if rule is advanced + * * @param bool $isAdvanced * @return $this */ @@ -260,6 +264,8 @@ public function setProductIds(array $productIds = null); public function getSortOrder(); /** + * Set sort order + * * @param int $sortOrder * @return $this */ @@ -446,5 +452,5 @@ public function getExtensionAttributes(); * @param \Magento\SalesRule\Api\Data\RuleExtensionInterface $extensionAttributes * @return $this */ - public function setExtensionAttributes(\Magento\SalesRule\Api\Data\RuleExtensionInterface $extensionAttributes); + public function setExtensionAttributes(RuleExtensionInterface $extensionAttributes); } diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php index 7d55d18b770e..351333191349 100644 --- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php +++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Save.php @@ -61,7 +61,8 @@ public function __construct( */ public function execute() { - if ($this->getRequest()->getPostValue()) { + $data = $this->getRequest()->getPostValue(); + if ($data) { try { /** @var $model \Magento\SalesRule\Model\Rule */ $model = $this->_objectManager->create(\Magento\SalesRule\Model\Rule::class); @@ -69,7 +70,6 @@ public function execute() 'adminhtml_controller_salesrule_prepare_save', ['request' => $this->getRequest()] ); - $data = $this->getRequest()->getPostValue(); if (empty($data['from_date'])) { $data['from_date'] = $this->timezone->formatDate(); } diff --git a/app/code/Magento/SalesRule/Model/CouponSearchResult.php b/app/code/Magento/SalesRule/Model/CouponSearchResult.php new file mode 100644 index 000000000000..cba57900cf60 --- /dev/null +++ b/app/code/Magento/SalesRule/Model/CouponSearchResult.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\SalesRule\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\SalesRule\Api\Data\CouponSearchResultInterface; + +/** + * Service Data Object with Coupon search results. + * + * @phpcs:ignoreFile + */ +class CouponSearchResult extends SearchResults implements CouponSearchResultInterface +{ + /** + * @inheritdoc + */ + public function setItems(array $items = null) + { + return parent::setItems($items); + } +} diff --git a/app/code/Magento/SalesRule/Model/Data/Rule.php b/app/code/Magento/SalesRule/Model/Data/Rule.php index 58520831c016..869822ab917c 100644 --- a/app/code/Magento/SalesRule/Model/Data/Rule.php +++ b/app/code/Magento/SalesRule/Model/Data/Rule.php @@ -5,10 +5,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\SalesRule\Model\Data; +use Magento\Framework\Api\AbstractExtensibleObject; use Magento\SalesRule\Api\Data\ConditionInterface; +use Magento\SalesRule\Api\Data\RuleExtensionInterface; use Magento\SalesRule\Api\Data\RuleInterface; +use Magento\SalesRule\Api\Data\RuleLabelInterface; /** * Class Rule @@ -16,7 +21,7 @@ * @SuppressWarnings(PHPMD.ExcessivePublicCount) * @codeCoverageIgnore */ -class Rule extends \Magento\Framework\Api\AbstractExtensibleObject implements RuleInterface +class Rule extends AbstractExtensibleObject implements RuleInterface { const KEY_RULE_ID = 'rule_id'; const KEY_NAME = 'name'; @@ -187,7 +192,7 @@ public function getIsActive() * Set whether the coupon is active * * @param bool $isActive - * @return bool + * @return $this */ public function setIsActive($isActive) { @@ -197,7 +202,7 @@ public function setIsActive($isActive) /** * Get condition for the rule * - * @return \Magento\SalesRule\Api\Data\ConditionInterface|null + * @return ConditionInterface|null */ public function getCondition() { @@ -207,7 +212,7 @@ public function getCondition() /** * Set condition for the rule * - * @param \Magento\SalesRule\Api\Data\ConditionInterface|null $condition + * @param ConditionInterface|null $condition * @return $this */ public function setCondition(ConditionInterface $condition = null) @@ -218,7 +223,7 @@ public function setCondition(ConditionInterface $condition = null) /** * Get action condition * - * @return \Magento\SalesRule\Api\Data\ConditionInterface|null + * @return ConditionInterface|null */ public function getActionCondition() { @@ -228,7 +233,7 @@ public function getActionCondition() /** * Set action condition * - * @param \Magento\SalesRule\Api\Data\ConditionInterface|null $actionCondition + * @param ConditionInterface|null $actionCondition * @return $this */ public function setActionCondition(ConditionInterface $actionCondition = null) @@ -283,7 +288,7 @@ public function setIsAdvanced($isAdvanced) /** * Get display label * - * @return \Magento\SalesRule\Api\Data\RuleLabelInterface[]|null + * @return RuleLabelInterface[]|null */ public function getStoreLabels() { @@ -293,7 +298,7 @@ public function getStoreLabels() /** * Set display label * - * @param \Magento\SalesRule\Api\Data\RuleLabelInterface[]|null $storeLabels + * @param RuleLabelInterface[]|null $storeLabels * @return $this */ public function setStoreLabels(array $storeLabels = null) @@ -622,7 +627,7 @@ public function setSimpleFreeShipping($simpleFreeShipping) /** * @inheritdoc * - * @return \Magento\SalesRule\Api\Data\RuleExtensionInterface|null + * @return RuleExtensionInterface|null */ public function getExtensionAttributes() { @@ -632,11 +637,11 @@ public function getExtensionAttributes() /** * @inheritdoc * - * @param \Magento\SalesRule\Api\Data\RuleExtensionInterface $extensionAttributes + * @param RuleExtensionInterface $extensionAttributes * @return $this */ public function setExtensionAttributes( - \Magento\SalesRule\Api\Data\RuleExtensionInterface $extensionAttributes + RuleExtensionInterface $extensionAttributes ) { return $this->_setExtensionAttributes($extensionAttributes); } diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php index cf6301cb31a9..29cdf34c5a78 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php @@ -65,7 +65,6 @@ public function loadAttributeOptions() 'base_subtotal' => __('Subtotal'), 'total_qty' => __('Total Items Quantity'), 'weight' => __('Total Weight'), - 'payment_method' => __('Payment Method'), 'shipping_method' => __('Shipping Method'), 'postcode' => __('Shipping Postcode'), 'region' => __('Shipping Region'), diff --git a/app/code/Magento/SalesRule/Model/RuleSearchResult.php b/app/code/Magento/SalesRule/Model/RuleSearchResult.php new file mode 100644 index 000000000000..834b2b575ec2 --- /dev/null +++ b/app/code/Magento/SalesRule/Model/RuleSearchResult.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\SalesRule\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\SalesRule\Api\Data\RuleSearchResultInterface; + +/** + * Service Data Object with Sales Rule search results. + * + * @phpcs:ignoreFile + */ +class RuleSearchResult extends SearchResults implements RuleSearchResultInterface +{ + /** + * @inheritdoc + */ + public function setItems(array $items = null) + { + return parent::setItems($items); + } +} diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php index 1214e6642b44..a50046e38775 100644 --- a/app/code/Magento/SalesRule/Model/RulesApplier.php +++ b/app/code/Magento/SalesRule/Model/RulesApplier.php @@ -209,7 +209,7 @@ protected function getDiscountData($item, $rule) */ private function setDiscountBreakdown($discountData, $item, $rule) { - if ($discountData->getAmount() > 0) { + if ($discountData->getAmount() > 0 && $item->getExtensionAttributes()) { /** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */ $discount = $this->discountFactory->create(); $discount->setBaseOriginalAmount($discountData->getBaseOriginalAmount()); diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml index f9bc44a11cc4..c840162f0d16 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml @@ -105,7 +105,18 @@ <waitForElementVisible selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="waitForCategoryVisible" after="openChooser"/> <checkOption selector="{{AdminCartPriceRulesFormSection.categoryCheckbox(categoryName)}}" stepKey="checkCategoryName" after="waitForCategoryVisible"/> </actionGroup> - + <actionGroup name="AdminCreateMultiWebsiteCartPriceRuleActionGroup" extends="AdminCreateCartPriceRuleActionGroup"> + <annotations> + <description>EXTENDS: AdminCreateCartPriceRuleActionGroup. Removes 'clickSaveButton' for the next data changing. Assign cart price rule to 2 websites instead of 1.</description> + </annotations> + <arguments> + <argument name="ruleName"/> + </arguments> + <remove keyForRemoval="clickSaveButton"/> + <remove keyForRemoval="seeSuccessMessage"/> + <remove keyForRemoval="selectWebsites"/> + <selectOption selector="{{AdminCartPriceRulesFormSection.websites}}" parameterArray="['FirstWebsite', 'SecondWebsite']" stepKey="selectWebsites" after="fillRuleName"/> + </actionGroup> <actionGroup name="CreateCartPriceRuleSecondWebsiteActionGroup"> <annotations> <description>Goes to the Admin Cart Price Rule grid page. Clicks on Add New Rule. Fills the provided Rule (Name). Selects 'Second Website' from the 'Websites' menu.</description> diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminDeleteCartPriceRuleActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminDeleteCartPriceRuleActionGroup.xml index 17beb4bebc7b..af9c462bfd42 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminDeleteCartPriceRuleActionGroup.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminDeleteCartPriceRuleActionGroup.xml @@ -15,13 +15,16 @@ <arguments> <argument name="ruleName" type="entity"/> </arguments> - + <amOnPage url="{{AdminCartPriceRulesPage.url}}" stepKey="goToCartPriceRules"/> <waitForPageLoad stepKey="waitForCartPriceRules"/> + <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="resetFilterBeforeDelete"/> + <waitForPageLoad stepKey="waitForCartPriceRulesResetFilter"/> <fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="{{ruleName.name}}" stepKey="filterByName"/> <click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="doFilter"/> <click selector="{{AdminCartPriceRulesSection.rowByIndex('1')}}" stepKey="goToEditRulePage"/> <click selector="{{AdminCartPriceRulesFormSection.delete}}" stepKey="clickDeleteButton"/> - <click selector="{{AdminCartPriceRulesFormSection.modalAcceptButton}}" stepKey="confirmDelete"/> + <waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForConfirmModal"/> + <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml index 075584386124..3849d153be46 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml @@ -19,6 +19,7 @@ <element name="description" type="textarea" selector="//div[@class='admin__field-control']/textarea[@name='description']"/> <element name="active" type="checkbox" selector="//div[@class='admin__actions-switch']/input[@name='is_active']/../label"/> <element name="websites" type="multiselect" selector="select[name='website_ids']"/> + <element name="websitesOptions" type="select" selector="[name='website_ids'] option"/> <element name="customerGroups" type="multiselect" selector="select[name='customer_group_ids']"/> <element name="customerGroupsOptions" type="multiselect" selector="select[name='customer_group_ids'] option"/> <element name="coupon" type="select" selector="select[name='coupon_type']"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/PriceRuleConditionsSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/PriceRuleConditionsSection.xml index 9a74ced2a2c1..89398051fcf6 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Section/PriceRuleConditionsSection.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Section/PriceRuleConditionsSection.xml @@ -11,6 +11,7 @@ <element name="rulesDropdown" type="select" selector="select[data-form-part='sales_rule_form'][data-ui-id='newchild-0-select-rule-conditions-1-new-child']"/> <element name="addProductAttributesButton" type="text" selector="#conditions__1--1__children>li>span>a"/> <element name="productAttributesDropdown" type="select" selector="#conditions__1--1__new_child"/> + <element name="firstProductAttributeSelected" type="select" selector="#conditions__1__children .rule-param:nth-of-type(2) a:nth-child(1)"/> <element name="changeCategoriesButton" type="text" selector="#conditions__1--1__children>li>span.rule-param:nth-of-type(2)>a"/> <element name="categoriesChooser" type="text" selector="#conditions__1--1__children>li>span.rule-param:nth-of-type(2)>span>label>a"/> <element name="treeRoot" type="text" selector=".x-tree-root-ct.x-tree-lines"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateBuyXGetYFreeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateBuyXGetYFreeTest.xml index 92d221de9e15..02078ff15ecc 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateBuyXGetYFreeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateBuyXGetYFreeTest.xml @@ -30,7 +30,7 @@ <argument name="ruleName" value="{{_defaultCoupon.code}}"/> </actionGroup> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a cart price rule of type Buy X get Y free --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml index 03dffe9f448e..9d807de409a0 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml @@ -30,7 +30,7 @@ <argument name="ruleName" value="{{_defaultCoupon.code}}"/> </actionGroup> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a cart price rule --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountDiscountTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountDiscountTest.xml index 08a08275ee07..1681d910ccdb 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountDiscountTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountDiscountTest.xml @@ -30,7 +30,7 @@ <argument name="ruleName" value="{{_defaultCoupon.code}}"/> </actionGroup> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a cart price rule for $10 Fixed amount discount --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountWholeCartDiscountTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountWholeCartDiscountTest.xml index a39530f7607e..69918bda8c42 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountWholeCartDiscountTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateFixedAmountWholeCartDiscountTest.xml @@ -30,7 +30,7 @@ <argument name="ruleName" value="{{SimpleSalesRule.name}}"/> </actionGroup> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a cart price rule for Fixed amount discount for whole cart --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreatePercentOfProductPriceTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreatePercentOfProductPriceTest.xml index 1f7d849ac02b..898e5a07304b 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreatePercentOfProductPriceTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreatePercentOfProductPriceTest.xml @@ -30,7 +30,7 @@ <argument name="ruleName" value="{{_defaultCoupon.code}}"/> </actionGroup> <deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a cart price rule for 50 percent of product price --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml index 0d365dc089e4..e4e9a6278094 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/EndToEndB2CGuestUserTest.xml @@ -38,6 +38,45 @@ <argument name="total" value="447.00"/> </actionGroup> + <actionGroup ref="StorefrontCancelCouponActionGroup" stepKey="couponCancelCoupon" after="couponCheckCartWithDiscount"/> + <actionGroup ref="StorefrontCheckCartActionGroup" stepKey="cartAssertCartAfterCancelCoupon" after="couponCancelCoupon"> + <argument name="subtotal" value="480.00"/> + <argument name="shipping" value="15.00"/> + <argument name="shippingMethod" value="Flat Rate - Fixed"/> + <argument name="total" value="495.00"/> + </actionGroup> + <comment userInput="End of using coupon code" stepKey="endOfUsingCouponCode" after="cartAssertCartAfterCancelCoupon" /> + </test> + <test name="EndToEndB2CGuestUserMysqlTest"> + <before> + <createData entity="ApiSalesRule" stepKey="createSalesRule"/> + <createData entity="ApiSalesRuleCoupon" stepKey="createSalesRuleCoupon"> + <requiredEntity createDataKey="createSalesRule"/> + </createData> + </before> + <after> + <deleteData createDataKey="createSalesRule" stepKey="deleteSalesRule"/> + </after> + + <!-- Step 5: User uses coupon codes --> + <comment userInput="Start of using coupon code" stepKey="startOfUsingCouponCode" after="endOfComparingProducts" /> + <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="couponOpenCart" after="startOfUsingCouponCode"/> + + <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="couponApplyCoupon" after="couponOpenCart"> + <argument name="coupon" value="$$createSalesRuleCoupon$$"/> + </actionGroup> + + <actionGroup ref="StorefrontCheckCouponAppliedActionGroup" stepKey="couponCheckAppliedDiscount" after="couponApplyCoupon"> + <argument name="rule" value="$$createSalesRule$$"/> + <argument name="discount" value="48.00"/> + </actionGroup> + <actionGroup ref="StorefrontCheckCartActionGroup" stepKey="couponCheckCartWithDiscount" after="couponCheckAppliedDiscount"> + <argument name="subtotal" value="480.00"/> + <argument name="shipping" value="15.00"/> + <argument name="shippingMethod" value="Flat Rate - Fixed"/> + <argument name="total" value="447.00"/> + </actionGroup> + <actionGroup ref="StorefrontCancelCouponActionGroup" stepKey="couponCancelCoupon" after="couponCheckCartWithDiscount"/> <actionGroup ref="StorefrontCheckCartActionGroup" stepKey="cartAssertCartAfterCancelCoupon" after="couponCancelCoupon"> <argument name="subtotal" value="480.00"/> diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php index 8ca6b20db3b5..da358372e089 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/ProductTest.php @@ -247,10 +247,10 @@ public function testValidateCategoriesIgnoresVisibility(): void * @param boolean $isValid * @param string $conditionValue * @param string $operator - * @param double $productPrice + * @param string $productPrice * @dataProvider localisationProvider */ - public function testQuoteLocaleFormatPrice($isValid, $conditionValue, $operator = '>=', $productPrice = 2000.00) + public function testQuoteLocaleFormatPrice($isValid, $conditionValue, $operator = '>=', $productPrice = '2000.00') { $attr = $this->getMockBuilder(\Magento\Framework\Model\ResourceModel\Db\AbstractDb::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml index c1d22a04771a..f44b172d6b47 100644 --- a/app/code/Magento/SalesRule/etc/di.xml +++ b/app/code/Magento/SalesRule/etc/di.xml @@ -13,7 +13,7 @@ <preference for="Magento\SalesRule\Api\Data\ConditionInterface" type="Magento\SalesRule\Model\Data\Condition" /> <preference for="Magento\SalesRule\Api\Data\RuleSearchResultInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\SalesRule\Model\RuleSearchResult" /> <preference for="Magento\SalesRule\Api\Data\RuleLabelInterface" type="Magento\SalesRule\Model\Data\RuleLabel" /> <preference for="Magento\SalesRule\Api\Data\CouponInterface" @@ -23,7 +23,7 @@ <preference for="Magento\SalesRule\Model\Spi\CouponResourceInterface" type="Magento\SalesRule\Model\ResourceModel\Coupon" /> <preference for="Magento\SalesRule\Api\Data\CouponSearchResultInterface" - type="Magento\Framework\Api\SearchResults" /> + type="Magento\SalesRule\Model\CouponSearchResult" /> <preference for="Magento\SalesRule\Api\Data\CouponGenerationSpecInterface" type="Magento\SalesRule\Model\Data\CouponGenerationSpec" /> <preference for="Magento\SalesRule\Api\Data\CouponMassDeleteResultInterface" diff --git a/app/code/Magento/Search/Block/Adminhtml/Dashboard/Last.php b/app/code/Magento/Search/Block/Adminhtml/Dashboard/Last.php index ad8d247b2a6f..ff49f4a15b06 100644 --- a/app/code/Magento/Search/Block/Adminhtml/Dashboard/Last.php +++ b/app/code/Magento/Search/Block/Adminhtml/Dashboard/Last.php @@ -24,7 +24,7 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid protected $_queriesFactory; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -36,14 +36,14 @@ class Last extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Search\Model\ResourceModel\Query\CollectionFactory $queriesFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Search\Model\ResourceModel\Query\CollectionFactory $queriesFactory, array $data = [] ) { diff --git a/app/code/Magento/Search/Block/Adminhtml/Dashboard/Top.php b/app/code/Magento/Search/Block/Adminhtml/Dashboard/Top.php index 63893f788673..3e10e1137d6b 100644 --- a/app/code/Magento/Search/Block/Adminhtml/Dashboard/Top.php +++ b/app/code/Magento/Search/Block/Adminhtml/Dashboard/Top.php @@ -24,7 +24,7 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid protected $_queriesFactory; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -36,14 +36,14 @@ class Top extends \Magento\Backend\Block\Dashboard\Grid /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Backend\Helper\Data $backendHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Search\Model\ResourceModel\Query\CollectionFactory $queriesFactory * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Search\Model\ResourceModel\Query\CollectionFactory $queriesFactory, array $data = [] ) { diff --git a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php index e34c841f32bd..a1bc1df3f9bd 100644 --- a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php +++ b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php @@ -130,7 +130,6 @@ public function setQueryFilter($query) */ public function setPopularQueryFilter($storeIds = null) { - $this->getSelect()->reset( \Magento\Framework\DB\Select::FROM )->reset( @@ -140,13 +139,10 @@ public function setPopularQueryFilter($storeIds = null) )->from( ['main_table' => $this->getTable('search_query')] ); - if ($storeIds) { - $this->addStoreFilter($storeIds); - $this->getSelect()->where('num_results > 0'); - } elseif (null === $storeIds) { - $this->addStoreFilter($this->_storeManager->getStore()->getId()); - $this->getSelect()->where('num_results > 0'); - } + + $storeIds = $storeIds ?: $this->_storeManager->getStore()->getId(); + $this->addStoreFilter($storeIds); + $this->getSelect()->where('num_results > 0'); $this->getSelect()->order(['popularity desc']); @@ -172,10 +168,9 @@ public function setRecentQueryFilter() */ public function addStoreFilter($storeIds) { - if (!is_array($storeIds)) { - $storeIds = [$storeIds]; - } - $this->getSelect()->where('main_table.store_id IN (?)', $storeIds); + $condition = is_array($storeIds) ? 'main_table.store_id IN (?)' : 'main_table.store_id = ?'; + $this->getSelect()->where($condition, $storeIds); + return $this; } } diff --git a/app/code/Magento/Search/Test/Mftf/Data/ConfigData.xml b/app/code/Magento/Search/Test/Mftf/Data/ConfigData.xml new file mode 100644 index 000000000000..4a742b290c98 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/Data/ConfigData.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="SearchEngineMysqlConfigData"> + <data key="path">catalog/search/engine</data> + <data key="scope_id">1</data> + <data key="label">MySQL</data> + <data key="value">mysql</data> + </entity> +</entities> diff --git a/app/code/Magento/Search/Test/Mftf/Suite/SearchEngineMysqlSuite.xml b/app/code/Magento/Search/Test/Mftf/Suite/SearchEngineMysqlSuite.xml new file mode 100644 index 000000000000..9ed6ccda6220 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/Suite/SearchEngineMysqlSuite.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<suites xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Suite/etc/suiteSchema.xsd"> + <suite name="SearchEngineMysqlSuite"> + <before> + <magentoCLI stepKey="setSearchEngineToMysql" command="config:set {{SearchEngineMysqlConfigData.path}} {{SearchEngineMysqlConfigData.value}}"/> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after></after> + <include> + <group name="SearchEngineMysql" /> + </include> + <exclude> + <group name="skip"/> + </exclude> + </suite> +</suites> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml index 61a89b4610d6..c5124ac9c74a 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml @@ -32,6 +32,10 @@ <!-- Create product with description --> <comment userInput="Create product with description" stepKey="createProductWithDescriptionComment"/> <createData entity="SimpleProductWithDescription" stepKey="simpleProduct"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <!-- Delete created product --> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml index 119faef9f2f5..e49db08954e1 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml @@ -24,6 +24,10 @@ <!--Create Simple Product --> <createData entity="defaultSimpleProduct" stepKey="simpleProduct"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> <!-- Delete create product --> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml index ca48fb8565ca..a1aa8be999ae 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml @@ -24,6 +24,10 @@ <!-- Create product with short description --> <createData entity="ApiProductWithDescription" stepKey="product"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml index 6033ea8dee28..3a8443706c9c 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml @@ -24,6 +24,10 @@ <!--Create Simple Product --> <createData entity="defaultSimpleProduct" stepKey="simpleProduct"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> diff --git a/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php b/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php index 982d00bd9f64..748e441652f7 100644 --- a/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php +++ b/app/code/Magento/Search/Test/Unit/Model/Search/PageSizeProviderTest.php @@ -50,6 +50,9 @@ public function testGetPageSize($searchEngine, $size) $this->assertEquals($size, $this->model->getMaxPageSize()); } + /** + * @return array + */ public function getPageSizeDataProvider() { return [ diff --git a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php index 8cc9b809ff88..f42ce50d2804 100644 --- a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php +++ b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php @@ -63,11 +63,13 @@ public function prepareDataSource(array $dataSource) 'confirm' => [ 'title' => __('Delete'), 'message' => __('Are you sure you want to delete synonym group with id: %1?', $item['group_id']) - ] + ], + '__disableTmpl' => true ]; $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl(self::SYNONYM_URL_PATH_EDIT, ['group_id' => $item['group_id']]), 'label' => __('View/Edit'), + '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml index ab4b54298c2a..1a01ffa42401 100644 --- a/app/code/Magento/Search/etc/db_schema.xml +++ b/app/code/Magento/Search/etc/db_schema.xml @@ -46,6 +46,10 @@ <index referenceId="SEARCH_QUERY_IS_PROCESSED" indexType="btree"> <column name="is_processed"/> </index> + <index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree"> + <column name="store_id"/> + <column name="popularity"/> + </index> </table> <table name="search_synonyms" resource="default" engine="innodb" comment="table storing various synonyms groups"> <column xsi:type="bigint" name="group_id" padding="20" unsigned="true" nullable="false" identity="true" diff --git a/app/code/Magento/Search/etc/db_schema_whitelist.json b/app/code/Magento/Search/etc/db_schema_whitelist.json index 71adbc68887d..16bbd0ce9fa3 100644 --- a/app/code/Magento/Search/etc/db_schema_whitelist.json +++ b/app/code/Magento/Search/etc/db_schema_whitelist.json @@ -17,7 +17,8 @@ "SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true, "SEARCH_QUERY_STORE_ID": true, "SEARCH_QUERY_IS_PROCESSED": true, - "SEARCH_QUERY_SYNONYM_FOR": true + "SEARCH_QUERY_SYNONYM_FOR": true, + "SEARCH_QUERY_STORE_ID_POPULARITY": true }, "constraint": { "PRIMARY": true, @@ -43,4 +44,4 @@ "SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true } } -} \ No newline at end of file +} diff --git a/app/code/Magento/Search/view/adminhtml/layout/search_term_grid_block.xml b/app/code/Magento/Search/view/adminhtml/layout/search_term_grid_block.xml index 38c6fa52455b..e7f31097368e 100644 --- a/app/code/Magento/Search/view/adminhtml/layout/search_term_grid_block.xml +++ b/app/code/Magento/Search/view/adminhtml/layout/search_term_grid_block.xml @@ -81,16 +81,7 @@ <argument name="sortable" xsi:type="string">1</argument> <argument name="index" xsi:type="string">display_in_terms</argument> <argument name="type" xsi:type="string">options</argument> - <argument name="options" xsi:type="array"> - <item name="yes" xsi:type="array"> - <item name="value" xsi:type="string">1</item> - <item name="label" xsi:type="string" translate="true">yes</item> - </item> - <item name="no" xsi:type="array"> - <item name="value" xsi:type="string">0</item> - <item name="label" xsi:type="string" translate="true">no</item> - </item> - </argument> + <argument name="options" xsi:type="options" model="Magento\Config\Model\Config\Source\Yesno"/> </arguments> </block> <block class="Magento\Backend\Block\Widget\Grid\Column" name="adminhtml.catalog.search.grid.columnSet.action" as="action"> diff --git a/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php b/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php new file mode 100644 index 000000000000..22377897e564 --- /dev/null +++ b/app/code/Magento/SendFriend/Test/Unit/Model/CaptchaValidatorTest.php @@ -0,0 +1,161 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\SendFriend\Test\Unit\Model; + +use Magento\Authorization\Model\UserContextInterface; +use Magento\Captcha\Helper\Data; +use Magento\Captcha\Model\DefaultModel; +use Magento\Captcha\Observer\CaptchaStringResolver; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\SendFriend\Model\CaptchaValidator; +use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject; + +/** + * Test CaptchaValidatorTest + */ +class CaptchaValidatorTest extends TestCase +{ + const FORM_ID = 'product_sendtofriend_form'; + + /** + * @var CaptchaValidator + */ + private $model; + + /** + * @var CaptchaStringResolver|PHPUnit_Framework_MockObject_MockObject + */ + private $captchaStringResolverMock; + + /** + * @var UserContextInterface|PHPUnit_Framework_MockObject_MockObject + */ + private $currentUserMock; + + /** + * @var CustomerRepositoryInterface|PHPUnit_Framework_MockObject_MockObject + */ + private $customerRepositoryMock; + + /** + * @var Data|PHPUnit_Framework_MockObject_MockObject + */ + private $captchaHelperMock; + + /** + * @var DefaultModel|PHPUnit_Framework_MockObject_MockObject + */ + private $captchaMock; + + /** + * @var RequestInterface|PHPUnit_Framework_MockObject_MockObject + */ + private $requestMock; + + /** + * Set Up + */ + protected function setUp() + { + $objectManager = new ObjectManager($this); + + $this->captchaHelperMock = $this->createMock(Data::class); + $this->captchaStringResolverMock = $this->createMock(CaptchaStringResolver::class); + $this->currentUserMock = $this->getMockBuilder(UserContextInterface::class) + ->getMockForAbstractClass(); + $this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class); + $this->captchaMock = $this->createMock(DefaultModel::class); + $this->requestMock = $this->getMockBuilder(RequestInterface::class)->getMock(); + + $this->model = $objectManager->getObject( + CaptchaValidator::class, + [ + 'captchaHelper' => $this->captchaHelperMock, + 'captchaStringResolver' => $this->captchaStringResolverMock, + 'currentUser' => $this->currentUserMock, + 'customerRepository' => $this->customerRepositoryMock, + ] + ); + } + + /** + * Testing the captcha validation before sending the email + * + * @dataProvider captchaProvider + * + * @param bool $captchaIsRequired + * @param bool $captchaWordIsValid + * + * @throws LocalizedException + * @throws NoSuchEntityException + */ + public function testCaptchaValidationOnSend(bool $captchaIsRequired, bool $captchaWordIsValid) + { + $word = 'test-word'; + $this->captchaHelperMock->expects($this->once())->method('getCaptcha')->with(static::FORM_ID) + ->will($this->returnValue($this->captchaMock)); + $this->captchaMock->expects($this->once())->method('isRequired') + ->will($this->returnValue($captchaIsRequired)); + + if ($captchaIsRequired) { + $this->captchaStringResolverMock->expects($this->once())->method('resolve') + ->with($this->requestMock, static::FORM_ID)->will($this->returnValue($word)); + $this->captchaMock->expects($this->once())->method('isCorrect')->with($word) + ->will($this->returnValue($captchaWordIsValid)); + } + + $this->model->validateSending($this->requestMock); + } + + /** + * Testing the wrong used word for captcha + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Incorrect CAPTCHA + */ + public function testWrongCaptcha() + { + $word = 'test-word'; + $captchaIsRequired = true; + $captchaWordIsCorrect = false; + $this->captchaHelperMock->expects($this->once())->method('getCaptcha')->with(static::FORM_ID) + ->will($this->returnValue($this->captchaMock)); + $this->captchaMock->expects($this->once())->method('isRequired') + ->will($this->returnValue($captchaIsRequired)); + $this->captchaStringResolverMock->expects($this->any())->method('resolve') + ->with($this->requestMock, static::FORM_ID)->will($this->returnValue($word)); + $this->captchaMock->expects($this->any())->method('isCorrect')->with($word) + ->will($this->returnValue($captchaWordIsCorrect)); + + $this->model->validateSending($this->requestMock); + } + + /** + * Providing captcha settings + * + * @return array + */ + public function captchaProvider(): array + { + return [ + [ + true, + true + ], [ + false, + false + ] + ]; + } +} diff --git a/app/code/Magento/SendFriend/etc/adminhtml/system.xml b/app/code/Magento/SendFriend/etc/adminhtml/system.xml index 785b7a8bb40c..5cace4bcf92d 100644 --- a/app/code/Magento/SendFriend/etc/adminhtml/system.xml +++ b/app/code/Magento/SendFriend/etc/adminhtml/system.xml @@ -13,8 +13,11 @@ <resource>Magento_Config::sendfriend</resource> <group id="email" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Email Templates</label> - <field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <field id="enabled" translate="label comment" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Enabled</label> + <comment> + <![CDATA[We strongly recommend to enable a <a href="https://devdocs.magento.com/guides/v2.3/security/google-recaptcha.html" target="_blank">CAPTCHA solution</a> alongside enabling "Email to a Friend" to ensure abuse of this feature does not occur.]]> + </comment> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> </field> <field id="template" translate="label comment" type="select" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> diff --git a/app/code/Magento/SendFriend/etc/config.xml b/app/code/Magento/SendFriend/etc/config.xml index d65e5a4a073d..6239a4da591e 100644 --- a/app/code/Magento/SendFriend/etc/config.xml +++ b/app/code/Magento/SendFriend/etc/config.xml @@ -9,7 +9,7 @@ <default> <sendfriend> <email> - <enabled>1</enabled> + <enabled>0</enabled> <template>sendfriend_email_template</template> <allow_guest>0</allow_guest> <max_recipients>5</max_recipients> diff --git a/app/code/Magento/SendFriend/i18n/en_US.csv b/app/code/Magento/SendFriend/i18n/en_US.csv index eee540c89a7b..8d5b596fe1ca 100644 --- a/app/code/Magento/SendFriend/i18n/en_US.csv +++ b/app/code/Magento/SendFriend/i18n/en_US.csv @@ -45,3 +45,4 @@ Enabled,Enabled "Max Recipients","Max Recipients" "Max Products Sent in 1 Hour","Max Products Sent in 1 Hour" "Limit Sending By","Limit Sending By" +"We strongly recommend to enable a <a href=""https://devdocs.magento.com/guides/v2.3/security/google-recaptcha.html"" target="_blank">CAPTCHA solution</a> alongside enabling ""Email to a Friend"" to ensure abuse of this feature does not occur.","We strongly recommend to enable a <a href=""https://devdocs.magento.com/guides/v2.3/security/google-recaptcha.html"" target="_blank">CAPTCHA solution</a> alongside enabling ""Email to a Friend"" to ensure abuse of this feature does not occur." diff --git a/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php b/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php index 356483c9a5dd..55eecfa00d6d 100644 --- a/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php +++ b/app/code/Magento/Shipping/Block/Adminhtml/Order/Tracking/View.php @@ -43,7 +43,7 @@ public function __construct( */ protected function _prepareLayout() { - $onclick = "submitAndReloadArea($('shipment_tracking_info').parentNode, '" . $this->getSubmitUrl() . "')"; + $onclick = "saveTrackingInfo($('shipment_tracking_info').parentNode, '" . $this->getSubmitUrl() . "')"; $this->addChild( 'save_button', \Magento\Backend\Block\Widget\Button::class, @@ -86,7 +86,10 @@ public function getRemoveUrl($track) } /** + * Get carrier title + * * @param string $code + * * @return \Magento\Framework\Phrase|string|bool */ public function getCarrierTitle($code) diff --git a/app/code/Magento/Shipping/Model/Shipping.php b/app/code/Magento/Shipping/Model/Shipping.php index 5470f9a96775..48127469ea98 100644 --- a/app/code/Magento/Shipping/Model/Shipping.php +++ b/app/code/Magento/Shipping/Model/Shipping.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Shipping\Model; use Magento\Framework\App\ObjectManager; @@ -272,7 +273,9 @@ public function collectRates(\Magento\Quote\Model\Quote\Address\RateRequest $req */ private function prepareCarrier(string $carrierCode, RateRequest $request): AbstractCarrier { - $carrier = $this->_carrierFactory->create($carrierCode, $request->getStoreId()); + $carrier = $this->isShippingCarrierAvailable($carrierCode) + ? $this->_carrierFactory->create($carrierCode, $request->getStoreId()) + : null; if (!$carrier) { throw new \RuntimeException('Failed to initialize carrier'); } @@ -360,6 +363,7 @@ public function composePackagesForCarrier($carrier, $request) { $allItems = $request->getAllItems(); $fullItems = []; + $weightItems = []; $maxWeight = (double)$carrier->getConfigData('max_package_weight'); @@ -425,15 +429,13 @@ public function composePackagesForCarrier($carrier, $request) if (!empty($decimalItems)) { foreach ($decimalItems as $decimalItem) { - $fullItems = array_merge( - $fullItems, - array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']) - ); + $weightItems[] = array_fill(0, $decimalItem['qty'] * $qty, $decimalItem['weight']); } } else { - $fullItems = array_merge($fullItems, array_fill(0, $qty, $itemWeight)); + $weightItems[] = array_fill(0, $qty, $itemWeight); } } + $fullItems = array_merge($fullItems, ...$weightItems); sort($fullItems); return $this->_makePieces($fullItems, $maxWeight); @@ -532,4 +534,18 @@ public function setCarrierAvailabilityConfigField($code = 'active') $this->_availabilityConfigField = $code; return $this; } + + /** + * Checks availability of carrier. + * + * @param string $carrierCode + * @return bool + */ + private function isShippingCarrierAvailable(string $carrierCode): bool + { + return $this->_scopeConfig->isSetFlag( + 'carriers/' . $carrierCode . '/' . $this->_availabilityConfigField, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + } } diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAddTrackingNumberToShipmentActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAddTrackingNumberToShipmentActionGroup.xml new file mode 100644 index 000000000000..87f139c9dc77 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAddTrackingNumberToShipmentActionGroup.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAddTrackingNumberToShipmentActionGroup"> + <arguments> + <argument name="trackingTitle" type="string" defaultValue=""/> + <argument name="trackingNumber" type="string"/> + </arguments> + + <fillField selector="{{AdminShipmentTrackingSection.trackingTitle}}" userInput="{{trackingTitle}}" stepKey="fillTrackingTitle"/> + <fillField selector="{{AdminShipmentTrackingSection.trackingNumber}}" userInput="{{trackingNumber}}" stepKey="fillTrackingNumber"/> + <click selector="{{AdminShipmentTrackingSection.addTrackingNumber}}" stepKey="clickAddTrackingNumber"/> + <waitForPageLoad stepKey="waitForTrackingInformation"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertExistingTrackingNumberActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertExistingTrackingNumberActionGroup.xml new file mode 100644 index 000000000000..03301aa22f58 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertExistingTrackingNumberActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAssertExistingTrackingNumberActionGroup"> + <arguments> + <argument name="trackingNumber" type="string"/> + </arguments> + + <see selector="#shipment_tracking_info .col-number" userInput="{{trackingNumber}}" stepKey="seeAvailableTrackingNumber"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertTrackingValidationErrorActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertTrackingValidationErrorActionGroup.xml new file mode 100644 index 000000000000..3783a9b1cc4d --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertTrackingValidationErrorActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminAssertTrackingValidationErrorActionGroup"> + <arguments> + <argument name="inputName" type="string"/> + <argument name="errorMessage" type="string" defaultValue="This is a required field."/> + </arguments> + + <see selector="{{AdminShipmentTrackingSection.trackingInfoErrorElement(inputName)}}" userInput="{{errorMessage}}" stepKey="seeTrackingInfoValidationError"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminChangeTableRatesShippingMethodStatusActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminChangeTableRatesShippingMethodStatusActionGroup.xml index e506ca3a7662..e0fec2a6dc4d 100644 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminChangeTableRatesShippingMethodStatusActionGroup.xml +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminChangeTableRatesShippingMethodStatusActionGroup.xml @@ -17,4 +17,14 @@ <uncheckOption selector="{{AdminShippingMethodTableRatesSection.enabledUseSystemValue}}" stepKey="uncheckUseSystemValue"/> <selectOption selector="{{AdminShippingMethodTableRatesSection.carriersTableRateActive}}" userInput="{{status}}" stepKey="changeTableRatesMethodStatus"/> </actionGroup> + <actionGroup name="AdminImportFileTableRatesShippingMethodActionGroup"> + <annotations> + <description>Import a file in Table Rates tab in Shipping Method config page.</description> + </annotations> + <arguments> + <argument name="file" type="string" defaultValue="test_tablerates.csv"/> + </arguments> + <conditionalClick selector="{{AdminShippingMethodTableRatesSection.carriersTableRateTab}}" dependentSelector="{{AdminShippingMethodTableRatesSection.carriersTableRateActive}}" visible="false" stepKey="expandTab"/> + <attachFile selector="{{AdminShippingMethodTableRatesSection.importFile}}" userInput="{{file}}" stepKey="attachFileForImport"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminDeleteTrackingNumberActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminDeleteTrackingNumberActionGroup.xml new file mode 100644 index 000000000000..8c2629293acb --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminDeleteTrackingNumberActionGroup.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminDeleteTrackingNumberActionGroup"> + <arguments> + <argument name="message" type="string" defaultValue="Are you sure?"/> + </arguments> + + <click selector="{{AdminShipmentTrackingSection.deleteTrackingNumber}}" stepKey="clickDeleteButton"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <waitForElementVisible selector="{{AdminGridConfirmActionSection.message}}" stepKey="waitForConfirmModal"/> + <see selector="{{AdminGridConfirmActionSection.message}}" userInput="{{message}}" stepKey="seeRemoveMessage"/> + <click selector="{{AdminGridConfirmActionSection.ok}}" stepKey="clickOkButton"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminSelectFirstGridRowActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminSelectFirstGridRowActionGroup.xml new file mode 100644 index 000000000000..fc30d752f201 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminSelectFirstGridRowActionGroup.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminSelectFirstGridRowActionGroup"> + <click selector="{{AdminDataGridTableSection.firstRow}}" stepKey="clickFirstRowInGrid"/> + <waitForPageLoad stepKey="waitToProcessPageToLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminShipmentActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminShipmentActionGroup.xml index e9809ae0f3e7..631db885ab3d 100644 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminShipmentActionGroup.xml +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminShipmentActionGroup.xml @@ -62,4 +62,24 @@ <seeInCurrentUrl url="{{AdminOrderDetailsPage.url}}" stepKey="seeViewOrderPageShipping"/> <see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created." stepKey="seeShipmentCreateSuccess"/> </actionGroup> + <actionGroup name="AdminShipmentCreateShippingLabelActionGroup"> + <arguments> + <argument name="productName" type="string" defaultValue="{{SimpleProduct.name}}"/> + </arguments> + <waitForElementVisible selector="{{AdminShipmentCreatePackageMainSection.addProductsToPackage}}" stepKey="waitForAddProductElement"/> + <click selector="{{AdminShipmentCreatePackageMainSection.addProductsToPackage}}" stepKey="clickAddProducts"/> + <waitForElementVisible selector="{{AdminShipmentCreatePackageProductGridSection.concreteProductCheckbox('productName')}}" stepKey="waitForProductBeVisible"/> + <checkOption selector="{{AdminShipmentCreatePackageProductGridSection.concreteProductCheckbox('productName')}}" stepKey="checkProductCheckbox"/> + <waitForElementVisible selector="{{AdminShipmentCreatePackageMainSection.addSelectedProductToPackage}}" stepKey="waitForAddSelectedProductElement"/> + <click selector="{{AdminShipmentCreatePackageMainSection.addSelectedProductToPackage}}" stepKey="clickAddSelectedProduct"/> + <waitForElementNotVisible selector="{{AdminShipmentCreatePackageMainSection.saveButtonDisabled}}" stepKey="waitForBeEnabled"/> + <click selector="{{AdminShipmentCreatePackageMainSection.save}}" stepKey="clickSave"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskDisappear"/> + <waitForPageLoad stepKey="waitForSaving"/> + <see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created. You created the shipping label." stepKey="seeShipmentCreateSuccess"/> + </actionGroup> + <actionGroup name="AdminGoToShipmentTabActionGroup"> + <click selector="{{AdminOrderDetailsOrderViewSection.shipments}}" stepKey="clickOrderShipmentsTab"/> + <waitForLoadingMaskToDisappear stepKey="waitForShipmentTabLoad" after="clickOrderShipmentsTab"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/StorefrontSetShippingMethodActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/StorefrontSetShippingMethodActionGroup.xml new file mode 100644 index 000000000000..7fdfe6d88b8e --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/StorefrontSetShippingMethodActionGroup.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontSetShippingMethodActionGroup"> + <annotations> + <description>Selects the provided Shipping Method on checkout shipping and wait loading mask.</description> + </annotations> + <arguments> + <argument name="shippingMethodName" type="string" defaultValue="Flat Rate"/> + </arguments> + <checkOption selector="{{CheckoutShippingMethodsSection.checkShippingMethodByName(shippingMethodName)}}" stepKey="selectFlatRateShippingMethod"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskForNextButton"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/Data/AdminShippingSettingsConfigData.xml b/app/code/Magento/Shipping/Test/Mftf/Data/AdminShippingSettingsConfigData.xml new file mode 100644 index 000000000000..ad366fd7294e --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Data/AdminShippingSettingsConfigData.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="AdminShippingSettingsOriginCountryConfigData"> + <data key="path">shipping/origin/country_id</data> + </entity> + <entity name="AdminShippingSettingsOriginZipCodeConfigData"> + <data key="path">shipping/origin/postcode</data> + </entity> + <entity name="AdminShippingSettingsOriginCityConfigData"> + <data key="path">shipping/origin/city</data> + </entity> + <entity name="AdminShippingSettingsOriginStreetAddressConfigData"> + <data key="path">shipping/origin/street_line1</data> + </entity> + <entity name="AdminShippingSettingsOriginStreetAddress2ConfigData"> + <data key="path">shipping/origin/street_line2</data> + </entity> +</entities> diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentCreatePackageSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentCreatePackageSection.xml new file mode 100644 index 000000000000..5f33921b5a44 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentCreatePackageSection.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShipmentCreatePackageMainSection"> + <element name="addProductsToPackage" type="button" selector="#package_block_1 button[data-action='package-add-items']"/> + <element name="addSelectedProductToPackage" type="button" selector="#package_block_1 button[data-action='package-save-items']"/> + <element name="save" type="button" selector="button[data-action='save-packages']"/> + <element name="saveButtonDisabled" type="button" selector="button[data-action='save-packages']._disabled"/> + </section> + <section name="AdminShipmentCreatePackageProductGridSection"> + <element name="concreteProductCheckbox" type="checkbox" selector="//td[contains(text(), '{{productName}}')]/parent::tr//input[contains(@class,'checkbox')]" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTotalSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTotalSection.xml index f2f39d77d8d7..d76ba0493829 100644 --- a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTotalSection.xml +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTotalSection.xml @@ -12,5 +12,6 @@ <element name="CommentText" type="textarea" selector="#shipment_comment_text"/> <element name="AppendComments" type="checkbox" selector=".order-totals input#notify_customer"/> <element name="EmailCopy" type="checkbox" selector=".order-totals input#send_email"/> + <element name="createShippingLabel" type="checkbox" selector="input#create_shipping_label"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingInformationShippingSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingInformationShippingSection.xml new file mode 100644 index 000000000000..bbb61ed013a3 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingInformationShippingSection.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShipmentTrackingInformationShippingSection"> + <element name="shippingInfoTable" type="block" selector="#shipment_tracking_info"/> + <element name="shippingMethod" type="text" selector="#shipment_tracking_info .odd .col-carrier"/> + <element name="shippingMethodTitle" type="text" selector="#shipment_tracking_info .odd .col-title"/> + <element name="shippingNumber" type="text" selector="#shipment_tracking_info .odd .col-number"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingSection.xml new file mode 100644 index 000000000000..52a5242f2d11 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentTrackingSection.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShipmentTrackingSection"> + <element name="trackingNumber" type="text" selector="#tracking-shipping-form #tracking_number"/> + <element name="trackingTitle" type="text" selector="#tracking-shipping-form #tracking_title"/> + <element name="addTrackingNumber" type="button" selector="#tracking-shipping-form button.save"/> + <element name="deleteTrackingNumber" type="button" selector="#tracking-shipping-form button.action-delete"/> + <element name="trackingInfoErrorElement" type="text" selector="#tracking-shipping-form #{{inputName}}-error" parameterized="true" /> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFlatRateSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFlatRateSection.xml index a7ed0ab498be..99c191a5225c 100644 --- a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFlatRateSection.xml +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFlatRateSection.xml @@ -11,5 +11,11 @@ <section name="AdminShippingMethodFlatRateSection"> <element name="carriersFlatRateTab" type="button" selector="#carriers_flatrate-head"/> <element name="carriersFlatRateActive" type="select" selector="#carriers_flatrate_active"/> + <element name="carriersEnableFlatRateActive" type="input" selector="#carriers_flatrate_active_inherit"/> + <element name="carriersFlatRateTitle" type="input" selector="#carriers_flatrate_title_inherit"/> + <element name="carriersFlatRateName" type="input" selector="#carriers_flatrate_name_inherit"/> + <element name="carriersFlatRateSpecificErrMsg" type="input" selector="#carriers_flatrate_specificerrmsg_inherit"/> + <element name="carriersFlatRateAllowSpecific" type="input" selector="#carriers_flatrate_sallowspecific_inherit"/> + <element name="carriersFlatRateSpecificCountry" type="input" selector="#carriers_flatrate_specificcountry"/> </section> </sections> diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFreeShippingSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFreeShippingSection.xml new file mode 100644 index 000000000000..bf8b5b9c3367 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodFreeShippingSection.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShippingMethodFreeShippingSection"> + <element name="carriersFreeShippingSectionHead" type="button" selector="#carriers_freeshipping-head"/> + <element name="carriersFreeShippingActive" type="input" selector="#carriers_freeshipping_active_inherit"/> + <element name="carriersFreeShippingTitle" type="input" selector="#carriers_freeshipping_title_inherit"/> + <element name="carriersFreeShippingName" type="input" selector="#carriers_freeshipping_name_inherit"/> + <element name="carriersFreeShippingSpecificErrMsg" type="input" selector="#carriers_freeshipping_specificerrmsg_inherit"/> + <element name="carriersFreeShippingAllowSpecific" type="input" selector="#carriers_freeshipping_sallowspecific_inherit"/> + <element name="carriersFreeShippingSpecificCountry" type="input" selector="#carriers_freeshipping_specificcountry"/> + </section> +</sections> diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodTableRatesSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodTableRatesSection.xml index 3c570201c997..944fc06047aa 100644 --- a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodTableRatesSection.xml +++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingMethodTableRatesSection.xml @@ -14,5 +14,13 @@ <element name="carriersTableRateActive" type="select" selector="#carriers_tablerate_active"/> <element name="condition" type="select" selector="#carriers_tablerate_condition_name"/> <element name="importFile" type="input" selector="#carriers_tablerate_import"/> + <element name="carriersTableRateTitle" type="input" selector="#carriers_tablerate_title_inherit"/> + <element name="carriersTableRateName" type="input" selector="#carriers_tablerate_name_inherit"/> + <element name="carriersTableRateConditionName" type="input" selector="#carriers_tablerate_condition_name_inherit"/> + <element name="carriersTableRateIncludeVirtualPrice" type="input" selector="#carriers_tablerate_include_virtual_price_inherit"/> + <element name="carriersTableRateHandlingType" type="input" selector="#carriers_tablerate_handling_type_inherit"/> + <element name="carriersTableRateSpecificErrMsg" type="input" selector="#carriers_tablerate_specificerrmsg_inherit"/> + <element name="carriersTableRateAllowSpecific" type="input" selector="#carriers_tablerate_sallowspecific_inherit"/> + <element name="carriersTableRateSpecificCountry" type="input" selector="#carriers_tablerate_specificcountry"/> </section> </sections> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml new file mode 100644 index 000000000000..0b7ddd0cfa78 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"> + <annotations> + <features value="Configuration"/> + <stories value="Disable configuration inputs"/> + <title value="Check that all input fields disabled after executing CLI app:config:dump"/> + <description value="Check that all input fields disabled after executing CLI app:config:dump"/> + <severity value="MAJOR"/> + <testCaseId value="MC-11158"/> + <useCaseId value="MAGETWO-96428"/> + <group value="configuration"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Assert configuration are disabled in Flat Rate section--> + <comment userInput="Assert configuration are disabled in Flat Rate section" stepKey="commentSeeDisabledFlatRateConfigs"/> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <conditionalClick selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateTab}}" dependentSelector="{{AdminShippingMethodFlatRateSection.carriersFlatRateActive}}" visible="false" stepKey="expandFlatRateTab"/> + <waitForElementVisible selector="{{AdminShippingMethodFlatRateSection.carriersEnableFlatRateActive}}" stepKey="waitForFlatRateTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersEnableFlatRateActive}}" userInput="disabled" stepKey="grabFlatRateActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateActiveDisabled" stepKey="assertFlatRateActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateTitle}}" userInput="disabled" stepKey="grabFlatRateTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateTitleDisabled" stepKey="assertFlatRateTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateName}}" userInput="disabled" stepKey="grabFlatRateNameDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateNameDisabled" stepKey="assertFlatRateNameDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateSpecificErrMsg}}" userInput="disabled" stepKey="grabFlatRateSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateSpecificErrMsgDisabled" stepKey="assertFlatRateSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateAllowSpecific}}" userInput="disabled" stepKey="grabFlatRateAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateAllowSpecificDisabled" stepKey="assertFlatRateAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFlatRateSection.carriersFlatRateSpecificCountry}}" userInput="disabled" stepKey="grabFlatRateSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFlatRateSpecificCountryDisabled" stepKey="assertFlatRateSpecificCountryDisabled"/> + <!--Assert configuration are disabled in Free Shipping section--> + <comment userInput="Assert configuration are disabled in Free Shipping section" stepKey="commentSeeDisabledFreeShippingConfigs"/> + <conditionalClick selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingSectionHead}}" dependentSelector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingActive}}" visible="false" stepKey="expandFreeShippingTab"/> + <waitForElementVisible selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingActive}}" stepKey="waitForFreeShippingTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingActive}}" userInput="disabled" stepKey="grabFreeShippingActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingActiveDisabled" stepKey="assertFreeShippingActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingTitle}}" userInput="disabled" stepKey="grabFreeShippingTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingTitleDisabled" stepKey="assertFreeShippingTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingName}}" userInput="disabled" stepKey="grabFreeShippingNameDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingNameDisabled" stepKey="assertFreeShippingNameDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingSpecificErrMsg}}" userInput="disabled" stepKey="grabFreeShippingSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingSpecificErrMsgDisabled" stepKey="assertFreeShippingSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingAllowSpecific}}" userInput="disabled" stepKey="grabFreeShippingAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingAllowSpecificDisabled" stepKey="assertFreeShippingAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodFreeShippingSection.carriersFreeShippingSpecificCountry}}" userInput="disabled" stepKey="grabFreeShippingSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabFreeShippingSpecificCountryDisabled" stepKey="assertFreeShippingSpecificCountryDisabled"/> + <!--Assert configuration are disabled in Table Rates section--> + <comment userInput="Assert configuration are disabled in Table Rates section" stepKey="commentSeeDisabledTableRatesConfigs"/> + <conditionalClick selector="{{AdminShippingMethodTableRatesSection.carriersTableRateTab}}" dependentSelector="{{AdminShippingMethodTableRatesSection.carriersTableRateActive}}" visible="false" stepKey="expandTableRateTab"/> + <waitForElementVisible selector="{{AdminShippingMethodTableRatesSection.enabledUseSystemValue}}" stepKey="waitForTableRateTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.enabledUseSystemValue}}" userInput="disabled" stepKey="grabTableRateActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateActiveDisabled" stepKey="assertTableRateActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateTitle}}" userInput="disabled" stepKey="grabTableRateTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateTitleDisabled" stepKey="assertTableRateTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateName}}" userInput="disabled" stepKey="grabTableRateNameDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateNameDisabled" stepKey="assertTableRateNameDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateConditionName}}" userInput="disabled" stepKey="grabTableRateConditionNameDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateConditionNameDisabled" stepKey="assertTableRateConditionNameDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateIncludeVirtualPrice}}" userInput="disabled" stepKey="grabTableRateIncludeVirtualPriceDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateIncludeVirtualPriceDisabled" stepKey="assertTableRateIncludeVirtualPriceDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateHandlingType}}" userInput="disabled" stepKey="grabTableRateHandlingTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateHandlingTypeDisabled" stepKey="assertTableRateHandlingTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateSpecificErrMsg}}" userInput="disabled" stepKey="grabTableRateSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateSpecificErrMsgDisabled" stepKey="assertTableRateSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateAllowSpecific}}" userInput="disabled" stepKey="grabTableRateAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateAllowSpecificDisabled" stepKey="assertTableRateAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodTableRatesSection.carriersTableRateSpecificCountry}}" userInput="disabled" stepKey="grabTableRateSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabTableRateSpecificCountryDisabled" stepKey="assertTableRateSpecificCountryDisabled"/> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckTheConfirmationPopupTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckTheConfirmationPopupTest.xml new file mode 100644 index 000000000000..87058245c601 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCheckTheConfirmationPopupTest.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckTheConfirmationPopupTest"> + <annotations> + <stories value="Admin confirmation modal should be in Magento style"/> + <title value="Admin confirmation modal should be in Magento style"/> + <description value="Testing the confirmation modal for removing the tracking number"/> + <severity value="CRITICAL"/> + <group value="shipping"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <createData entity="SimpleProduct2" stepKey="createSimpleProduct"/> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="CreateOrderActionGroup" stepKey="goToCreateOrderPage"> + <argument name="customer" value="$$createCustomer$$"/> + <argument name="product" value="$$createSimpleProduct$$"/> + </actionGroup> + <grabTextFrom selector="|Order # (\d+)|" stepKey="orderId"/> + <actionGroup ref="AdminShipThePendingOrderActionGroup" stepKey="createShipmentForOrder"/> + <actionGroup ref="FilterShipmentGridByOrderIdActionGroup" stepKey="filterForNewlyCreatedShipment"> + <argument name="orderId" value="$orderId"/> + </actionGroup> + <actionGroup ref="AdminSelectFirstGridRowActionGroup" stepKey="selectShipmentFromGrid"/> + <actionGroup ref="AdminAddTrackingNumberToShipmentActionGroup" stepKey="addTrackingNumber"> + <argument name="trackingNumber" value="123123"/> + </actionGroup> + <actionGroup ref="AdminDeleteTrackingNumberActionGroup" stepKey="deleteTrackingNumber"/> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateOrderCustomStoreShippingMethodTableRatesTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateOrderCustomStoreShippingMethodTableRatesTest.xml new file mode 100644 index 000000000000..b2e3e2516a5c --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateOrderCustomStoreShippingMethodTableRatesTest.xml @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateOrderCustomStoreShippingMethodTableRatesTest"> + <annotations> + <features value="Shipping"/> + <stories value="Shipping method Table Rates"/> + <title value="Create order on second store with shipping method Table Rates"/> + <description value="Create order on second store with shipping method Table Rates"/> + <severity value="MAJOR"/> + <testCaseId value="MC-6411"/> + <useCaseId value="MAGETWO-91702"/> + <group value="shipping"/> + </annotations> + <before> + <!--Create product and customer--> + <createData entity="SimpleProduct2" stepKey="createProduct"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create website, store group and store view--> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> + <argument name="newWebsiteName" value="{{customWebsite.name}}"/> + <argument name="websiteCode" value="{{customWebsite.code}}"/> + </actionGroup> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewStore"> + <argument name="website" value="{{customWebsite.name}}"/> + <argument name="storeGroupName" value="{{customStoreGroup.name}}"/> + <argument name="storeGroupCode" value="{{customStoreGroup.code}}"/> + </actionGroup> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createCustomStoreView"> + <argument name="StoreGroup" value="customStoreGroup"/> + <argument name="customStore" value="customStore"/> + </actionGroup> + <!--Create customer associated to website--> + <actionGroup ref="AdminGoCreatedWebsitePageActionGroup" stepKey="DeleteWebsite"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + </actionGroup> + <grabFromCurrentUrl regex="~/website_id/(\d+)/~" stepKey="grabWebsiteIdFromURL"/> + <createData entity="Simple_Customer_Without_Address" stepKey="createCustomer"> + <field key="website_id">$grabWebsiteIdFromURL</field> + </createData> + <!--Enable Table Rate method and import csv file--> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchDefaultWebsite"> + <argument name="website" value="_defaultWebsite"/> + </actionGroup> + <actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethodForDefaultWebsite"> + <argument name="status" value="0"/> + </actionGroup> + <actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfigForDefaultWebsite"/> + <actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="switchCustomWebsite"> + <argument name="website" value="customWebsite"/> + </actionGroup> + <actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethod"> + <argument name="status" value="1"/> + </actionGroup> + <actionGroup ref="AdminImportFileTableRatesShippingMethodActionGroup" stepKey="importCSVFile"> + <argument name="file" value="usa_tablerates.csv"/> + </actionGroup> + <actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + <after> + <!--Delete created data--> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Assign product to custom website--> + <amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="goToProductEditPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <actionGroup ref="unassignWebsiteFromProductActionGroup" stepKey="unassignWebsiteInProduct"> + <argument name="website" value="{{_defaultWebsite.name}}"/> + </actionGroup> + <actionGroup ref="SelectProductInWebsitesActionGroup" stepKey="selectWebsiteInProduct"> + <argument name="website" value="{{customWebsite.name}}"/> + </actionGroup> + <actionGroup ref="saveProductForm" stepKey="saveProduct"/> + <!--Create order--> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="navigateToNewOrderWithExistingCustomer"> + <argument name="customer" value="$$createCustomer$$"/> + <argument name="storeView" value="customStore"/> + </actionGroup> + <actionGroup ref="addSimpleProductToOrder" stepKey="addSimpleProductToTheOrder"> + <argument name="product" value="$$createProduct$$"/> + </actionGroup> + <actionGroup ref="fillOrderCustomerInformation" stepKey="fillCustomerInfo"> + <argument name="customer" value="$$createCustomer$$"/> + <argument name="address" value="US_Address_TX"/> + </actionGroup> + <!--Choose Best Way shipping Method--> + <actionGroup ref="AdminOrderSelectShippingMethodActionGroup" stepKey="chooseBestWayMethod"> + <argument name="methodTitle" value="bestway"/> + <argument name="methodName" value="tablerate"/> + </actionGroup> + <actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml new file mode 100644 index 000000000000..ca4d731eb82b --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminValidateShippingTrackingNumberTest"> + <annotations> + <stories value="Admin validate the shipping tracking number for an order"/> + <title value="Admin validate the shipping tracking number for an order"/> + <description value="Testing for a required tracking number when adding new shipping information"/> + <severity value="CRITICAL"/> + <group value="shipping"/> + </annotations> + <before> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <createData entity="SimpleProduct2" stepKey="createSimpleProduct"/> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <actionGroup ref="CreateOrderActionGroup" stepKey="goToCreateOrderPage"> + <argument name="customer" value="$$createCustomer$$"/> + <argument name="product" value="$$createSimpleProduct$$"/> + </actionGroup> + <grabTextFrom selector="|Order # (\d+)|" stepKey="orderId"/> + <actionGroup ref="AdminShipThePendingOrderActionGroup" stepKey="createShipmentForOrder"/> + <actionGroup ref="FilterShipmentGridByOrderIdActionGroup" stepKey="filterForNewlyCreatedShipment"> + <argument name="orderId" value="$orderId"/> + </actionGroup> + <actionGroup ref="AdminSelectFirstGridRowActionGroup" stepKey="selectShipmentFromGrid"/> + <actionGroup ref="AdminAddTrackingNumberToShipmentActionGroup" stepKey="addTrackingInformation"> + <argument name="trackingNumber" value=""/> + </actionGroup> + <actionGroup ref="AdminAssertTrackingValidationErrorActionGroup" stepKey="assertValidateTrackingNumber"> + <argument name="inputName" value="tracking_number"/> + </actionGroup> + <actionGroup ref="AdminAddTrackingNumberToShipmentActionGroup" stepKey="addTrackingNumber"> + <argument name="trackingNumber" value="123123"/> + </actionGroup> + <actionGroup ref="AdminAssertExistingTrackingNumberActionGroup" stepKey="checkAddedTrackingNumber"> + <argument name="trackingNumber" value="123123"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/StorefrontDisplayTableRatesShippingMethodForAETest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/StorefrontDisplayTableRatesShippingMethodForAETest.xml new file mode 100644 index 000000000000..bb29a4a28bcf --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/StorefrontDisplayTableRatesShippingMethodForAETest.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontDisplayTableRatesShippingMethodForAETest"> + <annotations> + <features value="Shipping"/> + <stories value="Table Rates"/> + <title value="Displaying of Table Rates for Armed Forces Europe (AE)"/> + <description value="Displaying of Table Rates for Armed Forces Europe (AE)"/> + <severity value="MAJOR"/> + <testCaseId value="MC-6405"/> + <group value="shipping"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Simple_US_Customer_ArmedForcesEurope" stepKey="createCustomer"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <!--Rollback config--> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodSystemConfigPage"/> + <actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreViewToMainWebsite"> + <argument name="website" value="_defaultWebsite"/> + </actionGroup> + <actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="disableTableRatesShippingMethod"> + <argument name="status" value="0"/> + </actionGroup> + <actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveSystemConfig"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--Admin Configuration: enable Table Rates and import CSV file with the rates--> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <actionGroup ref="AdminSwitchWebsiteActionGroup" stepKey="AdminSwitchStoreView"> + <argument name="website" value="_defaultWebsite"/> + </actionGroup> + <actionGroup ref="AdminChangeTableRatesShippingMethodStatusActionGroup" stepKey="enableTableRatesShippingMethod"/> + <attachFile selector="{{AdminShippingMethodTableRatesSection.importFile}}" userInput="tablerates.csv" stepKey="attachFileForImport"/> + <actionGroup ref="AdminSaveConfigActionGroup" stepKey="saveConfig"/> + <!--Login as created customer--> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + <!--Add the created product to the shopping cart--> + <actionGroup ref="AddSimpleProductToCart" stepKey="addProductToCart"> + <argument name="product" value="$$createProduct$$"/> + </actionGroup> + <!--Proceed to Checkout from the mini cart--> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart" /> + <!--Shipping Method: select table rate--> + <actionGroup ref="AssertStoreFrontShippingMethodAvailableActionGroup" stepKey="assertShippingMethodAvailable"> + <argument name="shippingMethodName" value="Best Way"/> + </actionGroup> + <actionGroup ref="StorefrontSetShippingMethodActionGroup" stepKey="setShippingMethodTableRate"> + <argument name="shippingMethodName" value="Best Way"/> + </actionGroup> + <!--Proceed to Review and Payments section--> + <click selector="{{CheckoutShippingSection.next}}" stepKey="clickToSaveShippingInfo"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskAfterClickNext"/> + <waitForPageLoad stepKey="waitForReviewAndPaymentsPageIsLoaded"/> + <!--Place order and assert the message of success--> + <actionGroup ref="ClickPlaceOrderActionGroup" stepKey="placeOrderProductSuccessful"/> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Unit/Model/ShippingTest.php b/app/code/Magento/Shipping/Test/Unit/Model/ShippingTest.php index 1df41aeba076..e5723c38ac56 100644 --- a/app/code/Magento/Shipping/Test/Unit/Model/ShippingTest.php +++ b/app/code/Magento/Shipping/Test/Unit/Model/ShippingTest.php @@ -3,12 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Shipping\Test\Unit\Model; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Type as ProductType; use Magento\CatalogInventory\Model\Stock\Item as StockItem; use Magento\CatalogInventory\Model\StockRegistry; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Quote\Model\Quote\Item as QuoteItem; use Magento\Shipping\Model\Carrier\AbstractCarrierInterface; use Magento\Shipping\Model\CarrierFactory; @@ -19,12 +21,14 @@ use PHPUnit_Framework_MockObject_MockObject as MockObject; /** - * @see Shipping + * Unit tests for \Magento\Shipping\Model\Shipping class. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ShippingTest extends \PHPUnit\Framework\TestCase { /** - * Test identification number of product + * Test identification number of product. * * @var int */ @@ -50,22 +54,34 @@ class ShippingTest extends \PHPUnit\Framework\TestCase */ private $carrier; + /** + * @var ScopeConfigInterface|MockObject + */ + private $scopeConfig; + + /** + * @inheritdoc + */ protected function setUp() { $this->stockRegistry = $this->createMock(StockRegistry::class); $this->stockItemData = $this->createMock(StockItem::class); + $this->scopeConfig = $this->createMock(ScopeConfigInterface::class); $this->shipping = (new ObjectManagerHelper($this))->getObject( Shipping::class, [ 'stockRegistry' => $this->stockRegistry, 'carrierFactory' => $this->getCarrierFactory(), + 'scopeConfig' => $this->scopeConfig, ] ); } /** + * Compose Packages For Carrier. * + * @return void */ public function testComposePackages() { @@ -125,14 +141,25 @@ function ($key) { /** * Active flag should be set before collecting carrier rates. + * + * @return void */ public function testCollectCarrierRatesSetActiveFlag() { + $carrierCode = 'carrier'; + $scopeStore = 'store'; + $this->scopeConfig->expects($this->once()) + ->method('isSetFlag') + ->with( + 'carriers/' . $carrierCode . '/active', + $scopeStore + ) + ->willReturn(true); $this->carrier->expects($this->atLeastOnce()) ->method('setActiveFlag') ->with('active'); - $this->shipping->collectCarrierRates('carrier', new RateRequest()); + $this->shipping->collectCarrierRates($carrierCode, new RateRequest()); } /** diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup.phtml index cd25cb919adb..28322d953492 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/order/packaging/popup.phtml @@ -31,7 +31,7 @@ $girthEnabled = $block->isDisplayGirthValue() && $block->isGirthAllowed() ? 1 : packaging.sendCreateLabelRequest(); }); packaging.setLabelCreatedCallback(function(response){ - setLocation("<?php $block->escapeJs($block->escapeUrl($block->getUrl( + setLocation("<?= $block->escapeJs($block->escapeUrl($block->getUrl( 'sales/order/view', ['order_id' => $block->getShipment()->getOrderId()] ))); ?>"); diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking/view.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking/view.phtml index 67587f19774c..a013abfd65f8 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking/view.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/order/tracking/view.phtml @@ -9,84 +9,102 @@ ?> <?php /** @var $block Magento\Shipping\Block\Adminhtml\Order\Tracking\View */ ?> <div class="admin__control-table-wrapper"> - <table class="data-table admin__control-table" id="shipment_tracking_info"> - <thead> - <tr class="headings"> - <th class="col-carrier"><?= $block->escapeHtml(__('Carrier')) ?></th> - <th class="col-title"><?= $block->escapeHtml(__('Title')) ?></th> - <th class="col-number"><?= $block->escapeHtml(__('Number')) ?></th> - <th class="col-delete last"><?= $block->escapeHtml(__('Action')) ?></th> - </tr> - </thead> - <tfoot> - <tr> - <td class="col-carrier"> - <select name="carrier" - class="select admin__control-select" - onchange="selectCarrier(this)"> - <?php foreach ($block->getCarriers() as $_code => $_name) : ?> - <option value="<?= $block->escapeHtmlAttr($_code) ?>"><?= $block->escapeHtml($_name) ?></option> - <?php endforeach; ?> - </select> - </td> - <td class="col-title"> - <input class="input-text admin__control-text" - type="text" - id="tracking_title" - name="title" - value="" /> - </td> - <td class="col-number"> - <input class="input-text admin__control-text" - type="text" - id="tracking_number" - name="number" - value="" /> - </td> - <td class="col-delete last"><?= $block->getSaveButtonHtml() ?></td> - </tr> - </tfoot> - <?php if ($_tracks = $block->getShipment()->getAllTracks()) : ?> - <tbody> - <?php $i = 0; foreach ($_tracks as $_track) :$i++ ?> - <tr class="<?= /* @noEscape */ ($i%2 == 0) ? 'even' : 'odd' ?>"> - <td class="col-carrier"> - <?= $block->escapeHtml($block->getCarrierTitle($_track->getCarrierCode())) ?> - </td> - <td class="col-title"><?= $block->escapeHtml($_track->getTitle()) ?></td> - <td class="col-number"> - <?php if ($_track->isCustom()) : ?> - <?= $block->escapeHtml($_track->getNumber()) ?> - <?php else : ?> - <a href="#" onclick="popWin('<?= $block->escapeJs($block->escapeUrl($this->helper(Magento\Shipping\Helper\Data::class)->getTrackingPopupUrlBySalesModel($_track))) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')"><?= $block->escapeHtml($_track->getNumber()) ?></a> - <div id="shipment_tracking_info_response_<?= (int) $_track->getId() ?>"></div> - <?php endif; ?> - </td> - <td class="col-delete last"><button class="action-delete" type="button" onclick="deleteTrackingNumber('<?= $block->escapeJs($block->escapeUrl($block->getRemoveUrl($_track))) ?>'); return false;"><span><?= $block->escapeHtml(__('Delete')) ?></span></button></td> - </tr> - <?php endforeach; ?> - </tbody> - <?php endif; ?> - </table> + <form id="tracking-shipping-form" data-mage-init='{"validation": {}}'> + <table class="data-table admin__control-table" id="shipment_tracking_info"> + <thead> + <tr class="headings"> + <th class="col-carrier"><?= $block->escapeHtml(__('Carrier')) ?></th> + <th class="col-title"><?= $block->escapeHtml(__('Title')) ?></th> + <th class="col-number"><?= $block->escapeHtml(__('Number')) ?></th> + <th class="col-delete last"><?= $block->escapeHtml(__('Action')) ?></th> + </tr> + </thead> + <tfoot> + <tr> + <td class="col-carrier"> + <select name="carrier" + class="select admin__control-select" + onchange="selectCarrier(this)"> + <?php foreach ($block->getCarriers() as $_code => $_name) : ?> + <option value="<?= $block->escapeHtmlAttr($_code) ?>"><?= $block->escapeHtml($_name) ?></option> + <?php endforeach; ?> + </select> + </td> + <td class="col-title"> + <input class="input-text admin__control-text" + type="text" + id="tracking_title" + name="title" + value="" /> + </td> + <td class="col-number"> + <input class="input-text admin__control-text required-entry" + type="text" + id="tracking_number" + name="number" + value="" /> + </td> + <td class="col-delete last"><?= $block->getSaveButtonHtml() ?></td> + </tr> + </tfoot> + <?php if ($_tracks = $block->getShipment()->getAllTracks()) : ?> + <tbody> + <?php $i = 0; foreach ($_tracks as $_track) :$i++ ?> + <tr class="<?= /* @noEscape */ ($i%2 == 0) ? 'even' : 'odd' ?>"> + <td class="col-carrier"> + <?= $block->escapeHtml($block->getCarrierTitle($_track->getCarrierCode())) ?> + </td> + <td class="col-title"><?= $block->escapeHtml($_track->getTitle()) ?></td> + <td class="col-number"> + <?php if ($_track->isCustom()) : ?> + <?= $block->escapeHtml($_track->getNumber()) ?> + <?php else : ?> + <a href="#" onclick="popWin('<?= $block->escapeJs($block->escapeUrl($this->helper(Magento\Shipping\Helper\Data::class)->getTrackingPopupUrlBySalesModel($_track))) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')"><?= $block->escapeHtml($_track->getNumber()) ?></a> + <div id="shipment_tracking_info_response_<?= (int) $_track->getId() ?>"></div> + <?php endif; ?> + </td> + <td class="col-delete last"><button class="action-delete" type="button" onclick="deleteTrackingNumber('<?= $block->escapeJs($block->escapeUrl($block->getRemoveUrl($_track))) ?>'); return false;"><span><?= $block->escapeHtml(__('Delete')) ?></span></button></td> + </tr> + <?php endforeach; ?> + </tbody> + <?php endif; ?> + </table> + </form> </div> <script> -require(['prototype'], function(){ - +require(['prototype', 'jquery', 'Magento_Ui/js/modal/confirm'], function(prototype, $j, confirm) { //<![CDATA[ function selectCarrier(elem) { var option = elem.options[elem.selectedIndex]; $('tracking_title').value = option.value && option.value != 'custom' ? option.text : ''; } -function deleteTrackingNumber(url) { - if (confirm('<?= $block->escapeJs($block->escapeHtml(__('Are you sure?'))) ?>')) { - submitAndReloadArea($('shipment_tracking_info').parentNode, url) +function saveTrackingInfo(node, url) { + var form = $j('#tracking-shipping-form'); + + if (form.validation() && form.validation('isValid')) { + submitAndReloadArea(node, url); } } +function deleteTrackingNumber(url) { + confirm({ + content: '<?= $block->escapeJs($block->escapeHtml(__('Are you sure?'))) ?>', + actions: { + /** + * Confirm action. + */ + confirm: function () { + submitAndReloadArea($('shipment_tracking_info').parentNode, url); + } + } + }); +} + window.selectCarrier = selectCarrier; window.deleteTrackingNumber = deleteTrackingNumber; +window.saveTrackingInfo = saveTrackingInfo; //]]> }); diff --git a/app/code/Magento/Shipping/view/adminhtml/templates/view/form.phtml b/app/code/Magento/Shipping/view/adminhtml/templates/view/form.phtml index f10556215108..44fe4b9ccd35 100644 --- a/app/code/Magento/Shipping/view/adminhtml/templates/view/form.phtml +++ b/app/code/Magento/Shipping/view/adminhtml/templates/view/form.phtml @@ -85,7 +85,7 @@ $order = $block->getShipment()->getOrder(); window.packaging.sendCreateLabelRequest(); }); window.packaging.setLabelCreatedCallback(function () { - setLocation("<?php $block->escapeUrl($block->getUrl('adminhtml/order_shipment/view', ['shipment_id' => $block->getShipment()->getId()])); ?>"); + setLocation("<?= $block->escapeUrl($block->getUrl('adminhtml/order_shipment/view', ['shipment_id' => $block->getShipment()->getId()])); ?>"); }); }; diff --git a/app/code/Magento/Shipping/view/frontend/templates/items.phtml b/app/code/Magento/Shipping/view/frontend/templates/items.phtml index f0f1423ed47a..177628c6b201 100644 --- a/app/code/Magento/Shipping/view/frontend/templates/items.phtml +++ b/app/code/Magento/Shipping/view/frontend/templates/items.phtml @@ -15,8 +15,9 @@ <?= $block->getChildHtml('track-all-link') ?> <?php endif; ?> <a href="<?= $block->escapeUrl($block->getPrintAllShipmentsUrl($_order)) ?>" - onclick="this.target='_blank'" - class="action print"> + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print All Shipments')) ?></span> </a> </div> @@ -24,8 +25,9 @@ <div class="order-title"> <strong><?= $block->escapeHtml(__('Shipment #')) ?><?= $block->escapeHtml($_shipment->getIncrementId()) ?></strong> <a href="<?= $block->escapeUrl($block->getPrintShipmentUrl($_shipment)) ?>" - onclick="this.target='_blank'" - class="action print"> + class="action print" + target="_blank" + rel="noopener"> <span><?= $block->escapeHtml(__('Print Shipment')) ?></span> </a> <a href="#" diff --git a/app/code/Magento/Signifyd/Model/CaseSearchResults.php b/app/code/Magento/Signifyd/Model/CaseSearchResults.php new file mode 100644 index 000000000000..ff1ab8839f6c --- /dev/null +++ b/app/code/Magento/Signifyd/Model/CaseSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Signifyd\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Signifyd\Api\Data\CaseSearchResultsInterface; + +/** + * Service Data Object with Case entities search results. + */ +class CaseSearchResults extends SearchResults implements CaseSearchResultsInterface +{ +} diff --git a/app/code/Magento/Signifyd/etc/di.xml b/app/code/Magento/Signifyd/etc/di.xml index c586019ca3d1..e82e8f84b358 100644 --- a/app/code/Magento/Signifyd/etc/di.xml +++ b/app/code/Magento/Signifyd/etc/di.xml @@ -9,7 +9,7 @@ <preference for="Magento\Signifyd\Api\Data\CaseInterface" type="Magento\Signifyd\Model\CaseEntity" /> <preference for="Magento\Signifyd\Api\CaseRepositoryInterface" type="Magento\Signifyd\Model\CaseRepository" /> <preference for="Magento\Signifyd\Api\CaseManagementInterface" type="Magento\Signifyd\Model\CaseManagement" /> - <preference for="Magento\Signifyd\Api\Data\CaseSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Signifyd\Api\Data\CaseSearchResultsInterface" type="Magento\Signifyd\Model\CaseSearchResults" /> <preference for="Magento\Signifyd\Api\CaseCreationServiceInterface" type="Magento\Signifyd\Model\CaseServices\CreationService" /> <preference for="Magento\Signifyd\Api\GuaranteeCreationServiceInterface" type="Magento\Signifyd\Model\Guarantee\CreationService" /> <preference for="Magento\Signifyd\Api\GuaranteeCancelingServiceInterface" type="Magento\Signifyd\Model\Guarantee\CancelingService" /> diff --git a/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php b/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php index 77ccce5d23bd..f73287111406 100644 --- a/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php +++ b/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php @@ -44,6 +44,7 @@ public function __construct( /** * Return whole scopes config data from db. + * * Ignore $path argument due to config source must return all config data * * @param string $path @@ -64,6 +65,8 @@ public function get($path = '') } /** + * Retrieve default connection + * * @return AdapterInterface */ private function getConnection() @@ -83,12 +86,17 @@ private function getConnection() */ private function getEntities($table, $keyField) { - $entities = $this->getConnection()->fetchAll( - $this->getConnection()->select()->from($this->resourceConnection->getTableName($table)) - ); $data = []; - foreach ($entities as $entity) { - $data[$entity[$keyField]] = $entity; + $tableName = $this->resourceConnection->getTableName($table); + // Check if db table exists before fetch data + if ($this->resourceConnection->getConnection()->isTableExists($tableName)) { + $entities = $this->getConnection()->fetchAll( + $this->getConnection()->select()->from($tableName) + ); + + foreach ($entities as $entity) { + $data[$entity[$keyField]] = $entity; + } } return $data; diff --git a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php index 5df50581792c..de2da5442382 100644 --- a/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php +++ b/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php @@ -5,6 +5,9 @@ */ namespace Magento\Store\App\FrontController\Plugin; +/** + * Class RequestPreprocessor + */ class RequestPreprocessor { /** @@ -52,6 +55,7 @@ public function __construct( /** * Auto-redirect to base url (without SID) if the requested url doesn't match it. + * * By default this feature is enabled in configuration. * * @param \Magento\Framework\App\FrontController $subject @@ -72,10 +76,11 @@ public function aroundDispatch( $this->_storeManager->getStore()->isCurrentlySecure() ); if ($baseUrl) { + // phpcs:disable Magento2.Functions.DiscouragedFunction $uri = parse_url($baseUrl); if (!$this->getBaseUrlChecker()->execute($uri, $request)) { $redirectUrl = $this->_url->getRedirectUrl( - $this->_url->getUrl(ltrim($request->getPathInfo(), '/'), ['_nosid' => true]) + $this->_url->getDirectUrl(ltrim($request->getPathInfo(), '/'), ['_nosid' => true]) ); $redirectCode = (int)$this->_scopeConfig->getValue( 'web/url/redirect_to_base', diff --git a/app/code/Magento/Store/Controller/Store/SwitchRequest.php b/app/code/Magento/Store/Controller/Store/SwitchRequest.php new file mode 100644 index 000000000000..9ce151bdab09 --- /dev/null +++ b/app/code/Magento/Store/Controller/Store/SwitchRequest.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Store\Controller\Store; + +use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Action\HttpGetActionInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Store\Model\StoreSwitcher\HashGenerator; +use Magento\Customer\Api\CustomerRepositoryInterface; +use \Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Url\DecoderInterface; +use \Magento\Framework\App\ActionInterface; +use Magento\Store\Model\StoreSwitcher\HashGenerator\HashData; + +/** + * Builds correct url to target store and performs redirect. + */ +class SwitchRequest extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface +{ + + /** + * @var customerSession + */ + private $customerSession; + + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + + /** + * @var HashGenerator + */ + private $hashGenerator; + + /** + * @var DecoderInterface + */ + private $urlDecoder; + + /** + * @param Context $context + * @param CustomerSession $session + * @param CustomerRepositoryInterface $customerRepository + * @param HashGenerator $hashGenerator + * @param DecoderInterface $urlDecoder + */ + public function __construct( + Context $context, + CustomerSession $session, + CustomerRepositoryInterface $customerRepository, + HashGenerator $hashGenerator, + DecoderInterface $urlDecoder + ) { + parent::__construct($context); + $this->customerSession = $session; + $this->customerRepository = $customerRepository; + $this->hashGenerator = $hashGenerator; + $this->urlDecoder = $urlDecoder; + } + + /** + * Execute action + * + * @return void + */ + public function execute() + { + $fromStoreCode = (string)$this->_request->getParam('___from_store'); + $customerId = (int)$this->_request->getParam('customer_id'); + $timeStamp = (string)$this->_request->getParam('time_stamp'); + $signature = (string)$this->_request->getParam('signature'); + $error = null; + $encodedUrl = (string)$this->_request->getParam(ActionInterface::PARAM_NAME_URL_ENCODED); + $targetUrl = $this->urlDecoder->decode($encodedUrl); + + $data = new HashData( + [ + "customer_id" => $customerId, + "time_stamp" => $timeStamp, + "___from_store" => $fromStoreCode + ] + ); + + if ($targetUrl && $this->hashGenerator->validateHash($signature, $data)) { + try { + $customer = $this->customerRepository->getById($customerId); + if (!$this->customerSession->isLoggedIn()) { + $this->customerSession->setCustomerDataAsLoggedIn($customer); + } + $this->getResponse()->setRedirect($targetUrl); + } catch (NoSuchEntityException $e) { + $error = __('The requested customer does not exist.'); + } catch (LocalizedException $e) { + $error = __('There was an error retrieving the customer record.'); + } + } else { + $error = __('The requested store cannot be found. Please check the request and try again.'); + } + + if ($error !== null) { + $this->messageManager->addErrorMessage($error); + } + } +} diff --git a/app/code/Magento/Store/Model/Config/Placeholder.php b/app/code/Magento/Store/Model/Config/Placeholder.php index ca5d869d347a..be84c7f444c4 100644 --- a/app/code/Magento/Store/Model/Config/Placeholder.php +++ b/app/code/Magento/Store/Model/Config/Placeholder.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Store\Model\Config; /** @@ -32,8 +33,8 @@ class Placeholder */ public function __construct(\Magento\Framework\App\RequestInterface $request, $urlPaths, $urlPlaceholder) { - $this->request = $request; - $this->urlPaths = $urlPaths; + $this->request = $request; + $this->urlPaths = $urlPaths; $this->urlPlaceholder = $urlPlaceholder; } @@ -45,15 +46,46 @@ public function __construct(\Magento\Framework\App\RequestInterface $request, $u */ public function process(array $data = []) { - foreach (array_keys($data) as $key) { - $this->_processData($data, $key); + // check provided arguments + if (empty($data)) { + return []; + } + + // initialize $pointer, $parents and $level variable + reset($data); + $pointer = &$data; + $parents = []; + $level = 0; + + while ($level >= 0) { + $current = &$pointer[key($pointer)]; + if (is_array($current)) { + reset($current); + $parents[$level] = &$pointer; + $pointer = &$current; + $level++; + } else { + $current = $this->_processPlaceholders($current, $data); + + // move pointer of last queue layer to next element + // or remove layer if all path elements were processed + while ($level >= 0 && next($pointer) === false) { + $level--; + // removal of last element of $parents is skipped here for better performance + // on next iteration that element will be overridden + $pointer = &$parents[$level]; + } + } } + return $data; } /** * Process array data recursively * + * @deprecated This method isn't used in process() implementation anymore + * * @param array &$data * @param string $path * @return void @@ -90,7 +122,7 @@ protected function _processPlaceholders($value, $data) if ($url) { $value = str_replace('{{' . $placeholder . '}}', $url, $value); - } elseif (strpos($value, (string) $this->urlPlaceholder) !== false) { + } elseif (strpos($value, (string)$this->urlPlaceholder) !== false) { $distroBaseUrl = $this->request->getDistroBaseUrl(); $value = str_replace($this->urlPlaceholder, $distroBaseUrl, $value); @@ -113,10 +145,9 @@ protected function _getPlaceholder($value) { if (is_string($value) && preg_match('/{{(.*)}}.*/', $value, $matches)) { $placeholder = $matches[1]; - if ($placeholder == 'unsecure_base_url' || $placeholder == 'secure_base_url' || strpos( - $value, - (string) $this->urlPlaceholder - ) !== false + if ($placeholder == 'unsecure_base_url' || + $placeholder == 'secure_base_url' || + strpos($value, (string)$this->urlPlaceholder) !== false ) { return $placeholder; } @@ -147,6 +178,8 @@ protected function _getValue($path, array $data) /** * Set array value by path * + * @deprecated This method isn't used in process() implementation anymore + * * @param array &$container * @param string $path * @param string $value @@ -154,13 +187,13 @@ protected function _getValue($path, array $data) */ protected function _setValue(array &$container, $path, $value) { - $segments = explode('/', $path); - $currentPointer = & $container; + $segments = explode('/', $path); + $currentPointer = &$container; foreach ($segments as $segment) { if (!isset($currentPointer[$segment])) { $currentPointer[$segment] = []; } - $currentPointer = & $currentPointer[$segment]; + $currentPointer = &$currentPointer[$segment]; } $currentPointer = $value; } diff --git a/app/code/Magento/Store/Model/ResourceModel/Store.php b/app/code/Magento/Store/Model/ResourceModel/Store.php index 88d7b5d8216f..7a2821987f9b 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Store.php +++ b/app/code/Magento/Store/Model/ResourceModel/Store.php @@ -166,11 +166,16 @@ protected function _changeGroup(\Magento\Framework\Model\AbstractModel $model) */ public function readAllStores() { - $select = $this->getConnection() - ->select() - ->from($this->getTable('store')); + $stores = []; + if ($this->getConnection()->isTableExists($this->getMainTable())) { + $select = $this->getConnection() + ->select() + ->from($this->getTable($this->getMainTable())); - return $this->getConnection()->fetchAll($select); + $stores = $this->getConnection()->fetchAll($select); + } + + return $stores; } /** diff --git a/app/code/Magento/Store/Model/ResourceModel/Website.php b/app/code/Magento/Store/Model/ResourceModel/Website.php index d6fefd60ae54..431a9d62e7c3 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Website.php +++ b/app/code/Magento/Store/Model/ResourceModel/Website.php @@ -47,12 +47,15 @@ protected function _initUniqueFields() public function readAllWebsites() { $websites = []; - $select = $this->getConnection() - ->select() - ->from($this->getTable('store_website')); + $tableName = $this->getMainTable(); + if ($this->getConnection()->isTableExists($tableName)) { + $select = $this->getConnection() + ->select() + ->from($tableName); - foreach ($this->getConnection()->fetchAll($select) as $websiteData) { - $websites[$websiteData['code']] = $websiteData; + foreach ($this->getConnection()->fetchAll($select) as $websiteData) { + $websites[$websiteData['code']] = $websiteData; + } } return $websites; @@ -115,6 +118,7 @@ protected function _afterDelete(\Magento\Framework\Model\AbstractModel $model) /** * Retrieve default stores select object + * * Select fields website_id, store_id * * @param bool $includeDefault include/exclude default admin website diff --git a/app/code/Magento/Store/Model/ScopeTreeProvider.php b/app/code/Magento/Store/Model/ScopeTreeProvider.php index da772ec0410e..d15030fe88ac 100644 --- a/app/code/Magento/Store/Model/ScopeTreeProvider.php +++ b/app/code/Magento/Store/Model/ScopeTreeProvider.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Store\Model; use Magento\Framework\App\Config\ScopeConfigInterface; @@ -78,25 +80,30 @@ public function get() 'scopes' => [], ]; - /** @var Group $group */ - foreach ($groups[$website->getId()] as $group) { - $groupScope = [ - 'scope' => ScopeInterface::SCOPE_GROUP, - 'scope_id' => $group->getId(), - 'scopes' => [], - ]; - - /** @var Store $store */ - foreach ($stores[$group->getId()] as $store) { - $storeScope = [ - 'scope' => ScopeInterface::SCOPE_STORES, - 'scope_id' => $store->getId(), + if (!empty($groups[$website->getId()])) { + /** @var Group $group */ + foreach ($groups[$website->getId()] as $group) { + $groupScope = [ + 'scope' => ScopeInterface::SCOPE_GROUP, + 'scope_id' => $group->getId(), 'scopes' => [], ]; - $groupScope['scopes'][] = $storeScope; + + if (!empty($stores[$group->getId()])) { + /** @var Store $store */ + foreach ($stores[$group->getId()] as $store) { + $storeScope = [ + 'scope' => ScopeInterface::SCOPE_STORES, + 'scope_id' => $store->getId(), + 'scopes' => [], + ]; + $groupScope['scopes'][] = $storeScope; + } + } + $websiteScope['scopes'][] = $groupScope; } - $websiteScope['scopes'][] = $groupScope; } + $defaultScope['scopes'][] = $websiteScope; } diff --git a/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator.php b/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator.php new file mode 100644 index 000000000000..456941bd41c2 --- /dev/null +++ b/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator.php @@ -0,0 +1,121 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Store\Model\StoreSwitcher; + +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\StoreSwitcher\HashGenerator\HashData; +use Magento\Store\Model\StoreSwitcherInterface; +use \Magento\Framework\App\DeploymentConfig as DeploymentConfig; +use Magento\Framework\Url\Helper\Data as UrlHelper; +use Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Authorization\Model\UserContextInterface; +use \Magento\Framework\App\ActionInterface; + +/** + * Generate one time token and build redirect url + */ +class HashGenerator implements StoreSwitcherInterface +{ + /** + * @var \Magento\Framework\App\DeploymentConfig + */ + private $deploymentConfig; + + /** + * @var UrlHelper + */ + private $urlHelper; + + /** + * @var UserContextInterface + */ + private $currentUser; + + /** + * @param DeploymentConfig $deploymentConfig + * @param UrlHelper $urlHelper + * @param UserContextInterface $currentUser + */ + public function __construct( + DeploymentConfig $deploymentConfig, + UrlHelper $urlHelper, + UserContextInterface $currentUser + ) { + $this->deploymentConfig = $deploymentConfig; + $this->urlHelper = $urlHelper; + $this->currentUser = $currentUser; + } + + /** + * Builds redirect url with token + * + * @param StoreInterface $fromStore store where we came from + * @param StoreInterface $targetStore store where to go to + * @param string $redirectUrl original url requested for redirect after switching + * @return string redirect url + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function switch(StoreInterface $fromStore, StoreInterface $targetStore, string $redirectUrl): string + { + $targetUrl = $redirectUrl; + $customerId = null; + $encodedUrl = $this->urlHelper->getEncodedUrl($redirectUrl); + + if ($this->currentUser->getUserType() == UserContextInterface::USER_TYPE_CUSTOMER) { + $customerId = $this->currentUser->getUserId(); + } + + if ($customerId) { + // phpcs:ignore + $urlParts = parse_url($targetUrl); + $host = $urlParts['host']; + $scheme = $urlParts['scheme']; + $key = (string)$this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); + $timeStamp = time(); + $fromStoreCode = $fromStore->getCode(); + $data = implode(',', [$customerId, $timeStamp, $fromStoreCode]); + $signature = hash_hmac('sha256', $data, $key); + $targetUrl = $scheme . "://" . $host . '/stores/store/switchrequest'; + $targetUrl = $this->urlHelper->addRequestParam( + $targetUrl, + ['customer_id' => $customerId] + ); + $targetUrl = $this->urlHelper->addRequestParam($targetUrl, ['time_stamp' => $timeStamp]); + $targetUrl = $this->urlHelper->addRequestParam($targetUrl, ['signature' => $signature]); + $targetUrl = $this->urlHelper->addRequestParam($targetUrl, ['___from_store' => $fromStoreCode]); + $targetUrl = $this->urlHelper->addRequestParam( + $targetUrl, + [ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl] + ); + } + return $targetUrl; + } + + /** + * Validates one time token + * + * @param string $signature + * @param HashData $hashData + * @return bool + */ + public function validateHash(string $signature, HashData $hashData): bool + { + if (!empty($signature) && !empty($hashData)) { + $timeStamp = $hashData->getTimestamp(); + $fromStoreCode = $hashData->getFromStoreCode(); + $customerId = $hashData->getCustomerId(); + $value = implode(",", [$customerId, $timeStamp, $fromStoreCode]); + $key = (string)$this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); + + if (time() - $timeStamp <= 5 && hash_equals($signature, hash_hmac('sha256', $value, $key))) { + return true; + } + } + return false; + } +} diff --git a/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator/HashData.php b/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator/HashData.php new file mode 100644 index 000000000000..2d0068efbdd9 --- /dev/null +++ b/app/code/Magento/Store/Model/StoreSwitcher/HashGenerator/HashData.php @@ -0,0 +1,46 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Store\Model\StoreSwitcher\HashGenerator; + +use Magento\Framework\DataObject; + +/** + * HashData object for one time token + */ +class HashData extends DataObject +{ + /** + * Get CustomerId + * + * @return int + */ + public function getCustomerId(): int + { + return (int)$this->getData('customer_id'); + } + + /** + * Get Timestamp + * + * @return int + */ + public function getTimestamp(): int + { + return (int)$this->getData('time_stamp'); + } + + /** + * Get Fromstore + * + * @return string + */ + public function getFromStoreCode(): string + { + return (string)$this->getData('___from_store'); + } +} diff --git a/app/code/Magento/Store/Model/System/Store.php b/app/code/Magento/Store/Model/System/Store.php index cf75f26aed9b..744019b10724 100644 --- a/app/code/Magento/Store/Model/System/Store.php +++ b/app/code/Magento/Store/Model/System/Store.php @@ -152,6 +152,12 @@ public function getStoreValuesForForm($empty = false, $all = false) } } } + array_walk( + $options, + function (&$item) { + $item['__disableTmpl'] = true; + } + ); return $options; } diff --git a/app/code/Magento/Store/Setup/Patch/Data/DisableSid.php b/app/code/Magento/Store/Setup/Patch/Data/DisableSid.php new file mode 100644 index 000000000000..95df83043f15 --- /dev/null +++ b/app/code/Magento/Store/Setup/Patch/Data/DisableSid.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Setup\Patch\Data; + +use Magento\Framework\Setup\Patch\DataPatchInterface; +use Magento\Framework\Setup\Patch\PatchVersionInterface; +use \Magento\Framework\App\Config\MutableScopeConfigInterface; + +/** + * Disable default frontend SID + */ +class DisableSid implements DataPatchInterface, PatchVersionInterface +{ + + /** + * Config path for flag whether use SID on frontend + */ + const XML_PATH_USE_FRONTEND_SID = 'web/session/use_frontend_sid'; + + /** + * @var \Magento\Framework\App\Config\MutableScopeConfigInterface + */ + private $mutableScopeConfig; + + /** + * scope type + */ + const SCOPE_STORE = 'store'; + + /** + * Disable Sid constructor. + * + * @param MutableScopeConfigInterface $mutableScopeConfig + */ + public function __construct( + MutableScopeConfigInterface $mutableScopeConfig + ) { + $this->mutableScopeConfig = $mutableScopeConfig; + } + + /** + * @inheritdoc + */ + public function apply() + { + $this->mutableScopeConfig->setValue(self::XML_PATH_USE_FRONTEND_SID, 0, self::SCOPE_STORE); + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return []; + } + + /** + * @inheritdoc + */ + public static function getVersion() + { + return '2.0.0'; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminWebsitePageActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminWebsitePageActionGroup.xml new file mode 100644 index 000000000000..1a43ae1d2bbd --- /dev/null +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminWebsitePageActionGroup.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminGoCreatedWebsitePageActionGroup"> + <annotations> + <description>Filter website name in grid and go first found website page</description> + </annotations> + <arguments> + <argument name="websiteName" type="string" defaultValue="SecondWebsite"/> + </arguments> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillSearchWebsiteField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <see userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="verifyThatCorrectWebsiteFound"/> + <click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingStoreRow"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml index 1a1847bf3830..982d829b5715 100644 --- a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml +++ b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml @@ -11,6 +11,9 @@ <data key="code">default</data> <data key="is_active">1</data> </entity> + <entity name="DefaultAllStoreView" type="store"> + <data key="name">All Store Views</data> + </entity> <entity name="customStore" type="store"> <!--data key="group_id">customStoreGroup.id</data--> <data key="name" unique="suffix">store</data> @@ -194,4 +197,4 @@ <data key="name">third_store_view</data> <data key="code">third_store_view</data> </entity> -</entities> \ No newline at end of file +</entities> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml index ed879a82d3f5..e93fd62a7499 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml @@ -21,15 +21,7 @@ <createData stepKey="b2" entity="customStoreGroup"/> </before> <after> - <actionGroup ref="DeleteCustomStoreActionGroup" stepKey="deleteCustomStoreGroup"> - <argument name="storeGroupName" value="customStoreGroup.name" /> - </actionGroup> - <actionGroup ref="DeleteCustomStoreActionGroup" stepKey="deleteCustomStoreGroup2"> - <argument name="storeGroupName" value="customStoreGroup.name" /> - </actionGroup> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin1"/> diff --git a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php index ba06d191c9f7..a8f76d0a28fe 100644 --- a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php +++ b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php @@ -53,11 +53,11 @@ public function setUp() public function testGet() { - $this->deploymentConfig->expects($this->once()) + $this->deploymentConfig->expects($this->any()) ->method('get') ->with('db') ->willReturn(true); - $this->resourceConnection->expects($this->once())->method('getConnection')->willReturn($this->connection); + $this->resourceConnection->expects($this->any())->method('getConnection')->willReturn($this->connection); $selectMock = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock(); $selectMock->expects($this->any())->method('from')->willReturnSelf(); diff --git a/app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php b/app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php index e44eacc79b82..6e003e2e5627 100644 --- a/app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/Config/PlaceholderTest.php @@ -23,7 +23,7 @@ protected function setUp() { $this->_requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); $this->_requestMock->expects( - $this->once() + $this->any() )->method( 'getDistroBaseUrl' )->will( @@ -54,11 +54,27 @@ public function testProcess() ], 'path' => 'value', 'some_url' => '{{base_url}}some', + 'level1' => [ + 'level2' => [ + 'level3' => [ + // test that all levels are processed (i.e. implementation is not hardcoded to 3 levels) + 'level4' => '{{secure_base_url}}level4' + ] + ] + ] ]; $expectedResult = $data; $expectedResult['web']['unsecure']['base_link_url'] = 'http://localhost/website/de'; $expectedResult['web']['secure']['base_link_url'] = 'https://localhost/website/de'; + $expectedResult['level1']['level2']['level3']['level4'] = 'https://localhost/level4'; $expectedResult['some_url'] = 'http://localhost/some'; $this->assertEquals($expectedResult, $this->_model->process($data)); } + + public function testProcessEmptyArray() + { + $data = []; + $expectedResult = []; + $this->assertEquals($expectedResult, $this->_model->process($data)); + } } diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php new file mode 100644 index 000000000000..926764b98968 --- /dev/null +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php @@ -0,0 +1,190 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Test\Unit\Model\ResourceModel; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Select; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Model\ResourceModel\Store; +use Magento\Framework\DB\Adapter\AdapterInterface; + +class StoreTest extends \PHPUnit\Framework\TestCase +{ + /** @var Store */ + protected $model; + + /** + * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** @var Select | \PHPUnit_Framework_MockObject_MockObject */ + protected $select; + + /** + * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + public function setUp() + { + $objectManagerHelper = new ObjectManager($this); + $this->select = $this->createMock(Select::class); + $this->resourceMock = $this->createPartialMock( + ResourceConnection::class, + [ + 'getConnection', + 'getTableName' + ] + ); + $this->connectionMock = $this->createPartialMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, + [ + 'isTableExists', + 'select', + 'fetchAll', + 'fetchOne', + 'from', + 'getCheckSql', + 'where', + 'quoteIdentifier', + 'quote' + ] + ); + + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); + $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); + $configCacheTypeMock = $this->createMock('\Magento\Framework\App\Cache\Type\Config'); + $this->model = $objectManagerHelper->getObject( + Store::class, + [ + 'context' => $contextMock, + 'configCacheType' => $configCacheTypeMock + ] + ); + } + + public function testCountAll($countAdmin = false) + { + $mainTable = 'store'; + $tableIdentifier = 'code'; + $tableIdentifierValue = 'admin'; + $count = 1; + + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->willReturn($this->select); + + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->select->expects($this->once()) + ->method('from') + ->with($mainTable, 'COUNT(*)') + ->willReturnSelf(); + + $this->connectionMock->expects($this->any()) + ->method('quoteIdentifier') + ->with($tableIdentifier) + ->willReturn($tableIdentifier); + + $this->connectionMock->expects($this->once()) + ->method('quote') + ->with($tableIdentifierValue) + ->willReturn($tableIdentifierValue); + + $this->select->expects($this->any()) + ->method('where') + ->with(sprintf('%s <> %s', $tableIdentifier, $tableIdentifierValue)) + ->willReturnSelf(); + + $this->connectionMock->expects($this->once()) + ->method('fetchOne') + ->with($this->select) + ->willReturn($count); + + $this->assertEquals($count, $this->model->countAll($countAdmin)); + } + + public function testReadAllStores() + { + $mainTable = 'store'; + $data = [ + ["store_id" => "0", "code" => "admin", "website_id" => 0, "name" => "Admin"], + ["store_id" => "1", "code" => "default", "website_id" => 1, "name" => "Default Store View"] + ]; + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->connectionMock->expects($this->once()) + ->method('isTableExists') + ->with($mainTable) + ->willReturn(true); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->willReturn($this->select); + + $this->select->expects($this->once()) + ->method('from') + ->with($mainTable) + ->willReturnSelf(); + + $this->connectionMock->expects($this->once()) + ->method('fetchAll') + ->with($this->select) + ->willReturn($data); + + $this->assertEquals($data, $this->model->readAllStores()); + } + + public function testReadAllStoresNoDbTable() + { + $mainTable = 'no_store_table'; + $data = []; + + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->connectionMock->expects($this->once()) + ->method('isTableExists') + ->with($mainTable) + ->willReturn(false); + + $this->connectionMock->expects($this->never()) + ->method('select') + ->willReturn($this->select); + + $this->select->expects($this->never()) + ->method('from') + ->with($mainTable) + ->willReturnSelf(); + + $this->connectionMock->expects($this->never()) + ->method('fetchAll') + ->with($this->select) + ->willReturn($data); + + $this->assertEquals($data, $this->model->readAllStores()); + } +} diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php new file mode 100644 index 000000000000..5fd5aa09a46b --- /dev/null +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php @@ -0,0 +1,217 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Store\Test\Unit\Model\ResourceModel; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Select; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Store\Model\ResourceModel\Website; + +class WebsiteTest extends \PHPUnit\Framework\TestCase +{ + /** @var Website */ + protected $model; + + /** + * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourceMock; + + /** @var Select | \PHPUnit_Framework_MockObject_MockObject */ + protected $select; + + /** + * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connectionMock; + + public function setUp() + { + $objectManagerHelper = new ObjectManager($this); + $this->select = $this->createMock(\Magento\Framework\DB\Select::class); + $this->resourceMock = $this->createPartialMock( + ResourceConnection::class, + [ + 'getConnection', + 'getTableName' + ] + ); + $this->connectionMock = $this->createPartialMock( + \Magento\Framework\DB\Adapter\Pdo\Mysql::class, + [ + 'isTableExists', + 'select', + 'fetchAll', + 'fetchOne', + 'from', + 'getCheckSql', + 'joinLeft', + 'where' + ] + ); + $contextMock = $this->createMock(\Magento\Framework\Model\ResourceModel\Db\Context::class); + $contextMock->expects($this->once())->method('getResources')->willReturn($this->resourceMock); + $this->model = $objectManagerHelper->getObject( + Website::class, + [ + 'context' => $contextMock + ] + ); + } + + public function testReadAllWebsites() + { + $data = [ + "admin" => ["website_id" => "0", "code" => "admin", "name" => "Admin"], + "base" => ["website_id" => "1", "code" => "base", "name" => "Main Website"] + ]; + $mainTable = 'store_website'; + + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->once()) + ->method('isTableExists') + ->with($mainTable) + ->willReturn(true); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->willReturn($this->select); + + $this->select->expects($this->once()) + ->method('from') + ->with($mainTable) + ->willReturnSelf(); + + $this->connectionMock->expects($this->once()) + ->method('fetchAll') + ->with($this->select) + ->willReturn($data); + + $this->assertEquals($data, $this->model->readAllWebsites()); + } + + public function testReadAllWebsitesNoDbTable() + { + $data = []; + $mainTable = 'no_store_website_table'; + + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->once()) + ->method('isTableExists') + ->with($mainTable) + ->willReturn(false); + + $this->connectionMock->expects($this->never()) + ->method('select') + ->willReturn($this->select); + + $this->select->expects($this->never()) + ->method('from') + ->with($mainTable) + ->willReturnSelf(); + + $this->connectionMock->expects($this->never()) + ->method('fetchAll') + ->with($this->select) + ->willReturn($data); + + $this->assertEquals($data, $this->model->readAllWebsites()); + } + + public function testGetDefaultStoresSelect($includeDefault = false) + { + $storeId = 1; + $storeWebsiteTable = 'store_website'; + $storeGroupTable = 'store_group'; + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->once()) + ->method('getCheckSql') + ->with( + 'store_group_table.default_store_id IS NULL', + '0', + 'store_group_table.default_store_id' + ) + ->willReturn($storeId); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->willReturn($this->select); + + $this->resourceMock->expects($this->atLeastOnce()) + ->method('getTableName') + ->withConsecutive([$storeWebsiteTable], [$storeGroupTable]) + ->willReturnOnConsecutiveCalls($storeWebsiteTable, $storeGroupTable); + + $this->select->expects($this->once()) + ->method('from') + ->with( + ['website_table' => $storeWebsiteTable], + ['website_id'] + ) + ->willReturnSelf(); + + $this->select->expects($this->once()) + ->method('joinLeft') + ->with( + ['store_group_table' => $storeGroupTable], + 'website_table.website_id=store_group_table.website_id' . + ' AND website_table.default_group_id = store_group_table.group_id', + ['store_id' => $storeId] + ) + ->willReturnSelf(); + + $this->assertInstanceOf('\Magento\Framework\DB\Select', $this->model->getDefaultStoresSelect($includeDefault)); + } + + public function testCountAll($includeDefault = false) + { + $count = 2; + $mainTable = 'store_website'; + + $this->resourceMock->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->connectionMock->expects($this->once()) + ->method('select') + ->willReturn($this->select); + + $this->resourceMock->expects($this->once()) + ->method('getTableName') + ->willReturn($mainTable); + + $this->select->expects($this->once()) + ->method('from') + ->with($mainTable, 'COUNT(*)') + ->willReturnSelf(); + + $this->connectionMock->expects($this->once()) + ->method('fetchOne') + ->with($this->select) + ->willReturn($count); + + $this->assertEquals($count, $this->model->countAll($includeDefault)); + } +} diff --git a/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php index 9cc4bb6ac8e5..6befb28e3538 100644 --- a/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/System/StoreTest.php @@ -6,6 +6,9 @@ namespace Magento\Store\Test\Unit\Model\System; +/** + * Class StoreTest covers Magento\Store\Model\System\Store. + */ class StoreTest extends \PHPUnit\Framework\TestCase { /** @@ -262,14 +265,15 @@ public function getStoreValuesForFormDataProvider() 'storeGroupId' => $groupId, 'groupWebsiteId' => $websiteId, 'expectedResult' => [ - ['label' => '', 'value' => ''], - ['label' => __('All Store Views'), 'value' => 0], - ['label' => $websiteName, 'value' => []], + ['label' => '', 'value' => '','__disableTmpl' => true], + ['label' => __('All Store Views'), 'value' => 0,'__disableTmpl' => true], + ['label' => $websiteName, 'value' => [],'__disableTmpl' => true], [ 'label' => str_repeat($nonEscapableNbspChar, 4) . $groupName, 'value' => [ ['label' => str_repeat($nonEscapableNbspChar, 4) . $storeName, 'value' => $storeId] - ] + ], + '__disableTmpl' => true ], ] ], diff --git a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php index 1fc13390e30b..907eb74e20fa 100644 --- a/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php +++ b/app/code/Magento/Store/Ui/Component/Listing/Column/Store/Options.php @@ -68,6 +68,26 @@ public function toOptionArray() return $this->options; } + /** + * Sanitize website/store option name + * + * @param string $name + * + * @return string + */ + protected function sanitizeName($name) + { + $matches = []; + preg_match('/\$[:]*{(.)*}/', $name, $matches); + if (count($matches) > 0) { + $name = $this->escaper->escapeHtml($this->escaper->escapeJs($name)); + } else { + $name = $this->escaper->escapeHtml($name); + } + + return $name; + } + /** * Generate current options * @@ -88,20 +108,20 @@ protected function generateCurrentOptions() /** @var \Magento\Store\Model\Store $store */ foreach ($storeCollection as $store) { if ($store->getGroupId() == $group->getId()) { - $name = $this->escaper->escapeHtml($store->getName()); + $name = $this->sanitizeName($store->getName()); $stores[$name]['label'] = str_repeat(' ', 8) . $name; $stores[$name]['value'] = $store->getId(); } } if (!empty($stores)) { - $name = $this->escaper->escapeHtml($group->getName()); + $name = $this->sanitizeName($group->getName()); $groups[$name]['label'] = str_repeat(' ', 4) . $name; $groups[$name]['value'] = array_values($stores); } } } if (!empty($groups)) { - $name = $this->escaper->escapeHtml($website->getName()); + $name = $this->sanitizeName($website->getName()); $this->currentOptions[$name]['label'] = $name; $this->currentOptions[$name]['value'] = array_values($groups); } diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index bb7c33be7056..1ca87ec068d4 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -12,6 +12,8 @@ "magento/module-directory": "*", "magento/module-media-storage": "*", "magento/module-ui": "*", + "magento/module-customer": "*", + "magento/module-authorization": "*", "magento/module-backend": "*" }, "suggest": { diff --git a/app/code/Magento/Store/etc/config.xml b/app/code/Magento/Store/etc/config.xml index b9e7ac1c6aca..07e4c8b0b652 100644 --- a/app/code/Magento/Store/etc/config.xml +++ b/app/code/Magento/Store/etc/config.xml @@ -83,7 +83,7 @@ <use_http_via>0</use_http_via> <use_http_x_forwarded_for>0</use_http_x_forwarded_for> <use_http_user_agent>0</use_http_user_agent> - <use_frontend_sid>1</use_frontend_sid> + <use_frontend_sid>0</use_frontend_sid> </session> <browser_capabilities> <cookies>1</cookies> @@ -135,14 +135,14 @@ </protected_extensions> <public_files_valid_paths> <protected> - <app>/app/*/*</app> - <bin>/bin/*/*</bin> - <dev>/dev/*/*</dev> - <generated>/generated/*/*</generated> - <lib>/lib/*/*</lib> - <setup>/setup/*/*</setup> - <update>/update/*/*</update> - <vendor>/vendor/*/*</vendor> + <app>*/app/*/*</app> + <bin>*/bin/*/*</bin> + <dev>*/dev/*/*</dev> + <generated>*/generated/*/*</generated> + <lib>*/lib/*/*</lib> + <setup>*/setup/*/*</setup> + <update>*/update/*/*</update> + <vendor>*/vendor/*/*</vendor> </protected> </public_files_valid_paths> </file> diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index defe0694d018..62f6f4142402 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -436,6 +436,7 @@ <item name="cleanTargetUrl" xsi:type="object">Magento\Store\Model\StoreSwitcher\CleanTargetUrl</item> <item name="manageStoreCookie" xsi:type="object">Magento\Store\Model\StoreSwitcher\ManageStoreCookie</item> <item name="managePrivateContent" xsi:type="object">Magento\Store\Model\StoreSwitcher\ManagePrivateContent</item> + <item name="hashGenerator" xsi:type="object">Magento\Store\Model\StoreSwitcher\HashGenerator</item> </argument> </arguments> </type> diff --git a/app/code/Magento/Store/etc/frontend/sections.xml b/app/code/Magento/Store/etc/frontend/sections.xml index b1a9fc3cb1d7..b7dbfe405263 100644 --- a/app/code/Magento/Store/etc/frontend/sections.xml +++ b/app/code/Magento/Store/etc/frontend/sections.xml @@ -8,4 +8,5 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd"> <action name="stores/store/switch"/> + <action name="stores/store/switchrequest"/> </config> diff --git a/app/code/Magento/Swatches/Observer/AddFieldsToAttributeObserver.php b/app/code/Magento/Swatches/Observer/AddFieldsToAttributeObserver.php index 3ef202af95a1..303f1eda2e40 100644 --- a/app/code/Magento/Swatches/Observer/AddFieldsToAttributeObserver.php +++ b/app/code/Magento/Swatches/Observer/AddFieldsToAttributeObserver.php @@ -6,7 +6,7 @@ namespace Magento\Swatches\Observer; use Magento\Config\Model\Config\Source; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Event\Observer as EventObserver; use Magento\Framework\Event\ObserverInterface; @@ -21,15 +21,15 @@ class AddFieldsToAttributeObserver implements ObserverInterface protected $yesNo; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Source\Yesno $yesNo */ - public function __construct(ModuleManagerInterface $moduleManager, Source\Yesno $yesNo) + public function __construct(Manager $moduleManager, Source\Yesno $yesNo) { $this->moduleManager = $moduleManager; $this->yesNo = $yesNo; diff --git a/app/code/Magento/Swatches/Observer/AddSwatchAttributeTypeObserver.php b/app/code/Magento/Swatches/Observer/AddSwatchAttributeTypeObserver.php index ca75da332169..fb8c185cc545 100644 --- a/app/code/Magento/Swatches/Observer/AddSwatchAttributeTypeObserver.php +++ b/app/code/Magento/Swatches/Observer/AddSwatchAttributeTypeObserver.php @@ -6,7 +6,7 @@ namespace Magento\Swatches\Observer; use Magento\Config\Model\Config\Source; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\Event\Observer as EventObserver; use Magento\Framework\Event\ObserverInterface; @@ -16,14 +16,14 @@ class AddSwatchAttributeTypeObserver implements ObserverInterface { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; /** - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager */ - public function __construct(ModuleManagerInterface $moduleManager) + public function __construct(Manager $moduleManager) { $this->moduleManager = $moduleManager; } diff --git a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml index 8b95b86065b7..4a67c0dfbe8e 100644 --- a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml +++ b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml @@ -85,6 +85,15 @@ <selectOption selector="{{AdminNewAttributePanel.useInProductListing}}" stepKey="switchOnUsedInProductListing" userInput="Yes" after="switchOnVisibleOnCatalogPagesOnStorefront"/> </actionGroup> + <actionGroup name="AddVisualSwatchWithProductWithStorefrontPreviewImageConfigActionGroup" extends="AddVisualSwatchToProductActionGroup"> + <selectOption selector="{{AdminNewAttributePanel.updateProductPreviewImage}}" userInput="Yes" stepKey="selectUpdatePreviewImage" after="selectInputType"/> + <click selector="{{AdminNewAttributePanel.storefrontPropertiesTab}}" stepKey="goToStorefrontPropertiesTab" after="fillDefaultStoreLabel2"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.storefrontPropertiesTitle}}" after="goToStorefrontPropertiesTab" stepKey="waitTabLoad"/> + <selectOption selector="{{AdminNewAttributePanel.useInLayeredNavigation}}" userInput="Filterable (with results)" stepKey="selectUseInLayer" after="waitTabLoad"/> + <selectOption selector="{{AdminNewAttributePanel.useInProductListing}}" userInput="Yes" stepKey="switchOnUsedInProductListing" after="selectUseInLayer"/> + <selectOption selector="{{AdminNewAttributePanel.usedForStoringInProductListing}}" userInput="Yes" stepKey="switchOnUsedForStoringInProductListing" after="switchOnUsedInProductListing"/> + </actionGroup> + <actionGroup name="AddTextSwatchToProductActionGroup"> <annotations> <description>Add text swatch property attribute.</description> diff --git a/app/code/Magento/Swatches/Test/Mftf/Section/AdminNewAttributePanelSection.xml b/app/code/Magento/Swatches/Test/Mftf/Section/AdminNewAttributePanelSection.xml index 0c2dea5f4123..5149fa3a1e51 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Section/AdminNewAttributePanelSection.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Section/AdminNewAttributePanelSection.xml @@ -9,6 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminNewAttributePanel"> + <element name="updateProductPreviewImage" type="select" selector="#update_product_preview_image"/> <element name="addVisualSwatchOption" type="button" selector="button#add_new_swatch_visual_option_button"/> <element name="addTextSwatchOption" type="button" selector="button#add_new_swatch_text_option_button"/> <element name="visualSwatchOptionAdminValue" type="input" selector="[data-role='swatch-visual-options-container'] input[name='optionvisual[value][option_{{row}}][0]']" parameterized="true"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateTextSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateTextSwatchTest.xml index 3ef347b7aca1..87d3f0bb5bcb 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateTextSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateTextSwatchTest.xml @@ -22,7 +22,7 @@ <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Create a new product attribute of type "Text Swatch" --> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchTest.xml index 90e94466351b..65f0e2b09b82 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCreateVisualSwatchTest.xml @@ -35,7 +35,7 @@ <waitForPageLoad stepKey="waitToClickSave"/> <click selector="{{AttributePropertiesSection.SaveAndEdit}}" stepKey="clickSaveAndEdit"/> <!-- Logout --> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Go to the edit page for the "color" attribute --> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml index 470421776cf8..1bcdd6fcf9a3 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml @@ -29,6 +29,9 @@ <fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('3')}}" userInput="123456789012345678901" stepKey="fillSwatch3" after="clickAddSwatch3"/> <fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('3')}}" userInput="123456789012345678901BrownD" stepKey="fillDescription3" after="fillSwatch3"/> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <see selector="{{StorefrontCategorySidebarSection.attributeNthOption(ProductAttributeFrontendLabel.label, '3')}}" userInput="123456789012345678901" stepKey="seeGreen" after="seeBlue"/> <see selector="{{StorefrontCategorySidebarSection.attributeNthOption(ProductAttributeFrontendLabel.label, '4')}}" userInput="123456789012345678901" stepKey="seeBrown" after="seeGreen"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml index b1ae06428c0a..c9602ddcd127 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml @@ -30,7 +30,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Begin creating a new product attribute --> @@ -103,6 +103,9 @@ <argument name="image" value="TestImageAdobe"/> </actionGroup> + <!-- Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml index 28df5ffd5343..7bf63d25417e 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml @@ -28,7 +28,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Begin creating a new product attribute --> @@ -82,6 +82,9 @@ <argument name="attributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> </actionGroup> + <!--Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml index d12cb0433fed..fd38c4891941 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml @@ -30,7 +30,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <!-- Begin creating a new product attribute --> @@ -94,6 +94,9 @@ <argument name="attributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> </actionGroup> + <!-- Run re-index task--> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml new file mode 100644 index 000000000000..292801166286 --- /dev/null +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontImageColorWhenFilterByColorFilterTest"> + <annotations> + <features value="Swatches"/> + <stories value="Color image when filtering by color filter"/> + <title value="Image color when filtering by color filter on the Storefront"/> + <description value="Image color when filtering by color filter on the Storefront"/> + <severity value="MAJOR"/> + <useCaseId value="MC-18821"/> + <testCaseId value="MC-11531"/> + <group value="Swatches"/> + </annotations> + <before> + <!--Create category and configurable product with two options--> + <createData entity="ApiCategory" stepKey="createCategory"/> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <actionGroup ref="deleteProductAttributeByLabel" stepKey="deleteAttribute"> + <argument name="ProductAttribute" value="visualSwatchAttribute"/> + </actionGroup> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="openProductIndexPage"/> + <actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearGridFilter"/> + <actionGroup ref="adminDataGridSelectPerPage" stepKey="selectNumberOfProductsPerPage"> + <argument name="perPage" value="100"/> + </actionGroup> + <actionGroup ref="deleteProductsIfTheyExist" stepKey="deleteAllProducts"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <amOnPage url="{{AdminProductEditPage.url($$createConfigProduct.id$$)}}" stepKey="navigateToConfigProductPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <!--Create visual swatch attribute--> + <actionGroup ref="AddVisualSwatchWithProductWithStorefrontPreviewImageConfigActionGroup" stepKey="addSwatchToProduct"> + <argument name="attribute" value="visualSwatchAttribute"/> + <argument name="option1" value="visualSwatchOption1"/> + <argument name="option2" value="visualSwatchOption2"/> + </actionGroup> + <click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="clickEditConfigurations"/> + <see userInput="Select Attributes" selector="{{AdminProductFormConfigurationsSection.stepsWizardTitle}}" stepKey="seeStepTitle"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/> + <!--Add images to product attribute options--> + <actionGroup ref="addUniqueImageToConfigurableProductOption" stepKey="addImageToConfigurableProductOptionOne"> + <argument name="image" value="MagentoLogo"/> + <argument name="frontend_label" value="{{visualSwatchAttribute.default_label}}"/> + <argument name="label" value="{{visualSwatchOption1.default_label}}"/> + </actionGroup> + <actionGroup ref="addUniqueImageToConfigurableProductOption" stepKey="addImageToConfigurableProductOptionTwo"> + <argument name="image" value="TestImageNew"/> + <argument name="frontend_label" value="{{visualSwatchAttribute.default_label}}"/> + <argument name="label" value="{{visualSwatchOption2.default_label}}"/> + </actionGroup> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnGenerateProductsButton"/> + <actionGroup ref="saveProductForm" stepKey="saveProductForm"/> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + + <!--Select any option in the Layered navigation and verify product image--> + <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage"/> + <actionGroup ref="SelectStorefrontSideBarAttributeOption" stepKey="selectStorefrontProductAttributeOption"> + <argument name="categoryName" value="$$createCategory.name$$"/> + <argument name="attributeDefaultLabel" value="{{visualSwatchAttribute.default_label}}"/> + </actionGroup> + <waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionByLabel(visualSwatchOption1.default_label)}}" stepKey="waitForOption"/> + <click selector="{{StorefrontCategorySidebarSection.filterOptionByLabel(visualSwatchOption1.default_label)}}" stepKey="clickFirstOption"/> + <grabAttributeFrom selector="{{StorefrontCategoryMainSection.productImage}}" userInput="src" stepKey="grabFirstOptionImg"/> + <assertContains expectedType="string" expected="{{MagentoLogo.filename}}" actualType="variable" actual="$grabFirstOptionImg" stepKey="assertProductFirstOptionImage"/> + <click selector="{{StorefrontCategorySidebarSection.removeFilter}}" stepKey="removeSideBarFilter"/> + <actionGroup ref="SelectStorefrontSideBarAttributeOption" stepKey="selectStorefrontProductAttributeForSecondOption"> + <argument name="categoryName" value="$$createCategory.name$$"/> + <argument name="attributeDefaultLabel" value="{{visualSwatchAttribute.default_label}}"/> + </actionGroup> + <waitForElementVisible selector="{{StorefrontCategorySidebarSection.filterOptionByLabel(visualSwatchOption2.default_label)}}" stepKey="waitForSecondOption"/> + <click selector="{{StorefrontCategorySidebarSection.filterOptionByLabel(visualSwatchOption2.default_label)}}" stepKey="clickSecondOption"/> + <grabAttributeFrom selector="{{StorefrontCategoryMainSection.productImage}}" userInput="src" stepKey="grabSecondOptionImg"/> + <assertContains expectedType="string" expected="{{TestImageNew.filename}}" actualType="variable" actual="$grabSecondOptionImg" stepKey="assertProductSecondOptionImage"/> + </test> +</tests> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml index 7ef030ef8dfa..5e712ebc3829 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml @@ -26,7 +26,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php b/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php index f8ba5c20250a..45c680366264 100644 --- a/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Observer/AddFieldsToAttributeObserverTest.php @@ -10,7 +10,7 @@ */ class AddFieldsToAttributeObserverTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; /** @var \Magento\Config\Model\Config\Source\Yesno|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php b/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php index 24afa1045e5c..f78797d93cb0 100644 --- a/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Observer/AddSwatchAttributeTypeObserverTest.php @@ -10,7 +10,7 @@ */ class AddSwatchAttributeTypeObserverTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index a7bafb6bca50..250141a942b1 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -840,7 +840,10 @@ define([ */ _Rewind: function (controls) { controls.find('div[option-id], option[option-id]').removeClass('disabled').removeAttr('disabled'); - controls.find('div[option-empty], option[option-empty]').attr('disabled', true).addClass('disabled'); + controls.find('div[option-empty], option[option-empty]') + .attr('disabled', true) + .addClass('disabled') + .attr('tabindex', '-1'); }, /** @@ -1265,7 +1268,10 @@ define([ dataMergeStrategy: this.options.gallerySwitchStrategy }); } - gallery.first(); + + if (gallery) { + gallery.first(); + } } else if (justAnImage && justAnImage.img) { context.find('.product-image-photo').attr('src', justAnImage.img); } diff --git a/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php b/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php index bba9bc3f3ebe..913fa4c46f0a 100644 --- a/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php +++ b/app/code/Magento/Tax/Model/App/Action/ContextPlugin.php @@ -34,7 +34,7 @@ class ContextPlugin /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManager; @@ -50,15 +50,15 @@ class ContextPlugin * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Tax\Model\Calculation\Proxy $calculation * @param \Magento\Tax\Helper\Data $taxHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\PageCache\Model\Config $cacheConfig */ public function __construct( \Magento\Customer\Model\Session $customerSession, \Magento\Framework\App\Http\Context $httpContext, - \Magento\Tax\Model\Calculation\Proxy $calculation, + \Magento\Tax\Model\Calculation\Proxy $calculation, //phpcs:ignore Magento2.Classes.DiscouragedDependencies \Magento\Tax\Helper\Data $taxHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\PageCache\Model\Config $cacheConfig ) { $this->customerSession = $customerSession; diff --git a/app/code/Magento/Tax/Model/TaxClassSearchResults.php b/app/code/Magento/Tax/Model/TaxClassSearchResults.php new file mode 100644 index 000000000000..4e92fd10a3de --- /dev/null +++ b/app/code/Magento/Tax/Model/TaxClassSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tax\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Tax\Api\Data\TaxClassSearchResultsInterface; + +/** + * Service Data Object with Tax Class search results. + */ +class TaxClassSearchResults extends SearchResults implements TaxClassSearchResultsInterface +{ +} diff --git a/app/code/Magento/Tax/Model/TaxRateSearchResults.php b/app/code/Magento/Tax/Model/TaxRateSearchResults.php new file mode 100644 index 000000000000..80e9b5eaa72f --- /dev/null +++ b/app/code/Magento/Tax/Model/TaxRateSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tax\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Tax\Api\Data\TaxRateSearchResultsInterface; + +/** + * Service Data Object with Tax Rate search results. + */ +class TaxRateSearchResults extends SearchResults implements TaxRateSearchResultsInterface +{ +} diff --git a/app/code/Magento/Tax/Model/TaxRuleSearchResults.php b/app/code/Magento/Tax/Model/TaxRuleSearchResults.php new file mode 100644 index 000000000000..aa70b31ab22a --- /dev/null +++ b/app/code/Magento/Tax/Model/TaxRuleSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Tax\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Tax\Api\Data\TaxRuleSearchResultsInterface; + +/** + * Service Data Object with Tax Rule search results. + */ +class TaxRuleSearchResults extends SearchResults implements TaxRuleSearchResultsInterface +{ +} diff --git a/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php b/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php index ef84eac32e95..cf5d939b35c0 100644 --- a/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php +++ b/app/code/Magento/Tax/Observer/AfterAddressSaveObserver.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Address; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\PageCache\Model\Config; use Magento\Tax\Api\TaxAddressManagerInterface; use Magento\Tax\Helper\Data; @@ -26,7 +26,7 @@ class AfterAddressSaveObserver implements ObserverInterface /** * Module manager * - * @var ModuleManagerInterface + * @var Manager */ private $moduleManager; @@ -46,13 +46,13 @@ class AfterAddressSaveObserver implements ObserverInterface /** * @param Data $taxHelper - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Config $cacheConfig * @param TaxAddressManagerInterface $addressManager */ public function __construct( Data $taxHelper, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, Config $cacheConfig, TaxAddressManagerInterface $addressManager ) { diff --git a/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php b/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php index 00b3a9f9e09a..c1e4ad66d75d 100644 --- a/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php +++ b/app/code/Magento/Tax/Observer/CustomerLoggedInObserver.php @@ -9,7 +9,7 @@ use Magento\Customer\Model\Session; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\PageCache\Model\Config; use Magento\Tax\Api\TaxAddressManagerInterface; use Magento\Tax\Helper\Data; @@ -33,7 +33,7 @@ class CustomerLoggedInObserver implements ObserverInterface /** * Module manager * - * @var ModuleManagerInterface + * @var Manager */ private $moduleManager; @@ -60,7 +60,7 @@ class CustomerLoggedInObserver implements ObserverInterface * @param GroupRepositoryInterface $groupRepository * @param Session $customerSession * @param Data $taxHelper - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Config $cacheConfig * @param TaxAddressManagerInterface $addressManager */ @@ -68,7 +68,7 @@ public function __construct( GroupRepositoryInterface $groupRepository, Session $customerSession, Data $taxHelper, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, Config $cacheConfig, TaxAddressManagerInterface $addressManager ) { diff --git a/app/code/Magento/Tax/Test/Unit/App/Action/ContextPluginTest.php b/app/code/Magento/Tax/Test/Unit/App/Action/ContextPluginTest.php index 020baa0c30ec..a6c7e9bb8685 100644 --- a/app/code/Magento/Tax/Test/Unit/App/Action/ContextPluginTest.php +++ b/app/code/Magento/Tax/Test/Unit/App/Action/ContextPluginTest.php @@ -38,7 +38,7 @@ class ContextPluginTest extends \PHPUnit\Framework\TestCase /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManagerMock; @@ -89,7 +89,7 @@ protected function setUp() ) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php b/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php index 2e957e528e29..571cc7173bc9 100644 --- a/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php +++ b/app/code/Magento/Tax/Test/Unit/Observer/AfterAddressSaveObserverTest.php @@ -6,7 +6,7 @@ namespace Magento\Tax\Test\Unit\Observer; use Magento\Framework\Event\Observer; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\PageCache\Model\Config; use Magento\Tax\Api\TaxAddressManagerInterface; @@ -31,7 +31,7 @@ class AfterAddressSaveObserverTest extends \PHPUnit\Framework\TestCase /** * Module manager * - * @var ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var Manager|\PHPUnit_Framework_MockObject_MockObject */ private $moduleManagerMock; @@ -65,7 +65,7 @@ protected function setUp() ->setMethods(['getCustomerAddress']) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); @@ -77,7 +77,7 @@ protected function setUp() ->setMethods(['isCatalogPriceDisplayAffectedByTax']) ->disableOriginalConstructor() ->getMock(); - + $this->addressManagerMock = $this->getMockBuilder(TaxAddressManagerInterface::class) ->setMethods(['setDefaultAddressAfterSave', 'setDefaultAddressAfterLogIn']) ->disableOriginalConstructor() diff --git a/app/code/Magento/Tax/Test/Unit/Observer/CustomerLoggedInObserverTest.php b/app/code/Magento/Tax/Test/Unit/Observer/CustomerLoggedInObserverTest.php index facbb6733b5c..c577f1727552 100644 --- a/app/code/Magento/Tax/Test/Unit/Observer/CustomerLoggedInObserverTest.php +++ b/app/code/Magento/Tax/Test/Unit/Observer/CustomerLoggedInObserverTest.php @@ -31,7 +31,7 @@ class CustomerLoggedInObserverTest extends \PHPUnit\Framework\TestCase /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManagerMock; @@ -82,7 +82,7 @@ protected function setUp() ) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml index 3b46b0f9e258..a0b43df226f2 100644 --- a/app/code/Magento/Tax/etc/di.xml +++ b/app/code/Magento/Tax/etc/di.xml @@ -37,8 +37,8 @@ </argument> </arguments> </type> - <preference for="Magento\Tax\Api\Data\TaxRateSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> - <preference for="Magento\Tax\Api\Data\TaxClassSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Tax\Api\Data\TaxRateSearchResultsInterface" type="Magento\Tax\Model\TaxRateSearchResults" /> + <preference for="Magento\Tax\Api\Data\TaxClassSearchResultsInterface" type="Magento\Tax\Model\TaxClassSearchResults" /> <preference for="Magento\Tax\Api\OrderTaxManagementInterface" type="Magento\Tax\Model\Sales\Order\TaxManagement" /> <preference for="Magento\Tax\Api\Data\OrderTaxDetailsAppliedTaxInterface" type="Magento\Tax\Model\Sales\Order\Tax" /> <preference for="Magento\Tax\Api\Data\OrderTaxDetailsInterface" type="Magento\Tax\Model\Sales\Order\Details" /> @@ -47,7 +47,7 @@ <preference for="Magento\Tax\Api\TaxClassRepositoryInterface" type="Magento\Tax\Model\TaxClass\Repository" /> <preference for="Magento\Tax\Api\Data\TaxClassInterface" type="Magento\Tax\Model\ClassModel" /> <preference for="Magento\Tax\Api\Data\TaxRuleInterface" type="Magento\Tax\Model\Calculation\Rule" /> - <preference for="Magento\Tax\Api\Data\TaxRuleSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Tax\Api\Data\TaxRuleSearchResultsInterface" type="Magento\Tax\Model\TaxRuleSearchResults" /> <preference for="Magento\Tax\Api\TaxRateManagementInterface" type="Magento\Tax\Model\TaxRateManagement" /> <preference for="Magento\Tax\Api\TaxRateRepositoryInterface" type="Magento\Tax\Model\Calculation\RateRepository" /> <preference for="Magento\Tax\Api\Data\TaxRateTitleInterface" type="Magento\Tax\Model\Calculation\Rate\Title" /> diff --git a/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml b/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml index 5dc1e5c72313..35bcfc265eaf 100644 --- a/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml +++ b/app/code/Magento/Tax/view/frontend/layout/sales_email_item_price.xml @@ -5,8 +5,7 @@ * See COPYING.txt for license details. */ --> -<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="items"> <block class="Magento\Tax\Block\Item\Price\Renderer" name="item_price" template="Magento_Tax::email/items/price/row.phtml"> @@ -16,11 +15,4 @@ </block> </referenceBlock> </body> -</page> - - - - - - - +</page> \ No newline at end of file diff --git a/app/code/Magento/TaxGraphQl/etc/schema.graphqls b/app/code/Magento/TaxGraphQl/etc/schema.graphqls index 2b8198347844..d0be08fe9a1b 100644 --- a/app/code/Magento/TaxGraphQl/etc/schema.graphqls +++ b/app/code/Magento/TaxGraphQl/etc/schema.graphqls @@ -2,5 +2,5 @@ # See COPYING.txt for license details. enum PriceAdjustmentCodesEnum { - TAX + TAX @deprecated(reason: "PriceAdjustmentCodesEnum is deprecated. Tax is included or excluded in price. Tax is not shown separtely in Catalog") } diff --git a/app/code/Magento/Theme/Model/Design/BackendModelFactory.php b/app/code/Magento/Theme/Model/Design/BackendModelFactory.php index 155afa89c417..df4ad381ca0d 100644 --- a/app/code/Magento/Theme/Model/Design/BackendModelFactory.php +++ b/app/code/Magento/Theme/Model/Design/BackendModelFactory.php @@ -3,6 +3,9 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +declare(strict_types=1); + namespace Magento\Theme\Model\Design; use Magento\Framework\App\Config\Value; @@ -11,6 +14,9 @@ use Magento\Theme\Model\Design\Config\MetadataProvider; use Magento\Theme\Model\ResourceModel\Design\Config\CollectionFactory; +/** + * Class BackendModelFactory + */ class BackendModelFactory extends ValueFactory { /** @@ -58,13 +64,15 @@ public function __construct( */ public function create(array $data = []) { + $storedData = $this->getStoredData($data['scope'], $data['scopeId'], $data['config']['path']); + $backendModelData = array_replace_recursive( - $this->getStoredData($data['scope'], $data['scopeId'], $data['config']['path']), + $storedData, [ 'path' => $data['config']['path'], 'scope' => $data['scope'], 'scope_id' => $data['scopeId'], - 'field_config' => $data['config'], + 'field_config' => $data['config'] ] ); @@ -76,6 +84,13 @@ public function create(array $data = []) $backendModel = $this->getNewBackendModel($backendType, $backendModelData); $backendModel->setValue($data['value']); + if ($storedData) { + foreach ($storedData as $key => $value) { + $backendModel->setOrigData($key, $value); + } + $backendModel->setOrigData('field_config', $data['config']); + } + return $backendModel; } @@ -166,9 +181,12 @@ protected function getMetadata() { if (!$this->metadata) { $this->metadata = $this->metadataProvider->get(); - array_walk($this->metadata, function (&$value) { - $value = $value['path']; - }); + array_walk( + $this->metadata, + function (&$value) { + $value = $value['path']; + } + ); } return $this->metadata; } diff --git a/app/code/Magento/Theme/Model/Design/Config/ValueChecker.php b/app/code/Magento/Theme/Model/Design/Config/ValueChecker.php index 42801f57c882..11d45616e387 100644 --- a/app/code/Magento/Theme/Model/Design/Config/ValueChecker.php +++ b/app/code/Magento/Theme/Model/Design/Config/ValueChecker.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Config as AppConfig; use Magento\Framework\App\ScopeFallbackResolverInterface; +/** + * Class ValueChecker + */ class ValueChecker { /** @@ -61,7 +64,7 @@ public function isDifferentFromDefault($value, $scope, $scopeId, array $fieldCon $fieldConfig ), $this->valueProcessor->process( - $this->appConfig->getValue($fieldConfig['path'], $scope, $scopeId), + ($this->appConfig->getValue($fieldConfig['path'], $scope, $scopeId) ?? ""), $scope, $scopeId, $fieldConfig @@ -80,12 +83,11 @@ public function isDifferentFromDefault($value, $scope, $scopeId, array $fieldCon */ protected function isEqual($value, $defaultValue) { - switch (gettype($value)) { - case 'array': - return $this->isEqualArrays($value, $defaultValue); - default: - return $value === $defaultValue; + if (is_array($value)) { + return $this->isEqualArrays($value, $defaultValue); } + + return $value === $defaultValue; } /** diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminWatermarkUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminWatermarkUploadTest.xml index a667f40ad327..afe70243f602 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminWatermarkUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminWatermarkUploadTest.xml @@ -16,6 +16,9 @@ <description value="Watermark images should be able to be uploaded in the admin"/> <severity value="MAJOR"/> <testCaseId value="MC-5796"/> + <skip> + <issueId value="MC-18496"/> + </skip> <group value="Watermark"/> </annotations> <before> diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 2ac959d0a988..22cc1c9e89fb 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -9,6 +9,9 @@ use Magento\Store\Model\ScopeInterface; use Magento\Theme\Ui\Component\Listing\Column\EditAction; +/** + * Class EditActionTest + */ class EditActionTest extends \PHPUnit\Framework\TestCase { /** @var EditAction */ @@ -64,6 +67,7 @@ public function testPrepareDataSource($dataSourceItem, $scope, $scopeId) 'edit' => [ 'href' => 'http://magento.com/theme/design_config/edit', 'label' => new \Magento\Framework\Phrase('Edit'), + '__disableTmpl' => true, ] ], ]; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 03d1fe70f2f0..5e2fe5104388 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -99,20 +99,52 @@ public function getPrepareDataSourceDataProvider() { return [ [ - ['name' => 'itemName', 'config' => []], - [['itemName' => '', 'entity_id' => 1]], - [['itemName' => ['view' => ['href' => 'url', 'label' => __('View')]], 'entity_id' => 1]], + [ + 'name' => 'itemName', + 'config' => [] + ], + [ + ['itemName' => '', 'entity_id' => 1] + ], + [ + [ + 'itemName' => [ + 'view' => [ + 'href' => 'url', + 'label' => __('View'), + '__disableTmpl' => true, + ] + ], + 'entity_id' => 1 + ] + ], '#', ['id' => 1] ], [ - ['name' => 'itemName', 'config' => [ - 'viewUrlPath' => 'url_path', - 'urlEntityParamName' => 'theme_id', - 'indexField' => 'theme_id'] + [ + 'name' => 'itemName', + 'config' => [ + 'viewUrlPath' => 'url_path', + 'urlEntityParamName' => 'theme_id', + 'indexField' => 'theme_id' + ] + ], + [ + ['itemName' => '', 'theme_id' => 2] + ], + [ + [ + 'itemName' => [ + 'view' => [ + 'href' => 'url', + 'label' => __('View'), + '__disableTmpl' => true, + ] + ], + 'theme_id' => 2 + ] ], - [['itemName' => '', 'theme_id' => 2]], - [['itemName' => ['view' => ['href' => 'url', 'label' => __('View')]], 'theme_id' => 2]], 'url_path', ['theme_id' => 2] ] diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php index 801f30ce30b0..1eeeaccff88c 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php @@ -73,7 +73,8 @@ public function prepareDataSource(array $dataSource) 'scope_id' => $scopeId, ] ), - 'label' => __('Edit') + 'label' => __('Edit'), + '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php index 774d5bab660a..9e47e2c52bdd 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php @@ -65,7 +65,8 @@ public function prepareDataSource(array $dataSource) : array $urlEntityParamName => $item[$indexField] ] ), - 'label' => __('View') + 'label' => __('View'), + '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Theme/composer.json b/app/code/Magento/Theme/composer.json index 37802ee6c68f..ecc944336cd8 100644 --- a/app/code/Magento/Theme/composer.json +++ b/app/code/Magento/Theme/composer.json @@ -19,7 +19,6 @@ "magento/module-widget": "*" }, "suggest": { - "magento/module-translation": "*", "magento/module-theme-sample-data": "*", "magento/module-deploy": "*", "magento/module-directory": "*" diff --git a/app/code/Magento/Theme/view/frontend/layout/default.xml b/app/code/Magento/Theme/view/frontend/layout/default.xml index 07d344cb3658..81cffe8c040b 100644 --- a/app/code/Magento/Theme/view/frontend/layout/default.xml +++ b/app/code/Magento/Theme/view/frontend/layout/default.xml @@ -11,8 +11,6 @@ <block name="require.js" class="Magento\Framework\View\Element\Template" template="Magento_Theme::page/js/require_js.phtml" /> <referenceContainer name="after.body.start"> <block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config"/> - <block class="Magento\Translation\Block\Html\Head\Config" name="translate-config"/> - <block class="Magento\Translation\Block\Js" name="translate" template="Magento_Translation::translate.phtml"/> <block class="Magento\Framework\View\Element\Js\Cookie" name="js_cookies" template="Magento_Theme::js/cookie.phtml"/> <block class="Magento\Theme\Block\Html\Notices" name="global_notices" template="Magento_Theme::html/notices.phtml"/> </referenceContainer> diff --git a/app/code/Magento/Tinymce3/view/base/web/tiny_mce/classes/html/Node.js b/app/code/Magento/Tinymce3/view/base/web/tiny_mce/classes/html/Node.js index 41cc0d9813bf..58074216458e 100644 --- a/app/code/Magento/Tinymce3/view/base/web/tiny_mce/classes/html/Node.js +++ b/app/code/Magento/Tinymce3/view/base/web/tiny_mce/classes/html/Node.js @@ -197,7 +197,7 @@ }, /** - * Wraps the node in in another node. + * Wraps the node in another node. * * @example * node.wrap(wrapperNode); diff --git a/app/code/Magento/Translation/Model/Inline/Parser.php b/app/code/Magento/Translation/Model/Inline/Parser.php index 52124aee869a..ca66d288d6f6 100644 --- a/app/code/Magento/Translation/Model/Inline/Parser.php +++ b/app/code/Magento/Translation/Model/Inline/Parser.php @@ -16,7 +16,7 @@ use Magento\Translation\Model\Inline\CacheManager; /** - * Parse content, applying necessary html element wrapping and client scripts for inline translation. + * Parses content and applies necessary html element wrapping and client scripts for inline translation. * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -229,7 +229,12 @@ public function processAjaxPost(array $translateParams) $storeId = $validStoreId; } } - $resource->saveTranslate($param['original'], $param['custom'], null, $storeId); + $resource->saveTranslate( + $param['original'], + $param['custom'], + null, + $storeId + ); } return $this->getCacheManger()->updateAndGetTranslations(); @@ -257,7 +262,7 @@ protected function _validateTranslationParams(array $translateParams) * Apply input filter to values of translation parameters * * @param array $translateParams - * @param array $fieldNames + * @param array $fieldNames Names of fields values of which are to be filtered * @return void */ protected function _filterTranslationParams(array &$translateParams, array $fieldNames) diff --git a/app/code/Magento/Translation/Model/Js/DataProvider.php b/app/code/Magento/Translation/Model/Js/DataProvider.php index 7aad7c765bcd..ae388239bc53 100644 --- a/app/code/Magento/Translation/Model/Js/DataProvider.php +++ b/app/code/Magento/Translation/Model/Js/DataProvider.php @@ -120,6 +120,8 @@ public function getData($themePath) } } + ksort($dictionary); + return $dictionary; } diff --git a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php index 021709bdda1f..b5bfbbc29a60 100644 --- a/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php +++ b/app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php @@ -90,7 +90,7 @@ public function testGetData() $themePath = 'blank'; $areaCode = 'adminhtml'; - $filePaths = [['path1'], ['path2'], ['path3'], ['path4']]; + $filePaths = [['path1'], ['path2'], ['path4'], ['path3']]; $jsFilesMap = [ ['base', $themePath, '*', '*', [$filePaths[0]]], @@ -111,8 +111,8 @@ public function testGetData() $contentsMap = [ 'content1$.mage.__("hello1")content1', 'content2$.mage.__("hello2")content2', + 'content2$.mage.__("hello4")content4', // this value should be last after running data provider 'content2$.mage.__("hello3")content3', - 'content2$.mage.__("hello4")content4' ]; $translateMap = [ @@ -147,7 +147,13 @@ public function testGetData() ->method('render') ->willReturnMap($translateMap); - $this->assertEquals($expectedResult, $this->model->getData($themePath)); + $actualResult = $this->model->getData($themePath); + $this->assertEquals($expectedResult, $actualResult); + $this->assertEquals( + json_encode($expectedResult), + json_encode($actualResult), + "Translations should be sorted by key" + ); } /** diff --git a/app/code/Magento/Translation/view/base/templates/translate.phtml b/app/code/Magento/Translation/view/base/templates/translate.phtml index 445c3e88830a..4c257eb76843 100644 --- a/app/code/Magento/Translation/view/base/templates/translate.phtml +++ b/app/code/Magento/Translation/view/base/templates/translate.phtml @@ -6,6 +6,10 @@ /** @var \Magento\Translation\Block\Js $block */ ?> +<!-- + For frontend area dictionary file is inserted into html head in Magento/Translation/view/base/templates/dictionary.phtml + Same translation mechanism should be introduced for admin area in 2.4 version. +--> <?php if ($block->dictionaryEnabled()) : ?> <script> require.config({ diff --git a/app/code/Magento/Translation/view/base/web/js/mage-translation-dictionary.js b/app/code/Magento/Translation/view/base/web/js/mage-translation-dictionary.js new file mode 100644 index 000000000000..72f497dde9ad --- /dev/null +++ b/app/code/Magento/Translation/view/base/web/js/mage-translation-dictionary.js @@ -0,0 +1,12 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'text!js-translation.json' +], function (dict) { + 'use strict'; + + return JSON.parse(dict); +}); diff --git a/app/code/Magento/Translation/view/frontend/layout/default.xml b/app/code/Magento/Translation/view/frontend/layout/default.xml new file mode 100644 index 000000000000..244c0464301d --- /dev/null +++ b/app/code/Magento/Translation/view/frontend/layout/default.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <body> + <referenceBlock name="head.additional"> + <block class="Magento\Translation\Block\Html\Head\Config" name="translate-config"/> + </referenceBlock> + </body> +</page> diff --git a/app/code/Magento/Translation/view/frontend/requirejs-config.js b/app/code/Magento/Translation/view/frontend/requirejs-config.js index b4b3ce0f8c55..b5351b9d471c 100644 --- a/app/code/Magento/Translation/view/frontend/requirejs-config.js +++ b/app/code/Magento/Translation/view/frontend/requirejs-config.js @@ -8,10 +8,12 @@ var config = { '*': { editTrigger: 'mage/edit-trigger', addClass: 'Magento_Translation/js/add-class', - 'Magento_Translation/add-class': 'Magento_Translation/js/add-class' + 'Magento_Translation/add-class': 'Magento_Translation/js/add-class', + mageTranslationDictionary: 'Magento_Translation/js/mage-translation-dictionary' } }, deps: [ - 'mage/translate-inline' + 'mage/translate-inline', + 'mageTranslationDictionary' ] }; diff --git a/app/code/Magento/Ui/Component/Control/SplitButton.php b/app/code/Magento/Ui/Component/Control/SplitButton.php index ef57268566ba..5c9d09565fc6 100644 --- a/app/code/Magento/Ui/Component/Control/SplitButton.php +++ b/app/code/Magento/Ui/Component/Control/SplitButton.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Ui\Component\Control; /** @@ -22,7 +23,7 @@ class SplitButton extends Button { /** - * {@inheritdoc} + * @inheritdoc */ protected function getTemplatePath() { @@ -83,12 +84,12 @@ public function getButtonAttributesHtml() 'style' => $this->getStyle(), ]; - if (($idHard = $this->getIdHard())) { + if ($idHard = $this->getIdHard()) { $attributes['id'] = $idHard; } //TODO perhaps we need to skip data-mage-init when disabled="disabled" - if (($dataAttribute = $this->getDataAttribute())) { + if ($dataAttribute = $this->getDataAttribute()) { $this->getDataAttributes($dataAttribute, $attributes); } @@ -112,7 +113,7 @@ public function getToggleAttributesHtml() $title = $this->getLabel(); } - if (($currentClass = $this->getClass())) { + if ($currentClass = $this->getClass()) { $classes[] = $currentClass; } @@ -201,12 +202,11 @@ public function hasSplit() { return $this->hasData('has_split') ? (bool)$this->getData('has_split') : true; } - /** * Add data attributes to $attributes array * * @param array $data - * @param array &$attributes + * @param array $attributes * @return void */ protected function getDataAttributes($data, &$attributes) diff --git a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php index b01b2937151c..586d76828ba3 100644 --- a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php +++ b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php @@ -62,6 +62,14 @@ public function prepare() if (empty($config['rawOptions'])) { $options = $this->convertOptionsValueToString($options); } + + array_walk( + $options, + function (&$item) { + $item['__disableTmpl'] = true; + } + ); + $config['options'] = array_values(array_replace_recursive($config['options'], $options)); } $this->setData('config', (array)$config); @@ -89,7 +97,7 @@ protected function convertOptionsValueToString(array $options) { array_walk( $options, - static function (&$value) { + function (&$value) { if (isset($value['value']) && is_scalar($value['value'])) { $value['value'] = (string)$value['value']; } diff --git a/app/code/Magento/Ui/Component/Form/Element/Wysiwyg.php b/app/code/Magento/Ui/Component/Form/Element/Wysiwyg.php index d39d2dc3cd93..040c27d4939e 100644 --- a/app/code/Magento/Ui/Component/Form/Element/Wysiwyg.php +++ b/app/code/Magento/Ui/Component/Form/Element/Wysiwyg.php @@ -3,12 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Ui\Component\Form\Element; use Magento\Framework\Data\Form\Element\Editor; use Magento\Framework\Data\Form; use Magento\Framework\Data\FormFactory; -use Magento\Framework\DataObject; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Ui\Component\Wysiwyg\ConfigInterface; @@ -51,6 +51,7 @@ public function __construct( array $config = [] ) { $wysiwygConfigData = isset($config['wysiwygConfigData']) ? $config['wysiwygConfigData'] : []; + $this->form = $formFactory->create(); $wysiwygId = $context->getNamespace() . '_' . $data['name']; $this->editor = $this->form->addField( diff --git a/app/code/Magento/Ui/Component/MassAction.php b/app/code/Magento/Ui/Component/MassAction.php index 4cca8d4c012b..5af263dd861c 100644 --- a/app/code/Magento/Ui/Component/MassAction.php +++ b/app/code/Magento/Ui/Component/MassAction.php @@ -28,7 +28,7 @@ public function prepare() if ($disabledAction) { continue; } - $config['actions'][] = $componentConfig; + $config['actions'][] = array_merge($componentConfig, ['__disableTmpl' => true]); } $origConfig = $this->getConfiguration(); diff --git a/app/code/Magento/Ui/Model/BookmarkSearchResults.php b/app/code/Magento/Ui/Model/BookmarkSearchResults.php new file mode 100644 index 000000000000..2171a5c0084e --- /dev/null +++ b/app/code/Magento/Ui/Model/BookmarkSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Ui\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Ui\Api\Data\BookmarkSearchResultsInterface; + +/** + * Service Data Object with Bookmark search results. + */ +class BookmarkSearchResults extends SearchResults implements BookmarkSearchResultsInterface +{ +} diff --git a/app/code/Magento/Ui/Model/Export/MetadataProvider.php b/app/code/Magento/Ui/Model/Export/MetadataProvider.php old mode 100644 new mode 100755 index 603e102fa30e..3f6685e37fcc --- a/app/code/Magento/Ui/Model/Export/MetadataProvider.php +++ b/app/code/Magento/Ui/Model/Export/MetadataProvider.php @@ -15,6 +15,7 @@ use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** + * Metadata Provider * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class MetadataProvider @@ -84,7 +85,7 @@ protected function getColumnsComponent(UiComponentInterface $component) return $childComponent; } } - throw new \Exception('No columns found'); + throw new \Exception('No columns found'); // @codingStandardsIgnoreLine } /** @@ -119,12 +120,6 @@ public function getHeaders(UiComponentInterface $component) $row[] = $column->getData('config/label'); } - array_walk($row, function (&$header) { - if (mb_strpos($header, 'ID') === 0) { - $header = '"' . $header . '"'; - } - }); - return $row; } diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index b2f494351597..c2e064bb3b06 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -104,7 +104,8 @@ public function getPrepareDataProvider() [ 'type' => 'first_action', 'label' => 'First Action', - 'url' => '/module/controller/firstAction' + 'url' => '/module/controller/firstAction', + '__disableTmpl' => true ], ], [ @@ -123,7 +124,8 @@ public function getPrepareDataProvider() 'label' => 'Second Sub Action 2', 'url' => '/module/controller/secondSubAction2' ], - ] + ], + '__disableTmpl' => true ], ], ]; diff --git a/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php old mode 100644 new mode 100755 index 80cf7666eeed..50bce70e08fe --- a/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php +++ b/app/code/Magento/Ui/Test/Unit/Model/Export/MetadataProviderTest.php @@ -97,12 +97,12 @@ public function testGetHeaders(array $columnLabels, array $expected): void public function getColumnsDataProvider(): array { return [ - [['ID'],['"ID"']], + [['ID'],['ID']], [['Name'],['Name']], [['Id'],['Id']], [['id'],['id']], - [['IDTEST'],['"IDTEST"']], - [['ID TEST'],['"ID TEST"']], + [['IDTEST'],['IDTEST']], + [['ID TEST'],['ID TEST']], ]; } diff --git a/app/code/Magento/Ui/etc/di.xml b/app/code/Magento/Ui/etc/di.xml index c029e18addf7..05ace9d556fa 100644 --- a/app/code/Magento/Ui/etc/di.xml +++ b/app/code/Magento/Ui/etc/di.xml @@ -14,7 +14,7 @@ <preference for="Magento\Framework\View\Element\UiComponent\ContextInterface" type="Magento\Framework\View\Element\UiComponent\Context" /> <preference for="Magento\Framework\View\Element\UiComponent\LayoutInterface" type="Magento\Framework\View\Layout\Generic"/> <preference for="Magento\Authorization\Model\UserContextInterface" type="Magento\Authorization\Model\CompositeUserContext"/> - <preference for="Magento\Ui\Api\Data\BookmarkSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Ui\Api\Data\BookmarkSearchResultsInterface" type="Magento\Ui\Model\BookmarkSearchResults" /> <preference for="Magento\Ui\Api\BookmarkRepositoryInterface" type="Magento\Ui\Model\ResourceModel\BookmarkRepository"/> <preference for="Magento\Ui\Api\Data\BookmarkInterface" type="Magento\Ui\Model\Bookmark"/> <preference for="Magento\Ui\Component\Wysiwyg\ConfigInterface" type="Magento\Ui\Component\Wysiwyg\Config"/> diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/insert-listing.js b/app/code/Magento/Ui/view/base/web/js/form/components/insert-listing.js index b33f0b5c7239..53580fc069c4 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/components/insert-listing.js +++ b/app/code/Magento/Ui/view/base/web/js/form/components/insert-listing.js @@ -155,7 +155,7 @@ define([ updateExternalValueByEditableData: function () { var updatedExtValue; - if (!this.behaviourType === 'edit' || _.isEmpty(this.editableData) || _.isEmpty(this.externalValue())) { + if (!(this.behaviourType === 'edit') || _.isEmpty(this.editableData) || _.isEmpty(this.externalValue())) { return; } diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js index f28569caa005..73bef6291064 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js @@ -435,9 +435,10 @@ define([ * @param {String} constructedMessage */ insertMethod: function (constructedMessage) { - var errorMsgBodyHtml = '<strong>%s</strong> %s.<br>' - .replace('%s', error.filename) - .replace('%s', $t('was not uploaded')); + var escapedFileName = $('<div>').text(error.filename).html(), + errorMsgBodyHtml = '<strong>%s</strong> %s.<br>' + .replace('%s', escapedFileName) + .replace('%s', $t('was not uploaded')); // html is escaped in message body for notification widget; prepend unescaped html here constructedMessage = constructedMessage.replace('%s', errorMsgBodyHtml); diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js index 98c3eb1c6f88..78016ee489a1 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js @@ -272,11 +272,22 @@ define([ } filter = utils.extend({}, filters.base, filter); + //Accepting labels as is. + filter.__disableTmpl = { + label: 1, + options: 1 + }; - return utils.template(filter, { + filter = utils.template(filter, { filters: this, column: column }, true, true); + + filter.__disableTmpl = { + label: true + }; + + return filter; }, /** diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js index 2925c5859edd..6ff7c1f67321 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js @@ -222,10 +222,14 @@ define([ ko.utils.setTextContent(option, allBindings.get('optionsCaption')); ko.selectExtensions.writeValue(option, undefined); } else if (typeof arrayEntry[optionsValue] === 'undefined') { // empty value === optgroup - option = utils.template(optgroupTmpl, { - label: arrayEntry[optionsText], - title: arrayEntry[optionsText + 'title'] - }); + if (arrayEntry.__disableTmpl) { + option = '<optgroup label="' + arrayEntry[optionsText] + '"></optgroup>'; + } else { + option = utils.template(optgroupTmpl, { + label: arrayEntry[optionsText], + title: arrayEntry[optionsText + 'title'] + }); + } option = ko.utils.parseHtmlFragment(option)[0]; } else { @@ -307,6 +311,10 @@ define([ obj.disabled = disabled; } + if (option.hasOwnProperty('__disableTmpl')) { + obj.__disableTmpl = option.__disableTmpl; + } + label = label.replace(nbspRe, '').trim(); if (Array.isArray(value)) { diff --git a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js index 3402d1d1df03..08f67955976c 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js @@ -1067,6 +1067,16 @@ define([ return new RegExp(param).test(value); }, $.mage.__('This link is not allowed.') + ], + 'validate-dob': [ + function (value) { + if (value === '') { + return true; + } + + return moment(value).isBefore(moment()); + }, + $.mage.__('The Date of Birth should not be greater than today.') ] }, function (data) { return { diff --git a/app/code/Magento/Ui/view/frontend/web/js/view/messages.js b/app/code/Magento/Ui/view/frontend/web/js/view/messages.js index 57a590c87179..b2fb3f216199 100644 --- a/app/code/Magento/Ui/view/frontend/web/js/view/messages.js +++ b/app/code/Magento/Ui/view/frontend/web/js/view/messages.js @@ -10,7 +10,8 @@ define([ 'ko', 'jquery', 'uiComponent', - '../model/messageList' + '../model/messageList', + 'jquery-ui-modules/effect-blind' ], function (ko, $, Component, globalMessages) { 'use strict'; diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 5320aeb5bcc8..72b68c476d88 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -9,7 +9,6 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Async\CallbackDeferred; -use Magento\Framework\Async\ProxyDeferredFactory; use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; @@ -22,6 +21,7 @@ use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; +use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; use Magento\Shipping\Model\Simplexml\Element; use Magento\Ups\Helper\Config; use Magento\Shipping\Model\Shipment\Request as Shipment; @@ -239,15 +239,16 @@ public function collectRates(RateRequest $request) //To use the correct result in the callback. $this->_result = $result = $this->_getQuotes(); - return $this->deferredProxyFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($request, $result) { - $this->_result = $result; - $this->_updateFreeMethodQuote($request); - return $this->getResult(); - } - ) + return $this->deferredProxyFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($request, $result) { + $this->_result = $result; + $this->_updateFreeMethodQuote($request); + return $this->getResult(); + } + ) + ] ); } @@ -782,19 +783,20 @@ protected function _getXmlQuotes() new Request($url, Request::METHOD_POST, ['Content-Type' => 'application/xml'], $xmlRequest) ); - return $this->deferredProxyFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($httpResponse) { - if ($httpResponse->get()->getStatusCode() >= 400) { - $xmlResponse = ''; - } else { - $xmlResponse = $httpResponse->get()->getBody(); - } + return $this->deferredProxyFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($httpResponse) { + if ($httpResponse->get()->getStatusCode() >= 400) { + $xmlResponse = ''; + } else { + $xmlResponse = $httpResponse->get()->getBody(); + } - return $this->_parseXmlResponse($xmlResponse); - } - ) + return $this->_parseXmlResponse($xmlResponse); + } + ) + ] ); } diff --git a/app/code/Magento/Ups/Model/Config/Backend/UpsUrl.php b/app/code/Magento/Ups/Model/Config/Backend/UpsUrl.php new file mode 100644 index 000000000000..9db35b6a42dc --- /dev/null +++ b/app/code/Magento/Ups/Model/Config/Backend/UpsUrl.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Ups\Model\Config\Backend; + +use Magento\Framework\App\Config\Value; +use Magento\Framework\Exception\ValidatorException; + +/** + * Represents a config URL that may point to a UPS endpoint + */ +class UpsUrl extends Value +{ + /** + * @inheritdoc + */ + public function beforeSave() + { + // phpcs:ignore Magento2.Functions.DiscouragedFunction + $host = parse_url((string)$this->getValue(), \PHP_URL_HOST); + + if (!empty($host) && !preg_match('/(?:.+\.|^)ups\.com$/i', $host)) { + throw new ValidatorException(__('UPS API endpoint URL\'s must use ups.com')); + } + + return parent::beforeSave(); + } +} diff --git a/app/code/Magento/Ups/Test/Mftf/Section/AdminShippingMethodsUpsSection.xml b/app/code/Magento/Ups/Test/Mftf/Section/AdminShippingMethodsUpsSection.xml index 4107f17dbc18..f330695867e7 100644 --- a/app/code/Magento/Ups/Test/Mftf/Section/AdminShippingMethodsUpsSection.xml +++ b/app/code/Magento/Ups/Test/Mftf/Section/AdminShippingMethodsUpsSection.xml @@ -12,5 +12,29 @@ <element name="carriersUpsTab" type="button" selector="#carriers_ups-head"/> <element name="carriersUpsType" type="select" selector="#carriers_ups_type"/> <element name="selectedUpsType" type="text" selector="#carriers_ups_type option[selected]"/> + <element name="carriersUPSActive" type="input" selector="#carriers_ups_active_inherit"/> + <element name="carriersUPSTypeSystem" type="input" selector="#carriers_ups_type_inherit"/> + <element name="carriersUPSAccountLive" type="input" selector="#carriers_ups_is_account_live_inherit"/> + <element name="carriersUPSGatewayXMLUrl" type="input" selector="#carriers_ups_gateway_xml_url_inherit"/> + <element name="carriersUPSModeXML" type="input" selector="#carriers_ups_mode_xml_inherit"/> + <element name="carriersUPSOriginShipment" type="input" selector="#carriers_ups_origin_shipment_inherit"/> + <element name="carriersUPSTitle" type="input" selector="#carriers_ups_title_inherit"/> + <element name="carriersUPSNegotiatedActive" type="input" selector="#carriers_ups_negotiated_active_inherit"/> + <element name="carriersUPSIncludeTaxes" type="input" selector="#carriers_ups_include_taxes_inherit"/> + <element name="carriersUPSShipmentRequestType" type="input" selector="#carriers_ups_shipment_requesttype_inherit"/> + <element name="carriersUPSContainer" type="input" selector="#carriers_ups_container_inherit"/> + <element name="carriersUPSDestType" type="input" selector="#carriers_ups_dest_type_inherit"/> + <element name="carriersUPSTrackingXmlUrl" type="input" selector="#carriers_ups_tracking_xml_url_inherit"/> + <element name="carriersUPSUnitOfMeasure" type="input" selector="#carriers_ups_unit_of_measure_inherit"/> + <element name="carriersUPSMaxPackageWeight" type="input" selector="#carriers_ups_max_package_weight_inherit"/> + <element name="carriersUPSPickup" type="input" selector="#carriers_ups_pickup_inherit"/> + <element name="carriersUPSMinPackageWeight" type="input" selector="#carriers_ups_min_package_weight_inherit"/> + <element name="carriersUPSHandlingType" type="input" selector="#carriers_ups_handling_type_inherit"/> + <element name="carriersUPSHandlingAction" type="input" selector="#carriers_ups_handling_action_inherit"/> + <element name="carriersUPSAllowedMethods" type="input" selector="#carriers_ups_allowed_methods_inherit"/> + <element name="carriersUPSFreeMethod" type="input" selector="#carriers_ups_free_method_inherit"/> + <element name="carriersUPSSpecificErrMsg" type="input" selector="#carriers_ups_specificerrmsg_inherit"/> + <element name="carriersUPSAllowSpecific" type="input" selector="#carriers_ups_sallowspecific_inherit"/> + <element name="carriersUPSSpecificCountry" type="input" selector="#carriers_ups_specificcountry"/> </section> </sections> diff --git a/app/code/Magento/Ups/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml b/app/code/Magento/Ups/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml new file mode 100644 index 000000000000..126586669afd --- /dev/null +++ b/app/code/Magento/Ups/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"> + <!--Assert configuration are disabled in UPS section--> + <comment userInput="Assert configuration are disabled in UPS section" stepKey="commentSeeDisabledUPSConfigs"/> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <conditionalClick selector="{{AdminShippingMethodsUpsSection.carriersUpsTab}}" dependentSelector="{{AdminShippingMethodsUpsSection.carriersUPSActive}}" visible="false" stepKey="expandUPSTab"/> + <waitForElementVisible selector="{{AdminShippingMethodsUpsSection.carriersUPSActive}}" stepKey="waitUPSTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSActive}}" userInput="disabled" stepKey="grabUPSActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSActiveDisabled" stepKey="assertUPSActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSTypeSystem}}" userInput="disabled" stepKey="grabUPSTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSTypeDisabled" stepKey="assertUPSTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSAccountLive}}" userInput="disabled" stepKey="grabUPSAccountLiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSAccountLiveDisabled" stepKey="assertUPSAccountLiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSGatewayXMLUrl}}" userInput="disabled" stepKey="grabUPSGatewayXMLUrlDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSGatewayXMLUrlDisabled" stepKey="assertUPSGatewayXMLUrlDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSModeXML}}" userInput="disabled" stepKey="grabUPSModeXMLDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSModeXMLDisabled" stepKey="assertUPSModeXMLDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSOriginShipment}}" userInput="disabled" stepKey="grabUPSOriginShipmentDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSOriginShipmentDisabled" stepKey="assertUPSOriginShipmentDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSTitle}}" userInput="disabled" stepKey="grabUPSTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSTitleDisabled" stepKey="assertUPSTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSNegotiatedActive}}" userInput="disabled" stepKey="grabUPSNegotiatedActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSNegotiatedActiveDisabled" stepKey="assertUPSNegotiatedActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSIncludeTaxes}}" userInput="disabled" stepKey="grabUPSIncludeTaxesDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSIncludeTaxesDisabled" stepKey="assertUPSIncludeTaxesDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSShipmentRequestType}}" userInput="disabled" stepKey="grabUPSShipmentRequestTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSShipmentRequestTypeDisabled" stepKey="assertUPSShipmentRequestTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSContainer}}" userInput="disabled" stepKey="grabUPSContainerDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSContainerDisabled" stepKey="assertUPSContainerDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSDestType}}" userInput="disabled" stepKey="grabUPSDestTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSDestTypeDisabled" stepKey="assertUPSDestTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSTrackingXmlUrl}}" userInput="disabled" stepKey="grabUPSTrackingXmlUrlDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSTrackingXmlUrlDisabled" stepKey="assertUPSTrackingXmlUrlDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSUnitOfMeasure}}" userInput="disabled" stepKey="grabUPSUnitOfMeasureDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSUnitOfMeasureDisabled" stepKey="assertUPSUnitOfMeasureDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSMaxPackageWeight}}" userInput="disabled" stepKey="grabUPSMaxPackageWeightDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSMaxPackageWeightDisabled" stepKey="assertUPSMaxPackageWeightDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSPickup}}" userInput="disabled" stepKey="grabUPSPickupDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSPickupDisabled" stepKey="assertUPSPickupDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSMinPackageWeight}}" userInput="disabled" stepKey="grabUPSMinPackageWeightDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSMinPackageWeightDisabled" stepKey="assertUPSMinPackageWeightDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSHandlingType}}" userInput="disabled" stepKey="grabUPSHandlingTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSHandlingTypeDisabled" stepKey="assertUPSHandlingTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSHandlingAction}}" userInput="disabled" stepKey="grabUPSHandlingActionDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSHandlingActionDisabled" stepKey="assertUPSHandlingActionDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSAllowedMethods}}" userInput="disabled" stepKey="grabUPSAllowedMethodsDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSAllowedMethodsDisabled" stepKey="assertUPSAllowedMethodsDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSFreeMethod}}" userInput="disabled" stepKey="grabUPSFreeMethodDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSFreeMethodDisabled" stepKey="assertUPSFreeMethodDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSSpecificErrMsg}}" userInput="disabled" stepKey="grabUPSSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSSpecificErrMsgDisabled" stepKey="assertUPSSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSAllowSpecific}}" userInput="disabled" stepKey="grabUPSAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSAllowSpecificDisabled" stepKey="assertUPSAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodsUpsSection.carriersUPSSpecificCountry}}" userInput="disabled" stepKey="grabUPSSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUPSSpecificCountryDisabled" stepKey="assertUPSSpecificCountryDisabled"/> + </test> +</tests> diff --git a/app/code/Magento/Ups/Test/Unit/Model/Config/Backend/UpsUrlTest.php b/app/code/Magento/Ups/Test/Unit/Model/Config/Backend/UpsUrlTest.php new file mode 100644 index 000000000000..149f9378889f --- /dev/null +++ b/app/code/Magento/Ups/Test/Unit/Model/Config/Backend/UpsUrlTest.php @@ -0,0 +1,78 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Ups\Test\Unit\Model\Config\Backend; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Ups\Model\Config\Backend\UpsUrl; +use PHPUnit\Framework\TestCase; + +/** + * Verify behavior of UpsUrl backend type + */ +class UpsUrlTest extends TestCase +{ + + /** + * @var UpsUrl + */ + private $config; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + /** @var UpsUrl $upsUrl */ + $this->config = $objectManager->getObject(UpsUrl::class); + } + + /** + * @dataProvider validDataProvider + * @param string $data The valid data + */ + public function testBeforeSave($data = null) + { + $this->config->setValue($data); + $this->config->beforeSave(); + } + + /** + * @dataProvider invalidDataProvider + * @param string $data The invalid data + * @expectedException \Magento\Framework\Exception\ValidatorException + * @expectedExceptionMessage UPS API endpoint URL's must use ups.com + */ + public function testBeforeSaveErrors($data) + { + $this->config->setValue($data); + $this->config->beforeSave(); + } + + public function validDataProvider() + { + return [ + [], + [null], + [''], + ['http://ups.com'], + ['https://foo.ups.com'], + ['http://foo.ups.com/foo/bar?baz=bash&fizz=buzz'], + ]; + } + + public function invalidDataProvider() + { + return [ + ['http://upsfoo.com'], + ['https://fooups.com'], + ['https://ups.com.fake.com'], + ['https://ups.info'], + ['http://ups.com.foo.com/foo/bar?baz=bash&fizz=buzz'], + ['http://fooups.com/foo/bar?baz=bash&fizz=buzz'], + ]; + } +} diff --git a/app/code/Magento/Ups/etc/adminhtml/system.xml b/app/code/Magento/Ups/etc/adminhtml/system.xml index f1b8b22820cb..c069eb48a59c 100644 --- a/app/code/Magento/Ups/etc/adminhtml/system.xml +++ b/app/code/Magento/Ups/etc/adminhtml/system.xml @@ -56,9 +56,11 @@ </field> <field id="gateway_url" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Gateway URL</label> + <backend_model>Magento\Ups\Model\Config\Backend\UpsUrl</backend_model> </field> <field id="gateway_xml_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Gateway XML URL</label> + <backend_model>Magento\Ups\Model\Config\Backend\UpsUrl</backend_model> </field> <field id="handling_type" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Calculate Handling Fee</label> @@ -104,6 +106,7 @@ </field> <field id="tracking_xml_url" translate="label" type="text" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>Tracking XML URL</label> + <backend_model>Magento\Ups\Model\Config\Backend\UpsUrl</backend_model> </field> <field id="type" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1"> <label>UPS Type</label> diff --git a/app/code/Magento/Ups/i18n/en_US.csv b/app/code/Magento/Ups/i18n/en_US.csv index baf8ecc85544..68dd34a313bd 100644 --- a/app/code/Magento/Ups/i18n/en_US.csv +++ b/app/code/Magento/Ups/i18n/en_US.csv @@ -114,3 +114,4 @@ Title,Title Mode,Mode "This enables or disables SSL verification of the Magento server by UPS.","This enables or disables SSL verification of the Magento server by UPS." Debug,Debug +"UPS API endpoint URL's must use ups.com","UPS API endpoint URL's must use ups.com" diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUrlRewritesForProductAfterImportTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUrlRewritesForProductAfterImportTest.xml new file mode 100644 index 000000000000..a3d3b897ef75 --- /dev/null +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUrlRewritesForProductAfterImportTest.xml @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminUrlRewritesForProductAfterImportTest"> + <annotations> + <features value="Url Rewrite"/> + <stories value="Different number of URL rewrites when editing or importing a product"/> + <title value="Verify the number of URL rewrites when edit or import product"/> + <description value="After importing products to admin verify the number of URL including categories matches"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20229"/> + <group value="urlRewrite"/> + </annotations> + <before> + <comment userInput="Set the configuration for Generate category/product URL Rewrites" stepKey="commentSetURLRewriteConfiguration" /> + <comment userInput="Enable config to generate category/product URL Rewrites " stepKey="commentEnableConfig" /> + <magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 1" stepKey="enableGenerateUrlRewrite"/> + <createData entity="NewRootCategory" stepKey="simpleSubCategory1"> + <field key="parent_id">2</field> + </createData> + <createData entity="SubCategoryWithParent" stepKey="simpleSubCategory2"> + <requiredEntity createDataKey="simpleSubCategory1"/> + </createData> + <createData entity="SubCategoryWithParent" stepKey="simpleSubCategory3"> + <requiredEntity createDataKey="simpleSubCategory2"/> + </createData> + <comment userInput="Create Simple product 1 and assign it to Category 3 " stepKey="commentCreateSimpleProduct" /> + <createData entity="SimpleProductAfterImport1" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="simpleSubCategory3"/> + </createData> + </before> + <after> + <comment userInput="Delete all products that replaced products in the before block post import " stepKey="commentDeleteAllProducts" /> + <deleteData stepKey="deleteSimpleProduct1" url="/V1/products/SimpleProductForTest1"/> + <deleteData createDataKey="simpleSubCategory3" stepKey="deleteSimpleSubCategory3"/> + <deleteData createDataKey="simpleSubCategory2" stepKey="deleteSimpleSubCategory2"/> + <deleteData createDataKey="simpleSubCategory1" stepKey="deleteSimpleSubCategory1"/> + <comment userInput="Disable config to generate category/product URL Rewrites " stepKey="commentDisableConfig" /> + <magentoCLI command="config:set catalog/seo/generate_category_product_rewrites 0" stepKey="disableGenerateUrlRewrite"/> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="amOnLogoutPage"/> + </after> + + <comment userInput="1. Log in to Admin " stepKey="commentAdminLogin" /> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <comment userInput="2. Open Marketing - SEO and Search - URL Rewrites " stepKey="commentVerifyUrlRewrite" /> + <amOnPage url="{{AdminUrlRewriteIndexPage.url}}" stepKey="amOnUrlRewriteIndexPage"/> + <fillField selector="{{AdminUrlRewriteIndexSection.requestPathFilter}}" userInput="$createSimpleProduct.custom_attributes[url_key]$.html" stepKey="inputProductName"/> + <click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickSearchButton"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($createSimpleProduct.custom_attributes[url_key]$.html)}}" stepKey="seeValue1"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$.html)}}" stepKey="seeValue2"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$.html)}}" stepKey="seeValue3"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$simpleSubCategory3.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$.html)}}" stepKey="seeValue4"/> + + <comment userInput="3. Import products with add/update behavior " stepKey="commentProductImport" /> + <actionGroup ref="AdminImportProductsActionGroup" stepKey="adminImportProducts"> + <argument name="behavior" value="Add/Update"/> + <argument name="importFile" value="catalog_import_products_url_rewrite.csv"/> + <argument name="importNoticeMessage" value="Created: 0, Updated: 1, Deleted: 0"/> + </actionGroup> + + <comment userInput="4. Assert Simple Product1 on grid " stepKey="commentVerifyProduct" /> + <actionGroup ref="AssertProductOnAdminGridActionGroup" stepKey="assertSimpleProduct1OnAdminGrid"> + <argument name="product" value="SimpleProductAfterImport1"/> + </actionGroup> + + <comment userInput="5. Open Marketing - SEO and Search - URL Rewrites" stepKey="commentVerifyURLAfterImport" /> + <amOnPage url="{{AdminUrlRewriteIndexPage.url}}" stepKey="amOnUrlRewriteIndexPage2"/> + <fillField selector="{{AdminUrlRewriteIndexSection.requestPathFilter}}" userInput="$createSimpleProduct.custom_attributes[url_key]$-new.html" stepKey="inputProductName2"/> + <click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickSearchButton2"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue1"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue2"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue3"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$simpleSubCategory3.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue4"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue5"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue6"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.requestPathColumnValue($simpleSubCategory1.custom_attributes[url_key]$/$simpleSubCategory2.custom_attributes[url_key]$/$simpleSubCategory3.custom_attributes[url_key]$/$createSimpleProduct.custom_attributes[url_key]$-new.html)}}" stepKey="seeInListValue7"/> + </test> +</tests> diff --git a/app/code/Magento/UrlRewrite/etc/db_schema.xml b/app/code/Magento/UrlRewrite/etc/db_schema.xml index 06d4949e63d9..93e84d8e02a0 100644 --- a/app/code/Magento/UrlRewrite/etc/db_schema.xml +++ b/app/code/Magento/UrlRewrite/etc/db_schema.xml @@ -37,5 +37,8 @@ <column name="store_id"/> <column name="entity_id"/> </index> + <index referenceId="URL_REWRITE_ENTITY_ID" indexType="btree"> + <column name="entity_id"/> + </index> </table> </schema> diff --git a/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json b/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json index bdaed647587a..658673959a73 100644 --- a/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json +++ b/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json @@ -14,11 +14,12 @@ }, "index": { "URL_REWRITE_TARGET_PATH": true, - "URL_REWRITE_STORE_ID_ENTITY_ID": true + "URL_REWRITE_STORE_ID_ENTITY_ID": true, + "URL_REWRITE_ENTITY_ID": true }, "constraint": { "PRIMARY": true, "URL_REWRITE_REQUEST_PATH_STORE_ID": true } } -} \ No newline at end of file +} diff --git a/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/EntityUrl.php b/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/EntityUrl.php index 0acece9271f7..e6b03755bea4 100644 --- a/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/EntityUrl.php +++ b/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/EntityUrl.php @@ -31,6 +31,11 @@ class EntityUrl implements ResolverInterface */ private $customUrlLocator; + /** + * @var int + */ + private $redirectType; + /** * @param UrlFinderInterface $urlFinder * @param CustomUrlLocatorInterface $customUrlLocator @@ -57,49 +62,83 @@ public function resolve( throw new GraphQlInputException(__('"url" argument should be specified and not empty')); } + $storeId = (int)$context->getExtensionAttributes()->getStore()->getId(); $result = null; $url = $args['url']; if (substr($url, 0, 1) === '/' && $url !== '/') { $url = ltrim($url, '/'); } + $this->redirectType = 0; $customUrl = $this->customUrlLocator->locateUrl($url); $url = $customUrl ?: $url; - $urlRewrite = $this->findCanonicalUrl($url, (int)$context->getExtensionAttributes()->getStore()->getId()); - if ($urlRewrite) { - if (!$urlRewrite->getEntityId()) { + $finalUrlRewrite = $this->findFinalUrl($url, $storeId); + if ($finalUrlRewrite) { + $relativeUrl = $finalUrlRewrite->getRequestPath(); + $resultArray = $this->rewriteCustomUrls($finalUrlRewrite, $storeId) ?? [ + 'id' => $finalUrlRewrite->getEntityId(), + 'canonical_url' => $relativeUrl, + 'relative_url' => $relativeUrl, + 'redirectCode' => $this->redirectType, + 'type' => $this->sanitizeType($finalUrlRewrite->getEntityType()) + ]; + + if (empty($resultArray['id'])) { throw new GraphQlNoSuchEntityException( __('No such entity found with matching URL key: %url', ['url' => $url]) ); } - $result = [ - 'id' => $urlRewrite->getEntityId(), - 'canonical_url' => $urlRewrite->getTargetPath(), - 'relative_url' => $urlRewrite->getTargetPath(), - 'type' => $this->sanitizeType($urlRewrite->getEntityType()) - ]; + + $result = $resultArray; } return $result; } /** - * Find the canonical url passing through all redirects if any + * Handle custom urls with and without redirects + * + * @param UrlRewrite $finalUrlRewrite + * @param int $storeId + * @return array|null + */ + private function rewriteCustomUrls(UrlRewrite $finalUrlRewrite, int $storeId): ?array + { + if ($finalUrlRewrite->getEntityType() === 'custom' || !($finalUrlRewrite->getEntityId() > 0)) { + $finalCustomUrlRewrite = clone $finalUrlRewrite; + $finalUrlRewrite = $this->findFinalUrl($finalCustomUrlRewrite->getTargetPath(), $storeId, true); + $relativeUrl = + $finalCustomUrlRewrite->getRedirectType() == 0 + ? $finalCustomUrlRewrite->getRequestPath() : $finalUrlRewrite->getRequestPath(); + return [ + 'id' => $finalUrlRewrite->getEntityId(), + 'canonical_url' => $relativeUrl, + 'relative_url' => $relativeUrl, + 'redirectCode' => $finalCustomUrlRewrite->getRedirectType(), + 'type' => $this->sanitizeType($finalUrlRewrite->getEntityType()) + ]; + } + return null; + } + + /** + * Find the final url passing through all redirects if any * * @param string $requestPath * @param int $storeId + * @param bool $findCustom * @return UrlRewrite|null */ - private function findCanonicalUrl(string $requestPath, int $storeId) : ?UrlRewrite + private function findFinalUrl(string $requestPath, int $storeId, bool $findCustom = false): ?UrlRewrite { $urlRewrite = $this->findUrlFromRequestPath($requestPath, $storeId); - if ($urlRewrite && $urlRewrite->getRedirectType() > 0) { + if ($urlRewrite) { + $this->redirectType = $urlRewrite->getRedirectType(); while ($urlRewrite && $urlRewrite->getRedirectType() > 0) { $urlRewrite = $this->findUrlFromRequestPath($urlRewrite->getTargetPath(), $storeId); } - } - if (!$urlRewrite) { + } else { $urlRewrite = $this->findUrlFromTargetPath($requestPath, $storeId); } - if ($urlRewrite && !$urlRewrite->getEntityId() && !$urlRewrite->getIsAutogenerated()) { + if ($urlRewrite && ($findCustom && !$urlRewrite->getEntityId() && !$urlRewrite->getIsAutogenerated())) { $urlRewrite = $this->findUrlFromTargetPath($urlRewrite->getTargetPath(), $storeId); } @@ -113,7 +152,7 @@ private function findCanonicalUrl(string $requestPath, int $storeId) : ?UrlRewri * @param int $storeId * @return UrlRewrite|null */ - private function findUrlFromRequestPath(string $requestPath, int $storeId) : ?UrlRewrite + private function findUrlFromRequestPath(string $requestPath, int $storeId): ?UrlRewrite { return $this->urlFinder->findOneByData( [ @@ -130,7 +169,7 @@ private function findUrlFromRequestPath(string $requestPath, int $storeId) : ?Ur * @param int $storeId * @return UrlRewrite|null */ - private function findUrlFromTargetPath(string $targetPath, int $storeId) : ?UrlRewrite + private function findUrlFromTargetPath(string $targetPath, int $storeId): ?UrlRewrite { return $this->urlFinder->findOneByData( [ diff --git a/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls b/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls index ace3e0eae831..7f7ebb627b4d 100644 --- a/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls +++ b/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls @@ -9,6 +9,7 @@ type EntityUrl @doc(description: "EntityUrl is an output object containing the ` id: Int @doc(description: "The ID assigned to the object associated with the specified url. This could be a product ID, category ID, or page ID.") canonical_url: String @deprecated(reason: "The canonical_url field is deprecated, use relative_url instead.") relative_url: String @doc(description: "The internal relative URL. If the specified url is a redirect, the query returns the redirected URL, not the original.") + redirectCode: Int @doc(description: "301 or 302 HTTP code for url permanent or temporary redirect or 0 for the 200 no redirect") type: UrlRewriteEntityTypeEnum @doc(description: "One of PRODUCT, CATEGORY, or CMS_PAGE.") } diff --git a/app/code/Magento/User/Model/User.php b/app/code/Magento/User/Model/User.php index b1f4786f847e..0c59f165f11f 100644 --- a/app/code/Magento/User/Model/User.php +++ b/app/code/Magento/User/Model/User.php @@ -675,6 +675,10 @@ public function loadByUsername($username) { $data = $this->getResource()->loadByUsername($username); if ($data !== false) { + if (is_string($data['extra'])) { + $data['extra'] = $this->serializer->unserialize($data['extra']); + } + $this->setData($data); $this->setOrigData(); } diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 7136a403003d..1c8ff0ce9efa 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -8,7 +8,6 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Async\CallbackDeferred; -use Magento\Framework\Async\ProxyDeferredFactory; use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\Xml\Security; @@ -16,6 +15,7 @@ use Magento\Shipping\Helper\Carrier as CarrierHelper; use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; use Magento\Shipping\Model\Rate\Result; +use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; use Magento\Usps\Helper\Data as DataHelper; /** @@ -239,16 +239,17 @@ public function collectRates(RateRequest $request) //Saving current result to use the right one in the callback. $this->_result = $result = $this->_getQuotes(); - return $this->proxyDeferredFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($request, $result) { - $this->_result = $result; - $this->_updateFreeMethodQuote($request); + return $this->proxyDeferredFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($request, $result) { + $this->_result = $result; + $this->_updateFreeMethodQuote($request); - return $this->getResult(); - } - ) + return $this->getResult(); + } + ) + ] ); } @@ -555,18 +556,19 @@ protected function _getXmlQuotes() ) ); - return $this->proxyDeferredFactory->createFor( - Result::class, - new CallbackDeferred( - function () use ($deferredResponse, $request, $debugData) { - $responseBody = $deferredResponse->get()->getBody(); - $debugData['result'] = $responseBody; - $this->_setCachedQuotes($request, $responseBody); - $this->_debug($debugData); - - return $this->_parseXmlResponse($responseBody); - } - ) + return $this->proxyDeferredFactory->create( + [ + 'deferred' => new CallbackDeferred( + function () use ($deferredResponse, $request, $debugData) { + $responseBody = $deferredResponse->get()->getBody(); + $debugData['result'] = $responseBody; + $this->_setCachedQuotes($request, $responseBody); + $this->_debug($debugData); + + return $this->_parseXmlResponse($responseBody); + } + ) + ] ); } diff --git a/app/code/Magento/Usps/Test/Mftf/Section/AdminShippingMethodUSPSSection.xml b/app/code/Magento/Usps/Test/Mftf/Section/AdminShippingMethodUSPSSection.xml new file mode 100644 index 000000000000..9226c40e1316 --- /dev/null +++ b/app/code/Magento/Usps/Test/Mftf/Section/AdminShippingMethodUSPSSection.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminShippingMethodUSPSSection"> + <element name="carriersUSPSTab" type="button" selector="#carriers_usps-head"/> + <element name="carriersUSPSActive" type="input" selector="#carriers_usps_active_inherit"/> + <element name="carriersUSPSGatewayXMLUrl" type="input" selector="#carriers_usps_gateway_url_inherit"/> + <element name="carriersUSPSGatewaySecureUrl" type="input" selector="#carriers_usps_gateway_secure_url_inherit"/> + <element name="carriersUSPSTitle" type="input" selector="#carriers_usps_title_inherit"/> + <element name="carriersUSPSUserId" type="input" selector="#carriers_usps_userid"/> + <element name="carriersUSPSPassword" type="input" selector="#carriers_usps_password"/> + <element name="carriersUSPSShipmentRequestType" type="select" selector="#carriers_usps_shipment_requesttype_inherit"/> + <element name="carriersUSPSContainer" type="input" selector="#carriers_usps_container_inherit"/> + <element name="carriersUSPSSize" type="input" selector="#carriers_usps_size_inherit"/> + <element name="carriersUSPSDestType" type="input" selector="#carriers_usps_machinable_inherit"/> + <element name="carriersUSPSMachinable" type="input" selector="#carriers_ups_tracking_xml_url_inherit"/> + <element name="carriersUSPSMaxPackageWeight" type="input" selector="#carriers_usps_max_package_weight_inherit"/> + <element name="carriersUSPSHandlingType" type="input" selector="#carriers_usps_handling_type_inherit"/> + <element name="carriersUSPSHandlingAction" type="input" selector="#carriers_usps_handling_action_inherit"/> + <element name="carriersUSPSAllowedMethods" type="input" selector="#carriers_usps_allowed_methods_inherit"/> + <element name="carriersUSPSFreeMethod" type="input" selector="#carriers_usps_free_method_inherit"/> + <element name="carriersUSPSSpecificErrMsg" type="input" selector="#carriers_usps_specificerrmsg_inherit"/> + <element name="carriersUSPSAllowSpecific" type="input" selector="#carriers_usps_sallowspecific_inherit"/> + <element name="carriersUSPSSpecificCountry" type="input" selector="#carriers_usps_specificcountry"/> + </section> +</sections> diff --git a/app/code/Magento/Usps/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml b/app/code/Magento/Usps/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml new file mode 100644 index 000000000000..cd77861fccd5 --- /dev/null +++ b/app/code/Magento/Usps/Test/Mftf/Test/AdminCheckInputFieldsDisabledAfterAppConfigDumpTest.xml @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCheckInputFieldsDisabledAfterAppConfigDumpTest"> + <!--Assert configuration are disabled in USPS section--> + <comment userInput="Assert configuration are disabled in USPS section" stepKey="commentSeeDisabledUSPSConfigs"/> + <actionGroup ref="AdminOpenShippingMethodsConfigPageActionGroup" stepKey="openShippingMethodConfigPage"/> + <conditionalClick selector="{{AdminShippingMethodUSPSSection.carriersUSPSTab}}" dependentSelector="{{AdminShippingMethodUSPSSection.carriersUSPSActive}}" visible="false" stepKey="expandUSPSTab"/> + <waitForElementVisible selector="{{AdminShippingMethodUSPSSection.carriersUSPSActive}}" stepKey="waitUSPSTabOpen"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSActive}}" userInput="disabled" stepKey="grabUSPSActiveDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSActiveDisabled" stepKey="assertUSPSActiveDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSGatewayXMLUrl}}" userInput="disabled" stepKey="grabUSPSGatewayXMLUrlDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSGatewayXMLUrlDisabled" stepKey="assertUSPSGatewayXMLUrlDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSGatewaySecureUrl}}" userInput="disabled" stepKey="grabUSPSGatewaySecureUrlDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSGatewaySecureUrlDisabled" stepKey="assertUSPSGatewaySecureUrlDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSTitle}}" userInput="disabled" stepKey="grabUSPSTitleDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSTitleDisabled" stepKey="assertUSPSTitleDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSUserId}}" userInput="disabled" stepKey="grabUSPSUserIdDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSUserIdDisabled" stepKey="assertUSPSUserIdDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSPassword}}" userInput="disabled" stepKey="grabUSPSPasswordDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSPasswordDisabled" stepKey="assertUSPSPasswordDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSShipmentRequestType}}" userInput="disabled" stepKey="grabUSPSShipmentRequestTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSShipmentRequestTypeDisabled" stepKey="assertUSPSShipmentRequestTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSContainer}}" userInput="disabled" stepKey="grabUSPSContainerDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSContainerDisabled" stepKey="assertUSPSContainerDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSSize}}" userInput="disabled" stepKey="grabUSPSSizeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSSizeDisabled" stepKey="assertUSPSSizeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSDestType}}" userInput="disabled" stepKey="grabUSPSDestTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSDestTypeDisabled" stepKey="assertUSPSDestTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSMachinable}}" userInput="disabled" stepKey="grabUSPSMachinableDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSMachinableDisabled" stepKey="assertUSPSMachinableDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSMaxPackageWeight}}" userInput="disabled" stepKey="grabUSPSMaxPackageWeightDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSMaxPackageWeightDisabled" stepKey="assertUSPSMaxPackageWeightDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSHandlingType}}" userInput="disabled" stepKey="grabUSPSHandlingTypeDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSHandlingTypeDisabled" stepKey="assertUSPSHandlingTypeDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSHandlingAction}}" userInput="disabled" stepKey="grabUSPSHandlingActionDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSHandlingActionDisabled" stepKey="assertUSPSHandlingActionDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSAllowedMethods}}" userInput="disabled" stepKey="grabUSPSAllowedMethodsDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSAllowedMethodsDisabled" stepKey="assertUSPSAllowedMethodsDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSFreeMethod}}" userInput="disabled" stepKey="grabUSPSFreeMethodDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSFreeMethodDisabled" stepKey="assertUSPSFreeMethodDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSSpecificErrMsg}}" userInput="disabled" stepKey="grabUSPSSpecificErrMsgDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSSpecificErrMsgDisabled" stepKey="assertUSPSSpecificErrMsgDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSAllowSpecific}}" userInput="disabled" stepKey="grabUSPSAllowSpecificDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSAllowSpecificDisabled" stepKey="assertUSPSAllowSpecificDisabled"/> + <grabAttributeFrom selector="{{AdminShippingMethodUSPSSection.carriersUSPSSpecificCountry}}" userInput="disabled" stepKey="grabUSPSSpecificCountryDisabled"/> + <assertEquals expected='true' expectedType="string" actual="$grabUSPSSpecificCountryDisabled" stepKey="assertUSPSSpecificCountryDisabled"/> + </test> +</tests> diff --git a/app/code/Magento/Vault/Model/PaymentTokenSearchResults.php b/app/code/Magento/Vault/Model/PaymentTokenSearchResults.php new file mode 100644 index 000000000000..39dcf503779b --- /dev/null +++ b/app/code/Magento/Vault/Model/PaymentTokenSearchResults.php @@ -0,0 +1,18 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Vault\Model; + +use Magento\Framework\Api\SearchResults; +use Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface; + +/** + * Service Data Object with Payment Token search results. + */ +class PaymentTokenSearchResults extends SearchResults implements PaymentTokenSearchResultsInterface +{ +} diff --git a/app/code/Magento/Vault/etc/di.xml b/app/code/Magento/Vault/etc/di.xml index 95191e441757..0192a783bd5a 100644 --- a/app/code/Magento/Vault/etc/di.xml +++ b/app/code/Magento/Vault/etc/di.xml @@ -13,7 +13,7 @@ <preference for="Magento\Vault\Api\PaymentTokenRepositoryInterface" type="Magento\Vault\Model\PaymentTokenRepository" /> <preference for="Magento\Vault\Api\PaymentTokenManagementInterface" type="Magento\Vault\Model\PaymentTokenManagement" /> <preference for="Magento\Vault\Api\PaymentMethodListInterface" type="Magento\Vault\Model\PaymentMethodList" /> - <preference for="Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface" type="Magento\Framework\Api\SearchResults" /> + <preference for="Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface" type="Magento\Vault\Model\PaymentTokenSearchResults" /> <preference for="Magento\Vault\Model\Ui\TokenUiComponentInterface" type="Magento\Vault\Model\Ui\TokenUiComponent" /> <type name="Magento\Sales\Api\Data\OrderPaymentInterface"> diff --git a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php index d89513b50c9c..8dcaabda93aa 100644 --- a/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php +++ b/app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php @@ -99,7 +99,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function getUserId() { @@ -108,7 +108,7 @@ public function getUserId() } /** - * {@inheritdoc} + * @inheritdoc */ public function getUserType() { @@ -187,6 +187,8 @@ protected function processRequest() } /** + * Set user data based on user type received from token data. + * * @param Token $token * @return void */ diff --git a/app/code/Magento/Weee/Model/App/Action/ContextPlugin.php b/app/code/Magento/Weee/Model/App/Action/ContextPlugin.php index 5d5426660d8f..aae6f769eb50 100644 --- a/app/code/Magento/Weee/Model/App/Action/ContextPlugin.php +++ b/app/code/Magento/Weee/Model/App/Action/ContextPlugin.php @@ -33,7 +33,7 @@ class ContextPlugin protected $weeeHelper; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManager; @@ -63,7 +63,7 @@ class ContextPlugin * @param \Magento\Weee\Model\Tax $weeeTax * @param \Magento\Tax\Helper\Data $taxHelper * @param \Magento\Weee\Helper\Data $weeeHelper - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\PageCache\Model\Config $cacheConfig * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig @@ -74,7 +74,7 @@ public function __construct( \Magento\Weee\Model\Tax $weeeTax, \Magento\Tax\Helper\Data $taxHelper, \Magento\Weee\Helper\Data $weeeHelper, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\PageCache\Model\Config $cacheConfig, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig diff --git a/app/code/Magento/Weee/Model/ResourceModel/Tax.php b/app/code/Magento/Weee/Model/ResourceModel/Tax.php index b097e4a018f2..2cbb6054a31e 100644 --- a/app/code/Magento/Weee/Model/ResourceModel/Tax.php +++ b/app/code/Magento/Weee/Model/ResourceModel/Tax.php @@ -5,9 +5,6 @@ */ namespace Magento\Weee\Model\ResourceModel; -use Magento\Catalog\Model\Product; -use Magento\Catalog\Model\Product\Condition\ConditionInterface; - /** * Wee tax resource model * @@ -21,6 +18,11 @@ class Tax extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb */ protected $dateTime; + /** + * @var array + */ + private $weeeTaxCalculationsByEntityCache = []; + /** * @param \Magento\Framework\Model\ResourceModel\Db\Context $context * @param \Magento\Framework\Stdlib\DateTime $dateTime @@ -46,7 +48,7 @@ protected function _construct() } /** - * Fetch one + * Fetch one calculated weee attribute from a select criteria * * @param \Magento\Framework\DB\Select|string $select * @return string @@ -57,6 +59,8 @@ public function fetchOne($select) } /** + * Is there a weee attribute available for the location provided + * * @param int $countryId * @param int $regionId * @param int $websiteId @@ -91,6 +95,8 @@ public function isWeeeInLocation($countryId, $regionId, $websiteId) } /** + * Fetch calculated weee attributes by location, store and entity + * * @param int $countryId * @param int $regionId * @param int $websiteId @@ -100,43 +106,56 @@ public function isWeeeInLocation($countryId, $regionId, $websiteId) */ public function fetchWeeeTaxCalculationsByEntity($countryId, $regionId, $websiteId, $storeId, $entityId) { - $attributeSelect = $this->getConnection()->select(); - $attributeSelect->from( - ['eavTable' => $this->getTable('eav_attribute')], - ['eavTable.attribute_code', 'eavTable.attribute_id', 'eavTable.frontend_label'] - )->joinLeft( - ['eavLabel' => $this->getTable('eav_attribute_label')], - 'eavLabel.attribute_id = eavTable.attribute_id and eavLabel.store_id = ' .((int) $storeId), - 'eavLabel.value as label_value' - )->joinInner( - ['weeeTax' => $this->getTable('weee_tax')], - 'weeeTax.attribute_id = eavTable.attribute_id', - 'weeeTax.value as weee_value' - )->where( - 'eavTable.frontend_input = ?', - 'weee' - )->where( - 'weeeTax.website_id IN(?)', - [$websiteId, 0] - )->where( - 'weeeTax.country = ?', - $countryId - )->where( - 'weeeTax.state IN(?)', - [$regionId, 0] - )->where( - 'weeeTax.entity_id = ?', - (int)$entityId + $cacheKey = sprintf( + '%s-%s-%s-%s-%s', + $countryId, + $regionId, + $websiteId, + $storeId, + $entityId ); + if (!isset($this->weeeTaxCalculationsByEntityCache[$cacheKey])) { + $attributeSelect = $this->getConnection()->select(); + $attributeSelect->from( + ['eavTable' => $this->getTable('eav_attribute')], + ['eavTable.attribute_code', 'eavTable.attribute_id', 'eavTable.frontend_label'] + )->joinLeft( + ['eavLabel' => $this->getTable('eav_attribute_label')], + 'eavLabel.attribute_id = eavTable.attribute_id and eavLabel.store_id = ' . ((int)$storeId), + 'eavLabel.value as label_value' + )->joinInner( + ['weeeTax' => $this->getTable('weee_tax')], + 'weeeTax.attribute_id = eavTable.attribute_id', + 'weeeTax.value as weee_value' + )->where( + 'eavTable.frontend_input = ?', + 'weee' + )->where( + 'weeeTax.website_id IN(?)', + [$websiteId, 0] + )->where( + 'weeeTax.country = ?', + $countryId + )->where( + 'weeeTax.state IN(?)', + [$regionId, 0] + )->where( + 'weeeTax.entity_id = ?', + (int)$entityId + ); - $order = ['weeeTax.state ' . \Magento\Framework\DB\Select::SQL_DESC, - 'weeeTax.website_id ' . \Magento\Framework\DB\Select::SQL_DESC]; - $attributeSelect->order($order); + $order = ['weeeTax.state ' . \Magento\Framework\DB\Select::SQL_DESC, + 'weeeTax.website_id ' . \Magento\Framework\DB\Select::SQL_DESC]; + $attributeSelect->order($order); - $values = $this->getConnection()->fetchAll($attributeSelect); + $values = $this->getConnection()->fetchAll($attributeSelect); - if ($values) { - return $values; + if ($values) { + $this->weeeTaxCalculationsByEntityCache[$cacheKey] = $values; + return $values; + } + } else { + return $this->weeeTaxCalculationsByEntityCache[$cacheKey]; } return []; diff --git a/app/code/Magento/Weee/Observer/AfterAddressSave.php b/app/code/Magento/Weee/Observer/AfterAddressSave.php index 9acea506adf6..ba15854b2dff 100644 --- a/app/code/Magento/Weee/Observer/AfterAddressSave.php +++ b/app/code/Magento/Weee/Observer/AfterAddressSave.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Address; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\PageCache\Model\Config; use Magento\Tax\Api\TaxAddressManagerInterface; use Magento\Weee\Helper\Data; @@ -26,7 +26,7 @@ class AfterAddressSave implements ObserverInterface /** * Module manager * - * @var ModuleManagerInterface + * @var Manager */ private $moduleManager; @@ -46,13 +46,13 @@ class AfterAddressSave implements ObserverInterface /** * @param Data $weeeHelper - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Config $cacheConfig * @param TaxAddressManagerInterface $addressManager */ public function __construct( Data $weeeHelper, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, Config $cacheConfig, TaxAddressManagerInterface $addressManager ) { diff --git a/app/code/Magento/Weee/Observer/CustomerLoggedIn.php b/app/code/Magento/Weee/Observer/CustomerLoggedIn.php index 95299d96cabd..0b22c24d7fa2 100644 --- a/app/code/Magento/Weee/Observer/CustomerLoggedIn.php +++ b/app/code/Magento/Weee/Observer/CustomerLoggedIn.php @@ -8,7 +8,7 @@ use Magento\Customer\Model\Session; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\PageCache\Model\Config; use Magento\Tax\Api\TaxAddressManagerInterface; use Magento\Weee\Helper\Data; @@ -52,13 +52,13 @@ class CustomerLoggedIn implements ObserverInterface /** * @param Data $weeeHelper - * @param ModuleManagerInterface $moduleManager + * @param Manager $moduleManager * @param Config $cacheConfig * @param TaxAddressManagerInterface $addressManager */ public function __construct( Data $weeeHelper, - ModuleManagerInterface $moduleManager, + Manager $moduleManager, Config $cacheConfig, TaxAddressManagerInterface $addressManager ) { diff --git a/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php b/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php index b720f42378fa..c829b524527a 100644 --- a/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php +++ b/app/code/Magento/Weee/Test/Unit/App/Action/ContextPluginTest.php @@ -39,7 +39,7 @@ class ContextPluginTest extends \PHPUnit\Framework\TestCase protected $taxCalculationMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $moduleManagerMock; @@ -93,7 +93,7 @@ protected function setUp() ) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php index a7b88f572712..868d603f34b8 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/AfterAddressSaveTest.php @@ -18,7 +18,7 @@ class AfterAddressSaveTest extends \PHPUnit\Framework\TestCase * @var ObjectManager */ private $objectManager; - + /** * @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject */ @@ -27,7 +27,7 @@ class AfterAddressSaveTest extends \PHPUnit\Framework\TestCase /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ private $moduleManagerMock; @@ -42,7 +42,7 @@ class AfterAddressSaveTest extends \PHPUnit\Framework\TestCase * @var \Magento\Weee\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ private $weeeHelperMock; - + /** * @var TaxAddressManagerInterface|MockObject */ @@ -61,7 +61,7 @@ protected function setUp() ->setMethods(['getCustomerAddress']) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); @@ -129,7 +129,7 @@ public function testExecute( $this->addressManagerMock->expects($isNeedSetAddress ? $this->once() : $this->never()) ->method('setDefaultAddressAfterSave') ->with($address); - + $this->session->execute($this->observerMock); } diff --git a/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php b/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php index 06d1dbedcfd8..af8c2e70a8ff 100644 --- a/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php +++ b/app/code/Magento/Weee/Test/Unit/Observer/CustomerLoggedInTest.php @@ -21,7 +21,7 @@ class CustomerLoggedInTest extends \PHPUnit\Framework\TestCase /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManagerMock; @@ -59,7 +59,7 @@ protected function setUp() ) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/WeeeGraphQl/Model/Resolver/FixedProductTax.php b/app/code/Magento/WeeeGraphQl/Model/Resolver/FixedProductTax.php new file mode 100644 index 000000000000..98164c18e858 --- /dev/null +++ b/app/code/Magento/WeeeGraphQl/Model/Resolver/FixedProductTax.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\WeeeGraphQl\Model\Resolver; + +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Weee\Helper\Data; +use Magento\Framework\Exception\LocalizedException; +use Magento\Tax\Helper\Data as TaxHelper; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Tax\Model\Config; + +/** + * Resolver for FixedProductTax object that retrieves an array of FPT attributes with prices + */ +class FixedProductTax implements ResolverInterface +{ + /** + * @var Data + */ + private $weeeHelper; + + /** + * @var TaxHelper + */ + private $taxHelper; + + /** + * @param Data $weeeHelper + * @param TaxHelper $taxHelper + */ + public function __construct(Data $weeeHelper, TaxHelper $taxHelper) + { + $this->weeeHelper = $weeeHelper; + $this->taxHelper = $taxHelper; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($value['model'])) { + throw new LocalizedException(__('"model" value should be specified')); + } + + $fptArray = []; + $product = $value['model']; + + /** @var StoreInterface $store */ + $store = $context->getExtensionAttributes()->getStore(); + + if ($this->weeeHelper->isEnabled($store)) { + $attributes = $this->weeeHelper->getProductWeeeAttributesForDisplay($product); + foreach ($attributes as $attribute) { + $displayInclTaxes = $this->taxHelper->getPriceDisplayType($store); + $amount = $attribute->getData('amount'); + //add display mode for WEE to not return WEE if excluded + if ($displayInclTaxes === Config::DISPLAY_TYPE_EXCLUDING_TAX) { + $amount = $attribute->getData('amount_excl_tax'); + } elseif ($displayInclTaxes === Config::DISPLAY_TYPE_INCLUDING_TAX) { + $amount = $attribute->getData('amount_excl_tax') + $attribute->getData('tax_amount'); + } + $fptArray[] = [ + 'amount' => [ + 'value' => $amount, + 'currency' => $value['final_price']['currency'], + ], + 'label' => $attribute->getData('name') + ]; + } + } + + return $fptArray; + } +} diff --git a/app/code/Magento/WeeeGraphQl/Model/Resolver/StoreConfig.php b/app/code/Magento/WeeeGraphQl/Model/Resolver/StoreConfig.php new file mode 100644 index 000000000000..d2ea44fff5bc --- /dev/null +++ b/app/code/Magento/WeeeGraphQl/Model/Resolver/StoreConfig.php @@ -0,0 +1,118 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\WeeeGraphQl\Model\Resolver; + +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Weee\Helper\Data; +use Magento\Tax\Helper\Data as TaxHelper; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Weee\Model\Tax as WeeeDisplayConfig; +use Magento\Framework\Pricing\Render; + +/** + * Resolver for the FPT store config settings + */ +class StoreConfig implements ResolverInterface +{ + /** + * @var string + */ + private static $weeeDisplaySettingsNone = 'FPT_DISABLED'; + + /** + * @var array + */ + private static $weeeDisplaySettings = [ + WeeeDisplayConfig::DISPLAY_INCL => 'INCLUDE_FPT_WITHOUT_DETAILS', + WeeeDisplayConfig::DISPLAY_INCL_DESCR => 'INCLUDE_FPT_WITH_DETAILS', + WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL => 'EXCLUDE_FPT_AND_INCLUDE_WITH_DETAILS', + WeeeDisplayConfig::DISPLAY_EXCL => 'EXCLUDE_FPT_WITHOUT_DETAILS' + ]; + + /** + * @var Data + */ + private $weeeHelper; + + /** + * @var TaxHelper + */ + private $taxHelper; + + /** + * @var array + */ + private $computedFptSettings = []; + + /** + * @param Data $weeeHelper + * @param TaxHelper $taxHelper + */ + public function __construct(Data $weeeHelper, TaxHelper $taxHelper) + { + $this->weeeHelper = $weeeHelper; + $this->taxHelper = $taxHelper; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (empty($this->computedFptSettings)) { + /** @var StoreInterface $store */ + $store = $context->getExtensionAttributes()->getStore(); + $storeId = (int)$store->getId(); + + $this->computedFptSettings = [ + 'product_fixed_product_tax_display_setting' => self::$weeeDisplaySettingsNone, + 'category_fixed_product_tax_display_setting' => self::$weeeDisplaySettingsNone, + 'sales_fixed_product_tax_display_setting' => self::$weeeDisplaySettingsNone, + ]; + if ($this->weeeHelper->isEnabled($store)) { + $productFptDisplay = $this->getWeeDisplaySettingsByZone(Render::ZONE_ITEM_VIEW, $storeId); + $categoryFptDisplay = $this->getWeeDisplaySettingsByZone(Render::ZONE_ITEM_LIST, $storeId); + $salesModulesFptDisplay = $this->getWeeDisplaySettingsByZone(Render::ZONE_SALES, $storeId); + + $this->computedFptSettings = [ + 'product_fixed_product_tax_display_setting' => self::$weeeDisplaySettings[$productFptDisplay] ?? + self::$weeeDisplaySettingsNone, + 'category_fixed_product_tax_display_setting' => self::$weeeDisplaySettings[$categoryFptDisplay] ?? + self::$weeeDisplaySettingsNone, + 'sales_fixed_product_tax_display_setting' => self::$weeeDisplaySettings[$salesModulesFptDisplay] ?? + self::$weeeDisplaySettingsNone, + ]; + } + } + + return $this->computedFptSettings[$info->fieldName] ?? null; + } + + /** + * Get the weee system display setting + * + * @param string $zone + * @param string $storeId + * @return string + */ + private function getWeeDisplaySettingsByZone(string $zone, int $storeId): int + { + return (int) $this->weeeHelper->typeOfDisplay( + null, + $zone, + $storeId + ); + } +} diff --git a/app/code/Magento/WeeeGraphQl/composer.json b/app/code/Magento/WeeeGraphQl/composer.json index 0bf303f789a7..39b77bb569ac 100644 --- a/app/code/Magento/WeeeGraphQl/composer.json +++ b/app/code/Magento/WeeeGraphQl/composer.json @@ -4,10 +4,12 @@ "type": "magento2-module", "require": { "php": "~7.1.3||~7.2.0||~7.3.0", - "magento/framework": "*" + "magento/framework": "*", + "magento/module-store": "*", + "magento/module-tax": "*", + "magento/module-weee": "*" }, "suggest": { - "magento/module-weee": "*", "magento/module-catalog-graph-ql": "*" }, "license": [ diff --git a/app/code/Magento/WeeeGraphQl/etc/schema.graphqls b/app/code/Magento/WeeeGraphQl/etc/schema.graphqls index 731260ce9e1e..18b0e7c1823e 100644 --- a/app/code/Magento/WeeeGraphQl/etc/schema.graphqls +++ b/app/code/Magento/WeeeGraphQl/etc/schema.graphqls @@ -2,6 +2,29 @@ # See COPYING.txt for license details. enum PriceAdjustmentCodesEnum { - WEE - WEETAX + WEEE @deprecated(reason: "WEEE code is deprecated, use fixed_product_taxes.label") + WEEE_TAX @deprecated(reason: "Use fixed_product_taxes. PriceAdjustmentCodesEnum is deprecated. Tax is included or excluded in price. Tax is not shown separtely in Catalog") +} + +type ProductPrice { + fixed_product_taxes: [FixedProductTax] @doc(description: "The multiple FPTs that can be applied to a product price.") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\FixedProductTax") +} + +type FixedProductTax @doc(description: "A single FPT that can be applied to a product price.") { + amount: Money @doc(description: "Amount of the FPT as a money object.") + label: String @doc(description: "The label assigned to the FPT to be displayed on the frontend.") +} + +type StoreConfig { + product_fixed_product_tax_display_setting : FixedProductTaxDisplaySettings @doc(description: "Corresponds to the 'Display Prices On Product View Page' field. It indicates how FPT information is displayed on product pages") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\StoreConfig") + category_fixed_product_tax_display_setting : FixedProductTaxDisplaySettings @doc(description: "Corresponds to the 'Display Prices In Product Lists' field. It indicates how FPT information is displayed on category pages") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\StoreConfig") + sales_fixed_product_tax_display_setting : FixedProductTaxDisplaySettings @doc(description: "Corresponds to the 'Display Prices In Sales Modules' field. It indicates how FPT information is displayed on cart, checkout, and order pages") @resolver(class: "Magento\\WeeeGraphQl\\Model\\Resolver\\StoreConfig") +} + +enum FixedProductTaxDisplaySettings @doc(description: "This enumeration display settings for the fixed product tax") { + INCLUDE_FPT_WITHOUT_DETAILS @doc(description: "The displayed price includes the FPT amount without displaying the ProductPrice.fixed_product_taxes values. This value corresponds to 'Including FPT only'") + INCLUDE_FPT_WITH_DETAILS @doc(description: "The displayed price includes the FPT amount while displaying the values of ProductPrice.fixed_product_taxes separately. This value corresponds to 'Including FPT and FPT description'") + EXCLUDE_FPT_AND_INCLUDE_WITH_DETAILS @doc(description: "The displayed price does not include the FPT amount. The values of ProductPrice.fixed_product_taxes and the price including the FPT are displayed separately. This value corresponds to 'Excluding FPT, Including FPT description and final price'") + EXCLUDE_FPT_WITHOUT_DETAILS @doc(description: "The displayed price does not include the FPT amount. The values from ProductPrice.fixed_product_taxes are not displayed. This value corresponds to 'Excluding FPT'") + FPT_DISABLED @doc(description: "The FPT feature is not enabled. You can omit ProductPrice.fixed_product_taxes from your query") } diff --git a/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml b/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml index 2c4e2e70fec7..c63e76d85193 100644 --- a/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml +++ b/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml @@ -27,7 +27,7 @@ </before> <after> - <amOnPage url="admin/admin/auth/logout/" stepKey="logout"/> + <actionGroup ref="logout" stepKey="logout"/> </after> <!-- Create a CMS page containing the New Products widget --> diff --git a/app/code/Magento/Wishlist/Controller/Index/Add.php b/app/code/Magento/Wishlist/Controller/Index/Add.php index 5cb60905aea4..3ed152cb8412 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Add.php +++ b/app/code/Magento/Wishlist/Controller/Index/Add.php @@ -7,15 +7,18 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\App\Action; +use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Data\Form\FormKey\Validator; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Controller\ResultFactory; /** + * Wish list Add controller + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class Add extends \Magento\Wishlist\Controller\AbstractIndex +class Add extends \Magento\Wishlist\Controller\AbstractIndex implements HttpPostActionInterface { /** * @var \Magento\Wishlist\Controller\WishlistProviderInterface @@ -138,6 +141,7 @@ public function execute() 'referer' => $referer ] ); + // phpcs:disable Magento2.Exceptions.ThrowCatch } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage( __('We can\'t add the item to Wish List right now: %1.', $e->getMessage()) diff --git a/app/code/Magento/Wishlist/Controller/Index/Plugin.php b/app/code/Magento/Wishlist/Controller/Index/Plugin.php index 60d6859613d5..150e4de72b40 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Plugin.php +++ b/app/code/Magento/Wishlist/Controller/Index/Plugin.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -12,6 +11,9 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\App\Response\RedirectInterface; +/** + * Wishlist plugin before dispatch + */ class Plugin { /** @@ -75,7 +77,9 @@ public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject, if (!$this->customerSession->getBeforeWishlistUrl()) { $this->customerSession->setBeforeWishlistUrl($this->redirector->getRefererUrl()); } - $this->customerSession->setBeforeWishlistRequest($request->getParams()); + $data = $request->getParams(); + unset($data['login']); + $this->customerSession->setBeforeWishlistRequest($data); $this->customerSession->setBeforeRequestParams($this->customerSession->getBeforeWishlistRequest()); $this->customerSession->setBeforeModuleName('wishlist'); $this->customerSession->setBeforeControllerName('index'); diff --git a/app/code/Magento/Wishlist/Setup/Patch/Schema/AddProductIdConstraint.php b/app/code/Magento/Wishlist/Setup/Patch/Schema/AddProductIdConstraint.php deleted file mode 100644 index 5c65fce10ccd..000000000000 --- a/app/code/Magento/Wishlist/Setup/Patch/Schema/AddProductIdConstraint.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\Wishlist\Setup\Patch\Schema; - -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\Setup\Patch\SchemaPatchInterface; -use Magento\Framework\Setup\SchemaSetupInterface; - -/** - * Class AddProductIdConstraint - */ -class AddProductIdConstraint implements SchemaPatchInterface -{ - /** - * @var SchemaSetupInterface - */ - private $schemaSetup; - - /** - * @param SchemaSetupInterface $schemaSetup - */ - public function __construct( - SchemaSetupInterface $schemaSetup - ) { - $this->schemaSetup = $schemaSetup; - } - - /** - * Run code inside patch. - * - * @return void - */ - public function apply() - { - $this->schemaSetup->startSetup(); - - $this->schemaSetup->getConnection()->addForeignKey( - $this->schemaSetup->getConnection()->getForeignKeyName( - $this->schemaSetup->getTable('wishlist_item_option'), - 'product_id', - $this->schemaSetup->getTable('catalog_product_entity'), - 'entity_id' - ), - $this->schemaSetup->getTable('wishlist_item_option'), - 'product_id', - $this->schemaSetup->getTable('catalog_product_entity'), - 'entity_id', - AdapterInterface::FK_ACTION_CASCADE, - true - ); - - $this->schemaSetup->endSetup(); - } - - /** - * Get array of patches that have to be executed prior to this. - * - * @return string[] - */ - public static function getDependencies() - { - return []; - } - - /** - * Get aliases (previous names) for the patch. - * - * @return string[] - */ - public function getAliases() - { - return []; - } -} diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/ConfigurableProductChildImageShouldBeShownOnWishListTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/ConfigurableProductChildImageShouldBeShownOnWishListTest.xml index 6b951c89208c..0489ec750b7e 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/ConfigurableProductChildImageShouldBeShownOnWishListTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/ConfigurableProductChildImageShouldBeShownOnWishListTest.xml @@ -32,7 +32,7 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="customer" stepKey="deleteCustomer"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/> <waitForPageLoad stepKey="waitForProductIndexPageLoad"/> diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml index e8b645990390..aeb1d134d8e2 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml @@ -48,7 +48,7 @@ <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/> <actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearProductsFilters"/> <!--Logout everywhere--> - <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + <actionGroup ref="logout" stepKey="adminLogout"/> <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/> </after> diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeletePersistedWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeletePersistedWishlistTest.xml index 3c84562542ad..f1659baaa4e0 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeletePersistedWishlistTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeletePersistedWishlistTest.xml @@ -32,7 +32,7 @@ <deleteData stepKey="deleteCategory" createDataKey="category"/> <deleteData stepKey="deleteProduct" createDataKey="product"/> <deleteData stepKey="deleteCustomer" createDataKey="customer"/> - <amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/> + <actionGroup ref="logout" stepKey="adminLogout"/> </after> <amOnPage stepKey="amOnSignInPage" url="{{StorefrontCustomerSignInPage.url}}"/> diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontRemoveProductsFromWishlistUsingSidebarTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontRemoveProductsFromWishlistUsingSidebarTest.xml index e3382dc41d27..6c73cb6708ae 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontRemoveProductsFromWishlistUsingSidebarTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontRemoveProductsFromWishlistUsingSidebarTest.xml @@ -34,6 +34,11 @@ <deleteData createDataKey="categorySecond" stepKey="deleteCategorySecond"/> <deleteData createDataKey="customer" stepKey="deleteCustomer"/> </after> + + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <!-- Sign in as customer --> <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> <argument name="Customer" value="$$customer$$"/> diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml index e482449f623f..b8a84a327b58 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml @@ -26,6 +26,10 @@ <createData entity="Simple_US_Customer" stepKey="customer"/> </before> + <!-- Perform reindex and flush cache --> + <magentoCLI command="indexer:reindex" stepKey="reindex"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> <argument name="Customer" value="$$customer$$"/> </actionGroup> diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php index 399b48073b33..2b583f910151 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php @@ -6,6 +6,9 @@ namespace Magento\Wishlist\Test\Unit\Controller\Index; +/** + * Test for wishlist plugin before dispatch + */ class PluginTest extends \PHPUnit\Framework\TestCase { /** @@ -38,22 +41,26 @@ class PluginTest extends \PHPUnit\Framework\TestCase */ protected $request; + /** + * @inheritdoc + */ protected function setUp() { $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) ->disableOriginalConstructor() - ->setMethods([ - 'authenticate', - 'getBeforeWishlistUrl', - 'setBeforeWishlistUrl', - 'setBeforeWishlistRequest', - 'getBeforeWishlistRequest', - 'setBeforeRequestParams', - 'setBeforeModuleName', - 'setBeforeControllerName', - 'setBeforeAction', - ]) - ->getMock(); + ->setMethods( + [ + 'authenticate', + 'getBeforeWishlistUrl', + 'setBeforeWishlistUrl', + 'setBeforeWishlistRequest', + 'getBeforeWishlistRequest', + 'setBeforeRequestParams', + 'setBeforeModuleName', + 'setBeforeControllerName', + 'setBeforeAction', + ] + )->getMock(); $this->authenticationState = $this->createMock(\Magento\Wishlist\Model\AuthenticationState::class); $this->config = $this->createMock(\Magento\Framework\App\Config::class); @@ -62,6 +69,9 @@ protected function setUp() $this->request = $this->createMock(\Magento\Framework\App\Request\Http::class); } + /** + * @inheritdoc + */ protected function tearDown() { unset( @@ -96,6 +106,7 @@ public function testBeforeDispatch() $refererUrl = 'http://referer-url.com'; $params = [ 'product' => 1, + 'login' => [], ]; $actionFlag = $this->createMock(\Magento\Framework\App\ActionFlag::class); @@ -139,7 +150,7 @@ public function testBeforeDispatch() ->willReturnSelf(); $this->customerSession->expects($this->once()) ->method('setBeforeWishlistRequest') - ->with($params) + ->with(['product' => 1]) ->willReturnSelf(); $this->customerSession->expects($this->once()) ->method('getBeforeWishlistRequest') diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php index b55766d77fee..d0397be83fac 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/RssTest.php @@ -46,7 +46,7 @@ class RssTest extends \PHPUnit\Framework\TestCase protected $customerRepositoryMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ protected $moduleManagerMock; @@ -80,7 +80,7 @@ protected function setUp() $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class) ->getMock(); - $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\ModuleManagerInterface::class) + $this->moduleManagerMock = $this->getMockBuilder(\Magento\Framework\Module\Manager::class) ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Wishlist/etc/db_schema.xml b/app/code/Magento/Wishlist/etc/db_schema.xml index e3f3024df45f..e430a1ee40ea 100644 --- a/app/code/Magento/Wishlist/etc/db_schema.xml +++ b/app/code/Magento/Wishlist/etc/db_schema.xml @@ -77,5 +77,9 @@ <constraint xsi:type="foreign" referenceId="FK_A014B30B04B72DD0EAB3EECD779728D6" table="wishlist_item_option" column="wishlist_item_id" referenceTable="wishlist_item" referenceColumn="wishlist_item_id" onDelete="CASCADE"/> + <constraint xsi:type="foreign" referenceId="WISHLIST_ITEM_OPTION_PRODUCT_ID_CATALOG_PRODUCT_ENTITY_ENTITY_ID" + table="wishlist_item_option" + column="product_id" referenceTable="catalog_product_entity" referenceColumn="entity_id" + onDelete="CASCADE"/> </table> </schema> diff --git a/app/design/adminhtml/Magento/backend/Magento_AdminAnalytics/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_AdminAnalytics/web/css/source/_module.less new file mode 100644 index 000000000000..05c0653a9bac --- /dev/null +++ b/app/design/adminhtml/Magento/backend/Magento_AdminAnalytics/web/css/source/_module.less @@ -0,0 +1,43 @@ +// /** +// * Copyright © Magento, Inc. All rights reserved. +// * See COPYING.txt for license details. +// */ + +// +// Magento_AdminAnalytics Modal on dashboard +// --------------------------------------------- + +.admin-usage-notification { + -webkit-transition: visibility 0s .5s, opacity .5s ease; + transition: visibility 0s .5s, opacity .5s ease; + + &._show { + -webkit-transition: opacity .5s ease; + opacity: 1; + transition: opacity .5s ease; + visibility: visible; + } + + .modal-inner-wrap { + .modal-content, + .modal-header { + padding-left: 4rem; + padding-right: 4rem; + + .action-close { + display: none; + } + } + + -webkit-transform: translateX(0); + -webkit-transition: -webkit-transform 0s; + transition: transform 0s; + transform: translateX(0); + margin-top: 13rem; + max-width: 75rem; + } + + .admin__fieldset { + padding: 0; + } +} diff --git a/app/design/adminhtml/Magento/backend/Magento_Banner/web/css/source/_module.less b/app/design/adminhtml/Magento/backend/Magento_Banner/web/css/source/_module.less index d9e2cfdd66bf..dd67220db12d 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Banner/web/css/source/_module.less +++ b/app/design/adminhtml/Magento/backend/Magento_Banner/web/css/source/_module.less @@ -24,6 +24,7 @@ input[type='checkbox'].banner-content-checkbox { } .adminhtml-widget_instance-edit, +.adminhtml-cms_page-edit, .adminhtml-banner-edit { .admin__fieldset { .admin__field-control { diff --git a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_currency-addon.less b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_currency-addon.less index 659b1fa811db..fa158589feb9 100644 --- a/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_currency-addon.less +++ b/app/design/adminhtml/Magento/backend/Magento_ConfigurableProduct/web/css/source/module/components/_currency-addon.less @@ -22,10 +22,10 @@ position: relative; display: -webkit-inline-flex; display: -ms-inline-flexbox; + display: inline-flex; -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; - display: inline-flex; flex-flow: row nowrap; width: 100%; diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less index ffa5ee963952..055e74c97a2f 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/_order.less @@ -308,4 +308,62 @@ } } +// +// Create Order - Add Product Grid +// --------------------------------------------- + +#sales_order_create_search_grid { + .col-in_products { + .data-grid-checkbox-cell-inner { + position: relative; + } + .checkbox { + width: 1.6rem; + height: 1.6rem; + left: 0; + right: 0; + margin: auto; + } + } +} + +// +// Create Order - Add Product with Custom Options Modal +// ---------------------------------------------------- + +#product_composite_configure_form_fields { + .admin__field { + &.required { + .admin__field-label { + &:after { + color: #e22626; + content: '*'; + display: inline-block; + font-size: 1.6rem; + font-weight: 500; + line-height: 1; + margin-left: 10px; + margin-top: .2rem; + position: absolute; + z-index: 1; + } + } + .price-container, .price-notice, .price-wrapper { + &:after { + color: unset; + content: unset; + display: unset; + font-size: unset; + font-weight: unset; + line-height: unset; + margin-left: unset; + margin-top: unset; + position: unset; + z-index: unset; + } + } + } + } +} + // ToDo: MAGETWO-32299 UI: review the collapsible block diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_payment-shipping.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_payment-shipping.less index 029594625ed1..2c55d243ebe0 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_payment-shipping.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_payment-shipping.less @@ -73,7 +73,7 @@ } .order-shipping-address & { span { - top: 22px; + top: 0; } } } diff --git a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less index 6e663b15c89c..f2369ad8f35e 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less +++ b/app/design/adminhtml/Magento/backend/Magento_Sales/web/css/source/module/order/_total.less @@ -22,10 +22,6 @@ } } -.totals-actions { - text-align: right; -} - .order-totals-actions { margin-top: @indent__s; .actions { 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 c6f39e8e8840..ab4bac919ee5 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 @@ -59,15 +59,15 @@ .admin__control-select { &:extend(.abs-form-control-pattern all); .lib-css(appearance, none, 1); - background-image+: url('../images/arrows-bg.svg'); + background-image+: url('../images/arrows-bg.svg') !important; background-position+: ~'calc(100% - 12px)' -34px; background-size+: auto; - background-image+: linear-gradient(@color-gray89, @color-gray89); + background-image+: linear-gradient(@color-gray89, @color-gray89) !important; background-position+: 100%; background-size+: @field-control__height 100%; - background-image+: linear-gradient(@field-control__border-color,@field-control__border-color); + background-image+: linear-gradient(@field-control__border-color,@field-control__border-color) !important; background-position+: ~'calc(100% - @{field-control__height})' 0; background-size+: 1px 100%; @@ -86,13 +86,13 @@ } &:active { - background-image+: url('../images/arrows-bg.svg'); + background-image+: url('../images/arrows-bg.svg') !important; background-position+: ~'calc(100% - 12px)' 13px; - background-image+: linear-gradient(@color-gray89, @color-gray89); + background-image+: linear-gradient(@color-gray89, @color-gray89) !important; background-position+: 100%; - background-image+: linear-gradient(@field-control__focus__border-color, @field-control__focus__border-color); + background-image+: linear-gradient(@field-control__focus__border-color, @field-control__focus__border-color) !important; background-position+: ~'calc(100% - @{field-control__height})' 0; border-color: @field-control__focus__border-color; } diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less index 08aeb35d7adb..ddc6aa42c23e 100644 --- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less +++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less @@ -122,7 +122,7 @@ > .admin__field-control { #mix-grid .column(@field-control-grid__column, @field-grid__columns); input[type="checkbox"] { - margin-top: @indent__s; + margin-top: 0; } } @@ -156,7 +156,7 @@ .admin__field { margin-top: 8px; } - } + } } } &.composite-bundle { @@ -307,7 +307,7 @@ .admin__fieldset > & { margin-bottom: 3rem; position: relative; - + &.field-import_file { .input-file { margin-top: 6px; @@ -361,6 +361,11 @@ cursor: inherit; opacity: 1; outline: inherit; + .admin__action-multiselect-wrap { + .admin__action-multiselect { + .__form-control-pattern__disabled(); + } + } } &._hidden { @@ -664,7 +669,7 @@ display: inline-block; } } - + + .admin__field:last-child { width: auto; @@ -700,7 +705,7 @@ width: 100%; } } - & > .admin__field-label { + & > .admin__field-label { text-align: left; } 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 44fca79c31be..b2afde435a62 100644 --- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less +++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less @@ -4070,6 +4070,21 @@ } } +.adminhtml-email_template-preview { + .cms-revision-preview { + padding-top: 56.25%; + position: relative; + + #preview_iframe { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + } +} + .admin__scope-old { .buttons-set { margin: 0 0 15px; diff --git a/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less index 678ac535d5d7..07317e1670a0 100644 --- a/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Swatches/web/css/source/_module.less @@ -120,7 +120,7 @@ &.selected { .lib-css(background, @attr-swatch-option__selected__background); .lib-css(border, @attr-swatch-option__selected__border); - .lib-css(color, @attr-swatch-option__selected__color); + .lib-css(color, @attr-swatch-option__selected__color); } } } @@ -180,7 +180,9 @@ } &.disabled { + box-shadow: unset; cursor: default; + pointer-events: none; &:after { // ToDo: improve .lib-background-gradient() to support diagonal gradient diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less index a2daf0da247d..ce3f45c990b9 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less @@ -78,27 +78,28 @@ } .abs-discount-code { - .actions-toolbar { - display: table-cell; - vertical-align: top; - width: 1%; - - .primary { - float: left; - .action { - &:extend(.abs-revert-to-action-secondary all); - border-bottom-left-radius: 0; - border-top-left-radius: 0; - margin: 0 0 0 -2px; - white-space: nowrap; - width: auto; - } - } - } - .form-discount { + .form-discount { display: table; width: 100%; - + + .actions-toolbar { + display: table-cell; + vertical-align: top; + width: 1%; + + .primary { + float: left; + .action { + &:extend(.abs-revert-to-action-secondary all); + border-bottom-left-radius: 0; + border-top-left-radius: 0; + margin: 0 0 0 -2px; + white-space: nowrap; + width: auto; + } + } + } + > .field { > .label { display: none; diff --git a/app/design/frontend/Magento/luma/Magento_GiftMessage/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_GiftMessage/web/css/source/_module.less index ff377a4b88ac..0f2a0db56a35 100644 --- a/app/design/frontend/Magento/luma/Magento_GiftMessage/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_GiftMessage/web/css/source/_module.less @@ -328,7 +328,7 @@ .gift-options-cart-item { & + .towishlist { - left: 43px; + left: 0; position: absolute; } } diff --git a/app/etc/di.xml b/app/etc/di.xml index 335743aef8ee..f8818de2af84 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -66,7 +66,6 @@ <preference for="Magento\Framework\Config\CacheInterface" type="Magento\Framework\App\Cache\Type\Config" /> <preference for="Magento\Framework\Config\ValidationStateInterface" type="Magento\Framework\App\Arguments\ValidationState" /> <preference for="Magento\Framework\Module\ModuleListInterface" type="Magento\Framework\Module\ModuleList" /> - <preference for="Magento\Framework\Module\ModuleManagerInterface" type="Magento\Framework\Module\Manager" /> <preference for="Magento\Framework\Component\ComponentRegistrarInterface" type="Magento\Framework\Component\ComponentRegistrar"/> <preference for="Magento\Framework\Event\ConfigInterface" type="Magento\Framework\Event\Config" /> <preference for="Magento\Framework\Event\InvokerInterface" type="Magento\Framework\Event\Invoker\InvokerDefault" /> @@ -664,6 +663,14 @@ <argument name="argumentInterpreter" xsi:type="object">layoutArgumentGeneratorInterpreter</argument> </arguments> </type> + <type name="Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject"> + <arguments> + <argument name="classWhitelist" xsi:type="array"> + <item name="0" xsi:type="string">Magento\Framework\Data\OptionSourceInterface</item> + <item name="1" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface</item> + </argument> + </arguments> + </type> <type name="Magento\Framework\Mview\View"> <arguments> <argument name="state" xsi:type="object" shared="false">Magento\Indexer\Model\Mview\View\State</argument> @@ -1495,6 +1502,16 @@ </argument> </arguments> </type> + <virtualType name="Magento\Framework\Config\ValidationState\Required" type="Magento\Framework\Config\ValidationState\Configurable"> + <arguments> + <argument name="required" xsi:type="boolean">true</argument> + </arguments> + </virtualType> + <virtualType name="Magento\Framework\Config\ValidationState\NotRequired" type="Magento\Framework\Config\ValidationState\Configurable"> + <arguments> + <argument name="required" xsi:type="boolean">false</argument> + </arguments> + </virtualType> <virtualType name="Magento\Framework\Setup\Declaration\Schema\Config\SchemaLocator" type="Magento\Framework\Config\SchemaLocator"> <arguments> <argument name="realPath" xsi:type="string">urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd</argument> diff --git a/app/functions.php b/app/functions.php index 4b00d01819f7..6b3dae71c42c 100644 --- a/app/functions.php +++ b/app/functions.php @@ -13,6 +13,9 @@ * @return \Magento\Framework\Phrase */ if (!function_exists('__')) { + /** + * @return \Magento\Framework\Phrase + */ function __() { $argc = func_get_args(); diff --git a/composer.json b/composer.json index fdbfb664c9b1..34dd9aa5a50e 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,6 @@ "ext-pdo_mysql": "*", "ext-simplexml": "*", "ext-soap": "*", - "ext-spl": "*", "ext-xsl": "*", "ext-zip": "*", "lib-libxml": "*", @@ -43,7 +42,7 @@ "wikimedia/less.php": "~1.8.0", "paragonie/sodium_compat": "^1.6", "pelago/emogrifier": "^2.0.0", - "php-amqplib/php-amqplib": "~2.7.0", + "php-amqplib/php-amqplib": "~2.7.0|~2.10.0", "phpseclib/mcrypt_compat": "1.0.8", "phpseclib/phpseclib": "2.0.*", "ramsey/uuid": "~3.8.0", @@ -100,6 +99,7 @@ }, "replace": { "magento/module-marketplace": "*", + "magento/module-admin-analytics": "*", "magento/module-admin-notification": "*", "magento/module-advanced-pricing-import-export": "*", "magento/module-amqp": "*", @@ -171,6 +171,7 @@ "magento/module-graph-ql": "*", "magento/module-graph-ql-cache": "*", "magento/module-catalog-graph-ql": "*", + "magento/module-catalog-cms-graph-ql": "*", "magento/module-catalog-url-rewrite-graph-ql": "*", "magento/module-configurable-product-graph-ql": "*", "magento/module-customer-graph-ql": "*", diff --git a/composer.lock b/composer.lock index 9d6805ac8be4..a53d81ec6934 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "856f519091be654f930aa51de44332a7", + "content-hash": "86a1369b80e7beabe9ea3dcb38b89ca4", "packages": [ { "name": "braintree/braintree_php", @@ -201,16 +201,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.2.1", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "33810d865dd06a674130fceb729b2f279dc79e8c" + "reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/33810d865dd06a674130fceb729b2f279dc79e8c", - "reference": "33810d865dd06a674130fceb729b2f279dc79e8c", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527", + "reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527", "shasum": "" }, "require": { @@ -253,20 +253,20 @@ "ssl", "tls" ], - "time": "2019-07-31T08:13:16+00:00" + "time": "2019-08-30T08:44:50+00:00" }, { "name": "composer/composer", - "version": "1.8.6", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "19b5f66a0e233eb944f134df34091fe1c5dfcc11" + "reference": "314aa57fdcfc942065996f59fb73a8b3f74f3fa5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/19b5f66a0e233eb944f134df34091fe1c5dfcc11", - "reference": "19b5f66a0e233eb944f134df34091fe1c5dfcc11", + "url": "https://api.github.com/repos/composer/composer/zipball/314aa57fdcfc942065996f59fb73a8b3f74f3fa5", + "reference": "314aa57fdcfc942065996f59fb73a8b3f74f3fa5", "shasum": "" }, "require": { @@ -302,7 +302,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8-dev" + "dev-master": "1.9-dev" } }, "autoload": { @@ -326,14 +326,14 @@ "homepage": "http://seld.be" } ], - "description": "Composer helps you declare, manage and install dependencies of PHP projects, ensuring you have the right stack everywhere.", + "description": "Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.", "homepage": "https://getcomposer.org/", "keywords": [ "autoload", "dependency", "package" ], - "time": "2019-06-11T13:03:06+00:00" + "time": "2019-08-02T18:55:33+00:00" }, { "name": "composer/semver", @@ -882,23 +882,23 @@ }, { "name": "justinrainbow/json-schema", - "version": "5.2.8", + "version": "5.2.9", "source": { "type": "git", "url": "https://github.com/justinrainbow/json-schema.git", - "reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4" + "reference": "44c6787311242a979fa15c704327c20e7221a0e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/dcb6e1006bb5fd1e392b4daa68932880f37550d4", - "reference": "dcb6e1006bb5fd1e392b4daa68932880f37550d4", + "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/44c6787311242a979fa15c704327c20e7221a0e4", + "reference": "44c6787311242a979fa15c704327c20e7221a0e4", "shasum": "" }, "require": { "php": ">=5.3.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~2.2.20", + "friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1", "json-schema/json-schema-test-suite": "1.2.0", "phpunit/phpunit": "^4.8.35" }, @@ -944,7 +944,7 @@ "json", "schema" ], - "time": "2019-01-14T23:55:14+00:00" + "time": "2019-09-25T14:49:45+00:00" }, { "name": "magento/composer", @@ -1110,16 +1110,16 @@ }, { "name": "monolog/monolog", - "version": "1.24.0", + "version": "1.25.1", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266" + "reference": "70e65a5470a42cfec1a7da00d30edb6e617e8dcf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", - "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/70e65a5470a42cfec1a7da00d30edb6e617e8dcf", + "reference": "70e65a5470a42cfec1a7da00d30edb6e617e8dcf", "shasum": "" }, "require": { @@ -1184,7 +1184,7 @@ "logging", "psr-3" ], - "time": "2018-11-05T09:00:11+00:00" + "time": "2019-09-06T13:49:17+00:00" }, { "name": "paragonie/random_compat", @@ -1233,16 +1233,16 @@ }, { "name": "paragonie/sodium_compat", - "version": "v1.10.1", + "version": "v1.11.4", "source": { "type": "git", "url": "https://github.com/paragonie/sodium_compat.git", - "reference": "5115fa44886d1c2785d2f135ef4626db868eac4b" + "reference": "b7115d0a80d5f9e8ae4cbfdee59d1d39dcfc90ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/5115fa44886d1c2785d2f135ef4626db868eac4b", - "reference": "5115fa44886d1c2785d2f135ef4626db868eac4b", + "url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/b7115d0a80d5f9e8ae4cbfdee59d1d39dcfc90ea", + "reference": "b7115d0a80d5f9e8ae4cbfdee59d1d39dcfc90ea", "shasum": "" }, "require": { @@ -1311,20 +1311,20 @@ "secret-key cryptography", "side-channel resistant" ], - "time": "2019-07-12T16:36:59+00:00" + "time": "2019-10-18T15:04:07+00:00" }, { "name": "pelago/emogrifier", - "version": "v2.1.1", + "version": "v2.2.0", "source": { "type": "git", "url": "https://github.com/MyIntervals/emogrifier.git", - "reference": "8ee7fb5ad772915451ed3415c1992bd3697d4983" + "reference": "2472bc1c3a2dee8915ecc2256139c6100024332f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/8ee7fb5ad772915451ed3415c1992bd3697d4983", - "reference": "8ee7fb5ad772915451ed3415c1992bd3697d4983", + "url": "https://api.github.com/repos/MyIntervals/emogrifier/zipball/2472bc1c3a2dee8915ecc2256139c6100024332f", + "reference": "2472bc1c3a2dee8915ecc2256139c6100024332f", "shasum": "" }, "require": { @@ -1342,7 +1342,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1355,16 +1355,6 @@ "MIT" ], "authors": [ - { - "name": "John Reeve", - "email": "jreeve@pelagodesign.com" - }, - { - "name": "Cameron Brooks" - }, - { - "name": "Jaime Prado" - }, { "name": "Oliver Klee", "email": "github@oliverklee.de" @@ -1373,9 +1363,19 @@ "name": "Zoli Szabó", "email": "zoli.szabo+github@gmail.com" }, + { + "name": "John Reeve", + "email": "jreeve@pelagodesign.com" + }, { "name": "Jake Hotson", "email": "jake@qzdesign.co.uk" + }, + { + "name": "Cameron Brooks" + }, + { + "name": "Jaime Prado" } ], "description": "Converts CSS styles into inline style attributes in your HTML code", @@ -1385,43 +1385,40 @@ "email", "pre-processing" ], - "time": "2018-12-10T10:36:30+00:00" + "time": "2019-09-04T16:07:59+00:00" }, { "name": "php-amqplib/php-amqplib", - "version": "v2.7.3", + "version": "v2.10.1", "source": { "type": "git", "url": "https://github.com/php-amqplib/php-amqplib.git", - "reference": "a8ba54bd35b973fc6861e4c2e105f71e9e95f43f" + "reference": "6e2b2501e021e994fb64429e5a78118f83b5c200" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/a8ba54bd35b973fc6861e4c2e105f71e9e95f43f", - "reference": "a8ba54bd35b973fc6861e4c2e105f71e9e95f43f", + "url": "https://api.github.com/repos/php-amqplib/php-amqplib/zipball/6e2b2501e021e994fb64429e5a78118f83b5c200", + "reference": "6e2b2501e021e994fb64429e5a78118f83b5c200", "shasum": "" }, "require": { "ext-bcmath": "*", - "ext-mbstring": "*", - "php": ">=5.3.0" + "ext-sockets": "*", + "php": ">=5.6" }, "replace": { "videlalvaro/php-amqplib": "self.version" }, "require-dev": { - "phpdocumentor/phpdocumentor": "^2.9", - "phpunit/phpunit": "^4.8", - "scrutinizer/ocular": "^1.1", + "ext-curl": "*", + "nategood/httpful": "^0.2.20", + "phpunit/phpunit": "^5.7|^6.5|^7.0", "squizlabs/php_codesniffer": "^2.5" }, - "suggest": { - "ext-sockets": "Use AMQPSocketConnection" - }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "2.10-dev" } }, "autoload": { @@ -1447,6 +1444,11 @@ "name": "Raúl Araya", "email": "nubeiro@gmail.com", "role": "Maintainer" + }, + { + "name": "Luke Bakken", + "email": "luke@bakken.io", + "role": "Maintainer" } ], "description": "Formerly videlalvaro/php-amqplib. This library is a pure PHP implementation of the AMQP protocol. It's been tested against RabbitMQ.", @@ -1456,7 +1458,7 @@ "queue", "rabbitmq" ], - "time": "2018-04-30T03:54:54+00:00" + "time": "2019-10-10T13:23:40+00:00" }, { "name": "phpseclib/mcrypt_compat", @@ -1509,16 +1511,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.21", + "version": "2.0.23", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "9f1287e68b3f283339a9f98f67515dd619e5bf9d" + "reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/9f1287e68b3f283339a9f98f67515dd619e5bf9d", - "reference": "9f1287e68b3f283339a9f98f67515dd619e5bf9d", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/c78eb5058d5bb1a183133c36d4ba5b6675dfa099", + "reference": "c78eb5058d5bb1a183133c36d4ba5b6675dfa099", "shasum": "" }, "require": { @@ -1597,7 +1599,7 @@ "x.509", "x509" ], - "time": "2019-07-12T12:53:49+00:00" + "time": "2019-09-17T03:41:22+00:00" }, { "name": "psr/container", @@ -2079,16 +2081,16 @@ }, { "name": "symfony/css-selector", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "105c98bb0c5d8635bea056135304bd8edcc42b4d" + "reference": "f4b3ff6a549d9ed28b2b0ecd1781bf67cf220ee9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/105c98bb0c5d8635bea056135304bd8edcc42b4d", - "reference": "105c98bb0c5d8635bea056135304bd8edcc42b4d", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/f4b3ff6a549d9ed28b2b0ecd1781bf67cf220ee9", + "reference": "f4b3ff6a549d9ed28b2b0ecd1781bf67cf220ee9", "shasum": "" }, "require": { @@ -2128,20 +2130,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2019-01-16T21:53:39+00:00" + "time": "2019-10-02T08:36:26+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "212b020949331b6531250584531363844b34a94e" + "reference": "6229f58993e5a157f6096fc7145c0717d0be8807" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/212b020949331b6531250584531363844b34a94e", - "reference": "212b020949331b6531250584531363844b34a94e", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/6229f58993e5a157f6096fc7145c0717d0be8807", + "reference": "6229f58993e5a157f6096fc7145c0717d0be8807", "shasum": "" }, "require": { @@ -2198,20 +2200,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-06-27T06:42:14+00:00" + "time": "2019-10-01T16:40:32+00:00" }, { "name": "symfony/event-dispatcher-contracts", - "version": "v1.1.5", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher-contracts.git", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c" + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c61766f4440ca687de1084a5c00b08e167a2575c", - "reference": "c61766f4440ca687de1084a5c00b08e167a2575c", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/c43ab685673fb6c8d84220c77897b1d6cdbe1d18", + "reference": "c43ab685673fb6c8d84220c77897b1d6cdbe1d18", "shasum": "" }, "require": { @@ -2256,20 +2258,20 @@ "interoperability", "standards" ], - "time": "2019-06-20T06:46:26+00:00" + "time": "2019-09-17T09:54:03+00:00" }, { "name": "symfony/filesystem", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "b9896d034463ad6fd2bf17e2bf9418caecd6313d" + "reference": "9abbb7ef96a51f4d7e69627bc6f63307994e4263" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/b9896d034463ad6fd2bf17e2bf9418caecd6313d", - "reference": "b9896d034463ad6fd2bf17e2bf9418caecd6313d", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/9abbb7ef96a51f4d7e69627bc6f63307994e4263", + "reference": "9abbb7ef96a51f4d7e69627bc6f63307994e4263", "shasum": "" }, "require": { @@ -2306,20 +2308,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2019-06-23T08:51:25+00:00" + "time": "2019-08-20T14:07:54+00:00" }, { "name": "symfony/finder", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2" + "reference": "5e575faa95548d0586f6bedaeabec259714e44d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/9638d41e3729459860bb96f6247ccb61faaa45f2", - "reference": "9638d41e3729459860bb96f6247ccb61faaa45f2", + "url": "https://api.github.com/repos/symfony/finder/zipball/5e575faa95548d0586f6bedaeabec259714e44d1", + "reference": "5e575faa95548d0586f6bedaeabec259714e44d1", "shasum": "" }, "require": { @@ -2355,20 +2357,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2019-06-28T13:16:30+00:00" + "time": "2019-09-16T11:29:48+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "82ebae02209c21113908c229e9883c419720738a" + "reference": "550ebaac289296ce228a706d0867afc34687e3f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", - "reference": "82ebae02209c21113908c229e9883c419720738a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4", + "reference": "550ebaac289296ce228a706d0867afc34687e3f4", "shasum": "" }, "require": { @@ -2380,7 +2382,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -2396,13 +2398,13 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, { "name": "Gert de Pagter", "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony polyfill for ctype functions", @@ -2413,20 +2415,20 @@ "polyfill", "portable" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", - "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", "shasum": "" }, "require": { @@ -2438,7 +2440,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -2472,20 +2474,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/process", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "856d35814cf287480465bb7a6c413bb7f5f5e69c" + "reference": "50556892f3cc47d4200bfd1075314139c4c9ff4b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/856d35814cf287480465bb7a6c413bb7f5f5e69c", - "reference": "856d35814cf287480465bb7a6c413bb7f5f5e69c", + "url": "https://api.github.com/repos/symfony/process/zipball/50556892f3cc47d4200bfd1075314139c4c9ff4b", + "reference": "50556892f3cc47d4200bfd1075314139c4c9ff4b", "shasum": "" }, "require": { @@ -2521,7 +2523,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-05-30T16:10:05+00:00" + "time": "2019-09-26T21:17:10+00:00" }, { "name": "tedivm/jshrink", @@ -2841,16 +2843,16 @@ }, { "name": "zendframework/zend-code", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-code.git", - "reference": "c21db169075c6ec4b342149f446e7b7b724f95eb" + "reference": "936fa7ad4d53897ea3e3eb41b5b760828246a20b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-code/zipball/c21db169075c6ec4b342149f446e7b7b724f95eb", - "reference": "c21db169075c6ec4b342149f446e7b7b724f95eb", + "url": "https://api.github.com/repos/zendframework/zend-code/zipball/936fa7ad4d53897ea3e3eb41b5b760828246a20b", + "reference": "936fa7ad4d53897ea3e3eb41b5b760828246a20b", "shasum": "" }, "require": { @@ -2858,10 +2860,10 @@ "zendframework/zend-eventmanager": "^2.6 || ^3.0" }, "require-dev": { - "doctrine/annotations": "~1.0", + "doctrine/annotations": "^1.0", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "zendframework/zend-coding-standard": "^1.0.0", + "phpunit/phpunit": "^7.5.15", + "zendframework/zend-coding-standard": "^1.0", "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "suggest": { @@ -2884,13 +2886,13 @@ "license": [ "BSD-3-Clause" ], - "description": "provides facilities to generate arbitrary code using an object oriented interface", - "homepage": "https://github.com/zendframework/zend-code", + "description": "Extensions to the PHP Reflection API, static code scanning, and code generation", "keywords": [ + "ZendFramework", "code", - "zf2" + "zf" ], - "time": "2018-08-13T20:36:59+00:00" + "time": "2019-08-31T14:14:34+00:00" }, { "name": "zendframework/zend-config", @@ -3158,16 +3160,16 @@ }, { "name": "zendframework/zend-diactoros", - "version": "1.8.6", + "version": "1.8.7", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "20da13beba0dde8fb648be3cc19765732790f46e" + "reference": "a85e67b86e9b8520d07e6415fcbcb8391b44a75b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/20da13beba0dde8fb648be3cc19765732790f46e", - "reference": "20da13beba0dde8fb648be3cc19765732790f46e", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/a85e67b86e9b8520d07e6415fcbcb8391b44a75b", + "reference": "a85e67b86e9b8520d07e6415fcbcb8391b44a75b", "shasum": "" }, "require": { @@ -3187,9 +3189,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev", - "dev-develop": "1.9.x-dev", - "dev-release-2.0": "2.0.x-dev" + "dev-release-1.8": "1.8.x-dev" } }, "autoload": { @@ -3218,20 +3218,20 @@ "psr", "psr-7" ], - "time": "2018-09-05T19:29:37+00:00" + "time": "2019-08-06T17:53:53+00:00" }, { "name": "zendframework/zend-escaper", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-escaper.git", - "reference": "31d8aafae982f9568287cb4dce987e6aff8fd074" + "reference": "3801caa21b0ca6aca57fa1c42b08d35c395ebd5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/31d8aafae982f9568287cb4dce987e6aff8fd074", - "reference": "31d8aafae982f9568287cb4dce987e6aff8fd074", + "url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/3801caa21b0ca6aca57fa1c42b08d35c395ebd5f", + "reference": "3801caa21b0ca6aca57fa1c42b08d35c395ebd5f", "shasum": "" }, "require": { @@ -3263,7 +3263,7 @@ "escaper", "zf" ], - "time": "2018-04-25T15:48:53+00:00" + "time": "2019-09-05T20:03:20+00:00" }, { "name": "zendframework/zend-eventmanager", @@ -3384,16 +3384,16 @@ }, { "name": "zendframework/zend-filter", - "version": "2.9.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-filter.git", - "reference": "1c3e6d02f9cd5f6c929c9859498f5efbe216e86f" + "reference": "d78f2cdde1c31975e18b2a0753381ed7b61118ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/1c3e6d02f9cd5f6c929c9859498f5efbe216e86f", - "reference": "1c3e6d02f9cd5f6c929c9859498f5efbe216e86f", + "url": "https://api.github.com/repos/zendframework/zend-filter/zipball/d78f2cdde1c31975e18b2a0753381ed7b61118ef", + "reference": "d78f2cdde1c31975e18b2a0753381ed7b61118ef", "shasum": "" }, "require": { @@ -3439,26 +3439,26 @@ "license": [ "BSD-3-Clause" ], - "description": "provides a set of commonly needed data filters", + "description": "Programmatically filter and normalize data and files", "keywords": [ "ZendFramework", "filter", "zf" ], - "time": "2018-12-17T16:00:04+00:00" + "time": "2019-08-19T07:08:04+00:00" }, { "name": "zendframework/zend-form", - "version": "2.14.1", + "version": "2.14.3", "source": { "type": "git", "url": "https://github.com/zendframework/zend-form.git", - "reference": "ff9385b7d0d93d9bdbc2aa4af82ab616dbc7d4be" + "reference": "0b1616c59b1f3df194284e26f98c81ad0c377871" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-form/zipball/ff9385b7d0d93d9bdbc2aa4af82ab616dbc7d4be", - "reference": "ff9385b7d0d93d9bdbc2aa4af82ab616dbc7d4be", + "url": "https://api.github.com/repos/zendframework/zend-form/zipball/0b1616c59b1f3df194284e26f98c81ad0c377871", + "reference": "0b1616c59b1f3df194284e26f98c81ad0c377871", "shasum": "" }, "require": { @@ -3523,7 +3523,7 @@ "form", "zf" ], - "time": "2019-02-26T18:13:31+00:00" + "time": "2019-10-04T10:46:36+00:00" }, { "name": "zendframework/zend-http", @@ -3582,16 +3582,16 @@ }, { "name": "zendframework/zend-hydrator", - "version": "2.4.1", + "version": "2.4.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-hydrator.git", - "reference": "70b02f4d8676e64af932625751750b5ca72fff3a" + "reference": "2bfc6845019e7b6d38b0ab5e55190244dc510285" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-hydrator/zipball/70b02f4d8676e64af932625751750b5ca72fff3a", - "reference": "70b02f4d8676e64af932625751750b5ca72fff3a", + "url": "https://api.github.com/repos/zendframework/zend-hydrator/zipball/2bfc6845019e7b6d38b0ab5e55190244dc510285", + "reference": "2bfc6845019e7b6d38b0ab5e55190244dc510285", "shasum": "" }, "require": { @@ -3616,10 +3616,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-release-1.0": "1.0.x-dev", - "dev-release-1.1": "1.1.x-dev", - "dev-master": "2.4.x-dev", - "dev-develop": "2.5.x-dev" + "dev-release-2.4": "2.4.x-dev" }, "zf": { "component": "Zend\\Hydrator", @@ -3641,20 +3638,20 @@ "hydrator", "zf" ], - "time": "2018-11-19T19:16:10+00:00" + "time": "2019-10-04T11:17:36+00:00" }, { "name": "zendframework/zend-i18n", - "version": "2.9.0", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-i18n.git", - "reference": "6d69af5a04e1a4de7250043cb1322f077a0cdb7f" + "reference": "e17a54b3aee333ab156958f570cde630acee8b07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/6d69af5a04e1a4de7250043cb1322f077a0cdb7f", - "reference": "6d69af5a04e1a4de7250043cb1322f077a0cdb7f", + "url": "https://api.github.com/repos/zendframework/zend-i18n/zipball/e17a54b3aee333ab156958f570cde630acee8b07", + "reference": "e17a54b3aee333ab156958f570cde630acee8b07", "shasum": "" }, "require": { @@ -3662,7 +3659,7 @@ "zendframework/zend-stdlib": "^2.7 || ^3.0" }, "require-dev": { - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.2", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.16", "zendframework/zend-cache": "^2.6.1", "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-config": "^2.6", @@ -3709,20 +3706,20 @@ "i18n", "zf" ], - "time": "2018-05-16T16:39:13+00:00" + "time": "2019-09-30T12:04:37+00:00" }, { "name": "zendframework/zend-inputfilter", - "version": "2.10.0", + "version": "2.10.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-inputfilter.git", - "reference": "4f52b71ec9cef3a06e3bba8f5c2124e94055ec0c" + "reference": "1f44a2e9bc394a71638b43bc7024b572fa65410e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/4f52b71ec9cef3a06e3bba8f5c2124e94055ec0c", - "reference": "4f52b71ec9cef3a06e3bba8f5c2124e94055ec0c", + "url": "https://api.github.com/repos/zendframework/zend-inputfilter/zipball/1f44a2e9bc394a71638b43bc7024b572fa65410e", + "reference": "1f44a2e9bc394a71638b43bc7024b572fa65410e", "shasum": "" }, "require": { @@ -3733,7 +3730,7 @@ "zendframework/zend-validator": "^2.11" }, "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.15", "psr/http-message": "^1.0", "zendframework/zend-coding-standard": "~1.0.0" }, @@ -3766,7 +3763,7 @@ "inputfilter", "zf" ], - "time": "2019-01-30T16:58:51+00:00" + "time": "2019-08-28T19:45:32+00:00" }, { "name": "zendframework/zend-json", @@ -3825,16 +3822,16 @@ }, { "name": "zendframework/zend-loader", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-loader.git", - "reference": "78f11749ea340f6ca316bca5958eef80b38f9b6c" + "reference": "91da574d29b58547385b2298c020b257310898c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-loader/zipball/78f11749ea340f6ca316bca5958eef80b38f9b6c", - "reference": "78f11749ea340f6ca316bca5958eef80b38f9b6c", + "url": "https://api.github.com/repos/zendframework/zend-loader/zipball/91da574d29b58547385b2298c020b257310898c6", + "reference": "91da574d29b58547385b2298c020b257310898c6", "shasum": "" }, "require": { @@ -3866,20 +3863,20 @@ "loader", "zf" ], - "time": "2018-04-30T15:20:54+00:00" + "time": "2019-09-04T19:38:14+00:00" }, { "name": "zendframework/zend-log", - "version": "2.10.0", + "version": "2.11.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-log.git", - "reference": "9cec3b092acb39963659c2f32441cccc56b3f430" + "reference": "cb278772afdacb1924342248a069330977625ae6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-log/zipball/9cec3b092acb39963659c2f32441cccc56b3f430", - "reference": "9cec3b092acb39963659c2f32441cccc56b3f430", + "url": "https://api.github.com/repos/zendframework/zend-log/zipball/cb278772afdacb1924342248a069330977625ae6", + "reference": "cb278772afdacb1924342248a069330977625ae6", "shasum": "" }, "require": { @@ -3892,8 +3889,8 @@ "psr/log-implementation": "1.0.0" }, "require-dev": { - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^5.7.15 || ^6.0.8", + "mikey179/vfsstream": "^1.6.7", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.15", "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-db": "^2.6", "zendframework/zend-escaper": "^2.5", @@ -3904,7 +3901,6 @@ "suggest": { "ext-mongo": "mongo extension to use Mongo writer", "ext-mongodb": "mongodb extension to use MongoDB writer", - "zendframework/zend-console": "Zend\\Console component to use the RequestID log processor", "zendframework/zend-db": "Zend\\Db component to use the database log writer", "zendframework/zend-escaper": "Zend\\Escaper component, for use in the XML log formatter", "zendframework/zend-mail": "Zend\\Mail component to use the email log writer", @@ -3913,8 +3909,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.10.x-dev", - "dev-develop": "2.11.x-dev" + "dev-master": "2.11.x-dev", + "dev-develop": "2.12.x-dev" }, "zf": { "component": "Zend\\Log", @@ -3930,14 +3926,14 @@ "license": [ "BSD-3-Clause" ], - "description": "component for general purpose logging", - "homepage": "https://github.com/zendframework/zend-log", + "description": "Robust, composite logger with filtering, formatting, and PSR-3 support", "keywords": [ + "ZendFramework", "log", "logging", - "zf2" + "zf" ], - "time": "2018-04-09T21:59:51+00:00" + "time": "2019-08-23T21:28:18+00:00" }, { "name": "zendframework/zend-mail", @@ -4053,16 +4049,16 @@ }, { "name": "zendframework/zend-mime", - "version": "2.7.1", + "version": "2.7.2", "source": { "type": "git", "url": "https://github.com/zendframework/zend-mime.git", - "reference": "52ae5fa9f12845cae749271034a2d594f0e4c6f2" + "reference": "c91e0350be53cc9d29be15563445eec3b269d7c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-mime/zipball/52ae5fa9f12845cae749271034a2d594f0e4c6f2", - "reference": "52ae5fa9f12845cae749271034a2d594f0e4c6f2", + "url": "https://api.github.com/repos/zendframework/zend-mime/zipball/c91e0350be53cc9d29be15563445eec3b269d7c1", + "reference": "c91e0350be53cc9d29be15563445eec3b269d7c1", "shasum": "" }, "require": { @@ -4080,8 +4076,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.7-dev", - "dev-develop": "2.8-dev" + "dev-master": "2.7.x-dev", + "dev-develop": "2.8.x-dev" } }, "autoload": { @@ -4094,13 +4090,12 @@ "BSD-3-Clause" ], "description": "Create and parse MIME messages and parts", - "homepage": "https://github.com/zendframework/zend-mime", "keywords": [ "ZendFramework", "mime", "zf" ], - "time": "2018-05-14T19:02:50+00:00" + "time": "2019-10-16T19:30:37+00:00" }, { "name": "zendframework/zend-modulemanager", @@ -4365,16 +4360,16 @@ }, { "name": "zendframework/zend-server", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-server.git", - "reference": "23a2e9a5599c83c05da831cb7c649e8a7809595e" + "reference": "d80c44700ebb92191dd9a3005316a6ab6637c0d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-server/zipball/23a2e9a5599c83c05da831cb7c649e8a7809595e", - "reference": "23a2e9a5599c83c05da831cb7c649e8a7809595e", + "url": "https://api.github.com/repos/zendframework/zend-server/zipball/d80c44700ebb92191dd9a3005316a6ab6637c0d1", + "reference": "d80c44700ebb92191dd9a3005316a6ab6637c0d1", "shasum": "" }, "require": { @@ -4408,7 +4403,7 @@ "server", "zf" ], - "time": "2018-04-30T22:21:28+00:00" + "time": "2019-10-16T18:27:05+00:00" }, { "name": "zendframework/zend-servicemanager", @@ -4464,28 +4459,28 @@ }, { "name": "zendframework/zend-session", - "version": "2.8.5", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/zendframework/zend-session.git", - "reference": "2cfd90e1a2f6b066b9f908599251d8f64f07021b" + "reference": "0a0c7ae4d8be608e30ecff714c86164ccca19ca3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-session/zipball/2cfd90e1a2f6b066b9f908599251d8f64f07021b", - "reference": "2cfd90e1a2f6b066b9f908599251d8f64f07021b", + "url": "https://api.github.com/repos/zendframework/zend-session/zipball/0a0c7ae4d8be608e30ecff714c86164ccca19ca3", + "reference": "0a0c7ae4d8be608e30ecff714c86164ccca19ca3", "shasum": "" }, "require": { "php": "^5.6 || ^7.0", "zendframework/zend-eventmanager": "^2.6.2 || ^3.0", - "zendframework/zend-stdlib": "^2.7 || ^3.0" + "zendframework/zend-stdlib": "^3.2.1" }, "require-dev": { "container-interop/container-interop": "^1.1", "mongodb/mongodb": "^1.0.1", "php-mock/php-mock-phpunit": "^1.1.2 || ^2.0", - "phpunit/phpunit": "^5.7.5 || >=6.0.13 <6.5.0", + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.16", "zendframework/zend-cache": "^2.6.1", "zendframework/zend-coding-standard": "~1.0.0", "zendframework/zend-db": "^2.7", @@ -4504,8 +4499,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.8-dev", - "dev-develop": "2.9-dev" + "dev-master": "2.9.x-dev", + "dev-develop": "2.10.x-dev" }, "zf": { "component": "Zend\\Session", @@ -4521,13 +4516,13 @@ "license": [ "BSD-3-Clause" ], - "description": "manage and preserve session data, a logical complement of cookie data, across multiple page requests by the same client", + "description": "Object-oriented interface to PHP sessions and storage", "keywords": [ "ZendFramework", "session", "zf" ], - "time": "2018-02-22T16:33:54+00:00" + "time": "2019-09-20T12:50:51+00:00" }, { "name": "zendframework/zend-soap", @@ -4630,16 +4625,16 @@ }, { "name": "zendframework/zend-text", - "version": "2.7.0", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-text.git", - "reference": "ca987dd4594f5f9508771fccd82c89bc7fbb39ac" + "reference": "41e32dafa4015e160e2f95a7039554385c71624d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-text/zipball/ca987dd4594f5f9508771fccd82c89bc7fbb39ac", - "reference": "ca987dd4594f5f9508771fccd82c89bc7fbb39ac", + "url": "https://api.github.com/repos/zendframework/zend-text/zipball/41e32dafa4015e160e2f95a7039554385c71624d", + "reference": "41e32dafa4015e160e2f95a7039554385c71624d", "shasum": "" }, "require": { @@ -4674,20 +4669,20 @@ "text", "zf" ], - "time": "2018-04-30T14:55:10+00:00" + "time": "2019-10-16T20:36:27+00:00" }, { "name": "zendframework/zend-uri", - "version": "2.7.0", + "version": "2.7.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-uri.git", - "reference": "b2785cd38fe379a784645449db86f21b7739b1ee" + "reference": "bfc4a5b9a309711e968d7c72afae4ac50c650083" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-uri/zipball/b2785cd38fe379a784645449db86f21b7739b1ee", - "reference": "b2785cd38fe379a784645449db86f21b7739b1ee", + "url": "https://api.github.com/repos/zendframework/zend-uri/zipball/bfc4a5b9a309711e968d7c72afae4ac50c650083", + "reference": "bfc4a5b9a309711e968d7c72afae4ac50c650083", "shasum": "" }, "require": { @@ -4721,20 +4716,20 @@ "uri", "zf" ], - "time": "2019-02-27T21:39:04+00:00" + "time": "2019-10-07T13:35:33+00:00" }, { "name": "zendframework/zend-validator", - "version": "2.12.0", + "version": "2.12.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-validator.git", - "reference": "64c33668e5fa2d39c6289a878f927ea2b0850c30" + "reference": "7b870a7515f3a35afbecc39d63f34a861f40f58b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/64c33668e5fa2d39c6289a878f927ea2b0850c30", - "reference": "64c33668e5fa2d39c6289a878f927ea2b0850c30", + "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/7b870a7515f3a35afbecc39d63f34a861f40f58b", + "reference": "7b870a7515f3a35afbecc39d63f34a861f40f58b", "shasum": "" }, "require": { @@ -4788,26 +4783,26 @@ "license": [ "BSD-3-Clause" ], - "description": "provides a set of commonly needed validators", - "homepage": "https://github.com/zendframework/zend-validator", + "description": "Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria", "keywords": [ + "ZendFramework", "validator", - "zf2" + "zf" ], - "time": "2019-01-30T14:26:10+00:00" + "time": "2019-10-12T12:17:57+00:00" }, { "name": "zendframework/zend-view", - "version": "2.11.2", + "version": "2.11.3", "source": { "type": "git", "url": "https://github.com/zendframework/zend-view.git", - "reference": "4f5cb653ed4c64bb8d9bf05b294300feb00c67f2" + "reference": "e766457bd6ce13c5354e443bb949511b6904d7f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-view/zipball/4f5cb653ed4c64bb8d9bf05b294300feb00c67f2", - "reference": "4f5cb653ed4c64bb8d9bf05b294300feb00c67f2", + "url": "https://api.github.com/repos/zendframework/zend-view/zipball/e766457bd6ce13c5354e443bb949511b6904d7f5", + "reference": "e766457bd6ce13c5354e443bb949511b6904d7f5", "shasum": "" }, "require": { @@ -4875,13 +4870,13 @@ "license": [ "BSD-3-Clause" ], - "description": "provides a system of helpers, output filters, and variable escaping", - "homepage": "https://github.com/zendframework/zend-view", + "description": "Flexible view layer supporting and providing multiple view layers, helpers, and more", "keywords": [ + "ZendFramework", "view", - "zf2" + "zf" ], - "time": "2019-02-19T17:40:15+00:00" + "time": "2019-10-11T21:10:04+00:00" } ], "packages-dev": [ @@ -4938,25 +4933,26 @@ }, { "name": "allure-framework/allure-php-api", - "version": "1.1.4", + "version": "1.1.5", "source": { "type": "git", - "url": "https://github.com/allure-framework/allure-php-adapter-api.git", - "reference": "a462a0da121681577033e13c123b6cc4e89cdc64" + "url": "https://github.com/allure-framework/allure-php-commons.git", + "reference": "c7a675823ad75b8e02ddc364baae21668e7c4e88" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/allure-framework/allure-php-adapter-api/zipball/a462a0da121681577033e13c123b6cc4e89cdc64", - "reference": "a462a0da121681577033e13c123b6cc4e89cdc64", + "url": "https://api.github.com/repos/allure-framework/allure-php-commons/zipball/c7a675823ad75b8e02ddc364baae21668e7c4e88", + "reference": "c7a675823ad75b8e02ddc364baae21668e7c4e88", "shasum": "" }, "require": { - "jms/serializer": ">=0.16.0", - "moontoast/math": ">=1.1.0", + "jms/serializer": "^0.16.0", "php": ">=5.4.0", - "phpunit/phpunit": ">=4.0.0", - "ramsey/uuid": ">=3.0.0", - "symfony/http-foundation": ">=2.0" + "ramsey/uuid": "^3.0.0", + "symfony/http-foundation": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0.0" }, "type": "library", "autoload": { @@ -4986,7 +4982,7 @@ "php", "report" ], - "time": "2016-12-07T12:15:46+00:00" + "time": "2018-05-25T14:02:11+00:00" }, { "name": "allure-framework/allure-phpunit", @@ -5283,16 +5279,16 @@ }, { "name": "codeception/phpunit-wrapper", - "version": "6.6.1", + "version": "6.7.0", "source": { "type": "git", "url": "https://github.com/Codeception/phpunit-wrapper.git", - "reference": "d0da25a98bcebeb15d97c2ad3b2de6166b6e7a0c" + "reference": "93f59e028826464eac086052fa226e58967f6907" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/d0da25a98bcebeb15d97c2ad3b2de6166b6e7a0c", - "reference": "d0da25a98bcebeb15d97c2ad3b2de6166b6e7a0c", + "url": "https://api.github.com/repos/Codeception/phpunit-wrapper/zipball/93f59e028826464eac086052fa226e58967f6907", + "reference": "93f59e028826464eac086052fa226e58967f6907", "shasum": "" }, "require": { @@ -5325,7 +5321,7 @@ } ], "description": "PHPUnit classes used by Codeception", - "time": "2019-02-26T20:47:39+00:00" + "time": "2019-08-18T15:43:35+00:00" }, { "name": "codeception/stub", @@ -6030,16 +6026,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.6.1", + "version": "v1.8.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24" + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/53120e0eb10355388d6ccbe462f1fea34ddadb24", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", + "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", "shasum": "" }, "require": { @@ -6048,12 +6044,12 @@ }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^7.5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.7.x-dev" } }, "autoload": { @@ -6066,6 +6062,10 @@ "MIT" ], "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, { "name": "Roman Borschel", "email": "roman@code-factory.org" @@ -6074,10 +6074,6 @@ "name": "Benjamin Eberlei", "email": "kontakt@beberlei.de" }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, { "name": "Jonathan Wage", "email": "jonwage@gmail.com" @@ -6094,7 +6090,7 @@ "docblock", "parser" ], - "time": "2019-03-25T19:12:02+00:00" + "time": "2019-10-01T18:55:10+00:00" }, { "name": "doctrine/cache", @@ -6171,76 +6167,6 @@ ], "time": "2018-08-21T18:01:43+00:00" }, - { - "name": "doctrine/collections", - "version": "v1.6.2", - "source": { - "type": "git", - "url": "https://github.com/doctrine/collections.git", - "reference": "c5e0bc17b1620e97c968ac409acbff28b8b850be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/c5e0bc17b1620e97c968ac409acbff28b8b850be", - "reference": "c5e0bc17b1620e97c968ac409acbff28b8b850be", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "require-dev": { - "doctrine/coding-standard": "^6.0", - "phpstan/phpstan-shim": "^0.9.2", - "phpunit/phpunit": "^7.0", - "vimeo/psalm": "^3.2.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", - "homepage": "https://www.doctrine-project.org/projects/collections.html", - "keywords": [ - "array", - "collections", - "iterators", - "php" - ], - "time": "2019-06-09T13:48:14+00:00" - }, { "name": "doctrine/inflector", "version": "v1.1.0", @@ -6424,52 +6350,6 @@ ], "time": "2019-06-08T11:03:04+00:00" }, - { - "name": "epfremme/swagger-php", - "version": "v2.0.0", - "source": { - "type": "git", - "url": "https://github.com/epfremmer/swagger-php.git", - "reference": "eee28a442b7e6220391ec953d3c9b936354f23bc" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/epfremmer/swagger-php/zipball/eee28a442b7e6220391ec953d3c9b936354f23bc", - "reference": "eee28a442b7e6220391ec953d3c9b936354f23bc", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1.2", - "doctrine/collections": "^1.3", - "jms/serializer": "^1.1", - "php": ">=5.5", - "phpoption/phpoption": "^1.1", - "symfony/yaml": "^2.7|^3.1" - }, - "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "~4.8|~5.0", - "satooshi/php-coveralls": "^1.0" - }, - "type": "package", - "autoload": { - "psr-4": { - "Epfremme\\Swagger\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Edward Pfremmer", - "email": "epfremme@nerdery.com" - } - ], - "description": "Library for parsing swagger documentation into PHP entities for use in testing and code generation", - "time": "2016-09-26T17:24:17+00:00" - }, { "name": "facebook/webdriver", "version": "1.7.1", @@ -6573,16 +6453,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.14.4", + "version": "v2.14.6", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "69ccf81f3c968be18d646918db94ab88ddf3594f" + "reference": "8d18a8bb180e2acde1c8031db09aefb9b73f6127" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/69ccf81f3c968be18d646918db94ab88ddf3594f", - "reference": "69ccf81f3c968be18d646918db94ab88ddf3594f", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/8d18a8bb180e2acde1c8031db09aefb9b73f6127", + "reference": "8d18a8bb180e2acde1c8031db09aefb9b73f6127", "shasum": "" }, "require": { @@ -6612,9 +6492,10 @@ "php-cs-fixer/accessible-object": "^1.0", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", - "phpunitgoodpractices/traits": "^1.8", - "symfony/phpunit-bridge": "^4.3" + "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/traits": "^1.5.1", + "symfony/phpunit-bridge": "^4.0", + "symfony/yaml": "^3.0 || ^4.0" }, "suggest": { "ext-mbstring": "For handling non-UTF8 characters in cache signature.", @@ -6647,17 +6528,17 @@ "MIT" ], "authors": [ - { - "name": "Dariusz Rumiński", - "email": "dariusz.ruminski@gmail.com" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Dariusz Rumiński", + "email": "dariusz.ruminski@gmail.com" } ], "description": "A tool to automatically fix PHP code style", - "time": "2019-06-01T10:29:34+00:00" + "time": "2019-08-31T12:47:52+00:00" }, { "name": "fzaninotto/faker", @@ -6804,6 +6685,48 @@ "description": "Expands internal property references in a yaml file.", "time": "2017-12-16T16:06:03+00:00" }, + { + "name": "ircmaxell/password-compat", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", + "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", + "shasum": "" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ], + "time": "2014-11-20T16:49:30+00:00" + }, { "name": "jms/metadata", "version": "1.7.0", @@ -6896,56 +6819,44 @@ }, { "name": "jms/serializer", - "version": "1.14.0", + "version": "0.16.0", "source": { "type": "git", "url": "https://github.com/schmittjoh/serializer.git", - "reference": "ee96d57024af9a7716d56fcbe3aa94b3d030f3ca" + "reference": "c8a171357ca92b6706e395c757f334902d430ea9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/ee96d57024af9a7716d56fcbe3aa94b3d030f3ca", - "reference": "ee96d57024af9a7716d56fcbe3aa94b3d030f3ca", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/c8a171357ca92b6706e395c757f334902d430ea9", + "reference": "c8a171357ca92b6706e395c757f334902d430ea9", "shasum": "" }, "require": { - "doctrine/annotations": "^1.0", - "doctrine/instantiator": "^1.0.3", - "jms/metadata": "^1.3", + "doctrine/annotations": "1.*", + "jms/metadata": "~1.1", "jms/parser-lib": "1.*", - "php": "^5.5|^7.0", - "phpcollection/phpcollection": "~0.1", - "phpoption/phpoption": "^1.1" - }, - "conflict": { - "twig/twig": "<1.12" + "php": ">=5.3.2", + "phpcollection/phpcollection": "~0.1" }, "require-dev": { "doctrine/orm": "~2.1", - "doctrine/phpcr-odm": "^1.3|^2.0", - "ext-pdo_sqlite": "*", - "jackalope/jackalope-doctrine-dbal": "^1.1.5", - "phpunit/phpunit": "^4.8|^5.0", + "doctrine/phpcr-odm": "~1.0.1", + "jackalope/jackalope-doctrine-dbal": "1.0.*", "propel/propel1": "~1.7", - "psr/container": "^1.0", - "symfony/dependency-injection": "^2.7|^3.3|^4.0", - "symfony/expression-language": "^2.6|^3.0", - "symfony/filesystem": "^2.1", - "symfony/form": "~2.1|^3.0", - "symfony/translation": "^2.1|^3.0", - "symfony/validator": "^2.2|^3.0", - "symfony/yaml": "^2.1|^3.0", - "twig/twig": "~1.12|~2.0" + "symfony/filesystem": "2.*", + "symfony/form": "~2.1", + "symfony/translation": "~2.0", + "symfony/validator": "~2.0", + "symfony/yaml": "2.*", + "twig/twig": ">=1.8,<2.0-dev" }, "suggest": { - "doctrine/cache": "Required if you like to use cache functionality.", - "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.", "symfony/yaml": "Required if you'd like to serialize data to YAML format." }, "type": "library", "extra": { "branch-alias": { - "dev-1.x": "1.14-dev" + "dev-master": "0.15-dev" } }, "autoload": { @@ -6955,16 +6866,14 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "Apache2" ], "authors": [ { - "name": "Asmir Mustafic", - "email": "goetas@gmail.com" - }, - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" } ], "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.", @@ -6976,7 +6885,7 @@ "serialization", "xml" ], - "time": "2019-04-17T08:12:16+00:00" + "time": "2014-03-18T08:39:00+00:00" }, { "name": "league/container", @@ -7045,16 +6954,16 @@ }, { "name": "league/flysystem", - "version": "1.0.55", + "version": "1.0.57", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "33c91155537c6dc899eacdc54a13ac6303f156e6" + "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/33c91155537c6dc899eacdc54a13ac6303f156e6", - "reference": "33c91155537c6dc899eacdc54a13ac6303f156e6", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", + "reference": "0e9db7f0b96b9f12dcf6f65bc34b72b1a30ea55a", "shasum": "" }, "require": { @@ -7125,7 +7034,7 @@ "sftp", "storage" ], - "time": "2019-08-24T11:17:19+00:00" + "time": "2019-10-16T21:01:05+00:00" }, { "name": "lusitanian/oauth", @@ -7303,23 +7212,23 @@ }, { "name": "mikey179/vfsstream", - "version": "v1.6.6", + "version": "v1.6.7", "source": { "type": "git", "url": "https://github.com/bovigo/vfsStream.git", - "reference": "095238a0711c974ae5b4ebf4c4534a23f3f6c99d" + "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/095238a0711c974ae5b4ebf4c4534a23f3f6c99d", - "reference": "095238a0711c974ae5b4ebf4c4534a23f3f6c99d", + "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", + "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "~4.5" + "phpunit/phpunit": "^4.5|^5.0" }, "type": "library", "extra": { @@ -7345,56 +7254,7 @@ ], "description": "Virtual file system to mock the real file system in unit tests.", "homepage": "http://vfs.bovigo.org/", - "time": "2019-04-08T13:54:32+00:00" - }, - { - "name": "moontoast/math", - "version": "1.1.2", - "source": { - "type": "git", - "url": "https://github.com/ramsey/moontoast-math.git", - "reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ramsey/moontoast-math/zipball/c2792a25df5cad4ff3d760dd37078fc5b6fccc79", - "reference": "c2792a25df5cad4ff3d760dd37078fc5b6fccc79", - "shasum": "" - }, - "require": { - "ext-bcmath": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "jakub-onderka/php-parallel-lint": "^0.9.0", - "phpunit/phpunit": "^4.7|>=5.0 <5.4", - "satooshi/php-coveralls": "^0.6.1", - "squizlabs/php_codesniffer": "^2.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Moontoast\\Math\\": "src/Moontoast/Math/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Ben Ramsey", - "email": "ben@benramsey.com", - "homepage": "https://benramsey.com" - } - ], - "description": "A mathematics library, providing functionality for large numbers", - "homepage": "https://github.com/ramsey/moontoast-math", - "keywords": [ - "bcmath", - "math" - ], - "time": "2017-02-16T16:54:46+00:00" + "time": "2019-08-01T01:38:37+00:00" }, { "name": "mustache/mustache", @@ -7444,16 +7304,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.1", + "version": "1.9.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", "shasum": "" }, "require": { @@ -7488,7 +7348,7 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2019-08-09T12:45:53+00:00" }, { "name": "pdepend/pdepend", @@ -7733,35 +7593,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", - "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -7783,30 +7641,30 @@ "reflection", "static analysis" ], - "time": "2017-09-11T18:02:19+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.1", + "version": "4.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", - "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", "shasum": "" }, "require": { "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0", - "phpdocumentor/type-resolver": "^0.4.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "doctrine/instantiator": "~1.0.5", + "doctrine/instantiator": "^1.0.5", "mockery/mockery": "^1.0", "phpunit/phpunit": "^6.4" }, @@ -7834,41 +7692,40 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-04-30T17:48:53+00:00" + "time": "2019-09-12T14:27:41+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.4.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", - "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": "^5.5 || ^7.0", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -7881,7 +7738,8 @@ "email": "me@mikevanriel.com" } ], - "time": "2017-07-14T14:27:02+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpmd/phpmd", @@ -8003,22 +7861,22 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.1", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", - "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, @@ -8062,7 +7920,7 @@ "spy", "stub" ], - "time": "2019-06-13T12:50:23+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "phpunit/php-code-coverage", @@ -8764,16 +8622,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.0", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", - "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { @@ -8800,6 +8658,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -8808,17 +8670,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -8827,7 +8685,7 @@ "export", "exporter" ], - "time": "2017-04-03T13:19:02+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/finder-facade", @@ -9252,16 +9110,16 @@ }, { "name": "symfony/browser-kit", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "a29dd02a1f3f81b9a15c7730cc3226718ddb55ca" + "reference": "78b7611c45039e8ce81698be319851529bf040b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/a29dd02a1f3f81b9a15c7730cc3226718ddb55ca", - "reference": "a29dd02a1f3f81b9a15c7730cc3226718ddb55ca", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/78b7611c45039e8ce81698be319851529bf040b1", + "reference": "78b7611c45039e8ce81698be319851529bf040b1", "shasum": "" }, "require": { @@ -9307,20 +9165,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2019-06-11T15:41:59+00:00" + "time": "2019-09-10T11:25:17+00:00" }, { "name": "symfony/config", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "a17a2aea43950ce83a0603ed301bac362eb86870" + "reference": "0acb26407a9e1a64a275142f0ae5e36436342720" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a17a2aea43950ce83a0603ed301bac362eb86870", - "reference": "a17a2aea43950ce83a0603ed301bac362eb86870", + "url": "https://api.github.com/repos/symfony/config/zipball/0acb26407a9e1a64a275142f0ae5e36436342720", + "reference": "0acb26407a9e1a64a275142f0ae5e36436342720", "shasum": "" }, "require": { @@ -9371,26 +9229,26 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2019-07-18T10:34:59+00:00" + "time": "2019-09-19T15:51:53+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "9ad1b83d474ae17156f6914cb81ffe77aeac3a9b" + "reference": "e1e0762a814b957a1092bff75a550db49724d05b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/9ad1b83d474ae17156f6914cb81ffe77aeac3a9b", - "reference": "9ad1b83d474ae17156f6914cb81ffe77aeac3a9b", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e1e0762a814b957a1092bff75a550db49724d05b", + "reference": "e1e0762a814b957a1092bff75a550db49724d05b", "shasum": "" }, "require": { "php": "^7.1.3", "psr/container": "^1.0", - "symfony/service-contracts": "^1.1.2" + "symfony/service-contracts": "^1.1.6" }, "conflict": { "symfony/config": "<4.3", @@ -9444,20 +9302,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2019-07-26T07:03:43+00:00" + "time": "2019-10-02T12:58:58+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "291397232a2eefb3347eaab9170409981eaad0e2" + "reference": "e9f7b4d19d69b133bd638eeddcdc757723b4211f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/291397232a2eefb3347eaab9170409981eaad0e2", - "reference": "291397232a2eefb3347eaab9170409981eaad0e2", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/e9f7b4d19d69b133bd638eeddcdc757723b4211f", + "reference": "e9f7b4d19d69b133bd638eeddcdc757723b4211f", "shasum": "" }, "require": { @@ -9505,35 +9363,35 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2019-06-13T11:03:18+00:00" + "time": "2019-09-28T21:25:05+00:00" }, { "name": "symfony/http-foundation", - "version": "v4.3.3", + "version": "v2.8.50", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "8b778ee0c27731105fbf1535f51793ad1ae0ba2b" + "reference": "746f8d3638bf46ee8b202e62f2b214c3d61fb06a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/8b778ee0c27731105fbf1535f51793ad1ae0ba2b", - "reference": "8b778ee0c27731105fbf1535f51793ad1ae0ba2b", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/746f8d3638bf46ee8b202e62f2b214c3d61fb06a", + "reference": "746f8d3638bf46ee8b202e62f2b214c3d61fb06a", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/mime": "^4.3", - "symfony/polyfill-mbstring": "~1.1" + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php54": "~1.0", + "symfony/polyfill-php55": "~1.0" }, "require-dev": { - "predis/predis": "~1.0", - "symfony/expression-language": "~3.4|~4.0" + "symfony/expression-language": "~2.4|~3.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -9560,30 +9418,24 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2019-07-23T11:21:36+00:00" + "time": "2019-04-16T10:00:53+00:00" }, { - "name": "symfony/mime", - "version": "v4.3.3", + "name": "symfony/options-resolver", + "version": "v4.3.5", "source": { "type": "git", - "url": "https://github.com/symfony/mime.git", - "reference": "6b7148029b1dd5eda1502064f06d01357b7b2d8b" + "url": "https://github.com/symfony/options-resolver.git", + "reference": "81c2e120522a42f623233968244baebd6b36cb6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/6b7148029b1dd5eda1502064f06d01357b7b2d8b", - "reference": "6b7148029b1dd5eda1502064f06d01357b7b2d8b", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/81c2e120522a42f623233968244baebd6b36cb6a", + "reference": "81c2e120522a42f623233968244baebd6b36cb6a", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/polyfill-intl-idn": "^1.10", - "symfony/polyfill-mbstring": "^1.0" - }, - "require-dev": { - "egulias/email-validator": "^2.0", - "symfony/dependency-injection": "~3.4|^4.1" + "php": "^7.1.3" }, "type": "library", "extra": { @@ -9593,7 +9445,7 @@ }, "autoload": { "psr-4": { - "Symfony\\Component\\Mime\\": "" + "Symfony\\Component\\OptionsResolver\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -9613,43 +9465,47 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "A library to manipulate MIME messages", + "description": "Symfony OptionsResolver Component", "homepage": "https://symfony.com", "keywords": [ - "mime", - "mime-type" + "config", + "configuration", + "options" ], - "time": "2019-07-19T16:21:19+00:00" + "time": "2019-08-08T09:29:19+00:00" }, { - "name": "symfony/options-resolver", - "version": "v4.3.3", + "name": "symfony/polyfill-php54", + "version": "v1.12.0", "source": { "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "40762ead607c8f792ee4516881369ffa553fee6f" + "url": "https://github.com/symfony/polyfill-php54.git", + "reference": "a043bcced870214922fbb4bf22679d431ec0296a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/40762ead607c8f792ee4516881369ffa553fee6f", - "reference": "40762ead607c8f792ee4516881369ffa553fee6f", + "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/a043bcced870214922fbb4bf22679d431ec0296a", + "reference": "a043bcced870214922fbb4bf22679d431ec0296a", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=5.3.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "1.12-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\OptionsResolver\\": "" + "Symfony\\Polyfill\\Php54\\": "" }, - "exclude-from-classmap": [ - "/Tests/" + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -9658,54 +9514,51 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony OptionsResolver Component", + "description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ - "config", - "configuration", - "options" + "compatibility", + "polyfill", + "portable", + "shim" ], - "time": "2019-06-13T11:01:17+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { - "name": "symfony/polyfill-intl-idn", - "version": "v1.11.0", + "name": "symfony/polyfill-php55", + "version": "v1.12.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af" + "url": "https://github.com/symfony/polyfill-php55.git", + "reference": "548bb39407e78e54f785b4e18c7e0d5d9e493265" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/c766e95bec706cdd89903b1eda8afab7d7a6b7af", - "reference": "c766e95bec706cdd89903b1eda8afab7d7a6b7af", + "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/548bb39407e78e54f785b4e18c7e0d5d9e493265", + "reference": "548bb39407e78e54f785b4e18c7e0d5d9e493265", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.9" - }, - "suggest": { - "ext-intl": "For best performance" + "ircmaxell/password-compat": "~1.0", + "php": ">=5.3.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.12-dev" } }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Intl\\Idn\\": "" + "Symfony\\Polyfill\\Php55\\": "" }, "files": [ "bootstrap.php" @@ -9717,38 +9570,36 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Laurent Bassin", - "email": "laurent@bassin.info" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "description": "Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "idn", - "intl", "polyfill", "portable", "shim" ], - "time": "2019-03-04T13:44:35+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "bc4858fb611bda58719124ca079baff854149c89" + "reference": "54b4c428a0054e254223797d2713c31e08610831" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/bc4858fb611bda58719124ca079baff854149c89", - "reference": "bc4858fb611bda58719124ca079baff854149c89", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/54b4c428a0054e254223797d2713c31e08610831", + "reference": "54b4c428a0054e254223797d2713c31e08610831", "shasum": "" }, "require": { @@ -9758,7 +9609,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -9794,20 +9645,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.11.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c" + "reference": "04ce3335667451138df4307d6a9b61565560199e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/ab50dcf166d5f577978419edd37aa2bb8eabce0c", - "reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e", + "reference": "04ce3335667451138df4307d6a9b61565560199e", "shasum": "" }, "require": { @@ -9816,7 +9667,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.11-dev" + "dev-master": "1.12-dev" } }, "autoload": { @@ -9849,20 +9700,20 @@ "portable", "shim" ], - "time": "2019-02-06T07:57:58+00:00" + "time": "2019-08-06T08:03:45+00:00" }, { "name": "symfony/service-contracts", - "version": "v1.1.5", + "version": "v1.1.7", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d" + "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", - "reference": "f391a00de78ec7ec8cf5cdcdae59ec7b883edb8d", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/ffcde9615dc5bb4825b9f6aed07716f1f57faae0", + "reference": "ffcde9615dc5bb4825b9f6aed07716f1f57faae0", "shasum": "" }, "require": { @@ -9907,20 +9758,20 @@ "interoperability", "standards" ], - "time": "2019-06-13T11:15:36+00:00" + "time": "2019-09-17T11:12:18+00:00" }, { "name": "symfony/stopwatch", - "version": "v4.3.3", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "6b100e9309e8979cf1978ac1778eb155c1f7d93b" + "reference": "1e4ff456bd625be5032fac9be4294e60442e9b71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/6b100e9309e8979cf1978ac1778eb155c1f7d93b", - "reference": "6b100e9309e8979cf1978ac1778eb155c1f7d93b", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/1e4ff456bd625be5032fac9be4294e60442e9b71", + "reference": "1e4ff456bd625be5032fac9be4294e60442e9b71", "shasum": "" }, "require": { @@ -9957,24 +9808,24 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2019-05-27T08:16:38+00:00" + "time": "2019-08-07T11:52:19+00:00" }, { "name": "symfony/yaml", - "version": "v3.4.30", + "version": "v4.3.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "051d045c684148060ebfc9affb7e3f5e0899d40b" + "reference": "41e16350a2a1c7383c4735aa2f9fce74cf3d1178" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/051d045c684148060ebfc9affb7e3f5e0899d40b", - "reference": "051d045c684148060ebfc9affb7e3f5e0899d40b", + "url": "https://api.github.com/repos/symfony/yaml/zipball/41e16350a2a1c7383c4735aa2f9fce74cf3d1178", + "reference": "41e16350a2a1c7383c4735aa2f9fce74cf3d1178", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", + "php": "^7.1.3", "symfony/polyfill-ctype": "~1.8" }, "conflict": { @@ -9989,7 +9840,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.4-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -10016,7 +9867,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2019-07-24T13:01:31+00:00" + "time": "2019-09-11T15:41:19+00:00" }, { "name": "theseer/fdomdocument", @@ -10151,16 +10002,16 @@ }, { "name": "webmozart/assert", - "version": "1.4.0", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", - "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "url": "https://api.github.com/repos/webmozart/assert/zipball/88e6d84706d09a236046d686bbea96f07b3a34f4", + "reference": "88e6d84706d09a236046d686bbea96f07b3a34f4", "shasum": "" }, "require": { @@ -10168,8 +10019,7 @@ "symfony/polyfill-ctype": "^1.8" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", "extra": { @@ -10198,7 +10048,7 @@ "check", "validate" ], - "time": "2018-12-25T11:19:39+00:00" + "time": "2019-08-24T08:43:50+00:00" }, { "name": "weew/helpers-array", @@ -10260,7 +10110,6 @@ "ext-pdo_mysql": "*", "ext-simplexml": "*", "ext-soap": "*", - "ext-spl": "*", "ext-xsl": "*", "ext-zip": "*", "lib-libxml": "*" diff --git a/dev/tests/acceptance/tests/_data/catalog_import_products_url_rewrite.csv b/dev/tests/acceptance/tests/_data/catalog_import_products_url_rewrite.csv new file mode 100644 index 000000000000..95e359ce7a1d --- /dev/null +++ b/dev/tests/acceptance/tests/_data/catalog_import_products_url_rewrite.csv @@ -0,0 +1,2 @@ +sku,url_key +SimpleProductForTest1,SimpleProductAfterImport1-new diff --git a/dev/tests/acceptance/tests/_data/tablerates.csv b/dev/tests/acceptance/tests/_data/tablerates.csv new file mode 100644 index 000000000000..ddc591798e3c --- /dev/null +++ b/dev/tests/acceptance/tests/_data/tablerates.csv @@ -0,0 +1,21 @@ +Country,Region/State,Zip/Postal Code,Weight (and above),Shipping Price +ASM,*,*,0,9.95 +FSM,*,*,0,9.95 +GUM,*,*,0,9.95 +MHL,*,*,0,9.95 +MNP,*,*,0,9.95 +PLW,*,*,0,9.95 +USA,AA,*,0,9.95 +USA,AE,*,0,9.95 +USA,AK,*,0,9.95 +USA,AP,*,0,9.95 +USA,AS,*,0,9.95 +USA,FM,*,0,9.95 +USA,GU,*,0,9.95 +USA,HI,*,0,9.95 +USA,MH,*,0,9.95 +USA,MP,*,0,9.95 +USA,PR,*,0,9.95 +USA,PW,*,0,9.95 +USA,VI,*,0,9.95 +VIR,*,*,0,9.95 \ No newline at end of file diff --git a/dev/tests/acceptance/tests/_data/usa_tablerates.csv b/dev/tests/acceptance/tests/_data/usa_tablerates.csv new file mode 100644 index 000000000000..d5a59ae6bccf --- /dev/null +++ b/dev/tests/acceptance/tests/_data/usa_tablerates.csv @@ -0,0 +1,13 @@ +Country,Region/State,"Zip/Postal Code","Order Subtotal (and above)","Shipping Price" +USA,*,*,0.0000,7.9900 +USA,*,*,7.0000,6.9900 +USA,*,*,13.0000,5.9900 +USA,*,*,25.9900,4.9900 +USA,AK,*,0.0000,8.9900 +USA,AK,*,7.0000,7.9900 +USA,AK,*,13.0000,6.9900 +USA,AK,*,25.9900,5.9900 +USA,HI,*,0.0000,8.9900 +USA,HI,*,7.0000,7.9900 +USA,HI,*,13.0000,6.9900 +USA,HI,*,25.9900,5.9900 diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml index f0bfec543f28..cac9d0c3cb55 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml @@ -27,4 +27,23 @@ <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="searchGrabConfigProductPageImageSrc" after="searchAssertConfigProductPage"/> <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$searchGrabConfigProductPageImageSrc" stepKey="searchAssertConfigProductPageImageNotDefault" after="searchGrabConfigProductPageImageSrc"/> </test> + <test name="EndToEndB2CGuestUserMysqlTest"> + <!-- Search configurable product --> + <comment userInput="Search configurable product" stepKey="commentSearchConfigurableProduct" after="searchAssertSimpleProduct2ImageNotDefault" /> + <actionGroup ref="StorefrontCheckCategoryConfigurableProduct" stepKey="searchAssertFilterCategoryConfigProduct" after="commentSearchConfigurableProduct"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontCategoryProductSection.ProductImageByName($$createConfigProduct.name$$)}}" userInput="src" stepKey="searchGrabConfigProductImageSrc" after="searchAssertFilterCategoryConfigProduct"/> + <assertNotRegExp expected="'/placeholder\/small_image\.jpg/'" actual="$searchGrabConfigProductImageSrc" stepKey="searchAssertConfigProductImageNotDefault" after="searchGrabConfigProductImageSrc"/> + <click selector="{{StorefrontCategoryProductSection.ProductTitleByName($$createConfigProduct.name$$)}}" stepKey="searchClickConfigProductView" after="searchAssertConfigProductImageNotDefault"/> + <actionGroup ref="StorefrontCheckConfigurableProduct" stepKey="searchAssertConfigProductPage" after="searchClickConfigProductView"> + <argument name="product" value="$$createConfigProduct$$"/> + <argument name="optionProduct" value="$$createConfigChildProduct1$$"/> + </actionGroup> + <!-- @TODO: Move Image check to action group after MQE-697 is fixed --> + <grabAttributeFrom selector="{{StorefrontProductInfoMainSection.productImage}}" userInput="src" stepKey="searchGrabConfigProductPageImageSrc" after="searchAssertConfigProductPage"/> + <assertNotRegExp expected="'/placeholder\/image\.jpg/'" actual="$searchGrabConfigProductPageImageSrc" stepKey="searchAssertConfigProductPageImageNotDefault" after="searchGrabConfigProductPageImageSrc"/> + </test> </tests> diff --git a/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/etc/module.xml b/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/etc/module.xml new file mode 100644 index 000000000000..bae0739d237e --- /dev/null +++ b/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/etc/module.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> + <module name="Magento_TestModuleCatalogSearch"> + <sequence> + <module name="Magento_CatalogSearch"/> + </sequence> + </module> +</config> diff --git a/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/registration.php b/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/registration.php new file mode 100644 index 000000000000..78fb97a9e113 --- /dev/null +++ b/dev/tests/api-functional/_files/Magento/TestModuleCatalogSearch/registration.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Framework\Component\ComponentRegistrar; + +$registrar = new ComponentRegistrar(); +if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleCatalogSearch') === null) { + ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleCatalogSearch', __DIR__); +} diff --git a/dev/tests/api-functional/_files/Magento/TestModuleUps/Model/Carrier.php b/dev/tests/api-functional/_files/Magento/TestModuleUps/Model/Carrier.php index b3c3c124cfe4..9411523db0f2 100644 --- a/dev/tests/api-functional/_files/Magento/TestModuleUps/Model/Carrier.php +++ b/dev/tests/api-functional/_files/Magento/TestModuleUps/Model/Carrier.php @@ -7,10 +7,10 @@ namespace Magento\TestModuleUps\Model; -use Magento\Framework\Async\ProxyDeferredFactory; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\HTTP\ClientFactory; use Magento\Framework\Xml\Security; +use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; use Magento\Ups\Helper\Config; /** diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiConfigFixture.php b/dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiConfigFixture.php index a5be49303283..8061cb138660 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiConfigFixture.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/Annotation/ApiConfigFixture.php @@ -10,6 +10,7 @@ use Magento\Config\Model\Config; use Magento\Config\Model\ResourceModel\Config as ConfigResource; use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\Store\Model\StoreManagerInterface; use PHPUnit\Framework\TestCase; @@ -156,4 +157,31 @@ private function getStoreIdByCode(string $storeCode): int $store = $storeManager->getStore($storeCode); return (int)$store->getId(); } + + /** + * @inheritDoc + */ + protected function _setConfigValue($configPath, $value, $storeCode = false) + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + if ($storeCode === false) { + $objectManager->get( + \Magento\TestFramework\App\ApiMutableScopeConfig::class + )->setValue( + $configPath, + $value, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT + ); + + return; + } + \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\TestFramework\App\ApiMutableScopeConfig::class + )->setValue( + $configPath, + $value, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $storeCode + ); + } } diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/App/MutableScopeConfig.php b/dev/tests/api-functional/framework/Magento/TestFramework/App/ApiMutableScopeConfig.php similarity index 86% rename from dev/tests/api-functional/framework/Magento/TestFramework/App/MutableScopeConfig.php rename to dev/tests/api-functional/framework/Magento/TestFramework/App/ApiMutableScopeConfig.php index efcb5be34e59..fa0cebece9a9 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/App/MutableScopeConfig.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/App/ApiMutableScopeConfig.php @@ -17,7 +17,7 @@ /** * @inheritdoc */ -class MutableScopeConfig implements MutableScopeConfigInterface +class ApiMutableScopeConfig implements MutableScopeConfigInterface { /** * @var Config @@ -56,7 +56,6 @@ public function setValue( /** * Clean app config cache * - * @param string|null $type * @return void */ public function clean() @@ -89,19 +88,13 @@ private function getTestAppConfig() private function persistConfig($path, $value, $scopeType, $scopeCode): void { $pathParts = explode('/', $path); - $store = ''; - if ($scopeType === \Magento\Store\Model\ScopeInterface::SCOPE_STORE) { - if ($scopeCode !== null) { - $store = ObjectManager::getInstance() + $store = 0; + if ($scopeType === \Magento\Store\Model\ScopeInterface::SCOPE_STORE + && $scopeCode !== null) { + $store = ObjectManager::getInstance() ->get(\Magento\Store\Api\StoreRepositoryInterface::class) ->get($scopeCode) ->getId(); - } else { - $store = ObjectManager::getInstance() - ->get(\Magento\Store\Model\StoreManagerInterface::class) - ->getStore() - ->getId(); - } } $configData = [ 'section' => $pathParts[0], diff --git a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php index 9ad051b686d4..6400a61b3ef3 100644 --- a/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php +++ b/dev/tests/api-functional/framework/Magento/TestFramework/TestCase/WebapiAbstract.php @@ -7,6 +7,7 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; +use Magento\Framework\Webapi\Exception as WebapiException; use Magento\Webapi\Model\Soap\Fault; use Magento\TestFramework\Helper\Bootstrap; @@ -102,9 +103,11 @@ abstract class WebapiAbstract extends \PHPUnit\Framework\TestCase /** * Initialize fixture namespaces. + * //phpcs:disable */ public static function setUpBeforeClass() { + //phpcs:enable parent::setUpBeforeClass(); self::_setFixtureNamespace(); } @@ -113,9 +116,11 @@ public static function setUpBeforeClass() * Run garbage collector for cleaning memory * * @return void + * //phpcs:disable */ public static function tearDownAfterClass() { + //phpcs:enable //clear garbage in memory gc_collect_cycles(); @@ -133,8 +138,7 @@ public static function tearDownAfterClass() } /** - * Call safe delete for models which added to delete list - * Restore config values changed during the test + * Call safe delete for models which added to delete list, Restore config values changed during the test * * @return void */ @@ -178,6 +182,8 @@ protected function _webApiCall( /** * Mark test to be executed for SOAP adapter only. + * + * @param ?string $message */ protected function _markTestAsSoapOnly($message = null) { @@ -188,6 +194,8 @@ protected function _markTestAsSoapOnly($message = null) /** * Mark test to be executed for REST adapter only. + * + * @param ?string $message */ protected function _markTestAsRestOnly($message = null) { @@ -203,9 +211,11 @@ protected function _markTestAsRestOnly($message = null) * @param mixed $fixture * @param int $tearDown * @return void + * //phpcs:disable */ public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DOWN_AFTER_METHOD) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (!isset(self::$_fixtures[$fixturesNamespace])) { self::$_fixtures[$fixturesNamespace] = []; @@ -231,9 +241,11 @@ public static function setFixture($key, $fixture, $tearDown = self::AUTO_TEAR_DO * * @param string $key * @return mixed + * //phpcs:disable */ public static function getFixture($key) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) { return self::$_fixtures[$fixturesNamespace][$key]; @@ -247,9 +259,11 @@ public static function getFixture($key) * @param \Magento\Framework\Model\AbstractModel $model * @param bool $secure * @return \Magento\TestFramework\TestCase\WebapiAbstract + * //phpcs:disable */ public static function callModelDelete($model, $secure = false) { + //phpcs:enable if ($model instanceof \Magento\Framework\Model\AbstractModel && $model->getId()) { if ($secure) { self::_enableSecureArea(); @@ -300,9 +314,11 @@ protected function _getWebApiAdapter($webApiAdapterCode) * Set fixtures namespace * * @throws \RuntimeException + * //phpcs:disable */ protected static function _setFixtureNamespace() { + //phpcs:enable if (self::$_fixturesNamespace !== null) { throw new \RuntimeException('Fixture namespace is already set.'); } @@ -311,9 +327,11 @@ protected static function _setFixtureNamespace() /** * Unset fixtures namespace + * //phpcs:disable */ protected static function _unsetFixtureNamespace() { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); unset(self::$_fixtures[$fixturesNamespace]); self::$_fixturesNamespace = null; @@ -324,9 +342,12 @@ protected static function _unsetFixtureNamespace() * * @throws \RuntimeException * @return string + * //phpcs:disable */ protected static function _getFixtureNamespace() { + //phpcs:enable + $fixtureNamespace = self::$_fixturesNamespace; if ($fixtureNamespace === null) { throw new \RuntimeException('Fixture namespace must be set.'); @@ -339,9 +360,12 @@ protected static function _getFixtureNamespace() * * @param bool $flag * @return void + * //phpcs:disable */ protected static function _enableSecureArea($flag = true) { + //phpcs:enable + /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -388,9 +412,11 @@ protected function _assertMessagesEqual($expectedMessages, $receivedMessages) * Delete array of fixtures * * @param array $fixtures + * //phpcs:disable */ protected static function _deleteFixtures($fixtures) { + //phpcs:enable foreach ($fixtures as $fixture) { self::deleteFixture($fixture, true); } @@ -402,9 +428,11 @@ protected static function _deleteFixtures($fixtures) * @param string $key * @param bool $secure * @return void + * //phpcs:disable */ public static function deleteFixture($key, $secure = false) { + //phpcs:enable $fixturesNamespace = self::_getFixtureNamespace(); if (array_key_exists($key, self::$_fixtures[$fixturesNamespace])) { self::callModelDelete(self::$_fixtures[$fixturesNamespace][$key], $secure); @@ -456,11 +484,11 @@ protected function _cleanAppConfigCache() /** * Update application config data * - * @param string $path Config path with the form "section/group/node" - * @param string|int|null $value Value of config item - * @param bool $cleanAppCache If TRUE application cache will be refreshed - * @param bool $updateLocalConfig If TRUE local config object will be updated too - * @param bool $restore If TRUE config value will be restored after test run + * @param string $path Config path with the form "section/group/node" + * @param string|int|null $value Value of config item + * @param bool $cleanAppCache If TRUE application cache will be refreshed + * @param bool $updateLocalConfig If TRUE local config object will be updated too + * @param bool $restore If TRUE config value will be restored after test run * @return \Magento\TestFramework\TestCase\WebapiAbstract * @throws \RuntimeException */ @@ -520,6 +548,8 @@ protected function _restoreAppConfig() } /** + * Process rest exception result. + * * @param \Exception $e * @return array * <pre> ex. @@ -666,11 +696,19 @@ protected function _checkWrappedErrors($expectedWrappedErrors, $errorDetails) } /** + * Get actual wrapped errors. + * * @param \stdClass $errorNode * @return array */ private function getActualWrappedErrors(\stdClass $errorNode) { + if (!isset($errorNode->parameters)) { + return [ + 'message' => $errorNode->message, + ]; + } + $actualParameters = []; $parameterNode = $errorNode->parameters->parameter; if (is_array($parameterNode)) { @@ -686,4 +724,42 @@ private function getActualWrappedErrors(\stdClass $errorNode) 'params' => $actualParameters, ]; } + + /** + * Assert webapi errors. + * + * @param array $serviceInfo + * @param array $data + * @param array $expectedErrorData + * @return void + * @throws \Exception + */ + protected function assertWebApiCallErrors(array $serviceInfo, array $data, array $expectedErrorData) + { + try { + $this->_webApiCall($serviceInfo, $data); + $this->fail('Expected throwing exception'); + } catch (\Exception $e) { + if (TESTS_WEB_API_ADAPTER === self::ADAPTER_REST) { + self::assertEquals($expectedErrorData, $this->processRestExceptionResult($e)); + self::assertEquals(WebapiException::HTTP_BAD_REQUEST, $e->getCode()); + } elseif (TESTS_WEB_API_ADAPTER === self::ADAPTER_SOAP) { + $this->assertInstanceOf('SoapFault', $e); + $expectedWrappedErrors = []; + foreach ($expectedErrorData['errors'] as $error) { + // @see \Magento\TestFramework\TestCase\WebapiAbstract::getActualWrappedErrors() + $expectedWrappedError = [ + 'message' => $error['message'], + ]; + if (isset($error['parameters'])) { + $expectedWrappedError['params'] = $error['parameters']; + } + $expectedWrappedErrors[] = $expectedWrappedError; + } + $this->checkSoapFault($e, $expectedErrorData['message'], 'env:Sender', [], $expectedWrappedErrors); + } else { + throw $e; + } + } + } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php index 9a6520a3ab45..1cd299149507 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php @@ -4,16 +4,23 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Catalog\Api; use Magento\Framework\Api\Data\ImageContentInterface; use Magento\TestFramework\Helper\Bootstrap; +use Magento\Catalog\Model\ProductFactory; +use Magento\TestFramework\ObjectManager; +use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter; +use Magento\Catalog\Model\ProductRepository; +use Magento\Framework\Webapi\Rest\Request; +use Magento\TestFramework\TestCase\WebapiAbstract; /** * Class ProductAttributeMediaGalleryManagementInterfaceTest */ -class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestFramework\TestCase\WebapiAbstract +class ProductAttributeMediaGalleryManagementInterfaceTest extends WebapiAbstract { /** * Default create service request information (product with SKU 'simple' is used) @@ -41,12 +48,15 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF */ protected $testImagePath; + /** + * @inheritDoc + */ protected function setUp() { $this->createServiceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/simple/media', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST, + 'httpMethod' => Request::HTTP_METHOD_POST, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -58,7 +68,7 @@ protected function setUp() $this->updateServiceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/simple/media', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, + 'httpMethod' => Request::HTTP_METHOD_PUT, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -66,9 +76,10 @@ protected function setUp() 'operation' => 'catalogProductAttributeMediaGalleryManagementV1Update', ], ]; + $this->deleteServiceInfo = [ 'rest' => [ - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, + 'httpMethod' => Request::HTTP_METHOD_DELETE, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -76,6 +87,7 @@ protected function setUp() 'operation' => 'catalogProductAttributeMediaGalleryManagementV1Remove', ], ]; + $this->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg'; } @@ -87,7 +99,8 @@ protected function setUp() protected function getTargetSimpleProduct() { $objectManager = Bootstrap::getObjectManager(); - return $objectManager->get(\Magento\Catalog\Model\ProductFactory::class)->create()->load(1); + + return $objectManager->get(ProductFactory::class)->create()->load(1); } /** @@ -101,17 +114,20 @@ protected function getTargetGalleryEntryId() { $mediaGallery = $this->getTargetSimpleProduct()->getData('media_gallery'); $image = array_shift($mediaGallery['images']); + return (int)$image['value_id']; } /** + * Test create() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testCreate() { $requestData = [ 'id' => null, - 'media_type' => \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::MEDIA_TYPE_CODE, + 'media_type' => ImageEntryConverter::MEDIA_TYPE_CODE, 'label' => 'Image Text', 'position' => 1, 'types' => ['image'], @@ -138,13 +154,15 @@ public function testCreate() } /** + * Test create() method without file + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testCreateWithoutFileExtension() { $requestData = [ 'id' => null, - 'media_type' => \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::MEDIA_TYPE_CODE, + 'media_type' => ImageEntryConverter::MEDIA_TYPE_CODE, 'label' => 'Image Text', 'position' => 1, 'types' => ['image'], @@ -171,13 +189,15 @@ public function testCreateWithoutFileExtension() } /** + * Test create() method with not default store id + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testCreateWithNotDefaultStoreId() { $requestData = [ 'id' => null, - 'media_type' => \Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter::MEDIA_TYPE_CODE, + 'media_type' => ImageEntryConverter::MEDIA_TYPE_CODE, 'label' => 'Image Text', 'position' => 1, 'types' => ['image'], @@ -215,6 +235,8 @@ public function testCreateWithNotDefaultStoreId() } /** + * Test update() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php */ public function testUpdate() @@ -253,6 +275,8 @@ public function testUpdate() } /** + * Test update() method with not default store id + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php */ public function testUpdateWithNotDefaultStoreId() @@ -291,7 +315,9 @@ public function testUpdateWithNotDefaultStoreId() } /** - * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php + * Test delete() method + * + * @magentoApiDataFixture Magento/Catalog/_files/product_with_image_without_types.php */ public function testDelete() { @@ -309,6 +335,8 @@ public function testDelete() } /** + * Test create() method if provided content is not base64 encoded + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @expectedException \Exception * @expectedExceptionMessage The image content must be valid base64 encoded data. @@ -334,6 +362,8 @@ public function testCreateThrowsExceptionIfProvidedContentIsNotBase64Encoded() } /** + * Test create() method if provided content is not an image + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @expectedException \Exception * @expectedExceptionMessage The image content must be valid base64 encoded data. @@ -359,6 +389,8 @@ public function testCreateThrowsExceptionIfProvidedContentIsNotAnImage() } /** + * Test create() method if provided image has wrong MIME type + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @expectedException \Exception * @expectedExceptionMessage The image MIME type is not valid or not supported. @@ -384,6 +416,8 @@ public function testCreateThrowsExceptionIfProvidedImageHasWrongMimeType() } /** + * Test create method if target product does not exist + * * @expectedException \Exception * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again. */ @@ -409,6 +443,8 @@ public function testCreateThrowsExceptionIfTargetProductDoesNotExist() } /** + * Test create() method if provided image name contains forbidden characters + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @expectedException \Exception * @expectedExceptionMessage Provided image name contains forbidden characters. @@ -433,6 +469,8 @@ public function testCreateThrowsExceptionIfProvidedImageNameContainsForbiddenCha } /** + * Test update() method if target product does not exist + * * @expectedException \Exception * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again. */ @@ -456,6 +494,8 @@ public function testUpdateThrowsExceptionIfTargetProductDoesNotExist() } /** + * Test update() method if there is no image with given id + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php * @expectedException \Exception * @expectedExceptionMessage No image with the provided ID was found. Verify the ID and try again. @@ -481,6 +521,8 @@ public function testUpdateThrowsExceptionIfThereIsNoImageWithGivenId() } /** + * Test delete() method if target product does not exist + * * @expectedException \Exception * @expectedExceptionMessage The product that was requested doesn't exist. Verify the product and try again. */ @@ -496,6 +538,8 @@ public function testDeleteThrowsExceptionIfTargetProductDoesNotExist() } /** + * Test delete() method if there is no image with given id + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php * @expectedException \Exception * @expectedExceptionMessage No image with the provided ID was found. Verify the ID and try again. @@ -512,15 +556,17 @@ public function testDeleteThrowsExceptionIfThereIsNoImageWithGivenId() } /** + * Test get() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php */ public function testGet() { $productSku = 'simple'; - $objectManager = \Magento\TestFramework\ObjectManager::getInstance(); - /** @var \Magento\Catalog\Model\ProductRepository $repository */ - $repository = $objectManager->create(\Magento\Catalog\Model\ProductRepository::class); + $objectManager = ObjectManager::getInstance(); + /** @var ProductRepository $repository */ + $repository = $objectManager->create(ProductRepository::class); $product = $repository->get($productSku); $image = current($product->getMediaGallery('images')); $imageId = $image['value_id']; @@ -537,7 +583,7 @@ public function testGet() $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/' . $productSku . '/media/' . $imageId, - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + 'httpMethod' => Request::HTTP_METHOD_GET, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -560,6 +606,8 @@ public function testGet() } /** + * Test getList() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_image.php */ public function testGetList() @@ -568,7 +616,7 @@ public function testGetList() $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/' . urlencode($productSku) . '/media', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + 'httpMethod' => Request::HTTP_METHOD_GET, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -591,13 +639,16 @@ public function testGetList() $this->assertContains('thumbnail', $imageTypes); } + /** + * Test getList() method for absent sku + */ public function testGetListForAbsentSku() { $productSku = 'absent_sku_' . time(); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/' . urlencode($productSku) . '/media', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + 'httpMethod' => Request::HTTP_METHOD_GET, ], 'soap' => [ 'service' => 'catalogProductAttributeMediaGalleryManagementV1', @@ -622,6 +673,8 @@ public function testGetListForAbsentSku() } /** + * Test addProductVideo() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testAddProductVideo() diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php index 386bd9fc9aee..42aa92652a5f 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php @@ -4,12 +4,13 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Catalog\Api; use Magento\Framework\Webapi\Exception as HTTPExceptionCodes; -use Magento\TestFramework\Helper\Bootstrap; +/** + * API tests for \Magento\Catalog\Model\Product\Attribute\Repository. + */ class ProductAttributeRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstract { const SERVICE_NAME = 'catalogProductAttributeRepositoryV1'; @@ -130,6 +131,7 @@ public function testCreateWithExceptionIfAttributeAlreadyExists() try { $this->createAttribute($attributeCode); $this->fail("Expected exception"); + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch } catch (\SoapFault $e) { //Expects soap exception } catch (\Exception $e) { @@ -320,6 +322,20 @@ public function testDeleteById() $this->assertTrue($this->deleteAttribute($attributeCode)); } + /** + * Trying to delete system attribute. + * + * @magentoApiDataFixture Magento/Catalog/_files/product_system_attribute.php + * @expectedException \Exception + * @expectedExceptionMessage The system attribute can't be deleted. + * @return void + */ + public function testDeleteSystemAttributeById(): void + { + $attributeCode = 'test_attribute_code_333'; + $this->deleteAttribute($attributeCode); + } + /** * @return void */ diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index 3e935e1d7ae9..ed67f41a7823 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -9,6 +9,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\CatalogInventory\Api\Data\StockItemInterface; +use Magento\Downloadable\Api\DomainManagerInterface; use Magento\Downloadable\Model\Link; use Magento\Store\Model\Store; use Magento\Store\Model\Website; @@ -24,6 +25,8 @@ use Magento\Framework\Webapi\Exception as HTTPExceptionCodes; /** + * Test for \Magento\Catalog\Api\ProductRepositoryInterface + * * @magentoAppIsolation enabled * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -56,6 +59,34 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract ]; /** + * @inheritDoc + */ + protected function setUp() + { + parent::setUp(); + + $objectManager = Bootstrap::getObjectManager(); + /** @var DomainManagerInterface $domainManager */ + $domainManager = $objectManager->get(DomainManagerInterface::class); + $domainManager->addDomains(['example.com']); + } + + /** + * @inheritDoc + */ + protected function tearDown() + { + parent::tearDown(); + + $objectManager = Bootstrap::getObjectManager(); + /** @var DomainManagerInterface $domainManager */ + $domainManager = $objectManager->get(DomainManagerInterface::class); + $domainManager->removeDomains(['example.com']); + } + + /** + * Test get() method + * * @magentoApiDataFixture Magento/Catalog/_files/products_related.php */ public function testGet() @@ -69,6 +100,8 @@ public function testGet() } /** + * Get product + * * @param string $sku * @param string|null $storeCode * @return array|bool|float|int|string @@ -86,11 +119,14 @@ protected function getProduct($sku, $storeCode = null) 'operation' => self::SERVICE_NAME . 'Get', ], ]; - $response = $this->_webApiCall($serviceInfo, ['sku' => $sku], null, $storeCode); + return $response; } + /** + * Test get() method with invalid sku + */ public function testGetNoSuchEntityException() { $invalidSku = '(nonExistingSku)'; @@ -125,6 +161,8 @@ public function testGetNoSuchEntityException() } /** + * Product creation provider + * * @return array */ public function productCreationProvider() @@ -135,6 +173,7 @@ public function productCreationProvider() $data ); }; + return [ [$productBuilder([ProductInterface::TYPE_ID => 'simple', ProductInterface::SKU => 'psku-test-1'])], [$productBuilder([ProductInterface::TYPE_ID => 'virtual', ProductInterface::SKU => 'psku-test-2'])], @@ -161,6 +200,7 @@ private function loadWebsiteByCode($websiteCode) /** * Test removing association between product and website 1 + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_two_websites.php */ public function testUpdateWithDeleteWebsites() @@ -184,6 +224,7 @@ public function testUpdateWithDeleteWebsites() /** * Test removing all website associations + * * @magentoApiDataFixture Magento/Catalog/_files/product_with_two_websites.php */ public function testDeleteAllWebsiteAssociations() @@ -202,6 +243,8 @@ public function testDeleteAllWebsiteAssociations() } /** + * Test create() method with multiple websites + * * @magentoApiDataFixture Magento/Catalog/_files/second_website.php */ public function testCreateWithMultipleWebsites() @@ -305,6 +348,8 @@ public function testUpdateWithoutWebsiteIds() } /** + * Test create() method + * * @dataProvider productCreationProvider */ public function testCreate($product) @@ -372,6 +417,9 @@ public function testCreateAllStoreCodeForSingleWebsite($fixtureProduct) $this->deleteProduct($fixtureProduct[ProductInterface::SKU]); } + /** + * Test create() method with invalid price format + */ public function testCreateInvalidPriceFormat() { $this->_markTestAsRestOnly("In case of SOAP type casting is handled by PHP SoapServer, no need to test it"); @@ -408,6 +456,9 @@ public function testDeleteAllStoreCode($fixtureProduct) $this->getProduct($sku); } + /** + * Test product links + */ public function testProductLinks() { // Create simple product @@ -441,7 +492,6 @@ public function testProductLinks() ProductInterface::TYPE_ID => 'simple', ProductInterface::PRICE => 100, ProductInterface::STATUS => 1, - ProductInterface::TYPE_ID => 'simple', ProductInterface::ATTRIBUTE_SET_ID => 4, "product_links" => [$productLinkData] ]; @@ -504,6 +554,8 @@ public function testProductLinks() } /** + * Get options data + * * @param string $productSku * @return array */ @@ -543,6 +595,9 @@ protected function getOptionsData($productSku) ]; } + /** + * Test product options + */ public function testProductOptions() { //Create product with options @@ -604,9 +659,13 @@ public function testProductOptions() $this->deleteProduct($productData[ProductInterface::SKU]); } + /** + * Test product with media gallery + */ public function testProductWithMediaGallery() { $testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg'; + // @codingStandardsIgnoreLine $encodedImage = base64_encode(file_get_contents($testImagePath)); //create a product with media gallery $filename1 = 'tiny1' . time() . '.jpg'; @@ -635,7 +694,7 @@ public function testProductWithMediaGallery() 'position' => 2, 'media_type' => 'image', 'disabled' => false, - 'types' => ['image', 'small_image'], + 'types' => [], 'file' => '/t/i/' . $filename2, ], ]; @@ -648,7 +707,7 @@ public function testProductWithMediaGallery() 'label' => 'tiny1_new_label', 'position' => 1, 'disabled' => false, - 'types' => ['image', 'small_image'], + 'types' => [], 'file' => '/t/i/' . $filename1, ], ]; @@ -662,7 +721,7 @@ public function testProductWithMediaGallery() 'media_type' => 'image', 'position' => 1, 'disabled' => false, - 'types' => ['image', 'small_image'], + 'types' => [], 'file' => '/t/i/' . $filename1, ] ]; @@ -682,6 +741,8 @@ public function testProductWithMediaGallery() } /** + * Test update() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testUpdate() @@ -725,17 +786,19 @@ public function testUpdateWithExtensionAttributes(): void } /** + * Update product + * * @param array $product * @return array|bool|float|int|string */ protected function updateProduct($product) { if (isset($product['custom_attributes'])) { - for ($i=0; $i<sizeof($product['custom_attributes']); $i++) { - if ($product['custom_attributes'][$i]['attribute_code'] == 'category_ids' - && !is_array($product['custom_attributes'][$i]['value']) + foreach ($product['custom_attributes'] as &$customAttribute) { + if ($customAttribute['attribute_code'] == 'category_ids' + && !is_array($customAttribute['value']) ) { - $product['custom_attributes'][$i]['value'] = [""]; + $customAttribute['value'] = [""]; } } } @@ -761,6 +824,8 @@ protected function updateProduct($product) } /** + * Test delete() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testDelete() @@ -770,6 +835,8 @@ public function testDelete() } /** + * Test getList() method + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testGetList() @@ -832,6 +899,8 @@ public function testGetList() } /** + * Test getList() method with additional params + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testGetListWithAdditionalParams() @@ -871,6 +940,8 @@ public function testGetListWithAdditionalParams() } /** + * Test getList() method with filtering by website + * * @magentoApiDataFixture Magento/Catalog/_files/products_with_websites_and_stores.php * @return void */ @@ -958,6 +1029,11 @@ public function testGetListWithFilteringByStore(array $searchCriteria, array $sk } } + /** + * Test getList() method with filtering by store data provider + * + * @return array + */ public function testGetListWithFilteringByStoreDataProvider() { return [ @@ -997,6 +1073,8 @@ public function testGetListWithFilteringByStoreDataProvider() } /** + * Test getList() method with multiple filter groups and sorting and pagination + * * @magentoApiDataFixture Magento/Catalog/_files/products_for_search.php */ public function testGetListWithMultipleFilterGroupsAndSortingAndPagination() @@ -1066,6 +1144,8 @@ public function testGetListWithMultipleFilterGroupsAndSortingAndPagination() } /** + * Convert custom attributes to associative array + * * @param $customAttributes * @return array */ @@ -1075,10 +1155,13 @@ protected function convertCustomAttributesToAssociativeArray($customAttributes) foreach ($customAttributes as $customAttribute) { $converted[$customAttribute['attribute_code']] = $customAttribute['value']; } + return $converted; } /** + * Convert associative array to custom attributes + * * @param $data * @return array */ @@ -1088,10 +1171,13 @@ protected function convertAssociativeArrayToCustomAttributes($data) foreach ($data as $attributeCode => $attributeValue) { $customAttributes[] = ['attribute_code' => $attributeCode, 'value' => $attributeValue]; } + return $customAttributes; } /** + * Test eav attributes + * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ public function testEavAttributes() @@ -1135,7 +1221,6 @@ protected function getSimpleProductData($productData = []) ProductInterface::TYPE_ID => 'simple', ProductInterface::PRICE => 3.62, ProductInterface::STATUS => 1, - ProductInterface::TYPE_ID => 'simple', ProductInterface::ATTRIBUTE_SET_ID => 4, 'custom_attributes' => [ ['attribute_code' => 'cost', 'value' => ''], @@ -1145,6 +1230,8 @@ protected function getSimpleProductData($productData = []) } /** + * Save Product + * * @param $product * @param string|null $storeCode * @return mixed @@ -1152,11 +1239,11 @@ protected function getSimpleProductData($productData = []) protected function saveProduct($product, $storeCode = null) { if (isset($product['custom_attributes'])) { - for ($i=0; $i<sizeof($product['custom_attributes']); $i++) { - if ($product['custom_attributes'][$i]['attribute_code'] == 'category_ids' - && !is_array($product['custom_attributes'][$i]['value']) + foreach ($product['custom_attributes'] as &$customAttribute) { + if ($customAttribute['attribute_code'] == 'category_ids' + && !is_array($customAttribute['value']) ) { - $product['custom_attributes'][$i]['value'] = [""]; + $customAttribute['value'] = [""]; } } } @@ -1172,6 +1259,7 @@ protected function saveProduct($product, $storeCode = null) ], ]; $requestData = ['product' => $product]; + return $this->_webApiCall($serviceInfo, $requestData, null, $storeCode); } @@ -1199,6 +1287,9 @@ protected function deleteProduct($sku) $this->_webApiCall($serviceInfo, ['sku' => $sku]) : $this->_webApiCall($serviceInfo); } + /** + * Test tier prices + */ public function testTierPrices() { // create a product with tier prices @@ -1283,6 +1374,8 @@ public function testTierPrices() } /** + * Get stock item data + * * @return array */ private function getStockItemData() @@ -1315,6 +1408,8 @@ private function getStockItemData() } /** + * Test product category links + * * @magentoApiDataFixture Magento/Catalog/_files/category_product.php */ public function testProductCategoryLinks() @@ -1337,6 +1432,8 @@ public function testProductCategoryLinks() } /** + * Test update product category without categories + * * @magentoApiDataFixture Magento/Catalog/_files/category_product.php */ public function testUpdateProductCategoryLinksNullOrNotExists() @@ -1358,6 +1455,8 @@ public function testUpdateProductCategoryLinksNullOrNotExists() } /** + * Test update product category links position + * * @magentoApiDataFixture Magento/Catalog/_files/category_product.php */ public function testUpdateProductCategoryLinksPosistion() @@ -1375,6 +1474,8 @@ public function testUpdateProductCategoryLinksPosistion() } /** + * Test update product category links unassing + * * @magentoApiDataFixture Magento/Catalog/_files/category_product.php */ public function testUpdateProductCategoryLinksUnassign() @@ -1387,6 +1488,8 @@ public function testUpdateProductCategoryLinksUnassign() } /** + * Get media gallery data + * * @param $filename1 * @param $encodedImage * @param $filename2 @@ -1412,7 +1515,7 @@ private function getMediaGalleryData($filename1, $encodedImage, $filename2) 'media_type' => 'image', 'disabled' => false, 'label' => 'tiny2', - 'types' => ['image', 'small_image'], + 'types' => [], 'content' => [ 'type' => 'image/jpeg', 'name' => $filename2, @@ -1422,6 +1525,9 @@ private function getMediaGalleryData($filename1, $encodedImage, $filename2) ]; } + /** + * Test special price + */ public function testSpecialPrice() { $productData = $this->getSimpleProductData(); @@ -1471,6 +1577,9 @@ public function testResetSpecialPrice() $this->assertFalse(array_key_exists(self::KEY_SPECIAL_PRICE, $customAttributes)); } + /** + * Test update status + */ public function testUpdateStatus() { // Create simple product @@ -1543,6 +1652,8 @@ public function testUpdateMultiselectAttributes() } /** + * Get attribute options + * * @param string $attributeCode * @return array|bool|float|int|string */ @@ -1564,6 +1675,8 @@ private function getAttributeOptions($attributeCode) } /** + * Assert multiselect value + * * @param string $productSku * @param string $multiselectAttributeCode * @param string $expectedMultiselectValue diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiCurrencyTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiCurrencyTest.php index 844230f4e333..65e1e65e36be 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiCurrencyTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryMultiCurrencyTest.php @@ -17,6 +17,7 @@ class ProductRepositoryMultiCurrencyTest extends WebapiAbstract const WEBSITES_RESOURCE_PATH = '/V1/store/websites'; /** + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Store/_files/second_website_with_second_currency.php * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php */ diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php index 31894c1332ad..88bb3a8d59af 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php @@ -228,14 +228,21 @@ public function testGetCustomerActivateCustomer() 'token' => $this->token ] ]; - $requestData = ['confirmationKey' => $this->customerData[CustomerInterface::CONFIRMATION]]; + + $requestData = ['confirmationKey' => CustomerHelper::CONFIRMATION]; if (TESTS_WEB_API_ADAPTER === 'soap') { $requestData['customerId'] = 0; } - $customerResponseData = $this->_webApiCall($serviceInfo, $requestData); - $this->assertEquals($this->customerData[CustomerInterface::ID], $customerResponseData[CustomerInterface::ID]); - // Confirmation key is removed after confirmation - $this->assertFalse(isset($customerResponseData[CustomerInterface::CONFIRMATION])); + + try { + $customerResponseData = $this->_webApiCall($serviceInfo, $requestData); + $this->assertEquals( + $this->customerData[CustomerInterface::ID], + $customerResponseData[CustomerInterface::ID] + ); + } catch (\Exception $e) { + $this->fail('Customer is not activated.'); + } } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php index b2276d79f5ec..a93bbcbdf04b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php @@ -249,7 +249,15 @@ public function testCreateCustomerWithoutOptionalFields() public function testActivateCustomer() { $customerData = $this->_createCustomer(); - $this->assertNotNull($customerData[Customer::CONFIRMATION], 'Customer activation is not required'); + + // Update the customer's confirmation key to a known value + $customerData = $this->customerHelper->updateSampleCustomer( + $customerData[Customer::ID], + [ + 'id' => $customerData[Customer::ID], + 'confirmation' => CustomerHelper::CONFIRMATION + ] + ); $serviceInfo = [ 'rest' => [ @@ -265,16 +273,15 @@ public function testActivateCustomer() $requestData = [ 'email' => $customerData[Customer::EMAIL], - 'confirmationKey' => $customerData[Customer::CONFIRMATION], + 'confirmationKey' => CustomerHelper::CONFIRMATION ]; - $result = $this->_webApiCall($serviceInfo, $requestData); - - $this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!'); - $this->assertTrue( - !isset($result[Customer::CONFIRMATION]) || $result[Customer::CONFIRMATION] === null, - 'Customer is not activated!' - ); + try { + $result = $this->_webApiCall($serviceInfo, $requestData); + $this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!'); + } catch (\Exception $e) { + $this->fail('Customer is not activated.'); + } } public function testGetCustomerActivateCustomer() @@ -294,14 +301,15 @@ public function testGetCustomerActivateCustomer() ]; $requestData = [ 'email' => $customerData[Customer::EMAIL], - 'confirmationKey' => $customerData[Customer::CONFIRMATION], + 'confirmationKey' => CustomerHelper::CONFIRMATION ]; - $customerResponseData = $this->_webApiCall($serviceInfo, $requestData); - - $this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]); - // Confirmation key is removed after confirmation - $this->assertFalse(isset($customerResponseData[Customer::CONFIRMATION])); + try { + $customerResponseData = $this->_webApiCall($serviceInfo, $requestData); + $this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]); + } catch (\Exception $e) { + $this->fail('Customer is not activated.'); + } } public function testValidateResetPasswordLinkToken() diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php index c881969a3b67..3a24aab30cb6 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/LinkRepositoryTest.php @@ -12,6 +12,9 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; +/** + * API tests for Magento\Downloadable\Model\LinkRepository. + */ class LinkRepositoryTest extends WebapiAbstract { /** @@ -135,10 +138,12 @@ public function testCreateUploadsProvidedFileContent() 'number_of_downloads' => 100, 'link_type' => 'file', 'link_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'image.jpg', ], 'sample_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'image.jpg', ], @@ -292,6 +297,64 @@ public function testCreateThrowsExceptionIfLinkFileContentIsNotAValidBase64Encod $this->_webApiCall($this->createServiceInfo, $requestData); } + /** + * Check that error appears when link file not existing in filesystem. + * + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + * @expectedException \Exception + * @expectedExceptionMessage Link file not found. Please try again. + * @return void + */ + public function testCreateLinkWithMissingLinkFileThrowsException(): void + { + $requestData = [ + 'isGlobalScopeContent' => false, + 'sku' => 'downloadable-product', + 'link' => [ + 'title' => 'Link Title', + 'sort_order' => 1, + 'price' => 10, + 'is_shareable' => 1, + 'number_of_downloads' => 100, + 'link_type' => 'file', + 'link_file' => '/n/o/nexistfile.png', + 'sample_type' => 'url', + 'sample_file' => 'http://google.com', + ], + ]; + + $this->_webApiCall($this->createServiceInfo, $requestData); + } + + /** + * Check that error appears when link sample file not existing in filesystem. + * + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + * @expectedException \Exception + * @expectedExceptionMessage Link sample file not found. Please try again. + * @return void + */ + public function testCreateLinkWithMissingSampleFileThrowsException(): void + { + $requestData = [ + 'isGlobalScopeContent' => false, + 'sku' => 'downloadable-product', + 'link' => [ + 'title' => 'Link Title', + 'sort_order' => 1, + 'price' => 10, + 'is_shareable' => 1, + 'number_of_downloads' => 100, + 'link_type' => 'url', + 'link_url' => 'http://www.example.com/', + 'sample_type' => 'file', + 'sample_file' => '/n/o/nexistfile.png', + ], + ]; + + $this->_webApiCall($this->createServiceInfo, $requestData); + } + /** * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php * @expectedException \Exception @@ -339,6 +402,7 @@ public function testCreateThrowsExceptionIfLinkFileNameContainsForbiddenCharacte 'number_of_downloads' => 100, 'link_type' => 'file', 'link_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'name/with|forbidden{characters', ], @@ -370,6 +434,7 @@ public function testCreateThrowsExceptionIfSampleFileNameContainsForbiddenCharac 'link_url' => 'http://www.example.com/', 'sample_type' => 'file', 'sample_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'name/with|forbidden{characters', ], @@ -405,6 +470,58 @@ public function testCreateThrowsExceptionIfLinkUrlHasWrongFormat() $this->_webApiCall($this->createServiceInfo, $requestData); } + /** + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + * @expectedException \Exception + * @expectedExceptionMessage Link URL's domain is not in list of downloadable_domains in env.php. + */ + public function testCreateThrowsExceptionIfLinkUrlUsesDomainNotInWhitelist() + { + $requestData = [ + 'isGlobalScopeContent' => false, + 'sku' => 'downloadable-product', + 'link' => [ + 'title' => 'Link Title', + 'sort_order' => 1, + 'price' => 10, + 'is_shareable' => 1, + 'number_of_downloads' => 100, + 'link_type' => 'url', + 'link_url' => 'http://notAnywhereInEnv.com/', + 'sample_type' => 'url', + 'sample_url' => 'http://www.example.com/', + ], + ]; + + $this->_webApiCall($this->createServiceInfo, $requestData); + } + + /** + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + * @expectedException \Exception + * @expectedExceptionMessage Sample URL's domain is not in list of downloadable_domains in env.php. + */ + public function testCreateThrowsExceptionIfSampleUrlUsesDomainNotInWhitelist() + { + $requestData = [ + 'isGlobalScopeContent' => false, + 'sku' => 'downloadable-product', + 'link' => [ + 'title' => 'Link Title', + 'sort_order' => 1, + 'price' => 10, + 'is_shareable' => 1, + 'number_of_downloads' => 100, + 'link_type' => 'url', + 'link_url' => 'http://example.com/', + 'sample_type' => 'url', + 'sample_url' => 'http://www.notAnywhereInEnv.com/', + ], + ]; + + $this->_webApiCall($this->createServiceInfo, $requestData); + } + /** * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php * @expectedException \Exception @@ -610,7 +727,9 @@ public function testUpdate() 'is_shareable' => 0, 'number_of_downloads' => 50, 'link_type' => 'url', + 'link_url' => 'http://google.com', 'sample_type' => 'url', + 'sample_url' => 'http://google.com', ], ]; $this->assertEquals($linkId, $this->_webApiCall($this->updateServiceInfo, $requestData)); @@ -643,7 +762,9 @@ public function testUpdateSavesDataInGlobalScopeAndDoesNotAffectValuesStoredInSt 'is_shareable' => 0, 'number_of_downloads' => 50, 'link_type' => 'url', + 'link_url' => 'http://google.com', 'sample_type' => 'url', + 'sample_url' => 'http://google.com', ], ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/ProductRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/ProductRepositoryTest.php index 769abadf2058..c2393d0a5ad2 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/ProductRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/ProductRepositoryTest.php @@ -27,7 +27,14 @@ class ProductRepositoryTest extends WebapiAbstract protected function setUp() { + parent::setUp(); $this->testImagePath = __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test_image.jpg'; + + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + /** @var DomainManagerInterface $domainManager */ + $domainManager = $objectManager->get(DomainManagerInterface::class); + $domainManager->addDomains(['www.example.com']); } /** @@ -37,6 +44,12 @@ public function tearDown() { $this->deleteProductBySku(self::PRODUCT_SKU); parent::tearDown(); + + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + + /** @var DomainManagerInterface $domainManager */ + $domainManager = $objectManager->get(DomainManagerInterface::class); + $domainManager->removeDomains(['www.example.com']); } protected function getLinkData() @@ -227,7 +240,9 @@ public function testUpdateDownloadableProductLinks() 'price' => 5.0, 'number_of_downloads' => 999, 'link_type' => 'file', - 'sample_type' => 'file' + 'link_file' => $linkFile, + 'sample_type' => 'file', + 'sample_file' => $sampleFile, ]; $linkData = $this->getLinkData(); diff --git a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php index b537947d5e4d..a97e4c5d9e11 100644 --- a/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Downloadable/Api/SampleRepositoryTest.php @@ -11,6 +11,9 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; +/** + * API tests for Magento\Downloadable\Model\SampleRepository. + */ class SampleRepositoryTest extends WebapiAbstract { /** @@ -131,6 +134,7 @@ public function testCreateUploadsProvidedFileContent() 'title' => 'Title', 'sort_order' => 1, 'sample_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'image.jpg', ], @@ -223,6 +227,30 @@ public function testCreateThrowsExceptionIfSampleTypeIsInvalid() $this->_webApiCall($this->createServiceInfo, $requestData); } + /** + * Check that error appears when sample file not existing in filesystem. + * + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + * @expectedException \Exception + * @expectedExceptionMessage Sample file not found. Please try again. + * @return void + */ + public function testCreateSampleWithMissingFileThrowsException(): void + { + $requestData = [ + 'isGlobalScopeContent' => false, + 'sku' => 'downloadable-product', + 'sample' => [ + 'title' => 'Link Title', + 'sort_order' => 1, + 'sample_type' => 'file', + 'sample_file' => '/n/o/nexistfile.png', + ], + ]; + + $this->_webApiCall($this->createServiceInfo, $requestData); + } + /** * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php * @expectedException \Exception @@ -262,6 +290,7 @@ public function testCreateThrowsExceptionIfSampleFileNameContainsForbiddenCharac 'sort_order' => 15, 'sample_type' => 'file', 'sample_file_content' => [ + //phpcs:ignore Magento2.Functions.DiscouragedFunction 'file_data' => base64_encode(file_get_contents($this->testImagePath)), 'name' => 'name/with|forbidden{characters', ], @@ -380,6 +409,7 @@ public function testUpdate() 'title' => 'Updated Title', 'sort_order' => 2, 'sample_type' => 'url', + 'sample_url' => 'http://google.com', ], ]; @@ -408,6 +438,7 @@ public function testUpdateSavesDataInGlobalScopeAndDoesNotAffectValuesStoredInSt 'title' => 'Updated Title', 'sort_order' => 2, 'sample_type' => 'url', + 'sample_url' => 'http://google.com', ], ]; diff --git a/dev/tests/api-functional/testsuite/Magento/Framework/Api/Search/SearchTest.php b/dev/tests/api-functional/testsuite/Magento/Framework/Api/Search/SearchTest.php index 65ea71bd3493..e6bc36684ed8 100644 --- a/dev/tests/api-functional/testsuite/Magento/Framework/Api/Search/SearchTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Framework/Api/Search/SearchTest.php @@ -38,7 +38,7 @@ public function testCatalogSearch() ] ] ], - 'page_size' => 20000000000000, + 'page_size' => 999, 'current_page' => 0, ], ]; @@ -66,7 +66,15 @@ public function testCatalogSearch() $this->assertTrue(count($response['items']) > 0); $this->assertNotNull($response['items'][0]['id']); - $this->assertEquals('score', $response['items'][0]['custom_attributes'][0]['attribute_code']); + $this->assertTrue( + in_array( + $response['items'][0]['custom_attributes'][0]['attribute_code'], + [ + 'score', // mysql + '_score' // elasticsearch score + ] + ) + ); $this->assertTrue($response['items'][0]['custom_attributes'][0]['value'] > 0); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php index 5f70cf4fd668..0ca1be775258 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Customer/SetPaymentMethodTest.php @@ -156,9 +156,25 @@ function (string $maskedQuoteId) { ], [ function (string $maskedQuoteId) { - return $this->getInvalidAcceptJsInput($maskedQuoteId); + return $this->getEmptyAcceptJsInput($maskedQuoteId); }, - 'for "authorizenet_acceptjs" is missing.' + 'for "authorizenet_acceptjs" is missing.', + ], + [ + function (string $maskedQuoteId) { + return $this->getMissingCcLastFourAcceptJsInput( + $maskedQuoteId, + static::VALID_DESCRIPTOR, + static::VALID_NONCE + ); + }, + 'parameter "cc_last_4" for "authorizenet_acceptjs" is missing', + ], + [ + function (string $maskedQuoteId) { + return $this->getMissingOpaqueDataValueAcceptJsInput($maskedQuoteId, static::VALID_DESCRIPTOR); + }, + 'parameter "opaque_data_value" for "authorizenet_acceptjs" is missing', ], ]; } @@ -190,12 +206,12 @@ private function getInvalidSetPaymentMutation(string $maskedQuoteId): string } /** - * Get setPaymentMethodOnCart missing require additional data properties + * Get setPaymentMethodOnCart missing required additional data properties * * @param string $maskedQuoteId * @return string */ - private function getInvalidAcceptJsInput(string $maskedQuoteId): string + private function getEmptyAcceptJsInput(string $maskedQuoteId): string { return <<<QUERY mutation { @@ -216,12 +232,72 @@ private function getInvalidAcceptJsInput(string $maskedQuoteId): string QUERY; } + /** + * Get setPaymentMethodOnCart missing required additional data properties + * + * @param string $maskedQuoteId + * @return string + */ + private function getMissingCcLastFourAcceptJsInput(string $maskedQuoteId, string $descriptor, string $nonce): string + { + return <<<QUERY +mutation { + setPaymentMethodOnCart(input:{ + cart_id:"{$maskedQuoteId}" + payment_method:{ + code:"authorizenet_acceptjs" + authorizenet_acceptjs:{ + opaque_data_descriptor: "{$descriptor}" + opaque_data_value: "{$nonce}" + } + } + }) { + cart { + selected_payment_method { + code + } + } + } +} +QUERY; + } + + /** + * Get setPaymentMethodOnCart missing required additional data properties + * + * @param string $maskedQuoteId + * @return string + */ + private function getMissingOpaqueDataValueAcceptJsInput(string $maskedQuoteId, string $descriptor): string + { + return <<<QUERY +mutation { + setPaymentMethodOnCart(input:{ + cart_id:"{$maskedQuoteId}" + payment_method:{ + code:"authorizenet_acceptjs" + authorizenet_acceptjs:{ + opaque_data_descriptor: "{$descriptor}" + cc_last_4: 1111 + } + } + }) { + cart { + selected_payment_method { + code + } + } + } +} +QUERY; + } + private function assertPlaceOrderResponse(array $response, string $reservedOrderId): void { self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } private function assertSetPaymentMethodResponse(array $response, string $methodCode): void @@ -278,7 +354,7 @@ private function getPlaceOrderMutation(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Guest/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Guest/SetPaymentMethodTest.php index 3bd7ade23ae4..322d984f5fa7 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Guest/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/AuthorizenetAcceptjs/Guest/SetPaymentMethodTest.php @@ -113,8 +113,8 @@ private function assertPlaceOrderResponse(array $response, string $reservedOrder { self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } private function assertSetPaymentMethodResponse(array $response, string $methodCode): void @@ -171,7 +171,7 @@ private function getPlaceOrderMutation(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/CreateBraintreeClientTokenTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/CreateBraintreeClientTokenTest.php index 1564d00fa599..7d69c49ae6aa 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/CreateBraintreeClientTokenTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/CreateBraintreeClientTokenTest.php @@ -20,6 +20,7 @@ class CreateBraintreeClientTokenTest extends GraphQlAbstract * @magentoConfigFixture default_store payment/braintree/active 1 * @magentoConfigFixture default_store payment/braintree/environment sandbox * @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id + * @magentoConfigFixture default_store payment/braintree/merchant_account_id def_merchant_id * @magentoConfigFixture default_store payment/braintree/public_key def_public_key * @magentoConfigFixture default_store payment/braintree/private_key def_private_key */ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php index 84a639af30b0..ad756dfdd2e4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Customer/SetPaymentMethodTest.php @@ -8,6 +8,7 @@ namespace Magento\GraphQl\Braintree\Customer; use Magento\Braintree\Gateway\Command\GetPaymentNonceCommand; +use Magento\Framework\Exception\AuthenticationException; use Magento\Framework\Registry; use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; use Magento\Integration\Api\CustomerTokenServiceInterface; @@ -261,6 +262,34 @@ public function testSetPaymentMethodInvalidMethodInput(string $methodCode) $this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); } + /** + * @magentoConfigFixture default_store carriers/flatrate/active 1 + * @magentoConfigFixture default_store payment/braintree/active 1 + * @magentoConfigFixture default_store payment/braintree_cc_vault/active 1 + * @magentoConfigFixture default_store payment/braintree/environment sandbox + * @magentoConfigFixture default_store payment/braintree/merchant_id def_merchant_id + * @magentoConfigFixture default_store payment/braintree/public_key def_public_key + * @magentoConfigFixture default_store payment/braintree/private_key def_private_key + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php + * @dataProvider dataProviderTestSetPaymentMethodInvalidInput + * @expectedException \Exception + */ + public function testSetPaymentMethodWithoutRequiredPaymentMethodInput() + { + $reservedOrderId = 'test_quote'; + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId); + + $setPaymentQuery = $this->getSetPaymentBraintreeQueryInvalidPaymentMethodInput($maskedQuoteId); + $this->expectExceptionMessage("for \"braintree\" is missing."); + $this->graphQlMutation($setPaymentQuery, [], '', $this->getHeaderMap()); + } + public function dataProviderTestSetPaymentMethodInvalidInput(): array { return [ @@ -273,8 +302,8 @@ private function assertPlaceOrderResponse(array $response, string $reservedOrder { self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } private function assertSetPaymentMethodResponse(array $response, string $methodCode): void @@ -371,6 +400,33 @@ private function getSetPaymentBraintreeQueryInvalidInput(string $maskedQuoteId, QUERY; } + /** + * @param string $maskedQuoteId + * @return string + */ + private function getSetPaymentBraintreeQueryInvalidPaymentMethodInput(string $maskedQuoteId): string + { + return <<<QUERY +mutation { + setPaymentMethodOnCart(input:{ + cart_id:"{$maskedQuoteId}" + payment_method:{ + code:"braintree" + braintree:{ + payment_method_nonce:"fake-valid-nonce" + } + } + }) { + cart { + selected_payment_method { + code + } + } + } +} +QUERY; + } + /** * @param string $maskedQuoteId * @param string $methodCode @@ -407,7 +463,7 @@ private function getPlaceOrderQuery(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } @@ -437,7 +493,7 @@ private function getPaymentTokenQuery(): string * @param string $username * @param string $password * @return array - * @throws \Magento\Framework\Exception\AuthenticationException + * @throws AuthenticationException */ private function getHeaderMap(string $username = 'customer@example.com', string $password = 'password'): array { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php index 1d48c5253fe8..5ee7dd457657 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Braintree/Guest/SetPaymentMethodTest.php @@ -159,8 +159,8 @@ private function assertPlaceOrderResponse(array $response, string $reservedOrder { self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } private function assertSetPaymentMethodResponse(array $response, string $methodCode): void @@ -259,7 +259,7 @@ private function getPlaceOrderQuery(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php new file mode 100644 index 000000000000..0e88af2fcb22 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php @@ -0,0 +1,476 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Catalog; + +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; + +/** + * Test CategoryList GraphQl query + */ +class CategoryListTest extends GraphQlAbstract +{ + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + * @dataProvider filterSingleCategoryDataProvider + * @param $field + * @param $condition + * @param $value + */ + public function testFilterSingleCategoryByField($field, $condition, $value, $expectedResult) + { + $query = <<<QUERY +{ + categoryList(filters: { $field : { $condition : "$value" } }){ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(1, $result['categoryList']); + $this->assertResponseFields($result['categoryList'][0], $expectedResult); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + * @dataProvider filterMultipleCategoriesDataProvider + * @param $field + * @param $condition + * @param $value + * @param $expectedResult + */ + public function testFilterMultipleCategoriesByField($field, $condition, $value, $expectedResult) + { + $query = <<<QUERY +{ + categoryList(filters: { $field : { $condition : $value } }){ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(count($expectedResult), $result['categoryList']); + foreach ($expectedResult as $i => $expected) { + $this->assertResponseFields($result['categoryList'][$i], $expected); + } + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testFilterCategoryByMultipleFields() + { + $query = <<<QUERY +{ + categoryList(filters: {ids: {in: ["6","7","8","9","10"]}, name: {match: "Movable"}}){ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(3, $result['categoryList']); + + $expectedCategories = [7 => 'Movable', 9 => 'Movable Position 1', 10 => 'Movable Position 2']; + $actualCategories = array_column($result['categoryList'], 'name', 'id'); + $this->assertEquals($expectedCategories, $actualCategories); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testFilterWithInactiveCategory() + { + $query = <<<QUERY +{ + categoryList(filters: {url_key: {in: ["inactive", "category-2"]}}){ + id + name + url_key + url_path + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(1, $result['categoryList']); + $actualCategories = array_column($result['categoryList'], 'url_key', 'id'); + $this->assertContains('category-2', $actualCategories); + $this->assertNotContains('inactive', $actualCategories); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testQueryChildCategoriesWithProducts() + { + $query = <<<QUERY +{ + categoryList(filters: {ids: {in: ["3"]}}){ + id + name + url_key + url_path + description + products{ + total_count + items{ + name + sku + } + } + children{ + name + url_key + description + products{ + total_count + items{ + name + sku + } + } + children{ + name + } + } + } +} +QUERY; + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(1, $result['categoryList']); + $baseCategory = $result['categoryList'][0]; + + $this->assertEquals('Category 1', $baseCategory['name']); + $this->assertArrayHasKey('products', $baseCategory); + //Check base category products + $expectedBaseCategoryProducts = [ + ['sku' => 'simple', 'name' => 'Simple Product'], + ['sku' => '12345', 'name' => 'Simple Product Two'], + ['sku' => 'simple-4', 'name' => 'Simple Product Three'] + ]; + $this->assertCategoryProducts($baseCategory, $expectedBaseCategoryProducts); + //Check base category children + $expectedBaseCategoryChildren = [ + ['name' => 'Category 1.1', 'description' => 'Category 1.1 description.'], + ['name' => 'Category 1.2', 'description' => 'Its a description of Test Category 1.2'] + ]; + $this->assertCategoryChildren($baseCategory, $expectedBaseCategoryChildren); + + //Check first child category + $firstChildCategory = $baseCategory['children'][0]; + $this->assertEquals('Category 1.1', $firstChildCategory['name']); + $this->assertEquals('Category 1.1 description.', $firstChildCategory['description']); + $firstChildCategoryExpectedProducts = [ + ['sku' => 'simple', 'name' => 'Simple Product'], + ['sku' => '12345', 'name' => 'Simple Product Two'], + ]; + $this->assertCategoryProducts($firstChildCategory, $firstChildCategoryExpectedProducts); + $firstChildCategoryChildren = [['name' =>'Category 1.1.1']]; + $this->assertCategoryChildren($firstChildCategory, $firstChildCategoryChildren); + //Check second child category + $secondChildCategory = $baseCategory['children'][1]; + $this->assertEquals('Category 1.2', $secondChildCategory['name']); + $this->assertEquals('Its a description of Test Category 1.2', $secondChildCategory['description']); + $firstChildCategoryExpectedProducts = [ + ['sku' => 'simple', 'name' => 'Simple Product'], + ['sku' => 'simple-4', 'name' => 'Simple Product Three'] + ]; + $this->assertCategoryProducts($secondChildCategory, $firstChildCategoryExpectedProducts); + $firstChildCategoryChildren = []; + $this->assertCategoryChildren($secondChildCategory, $firstChildCategoryChildren); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testNoResultsFound() + { + $query = <<<QUERY +{ + categoryList(filters: {url_key: {in: ["inactive", "does-not-exist"]}}){ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertArrayHasKey('categoryList', $result); + $this->assertEquals([], $result['categoryList']); + } + + /** + * When no filters are supplied, the root category is returned + * + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testEmptyFiltersReturnRootCategory() + { + $query = <<<QUERY +{ + categoryList{ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); + $storeRootCategoryId = $storeManager->getStore()->getRootCategoryId(); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertArrayHasKey('categoryList', $result); + $this->assertEquals('Default Category', $result['categoryList'][0]['name']); + $this->assertEquals($storeRootCategoryId, $result['categoryList'][0]['id']); + } + + /** + * Filtering with match value less than minimum query should return empty result + * + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testMinimumMatchQueryLength() + { + $query = <<<QUERY +{ + categoryList(filters: {name: {match: "mo"}}){ + id + name + url_key + url_path + children_count + path + position + } +} +QUERY; + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertArrayHasKey('categoryList', $result); + $this->assertEquals([], $result['categoryList']); + } + + /** + * @return array + */ + public function filterSingleCategoryDataProvider(): array + { + return [ + [ + 'ids', + 'eq', + '4', + [ + 'id' => '4', + 'name' => 'Category 1.1', + 'url_key' => 'category-1-1', + 'url_path' => 'category-1/category-1-1', + 'children_count' => '0', + 'path' => '1/2/3/4', + 'position' => '1' + ] + ], + [ + 'name', + 'match', + 'Movable Position 2', + [ + 'id' => '10', + 'name' => 'Movable Position 2', + 'url_key' => 'movable-position-2', + 'url_path' => 'movable-position-2', + 'children_count' => '0', + 'path' => '1/2/10', + 'position' => '6' + ] + ], + [ + 'url_key', + 'eq', + 'category-1-1-1', + [ + 'id' => '5', + 'name' => 'Category 1.1.1', + 'url_key' => 'category-1-1-1', + 'url_path' => 'category-1/category-1-1/category-1-1-1', + 'children_count' => '0', + 'path' => '1/2/3/4/5', + 'position' => '1' + ] + ], + ]; + } + + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @return array + */ + public function filterMultipleCategoriesDataProvider(): array + { + return[ + //Filter by multiple IDs + [ + 'ids', + 'in', + '["4", "9", "10"]', + [ + [ + 'id' => '4', + 'name' => 'Category 1.1', + 'url_key' => 'category-1-1', + 'url_path' => 'category-1/category-1-1', + 'children_count' => '0', + 'path' => '1/2/3/4', + 'position' => '1' + ], + [ + 'id' => '9', + 'name' => 'Movable Position 1', + 'url_key' => 'movable-position-1', + 'url_path' => 'movable-position-1', + 'children_count' => '0', + 'path' => '1/2/9', + 'position' => '5' + ], + [ + 'id' => '10', + 'name' => 'Movable Position 2', + 'url_key' => 'movable-position-2', + 'url_path' => 'movable-position-2', + 'children_count' => '0', + 'path' => '1/2/10', + 'position' => '6' + ] + ] + ], + //Filter by multiple url keys + [ + 'url_key', + 'in', + '["category-1-2", "movable"]', + [ + [ + 'id' => '7', + 'name' => 'Movable', + 'url_key' => 'movable', + 'url_path' => 'movable', + 'children_count' => '0', + 'path' => '1/2/7', + 'position' => '3' + ], + [ + 'id' => '13', + 'name' => 'Category 1.2', + 'url_key' => 'category-1-2', + 'url_path' => 'category-1/category-1-2', + 'children_count' => '0', + 'path' => '1/2/3/13', + 'position' => '2' + ] + ] + ], + //Filter by matching multiple names + [ + 'name', + 'match', + '"Position"', + [ + [ + 'id' => '9', + 'name' => 'Movable Position 1', + 'url_key' => 'movable-position-1', + 'url_path' => 'movable-position-1', + 'children_count' => '0', + 'path' => '1/2/9', + 'position' => '5' + ], + [ + 'id' => '10', + 'name' => 'Movable Position 2', + 'url_key' => 'movable-position-2', + 'url_path' => 'movable-position-2', + 'children_count' => '0', + 'path' => '1/2/10', + 'position' => '6' + ], + [ + 'id' => '11', + 'name' => 'Movable Position 3', + 'url_key' => 'movable-position-3', + 'url_path' => 'movable-position-3', + 'children_count' => '0', + 'path' => '1/2/11', + 'position' => '7' + ] + ] + ] + ]; + } + + /** + * Check category products + * + * @param array $category + * @param array $expectedProducts + */ + private function assertCategoryProducts(array $category, array $expectedProducts) + { + $this->assertEquals(count($expectedProducts), $category['products']['total_count']); + $this->assertCount(count($expectedProducts), $category['products']['items']); + $this->assertResponseFields($category['products']['items'], $expectedProducts); + } + + /** + * Check category child categories + * + * @param array $category + * @param array $expectedChildren + */ + private function assertCategoryChildren(array $category, array $expectedChildren) + { + $this->assertArrayHasKey('children', $category); + $this->assertCount(count($expectedChildren), $category['children']); + foreach ($expectedChildren as $i => $expectedChild) { + $this->assertResponseFields($category['children'][$i], $expectedChild); + } + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php index cc0ef7aaf0f5..480388db98d2 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php @@ -13,6 +13,7 @@ use Magento\Catalog\Model\CategoryRepository; use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection; use Magento\Framework\DataObject; +use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException; use Magento\TestFramework\TestCase\GraphQlAbstract; @@ -502,6 +503,105 @@ public function testAnchorCategory() $this->assertEquals($expectedResponse, $response); } + /** + * @magentoApiDataFixture Magento/Catalog/_files/categories.php + */ + public function testBreadCrumbs() + { + /** @var CategoryCollection $categoryCollection */ + $categoryCollection = $this->objectManager->create(CategoryCollection::class); + $categoryCollection->addFieldToFilter('name', 'Category 1.1.1'); + /** @var CategoryInterface $category */ + $category = $categoryCollection->getFirstItem(); + $categoryId = $category->getId(); + $this->assertNotEmpty($categoryId, "Preconditions failed: category is not available."); + $query = <<<QUERY +{ + category(id: {$categoryId}) { + name + breadcrumbs { + category_id + category_name + category_level + category_url_key + category_url_path + } + } +} +QUERY; + $response = $this->graphQlQuery($query); + $expectedResponse = [ + 'category' => [ + 'name' => 'Category 1.1.1', + 'breadcrumbs' => [ + [ + 'category_id' => 3, + 'category_name' => "Category 1", + 'category_level' => 2, + 'category_url_key' => "category-1", + 'category_url_path' => "category-1" + ], + [ + 'category_id' => 4, + 'category_name' => "Category 1.1", + 'category_level' => 3, + 'category_url_key' => "category-1-1", + 'category_url_path' => "category-1/category-1-1" + ], + ] + ] + ]; + $this->assertEquals($expectedResponse, $response); + } + + /** + * Test category image is returned as full url (not relative path) + * + * @magentoApiDataFixture Magento/Catalog/_files/catalog_category_with_image.php + */ + public function testCategoryImage() + { + $categoryCollection = $this->objectManager->get(CategoryCollection::class); + $categoryModel = $categoryCollection + ->addAttributeToSelect('image') + ->addAttributeToFilter('name', ['eq' => 'Parent Image Category']) + ->getFirstItem(); + $categoryId = $categoryModel->getId(); + + $query = <<<QUERY + { +categoryList(filters: {ids: {in: ["$categoryId"]}}) { + id + name + url_key + image + children { + id + name + url_key + image + } + + } +} +QUERY; + + $response = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $response); + $this->assertNotEmpty($response['categoryList']); + $categoryList = $response['categoryList']; + $storeBaseUrl = $this->objectManager->get(StoreManagerInterface::class)->getStore()->getBaseUrl('media'); + $expectedImageUrl = rtrim($storeBaseUrl, '/'). '/' . ltrim($categoryModel->getImage(), '/'); + + $this->assertEquals($categoryId, $categoryList[0]['id']); + $this->assertEquals('Parent Image Category', $categoryList[0]['name']); + $this->assertEquals($expectedImageUrl, $categoryList[0]['image']); + + $childCategory = $categoryList[0]['children'][0]; + $this->assertEquals('Child Image Category', $childCategory['name']); + $this->assertEquals($expectedImageUrl, $childCategory['image']); + } + /** * @param ProductInterface $product * @param array $actualResponse diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php index e805bc940704..b6687b4e171d 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/MediaGalleryTest.php @@ -198,6 +198,6 @@ private function checkImageExists(string $url): bool curl_exec($connection); $responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE); // phpcs:enable Magento2.Functions.DiscouragedFunction - return $responseStatus === 200 ? true : false; + return $responseStatus === 200; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php index b957292a3ac2..52463485a34f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductImageTest.php @@ -144,6 +144,6 @@ private function checkImageExists(string $url): bool curl_exec($connection); $responseStatus = curl_getinfo($connection, CURLINFO_HTTP_CODE); - return $responseStatus === 200 ? true : false; + return $responseStatus === 200; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php new file mode 100644 index 000000000000..af237f1bd6fb --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php @@ -0,0 +1,1047 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Catalog; + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory; +use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\ConfigurableProduct\Api\LinkManagementInterface; +use Magento\ConfigurableProduct\Model\LinkManagement; +use Magento\Customer\Model\Group; +use Magento\Framework\ObjectManager\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; + +class ProductPriceTest extends GraphQlAbstract +{ + /** @var ObjectManager $objectManager */ + private $objectManager; + + /** @var ProductRepositoryInterface $productRepository */ + private $productRepository; + + protected function setUp() :void + { + $this->objectManager = Bootstrap::getObjectManager(); + /** @var ProductRepositoryInterface $productRepository */ + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/products.php + */ + public function testProductWithSinglePrice() + { + $skus = ['simple']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 10 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 10 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ] + ]; + + $this->assertPrices($expectedPriceRange, $product['price_range']); + } + + /** + * Pricing for Simple, Grouped and Configurable products with no special or tier prices configured + * + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_12345.php + * @magentoApiDataFixture Magento/GroupedProduct/_files/product_grouped_with_simple.php + * @magentoApiDataFixture Magento/Catalog/_files/product_simple_duplicated.php + */ + public function testMultipleProductTypes() + { + $skus = ["simple-1", "12345", "grouped"]; + + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(3, $result['products']['items']); + + $expected = [ + "simple-1" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 10 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 10 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ] + ], + "12345" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 30 + ], + "final_price" => [ + "value" => 30 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 40 + ], + "final_price" => [ + "value" => 40 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ] + ], + "grouped" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 100 + ], + "final_price" => [ + "value" => 100 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 100 + ], + "final_price" => [ + "value" => 100 + ], + "discount" => [ + "amount_off" => 0, + "percent_off" => 0 + ] + ] + ] + ]; + + foreach ($result['products']['items'] as $product) { + $this->assertNotEmpty($product['price_range']); + $this->assertPrices($expected[$product['sku']], $product['price_range']); + } + } + + /** + * Simple products with special price and tier price with % discount + * + * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testSimpleProductsWithSpecialPriceAndTierPrice() + { + $skus = ["simple1", "simple2"]; + $tierPriceFactory = $this->objectManager->get(ProductTierPriceInterfaceFactory::class); + + /** @var $tierPriceExtensionAttributesFactory */ + $tierPriceExtensionAttributesFactory = $this->objectManager->create(ProductTierPriceExtensionFactory::class); + $tierPriceExtensionAttribute = $tierPriceExtensionAttributesFactory->create()->setPercentageValue(10); + + $tierPrices[] = $tierPriceFactory->create( + [ + 'data' => [ + 'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, + 'qty' => 2 + ] + ] + )->setExtensionAttributes($tierPriceExtensionAttribute); + foreach ($skus as $sku) { + /** @var Product $simpleProduct */ + $simpleProduct = $this->productRepository->get($sku); + $simpleProduct->setTierPrices($tierPrices); + $this->productRepository->save($simpleProduct); + } + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(2, $result['products']['items']); + + $expectedPriceRange = [ + "simple1" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 5.99 + ], + "discount" => [ + "amount_off" => 4.01, + "percent_off" => 40.1 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 5.99 + ], + "discount" => [ + "amount_off" => 4.01, + "percent_off" => 40.1 + ] + ] + ], + "simple2" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 20 + ], + "final_price" => [ + "value" => 15.99 + ], + "discount" => [ + "amount_off" => 4.01, + "percent_off" => 20.05 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 20 + ], + "final_price" => [ + "value" => 15.99 + ], + "discount" => [ + "amount_off" => 4.01, + "percent_off" => 20.05 + ] + ] + ] + ]; + $expectedTierPrices = [ + "simple1" => [ + 0 => [ + 'discount' =>[ + 'amount_off' => 1, + 'percent_off' => 10 + ], + 'final_price' =>['value'=> 9], + 'quantity' => 2 + ] + ], + "simple2" => [ + 0 => [ + 'discount' =>[ + 'amount_off' => 2, + 'percent_off' => 10 + ], + 'final_price' =>['value'=> 18], + 'quantity' => 2 + ] + + ] + ]; + + foreach ($result['products']['items'] as $product) { + $this->assertNotEmpty($product['price_range']); + $this->assertNotEmpty($product['price_tiers']); + $this->assertPrices($expectedPriceRange[$product['sku']], $product['price_range']); + $this->assertResponseFields($product['price_tiers'], $expectedTierPrices[$product['sku']]); + } + } + + /** + * Check the pricing for a grouped product with simple products having special price set + * + * @magentoApiDataFixture Magento/GroupedProduct/_files/product_grouped_with_simple.php + */ + public function testGroupedProductsWithSpecialPriceAndTierPrices() + { + $groupedProductSku = 'grouped'; + $grouped = $this->productRepository->get($groupedProductSku); + //get the associated products + $groupedProductLinks = $grouped->getProductLinks(); + $tierPriceData = [ + [ + 'customer_group_id' => Group::CUST_GROUP_ALL, + 'percentage_value'=> null, + 'qty'=> 2, + 'value'=> 87 + ] + ]; + $associatedProductSkus = []; + foreach ($groupedProductLinks as $groupedProductLink) { + $associatedProductSkus[] = $groupedProductLink->getLinkedProductSku(); + } + + foreach ($associatedProductSkus as $associatedProductSku) { + $associatedProduct = $this->productRepository->get($associatedProductSku); + $associatedProduct->setSpecialPrice('95.75'); + $this->productRepository->save($associatedProduct); + $this->saveProductTierPrices($associatedProduct, $tierPriceData); + } + $skus = ['grouped']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => 100 + ], + "final_price" => [ + "value" => 95.75 + ], + "discount" => [ + "amount_off" => 100 - 95.75, + //difference between original and final over original price + "percent_off" => (100 - 95.75)*100/100 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 100 + ], + "final_price" => [ + "value" => 95.75 + ], + "discount" => [ + "amount_off" => 100 - 95.75, + "percent_off" => (100 - 95.75)*100/100 + ] + ] + ]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + $this->assertEmpty($product['price_tiers']); + + // update default quantity of each of the associated products to be greater than tier price qty of each of them + foreach ($groupedProductLinks as $groupedProductLink) { + $groupedProductLink->getExtensionAttributes()->setQty(3); + } + $this->productRepository->save($grouped); + $result = $this->graphQlQuery($query); + $product = $result['products']['items'][0]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + $this->assertEmpty($product['price_tiers']); + } + + /** + * Check pricing for bundled product with one item having special price set and dynamic price turned off + * + * @magentoApiDataFixture Magento/Bundle/_files/product_with_multiple_options_1.php + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testBundledProductWithSpecialPriceAndTierPrice() + { + $bundledProductSku = 'bundle-product'; + /** @var Product $bundled */ + $bundled = $this->productRepository->get($bundledProductSku); + $skus = ['bundle-product']; + $bundled->setSpecialPrice(10); + + // set the tier price for the bundled product + $tierPriceFactory = $this->objectManager->get(ProductTierPriceInterfaceFactory::class); + /** @var $tierPriceExtensionAttributesFactory */ + $tierPriceExtensionAttributesFactory = $this->objectManager->create(ProductTierPriceExtensionFactory::class); + $tierPriceExtensionAttribute = $tierPriceExtensionAttributesFactory->create()->setPercentageValue(10); + $tierPrices[] = $tierPriceFactory->create( + [ + 'data' => [ + 'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, + 'qty' => 2 + ] + ] + )->setExtensionAttributes($tierPriceExtensionAttribute); + $bundled->setTierPrices($tierPrices); + // Set Price view to PRICE RANGE + $bundled->setPriceView(0); + $this->productRepository->save($bundled); + + //Bundled product with dynamic prices turned OFF + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + $this->assertNotEmpty($product['price_tiers']); + + $bundleRegularPrice = 10; + $firstOptionPrice = 2.75; + $secondOptionPrice = 6.75; + + $minRegularPrice = $bundleRegularPrice + $firstOptionPrice ; + //Apply special price of 10% on minRegular price + $minFinalPrice = round($minRegularPrice * 0.1, 2); + + $maxRegularPrice = $bundleRegularPrice + $secondOptionPrice; + $maxFinalPrice = round($maxRegularPrice* 0.1, 2); + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => $minRegularPrice + ], + "final_price" => [ + "value" => $minFinalPrice + ], + "discount" => [ + "amount_off" => $minRegularPrice - $minFinalPrice, + "percent_off" => round(($minRegularPrice - $minFinalPrice)*100/$minRegularPrice, 2) + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => $maxRegularPrice + ], + "final_price" => [ + "value" => $maxFinalPrice + ], + "discount" => [ + "amount_off" => $maxRegularPrice - $maxFinalPrice, + "percent_off" => round(($maxRegularPrice - $maxFinalPrice)*100/$maxRegularPrice, 2) + ] + ] + ]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + $this->assertResponseFields( + $product['price_tiers'], + [ + 0 => [ + 'discount' =>[ + 'amount_off' => 1, + 'percent_off' => 10 + ], + 'final_price' =>['value'=> 9], + 'quantity' => 2 + ] + ] + ); + } + + /** + * Check pricing for bundled product with spl price, tier price with dynamic price turned on + * + * @magentoApiDataFixture Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options.php + */ + public function testBundledWithSpecialPriceAndTierPriceWithDynamicPrice() + { + $skus = ['bundle-product']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + $this->assertNotEmpty($product['price_tiers']); + + $minRegularPrice = 10; + $maxRegularPrice = 20; + + //Apply 10% special price on the cheapest simple product in bundle + $minFinalPrice = round(5.99 * 0.1, 2); + //Apply 10% special price on the expensive product in bundle + $maxFinalPrice = round(15.99 * 0.1, 2); + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => $minRegularPrice + ], + "final_price" => [ + "value" => $minFinalPrice + ], + "discount" => [ + "amount_off" => $minRegularPrice - $minFinalPrice, + "percent_off" => round(($minRegularPrice - $minFinalPrice)*100/$minRegularPrice, 2) + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => $maxRegularPrice + ], + "final_price" => [ + "value" => $maxFinalPrice + ], + "discount" => [ + "amount_off" => $maxRegularPrice - $maxFinalPrice, + "percent_off" => round(($maxRegularPrice - $maxFinalPrice)*100/$maxRegularPrice, 2) + ] + ] + ]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + $this->assertResponseFields( + $product['price_tiers'], + [ + 0 => [ + 'discount' =>[ + 'amount_off' => 1, + 'percent_off' => 10 + ], + 'final_price' =>['value'=> 0], + 'quantity' => 2 + ] + ] + ); + } + + /** + * Check pricing for Configurable product with each variants having special price and tier prices + * + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_12345.php + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testConfigurableProductWithVariantsHavingSpecialAndTierPrices() + { + $configurableProductSku ='12345'; + /** @var LinkManagementInterface $configurableProductLink */ + $configurableProductLinks = $this->objectManager->get(LinkManagement::class); + $configurableProductVariants = $configurableProductLinks->getChildren($configurableProductSku); + $tierPriceData = [ + [ + 'customer_group_id' => Group::CUST_GROUP_ALL, + 'percentage_value'=> null, + 'qty'=> 2, + 'value'=> 20 + ] + ]; + foreach ($configurableProductVariants as $configurableProductVariant) { + $configurableProductVariant->setSpecialPrice('25.99'); + $this->productRepository->save($configurableProductVariant); + $this->saveProductTierPrices($configurableProductVariant, $tierPriceData); + } + $sku = ['12345']; + $query = $this->getQueryConfigurableProductAndVariants($sku); + $result = $this->graphQlQuery($query); + + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + $regularPrice = []; + $finalPrice = []; + foreach ($configurableProductVariants as $configurableProductVariant) { + $regularPrice[] = $configurableProductVariant->getPrice(); + $finalPrice[] = $configurableProductVariant->getSpecialPrice(); + } + $regularPriceCheapestVariant = 30; + $specialPrice = 25.99; + $regularPriceExpensiveVariant = 40; + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => $regularPriceCheapestVariant + ], + "final_price" => [ + "value" => $specialPrice + ], + "discount" => [ + "amount_off" => $regularPriceCheapestVariant - $specialPrice, + "percent_off" => round( + ($regularPriceCheapestVariant - $specialPrice)*100/$regularPriceCheapestVariant, + 2 + ) + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => $regularPriceExpensiveVariant + ], + "final_price" => [ + "value" => $specialPrice + ], + "discount" => [ + "amount_off" => $regularPriceExpensiveVariant - $specialPrice, + "percent_off" => round( + ($regularPriceExpensiveVariant - $specialPrice)*100/$regularPriceExpensiveVariant, + 2 + ) + ] + ] + ]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + //configurable product's tier price is empty + $this->assertEmpty($product['price_tiers']); + $this->assertCount(2, $product['variants']); + + $configurableVariantsInResponse = array_map(null, $product['variants'], $configurableProductVariants); + + foreach ($configurableVariantsInResponse as $key => $configurableVariantPriceData) { + //validate that the tier prices and price range for each configurable variants are not empty + $this->assertNotEmpty($configurableVariantPriceData[0]['product']['price_range']); + $this->assertNotEmpty($configurableVariantPriceData[0]['product']['price_tiers']); + $this->assertResponseFields( + $configurableVariantsInResponse[$key][0]['product']['price_range'], + [ + "minimum_price" => [ + "regular_price" => [ + "value" => $configurableProductVariants[$key]->getPrice() + ], + "final_price" => [ + "value" => round($configurableProductVariants[$key]->getSpecialPrice(), 2) + ], + "discount" => [ + "amount_off" => ($regularPrice[$key] - $finalPrice[$key]), + "percent_off" => round(($regularPrice[$key] - $finalPrice[$key])*100/$regularPrice[$key], 2) + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => $configurableProductVariants[$key]->getPrice() + ], + "final_price" => [ + "value" => round($configurableProductVariants[$key]->getSpecialPrice(), 2) + ], + "discount" => [ + "amount_off" => $regularPrice[$key] - $finalPrice[$key], + "percent_off" => round(($regularPrice[$key] - $finalPrice[$key])*100/$regularPrice[$key], 2) + ] + ] + ] + ); + + $this->assertResponseFields( + $configurableVariantsInResponse[$key][0]['product']['price_tiers'], + [ + 0 => [ + 'discount' =>[ + 'amount_off' => $regularPrice[$key] - $tierPriceData[0]['value'], + 'percent_off' => round( + ( + $regularPrice[$key] - $tierPriceData[0]['value'] + ) * 100/$regularPrice[$key], + 2 + ) + ], + 'final_price' =>['value'=> $tierPriceData[0]['value']], + 'quantity' => 2 + ] + ] + ); + } + } + + /** + * Check the pricing for downloadable product type + * + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable.php + */ + public function testDownloadableProductWithSpecialPriceAndTierPrices() + { + $downloadableProductSku = 'downloadable-product'; + /** @var Product $downloadableProduct */ + $downloadableProduct = $this->productRepository->get($downloadableProductSku); + //setting the special price for the product + $downloadableProduct->setSpecialPrice('5.75'); + $this->productRepository->save($downloadableProduct); + //setting the tier price data for the product + $tierPriceData = [ + [ + 'customer_group_id' => Group::CUST_GROUP_ALL, + 'percentage_value'=> null, + 'qty'=> 2, + 'value'=> 7 + ] + ]; + $this->saveProductTierPrices($downloadableProduct, $tierPriceData); + $skus = ['downloadable-product']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']); + $this->assertNotEmpty($product['price_tiers']); + + $expectedPriceRange = [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 5.75 + ], + "discount" => [ + "amount_off" => 4.25, + //discount amount over regular price value + "percent_off" => (4.25/10)*100 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 5.75 + ], + "discount" => [ + "amount_off" => 4.25, + "percent_off" => (4.25/10)*100 + ] + ] + ]; + $this->assertPrices($expectedPriceRange, $product['price_range']); + $this->assertResponseFields( + $product['price_tiers'], + [ + 0 => [ + 'discount' =>[ + //regualr price - tier price value + 'amount_off' => 3, + 'percent_off' => 30 + ], + 'final_price' =>['value'=> 7], + 'quantity' => 2 + ] + ] + ); + } + + /** + * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * @magentoApiDataFixture Magento/Catalog/_files/product_virtual.php + * @magentoApiDataFixture Magento/CatalogRule/_files/catalog_rule_10_off_not_logged.php + */ + public function testProductWithCatalogDiscount() + { + $skus = ["virtual-product", "configurable"]; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertCount(2, $result['products']['items']); + + $expected = [ + "virtual-product" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 9 + ], + "discount" => [ + "amount_off" => 1, + "percent_off" => 10 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 9 + ], + "discount" => [ + "amount_off" => 1, + "percent_off" => 10 + ] + ] + ], + "configurable" => [ + "minimum_price" => [ + "regular_price" => [ + "value" => 10 + ], + "final_price" => [ + "value" => 9 + ], + "discount" => [ + "amount_off" => 1, + "percent_off" => 10 + ] + ], + "maximum_price" => [ + "regular_price" => [ + "value" => 20 + ], + "final_price" => [ + "value" => 18 + ], + "discount" => [ + "amount_off" => 2, + "percent_off" => 10 + ] + ] + ] + ]; + + foreach ($result['products']['items'] as $product) { + $this->assertNotEmpty($product['price_range']); + $this->assertPrices($expected[$product['sku']], $product['price_range']); + } + } + + /** + * Get GraphQl query to fetch products by sku + * + * @param array $skus + * @return string + */ + private function getProductQuery(array $skus): string + { + $stringSkus = '"' . implode('","', $skus) . '"'; + return <<<QUERY +{ + products(filter: {sku: {in: [$stringSkus]}}, sort: {name: ASC}) { + items { + name + sku + price_range { + minimum_price { + regular_price { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + } + maximum_price { + regular_price { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + } + } + price_tiers{ + discount{ + amount_off + percent_off + } + final_price{ + value + } + quantity + } + } + } +} +QUERY; + } + + /** + * Get GraphQl query to fetch Configurable product and its variants by sku + * + * @param array $sku + * @return string + */ + private function getQueryConfigurableProductAndVariants(array $sku): string + { + $stringSku = '"' . implode('","', $sku) . '"'; + return <<<QUERY +{ + products(filter: {sku: {in: [$stringSku]}}, sort: {name: ASC}) { + items { + name + sku + price_range { + minimum_price {regular_price + { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + } + maximum_price { + regular_price { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + } + } + price_tiers{ + discount{ + amount_off + percent_off + } + final_price{value} + quantity + } + ... on ConfigurableProduct{ + variants{ + product{ + + sku + price_range { + minimum_price {regular_price {value} + final_price { + value + + } + discount { + amount_off + percent_off + } + } + maximum_price { + regular_price { + value + + } + final_price { + value + + } + discount { + amount_off + percent_off + } + } + } + price_tiers{ + discount{ + amount_off + percent_off + } + final_price{value} + quantity + } + + } + } + } + } + } + } + +QUERY; + } + + /** + * Check prices from graphql response + * + * @param $expectedPrices + * @param $actualPrices + * @param string $currency + */ + private function assertPrices($expectedPrices, $actualPrices, $currency = 'USD') + { + $priceTypes = ['minimum_price', 'maximum_price']; + + foreach ($priceTypes as $priceType) { + $expected = $expectedPrices[$priceType]; + $actual = $actualPrices[$priceType]; + $this->assertEquals($expected['regular_price']['value'], $actual['regular_price']['value']); + $this->assertEquals( + $expected['regular_price']['currency'] ?? $currency, + $actual['regular_price']['currency'] + ); + $this->assertEquals($expected['final_price']['value'], $actual['final_price']['value']); + $this->assertEquals( + $expected['final_price']['currency'] ?? $currency, + $actual['final_price']['currency'] + ); + $this->assertEquals($expected['discount']['amount_off'], $actual['discount']['amount_off']); + $this->assertEquals($expected['discount']['percent_off'], $actual['discount']['percent_off']); + } + } + + /** + * @param ProductInterface $product + * @param array $tierPriceData + */ + private function saveProductTierPrices(ProductInterface $product, array $tierPriceData) + { + $tierPrices =[]; + $tierPriceFactory = $this->objectManager->get(ProductTierPriceInterfaceFactory::class); + foreach ($tierPriceData as $tierPrice) { + $tierPrices[] = $tierPriceFactory->create( + [ + 'data' => $tierPrice + ] + ); + /** ProductInterface $product */ + $product->setTierPrices($tierPrices); + $product->save(); + } + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php index 91f1795935f6..e1615eb9a667 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php @@ -14,7 +14,6 @@ use Magento\Catalog\Model\Category; use Magento\Catalog\Model\CategoryLinkManagement; use Magento\Eav\Model\Config; -use Magento\Indexer\Model\Indexer; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\GraphQlAbstract; use Magento\Catalog\Model\Product; @@ -28,6 +27,7 @@ * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.ExcessiveClassLength) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ class ProductSearchTest extends GraphQlAbstract { @@ -35,6 +35,7 @@ class ProductSearchTest extends GraphQlAbstract * Verify that layered navigation filters and aggregations are correct for product query * * Filter products by an array of skus + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -84,17 +85,37 @@ public function testFilterLn() $response['products'], 'Filters are missing in product query result.' ); + + $expectedFilters = $this->getExpectedFiltersDataSet(); + $actualFilters = $response['products']['filters']; + // presort expected and actual results as different search engines have different orders + usort($expectedFilters, [$this, 'compareFilterNames']); + usort($actualFilters, [$this, 'compareFilterNames']); + $this->assertFilters( - $response, - $this->getExpectedFiltersDataSet(), + ['products' => ['filters' => $actualFilters]], + $expectedFilters, 'Returned filters data set does not match the expected value' ); } + /** + * Compare arrays by value in 'name' field. + * + * @param array $a + * @param array $b + * @return int + */ + private function compareFilterNames(array $a, array $b) + { + return strcmp($a['name'], $b['name']); + } + /** * Layered navigation for Configurable products with out of stock options * Two configurable products each having two variations and one of the child products of one Configurable set to OOS * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/configurable_products_with_custom_attribute_layered_navigation.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -305,15 +326,17 @@ public function testFilterProductsByDropDownCustomAttribute() /** * @return void + * @throws \Magento\Framework\Exception\LocalizedException */ private function reIndexAndCleanCache() : void { - $objectManager = Bootstrap::getObjectManager(); - $indexer = $objectManager->create(Indexer::class); - $indexer->load('catalogsearch_fulltext'); - $indexer->reindexAll(); + $appDir = dirname(Bootstrap::getInstance()->getAppTempDir()); + $out = ''; + // phpcs:ignore Magento2.Security.InsecureFunction + exec("php -f {$appDir}/bin/magento indexer:reindex", $out); CacheCleaner::cleanAll(); } + /** * Filter products using an array of multi select custom attributes * @@ -676,9 +699,12 @@ public function testFilterByCategoryIdAndCustomAttribute() 'value'=> '13' ], ]; + // presort expected and actual results as different search engines have different orders + usort($expectedCategoryInAggregrations, [$this, 'compareLabels']); + usort($actualCategoriesFromResponse, [$this, 'compareLabels']); $categoryInAggregations = array_map(null, $expectedCategoryInAggregrations, $actualCategoriesFromResponse); -//Validate the categories and sub-categories data in the filter layer + //Validate the categories and sub-categories data in the filter layer foreach ($categoryInAggregations as $index => $categoryAggregationsData) { $this->assertNotEmpty($categoryAggregationsData); $this->assertEquals( @@ -694,6 +720,18 @@ public function testFilterByCategoryIdAndCustomAttribute() } } + /** + * Compare arrays by value in 'label' field. + * + * @param array $a + * @param array $b + * @return int + */ + private function compareLabels(array $a, array $b) + { + return strcmp($a['label'], $b['label']); + } + /** * Filter by exact match of product url key * @@ -982,6 +1020,7 @@ private function assertFilters($response, $expectedFilters, $message = '') /** * Verify product filtering using price range AND matching skus AND name sorted in DESC order * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -1052,13 +1091,14 @@ public function testFilterWithinSpecificPriceRangeSortedByNameDesc() * expected - error is thrown * Actual - empty array * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testSearchWithFilterWithPageSizeEqualTotalCount() { - + $this->reIndexAndCleanCache(); $query = <<<QUERY { @@ -1114,6 +1154,7 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount() /** * Filtering for products and sorting using multiple sort parameters * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -1486,18 +1527,24 @@ public function testSearchAndSortByRelevance() $this->assertEquals(3, $response['products']['total_count']); $this->assertNotEmpty($response['products']['filters'], 'Filters should have the Category layer'); $this->assertEquals('Colorful Category', $response['products']['filters'][0]['filter_items'][0]['label']); + $this->assertCount(2, $response['products']['aggregations']); $productsInResponse = ['Blue briefs','Navy Blue Striped Shoes','Grey shorts']; + /** @var \Magento\Config\Model\Config $config */ + $config = Bootstrap::getObjectManager()->get(\Magento\Config\Model\Config::class); + if (strpos($config->getConfigDataValue('catalog/search/engine'), 'elasticsearch') !== false) { + $this->markTestIncomplete('MC-20716'); + } $count = count($response['products']['items']); for ($i = 0; $i < $count; $i++) { $this->assertEquals($productsInResponse[$i], $response['products']['items'][$i]['name']); } - $this->assertCount(2, $response['products']['aggregations']); } /** * Filtering for product with sku "equals" a specific value * If pageSize and current page are not requested, default values are returned * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -1748,6 +1795,7 @@ public function testFilterWithinASpecificPriceRangeSortedByPriceDESC() /** * No items are returned if the conditions are not met * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -1807,6 +1855,7 @@ public function testQueryFilterNoMatchingItems() /** * Asserts that exception is thrown when current page > totalCount of items returned * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/multiple_mixed_products_2.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ @@ -1953,6 +2002,7 @@ public function testFilterProductsThatAreOutOfStockWithConfigSettings() /** * Verify that invalid current page return an error * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php * @expectedException \Exception * @expectedExceptionMessage currentPage value must be greater than 0 @@ -1982,6 +2032,7 @@ public function testInvalidCurrentPage() /** * Verify that invalid page size returns an error. * + * @magentoApiDataFixture Magento/Catalog/_files/category.php * @magentoApiDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php * @expectedException \Exception * @expectedExceptionMessage pageSize value must be greater than 0 diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/StoreConfigTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/StoreConfigTest.php index 7a30023c89f7..0982007daaa4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/StoreConfigTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/StoreConfigTest.php @@ -59,4 +59,50 @@ public function testGetStoreConfig() $this->assertEquals('asc', $response['storeConfig']['catalog_default_sort_by']); $this->assertEquals(2, $response['storeConfig']['root_category_id']); } + + /** + * @magentoApiDataFixture Magento/Store/_files/store.php + * @magentoConfigFixture catalog/seo/product_url_suffix global_test_product_suffix + * @magentoConfigFixture catalog/seo/category_url_suffix global_test_category_suffix + * @magentoConfigFixture catalog/seo/title_separator __ + * @magentoConfigFixture catalog/frontend/list_mode 3 + * @magentoConfigFixture catalog/frontend/grid_per_page_values 16 + * @magentoConfigFixture catalog/frontend/list_per_page_values 8 + * @magentoConfigFixture catalog/frontend/grid_per_page 16 + * @magentoConfigFixture catalog/frontend/list_per_page 8 + * @magentoConfigFixture catalog/frontend/default_sort_by asc + */ + public function testGetStoreConfigGlobal() + { + $query + = <<<QUERY +{ + storeConfig{ + product_url_suffix, + category_url_suffix, + title_separator, + list_mode, + grid_per_page_values, + list_per_page_values, + grid_per_page, + list_per_page, + catalog_default_sort_by, + root_category_id + } +} +QUERY; + $response = $this->graphQlQuery($query); + $this->assertArrayHasKey('storeConfig', $response); + + $this->assertEquals('global_test_product_suffix', $response['storeConfig']['product_url_suffix']); + $this->assertEquals('global_test_category_suffix', $response['storeConfig']['category_url_suffix']); + $this->assertEquals('__', $response['storeConfig']['title_separator']); + $this->assertEquals('3', $response['storeConfig']['list_mode']); + $this->assertEquals('16', $response['storeConfig']['grid_per_page_values']); + $this->assertEquals(16, $response['storeConfig']['grid_per_page']); + $this->assertEquals('8', $response['storeConfig']['list_per_page_values']); + $this->assertEquals(8, $response['storeConfig']['list_per_page']); + $this->assertEquals('asc', $response['storeConfig']['catalog_default_sort_by']); + $this->assertEquals(2, $response['storeConfig']['root_category_id']); + } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogCms/CategoryBlockTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogCms/CategoryBlockTest.php new file mode 100644 index 000000000000..52985422c335 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogCms/CategoryBlockTest.php @@ -0,0 +1,62 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\CatalogCms; + +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Cms\Api\BlockRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; +use Magento\Widget\Model\Template\FilterEmulate; + +/** + * Test category cms fields are resolved correctly + */ +class CategoryBlockTest extends GraphQlAbstract +{ + /** + * @magentoApiDataFixture Magento/Catalog/_files/category_tree.php + * @magentoApiDataFixture Magento/Cms/_files/block.php + */ + public function testCategoryCmsBlock() + { + $blockId = 'fixture_block'; + /** @var BlockRepositoryInterface $blockRepository */ + $blockRepository = Bootstrap::getObjectManager()->get(BlockRepositoryInterface::class); + $block = $blockRepository->getById($blockId); + $filter = Bootstrap::getObjectManager()->get(FilterEmulate::class); + $renderedContent = $filter->setUseSessionInUrl(false)->filter($block->getContent()); + + /** @var CategoryRepositoryInterface $categoryRepository */ + $categoryRepository = Bootstrap::getObjectManager()->get(CategoryRepositoryInterface::class); + $category = $categoryRepository->get(401); + $category->setLandingPage($block->getId()); + $categoryRepository->save($category); + + $query = <<<QUERY +{ + category(id: 401){ + name + cms_block{ + identifier + title + content + } + } +} +QUERY; + + $response = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $response); + $this->assertNotEmpty($response['category']); + $actualBlock = $response['category']['cms_block']; + + $this->assertEquals($block->getTitle(), $actualBlock['title']); + $this->assertEquals($block->getIdentifier(), $actualBlock['identifier']); + $this->assertEquals($renderedContent, $actualBlock['content']); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogUrlRewrite/UrlResolverTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogUrlRewrite/UrlResolverTest.php index b15cfe3a5b91..29696e29908f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogUrlRewrite/UrlResolverTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogUrlRewrite/UrlResolverTest.php @@ -65,33 +65,25 @@ public function testProductUrlResolver() 'store_id' => $storeId ] ); - $targetPath = $actualUrls->getTargetPath(); + $relativePath = $actualUrls->getRequestPath(); $expectedType = $actualUrls->getEntityType(); + $redirectCode = $actualUrls->getRedirectType(); - $query - = <<<QUERY -{ - urlResolver(url:"{$urlPath}") - { - id - relative_url - type - } -} -QUERY; - $response = $this->graphQlQuery($query); - $this->assertArrayHasKey('urlResolver', $response); - $this->assertEquals($product->getEntityId(), $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); - $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $urlPath, + $relativePath, + $expectedType, + $redirectCode + ); } /** - * Tests the use case where relative_url is provided as resolver input in the Query + * Test the use case where non seo friendly is provided as resolver input in the Query * * @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php */ - public function testProductUrlWithCanonicalUrlInput() + public function testProductUrlWithNonSeoFriendlyUrlInput() { $productSku = 'p002'; /** @var ProductRepositoryInterface $productRepository */ @@ -122,25 +114,127 @@ public function testProductUrlWithCanonicalUrlInput() 'store_id' => $storeId ] ); - $targetPath = $actualUrls->getTargetPath(); + // even of non seo friendly path requested, the seo friendly path should be prefered + $relativePath = $actualUrls->getRequestPath(); $expectedType = $actualUrls->getEntityType(); - $canonicalPath = $actualUrls->getTargetPath(); + $nonSeoFriendlyPath = $actualUrls->getTargetPath(); + $redirectCode = $actualUrls->getRedirectType(); + + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $nonSeoFriendlyPath, + $relativePath, + $expectedType, + $redirectCode + ); + } + + /** + * Test the use case where non seo friendly is provided as resolver input in the Query + * + * @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php + */ + public function testRedirectsAndCustomInput() + { + $productSku = 'p002'; + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $product = $productRepository->get($productSku, false, null, true); + + // generate permanent redirects + $renamedKey = 'p002-ren'; + $product->setUrlKey($renamedKey)->setData('save_rewrites_history', true)->save(); + + $storeId = $product->getStoreId(); + $query = <<<QUERY { - urlResolver(url:"{$canonicalPath}") - { - id - relative_url - type - } + products(filter: {sku: {eq: "{$productSku}"}}) + { + items { + url_key + url_suffix + } + } } QUERY; $response = $this->graphQlQuery($query); - $this->assertArrayHasKey('urlResolver', $response); - $this->assertEquals($product->getEntityId(), $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); - $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + $urlPath = $response['products']['items'][0]['url_key'] . $response['products']['items'][0]['url_suffix']; + $suffix = $response['products']['items'][0]['url_suffix']; + + /** @var UrlFinderInterface $urlFinder */ + $urlFinder = $this->objectManager->get(UrlFinderInterface::class); + $actualUrls = $urlFinder->findOneByData( + [ + 'request_path' => $urlPath, + 'store_id' => $storeId + ] + ); + // querying the end redirect gives the same record + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $renamedKey . $suffix, + $actualUrls->getRequestPath(), + $actualUrls->getEntityType(), + 0 + ); + + // querying a url that's a redirect the active redirected final url + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $productSku . $suffix, + $actualUrls->getRequestPath(), + $actualUrls->getEntityType(), + 301 + ); + + // create custom url that doesn't redirect + /** @var UrlRewrite $urlRewriteModel */ + $urlRewriteModel = $this->objectManager->create(UrlRewrite::class); + + $customUrl = 'custom-path'; + $urlRewriteArray = [ + 'entity_type' => 'custom', + 'entity_id' => '0', + 'request_path' => $customUrl, + 'target_path' => 'p002.html', + 'redirect_type' => '0', + 'store_id' => '1', + 'description' => '', + 'is_autogenerated' => '0', + 'metadata' => null, + ]; + foreach ($urlRewriteArray as $key => $value) { + $urlRewriteModel->setData($key, $value); + } + $urlRewriteModel->save(); + + // querying a custom url that should return the target entity but relative should be the custom url + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $customUrl, + $customUrl, + $actualUrls->getEntityType(), + 0 + ); + + // change custom url that does redirect + $urlRewriteModel->setRedirectType('301'); + $urlRewriteModel->setId($urlRewriteModel->getId()); + $urlRewriteModel->save(); + + ObjectManager::getInstance()->get(\Magento\TestFramework\Helper\CacheCleaner::class)->cleanAll(); + + //modifying query by adding spaces to avoid getting cached values. + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $customUrl, + $actualUrls->getRequestPath(), + strtoupper($actualUrls->getEntityType()), + 301 + ); + $urlRewriteModel->delete(); } /** @@ -166,7 +260,7 @@ public function testCategoryUrlResolver() ] ); $categoryId = $actualUrls->getEntityId(); - $targetPath = $actualUrls->getTargetPath(); + $relativePath = $actualUrls->getRequestPath(); $expectedType = $actualUrls->getEntityType(); $query @@ -181,26 +275,17 @@ public function testCategoryUrlResolver() $response = $this->graphQlQuery($query); $urlPath = $response['category']['url_key'] . $response['category']['url_suffix']; - $query - = <<<QUERY -{ - urlResolver(url:"{$urlPath}") - { - id - relative_url - type - } -} -QUERY; - $response = $this->graphQlQuery($query); - $this->assertArrayHasKey('urlResolver', $response); - $this->assertEquals($categoryId, $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); - $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + $this->queryUrlAndAssertResponse( + (int) $categoryId, + $urlPath, + $relativePath, + $expectedType, + 0 + ); } /** - * Tests the use case where the url_key of the existing product is changed + * Test the use case where the url_key of the existing product is changed * * @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php */ @@ -238,24 +323,16 @@ public function testProductUrlRewriteResolver() 'store_id' => $storeId ] ); - $targetPath = $actualUrls->getTargetPath(); + $relativePath = $actualUrls->getRequestPath(); $expectedType = $actualUrls->getEntityType(); - $query - = <<<QUERY -{ - urlResolver(url:"{$urlPath}") - { - id - relative_url - type - } -} -QUERY; - $response = $this->graphQlQuery($query); - $this->assertArrayHasKey('urlResolver', $response); - $this->assertEquals($product->getEntityId(), $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); - $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + + $this->queryUrlAndAssertResponse( + (int) $product->getEntityId(), + $urlPath, + $relativePath, + $expectedType, + 0 + ); } /** @@ -288,6 +365,7 @@ public function testInvalidUrlResolverInput() id relative_url type + redirectCode } } QUERY; @@ -319,7 +397,7 @@ public function testCategoryUrlWithLeadingSlash() ] ); $categoryId = $actualUrls->getEntityId(); - $targetPath = $actualUrls->getTargetPath(); + $relativePath = $actualUrls->getRequestPath(); $expectedType = $actualUrls->getEntityType(); $query @@ -333,22 +411,14 @@ public function testCategoryUrlWithLeadingSlash() QUERY; $response = $this->graphQlQuery($query); $urlPath = $response['category']['url_key'] . $response['category']['url_suffix']; - - $query = <<<QUERY -{ - urlResolver(url:"/{$urlPath}") - { - id - relative_url - type - } -} -QUERY; - $response = $this->graphQlQuery($query); - $this->assertArrayHasKey('urlResolver', $response); - $this->assertEquals($categoryId, $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); - $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + $urlPathWithLeadingSlash = "/{$urlPath}"; + $this->queryUrlAndAssertResponse( + (int) $categoryId, + $urlPathWithLeadingSlash, + $relativePath, + $expectedType, + 0 + ); } /** @@ -371,7 +441,7 @@ public function testGetNonExistentUrlRewrite() 'store_id' => 1 ] ); - $targetPath = $actualUrls->getTargetPath(); + $relativePath = $actualUrls->getRequestPath(); $query = <<<QUERY { @@ -380,12 +450,50 @@ public function testGetNonExistentUrlRewrite() id relative_url type + redirectCode } } QUERY; $response = $this->graphQlQuery($query); $this->assertArrayHasKey('urlResolver', $response); $this->assertEquals('PRODUCT', $response['urlResolver']['type']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); + $this->assertEquals($relativePath, $response['urlResolver']['relative_url']); + $this->assertEquals(0, $response['urlResolver']['redirectCode']); + } + + /** + * Assert response from GraphQl + * + * @param string $productId + * @param string $urlKey + * @param string $relativePath + * @param string $expectedType + * @param int $redirectCode + */ + private function queryUrlAndAssertResponse( + int $productId, + string $urlKey, + string $relativePath, + string $expectedType, + int $redirectCode + ): void { + $query + = <<<QUERY +{ + urlResolver(url:"{$urlKey}") + { + id + relative_url + type + redirectCode + } +} +QUERY; + $response = $this->graphQlQuery($query); + $this->assertArrayHasKey('urlResolver', $response); + $this->assertEquals($productId, $response['urlResolver']['id']); + $this->assertEquals($relativePath, $response['urlResolver']['relative_url']); + $this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']); + $this->assertEquals($redirectCode, $response['urlResolver']['redirectCode']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/CmsUrlRewrite/UrlResolverTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/CmsUrlRewrite/UrlResolverTest.php index ece421925a31..072c6bc38de7 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/CmsUrlRewrite/UrlResolverTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/CmsUrlRewrite/UrlResolverTest.php @@ -53,13 +53,34 @@ public function testCMSPageUrlResolver() id relative_url type + redirectCode } } QUERY; $response = $this->graphQlQuery($query); $this->assertEquals($cmsPageId, $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); + $this->assertEquals($requestPath, $response['urlResolver']['relative_url']); $this->assertEquals(strtoupper(str_replace('-', '_', $expectedEntityType)), $response['urlResolver']['type']); + $this->assertEquals(0, $response['urlResolver']['redirectCode']); + + // querying by non seo friendly url path should return seo friendly relative url + $query + = <<<QUERY +{ + urlResolver(url:"{$targetPath}") + { + id + relative_url + type + redirectCode + } +} +QUERY; + $response = $this->graphQlQuery($query); + $this->assertEquals($cmsPageId, $response['urlResolver']['id']); + $this->assertEquals($requestPath, $response['urlResolver']['relative_url']); + $this->assertEquals(strtoupper(str_replace('-', '_', $expectedEntityType)), $response['urlResolver']['type']); + $this->assertEquals(0, $response['urlResolver']['redirectCode']); } /** @@ -77,10 +98,6 @@ public function testResolveSlash() $page = $this->objectManager->get(\Magento\Cms\Model\Page::class); $page->load($homePageIdentifier); $homePageId = $page->getId(); - /** @var \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator $urlPathGenerator */ - $urlPathGenerator = $this->objectManager->get(\Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator::class); - /** @param \Magento\Cms\Api\Data\PageInterface $page */ - $targetPath = $urlPathGenerator->getCanonicalUrlPath($page); $query = <<<QUERY { @@ -89,13 +106,15 @@ public function testResolveSlash() id relative_url type + redirectCode } } QUERY; $response = $this->graphQlQuery($query); $this->assertArrayHasKey('urlResolver', $response); $this->assertEquals($homePageId, $response['urlResolver']['id']); - $this->assertEquals($targetPath, $response['urlResolver']['relative_url']); + $this->assertEquals($homePageIdentifier, $response['urlResolver']['relative_url']); $this->assertEquals('CMS_PAGE', $response['urlResolver']['type']); + $this->assertEquals(0, $response['urlResolver']['redirectCode']); } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php index 5ea5cef63a13..b1858e843bf0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php @@ -141,19 +141,14 @@ public function testAddMultipleConfigurableProductToCart() } /** - * @magentoApiDataFixture Magento/ConfigurableProduct/_files/configurable_products.php + * @magentoApiDataFixture Magento/Catalog/_files/configurable_products_with_custom_attribute_layered_navigation.php * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php * * @expectedException Exception - * @expectedExceptionMessage You need to choose options for your item. + * @expectedExceptionMessage Could not find specified product. */ public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAttributeToCart() { - $this->markTestSkipped( - 'Magento automatically selects the correct child product according to the super attribute - https://github.com/magento/graphql-ce/issues/940' - ); - $searchResponse = $this->graphQlQuery($this->getFetchProductQuery('configurable_12345')); $product = current($searchResponse['products']['items']); @@ -178,7 +173,7 @@ public function testAddVariationFromAnotherConfigurableProductWithTheSameSuperAt * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php * * @expectedException Exception - * @expectedExceptionMessage You need to choose options for your item. + * @expectedExceptionMessage Could not find specified product. */ public function testAddVariationFromAnotherConfigurableProductWithDifferentSuperAttributeToCart() { @@ -270,7 +265,8 @@ public function testAddNonExistentConfigurableProductVariationToCart() $this->expectException(\Exception::class); $this->expectExceptionMessage( - 'Could not add the product with SKU configurable to the shopping cart: Could not find specified product.' + 'Could not add the product with SKU configurable to the shopping cart: The product that was requested ' . + 'doesn\'t exist. Verify the product and try again.' ); $this->graphQlMutation($query); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/UpdateConfigurableCartItemsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/UpdateConfigurableCartItemsTest.php index 4f4e7ecab6fe..8f32caa9dcf0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/UpdateConfigurableCartItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/UpdateConfigurableCartItemsTest.php @@ -9,7 +9,7 @@ namespace Magento\GraphQl\ConfigurableProduct; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; -use Magento\Framework\Exception\NoSuchEntityException as NoSuchEntityException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; use Magento\Quote\Model\Quote\Item; use Magento\Quote\Model\QuoteFactory; diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php index 04fb30430525..408a254f65f2 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php @@ -49,7 +49,7 @@ public function testCreateCustomerAddress() 'region_id' => 4, 'region_code' => 'AZ' ], - 'country_id' => 'US', + 'country_code' => 'US', 'street' => ['Line 1 Street', 'Line 2'], 'company' => 'Company name', 'telephone' => '123456789', @@ -75,7 +75,7 @@ public function testCreateCustomerAddress() region_id: {$newAddress['region']['region_id']} region_code: "{$newAddress['region']['region_code']}" } - country_id: {$newAddress['country_id']} + country_code: {$newAddress['country_code']} street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"] company: "{$newAddress['company']}" telephone: "{$newAddress['telephone']}" @@ -98,7 +98,7 @@ public function testCreateCustomerAddress() region_id region_code } - country_id + country_code street company telephone @@ -133,6 +133,75 @@ public function testCreateCustomerAddress() $this->assertCustomerAddressesFields($address, $newAddress); } + /** + * Test case for deprecated `country_id` field. + * + * @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testCreateCustomerAddressWithCountryId() + { + $newAddress = [ + 'region' => [ + 'region' => 'Arizona', + 'region_id' => 4, + 'region_code' => 'AZ' + ], + 'country_id' => 'US', + 'street' => ['Line 1 Street', 'Line 2'], + 'company' => 'Company name', + 'telephone' => '123456789', + 'fax' => '123123123', + 'postcode' => '7777', + 'city' => 'City Name', + 'firstname' => 'Adam', + 'lastname' => 'Phillis', + 'middlename' => 'A', + 'prefix' => 'Mr.', + 'suffix' => 'Jr.', + 'vat_id' => '1', + 'default_shipping' => true, + 'default_billing' => false + ]; + + $mutation + = <<<MUTATION +mutation { + createCustomerAddress(input: { + region: { + region: "{$newAddress['region']['region']}" + region_id: {$newAddress['region']['region_id']} + region_code: "{$newAddress['region']['region_code']}" + } + country_id: {$newAddress['country_id']} + street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"] + company: "{$newAddress['company']}" + telephone: "{$newAddress['telephone']}" + fax: "{$newAddress['fax']}" + postcode: "{$newAddress['postcode']}" + city: "{$newAddress['city']}" + firstname: "{$newAddress['firstname']}" + lastname: "{$newAddress['lastname']}" + middlename: "{$newAddress['middlename']}" + prefix: "{$newAddress['prefix']}" + suffix: "{$newAddress['suffix']}" + vat_id: "{$newAddress['vat_id']}" + default_shipping: true + default_billing: false + }) { + country_id + } +} +MUTATION; + + $userName = 'customer@example.com'; + $password = 'password'; + + $response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); + $this->assertArrayHasKey('createCustomerAddress', $response); + $this->assertEquals($newAddress['country_id'], $response['createCustomerAddress']['country_id']); + } + /** * @expectedException Exception * @expectedExceptionMessage The current customer isn't authorized. @@ -153,7 +222,7 @@ public function testCreateCustomerAddressIfUserIsNotAuthorized() region: { region_id: 1 } - country_id: US + country_code: US postcode: "9999" default_shipping: true default_billing: false @@ -182,7 +251,7 @@ public function testCreateCustomerAddressWithMissingAttribute() region: { region_id: 1 } - country_id: US + country_code: US street: ["Line 1 Street","Line 2"] company: "Company name" telephone: "123456789" @@ -202,6 +271,27 @@ public function testCreateCustomerAddressWithMissingAttribute() $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php + * @expectedException Exception + * @expectedExceptionMessage "input" value should be specified + */ + public function testCreateCustomerAddressWithMissingInput() + { + $userName = 'customer@example.com'; + $password = 'password'; + $mutation = <<<MUTATION +mutation { + createCustomerAddress( + input: {} + ) { + city + } +} +MUTATION; + $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); + } + /** * @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -214,7 +304,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine() 'region_id' => 4, 'region_code' => 'AZ' ], - 'country_id' => 'US', + 'country_code' => 'US', 'street' => ['Line 1 Street', 'Line 2', 'Line 3'], 'company' => 'Company name', 'telephone' => '123456789', @@ -240,7 +330,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine() region_id: {$newAddress['region']['region_id']} region_code: "{$newAddress['region']['region_code']}" } - country_id: {$newAddress['country_id']} + country_code: {$newAddress['country_code']} street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}","{$newAddress['street'][2]}"] company: "{$newAddress['company']}" telephone: "{$newAddress['telephone']}" @@ -313,12 +403,15 @@ public function invalidInputDataProvider() * * @param AddressInterface $address * @param array $actualResponse + * @param string $countryFieldName */ - private function assertCustomerAddressesFields(AddressInterface $address, array $actualResponse): void - { + private function assertCustomerAddressesFields( + AddressInterface $address, + array $actualResponse + ): void { /** @var $addresses */ $assertionMap = [ - ['response_field' => 'country_id', 'expected_value' => $address->getCountryId()], + ['response_field' => 'country_code', 'expected_value' => $address->getCountryId()], ['response_field' => 'street', 'expected_value' => $address->getStreet()], ['response_field' => 'company', 'expected_value' => $address->getCompany()], ['response_field' => 'telephone', 'expected_value' => $address->getTelephone()], diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php index 5b3ff041d481..0be968d6d340 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php @@ -114,7 +114,7 @@ public function testCreateCustomerAccountWithoutPassword() /** * @expectedException \Exception - * @expectedExceptionMessage "input" value should be specified + * @expectedExceptionMessage Field CustomerInput.email of required type String! was not provided */ public function testCreateCustomerIfInputDataIsEmpty() { @@ -140,7 +140,7 @@ public function testCreateCustomerIfInputDataIsEmpty() /** * @expectedException \Exception - * @expectedExceptionMessage Required parameters are missing: Email + * @expectedExceptionMessage Field CustomerInput.email of required type String! was not provided */ public function testCreateCustomerIfEmailMissed() { @@ -275,7 +275,7 @@ public function testCreateCustomerIfNameEmpty() QUERY; $this->graphQlMutation($query); } - + /** * @magentoConfigFixture default_store newsletter/general/active 0 */ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GetCustomerTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GetCustomerTest.php index b15a799ae752..56e950c45fae 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GetCustomerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GetCustomerTest.php @@ -7,6 +7,7 @@ namespace Magento\GraphQl\Customer; +use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Model\CustomerAuthUpdate; use Magento\Customer\Model\CustomerRegistry; use Magento\Integration\Api\CustomerTokenServiceInterface; @@ -30,6 +31,11 @@ class GetCustomerTest extends GraphQlAbstract */ private $customerAuthUpdate; + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + protected function setUp() { parent::setUp(); @@ -37,6 +43,7 @@ protected function setUp() $this->customerTokenService = Bootstrap::getObjectManager()->get(CustomerTokenServiceInterface::class); $this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class); $this->customerAuthUpdate = Bootstrap::getObjectManager()->get(CustomerAuthUpdate::class); + $this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); } /** @@ -57,7 +64,12 @@ public function testGetCustomer() } } QUERY; - $response = $this->graphQlQuery($query, [], '', $this->getCustomerAuthHeaders($currentEmail, $currentPassword)); + $response = $this->graphQlQuery( + $query, + [], + '', + $this->getCustomerAuthHeaders($currentEmail, $currentPassword) + ); $this->assertEquals(null, $response['customer']['id']); $this->assertEquals('John', $response['customer']['firstname']); @@ -104,7 +116,38 @@ public function testGetCustomerIfAccountIsLocked() } } QUERY; - $this->graphQlQuery($query, [], '', $this->getCustomerAuthHeaders($currentEmail, $currentPassword)); + $this->graphQlQuery( + $query, + [], + '', + $this->getCustomerAuthHeaders($currentEmail, $currentPassword) + ); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @expectedExceptionMessage This account isn't confirmed. Verify and try again. + */ + public function testAccountIsNotConfirmed() + { + $customerEmail = 'customer@example.com'; + $currentPassword = 'password'; + $headersMap = $this->getCustomerAuthHeaders($customerEmail, $currentPassword); + $customer = $this->customerRepository->getById(1)->setConfirmation( + \Magento\Customer\Api\AccountManagementInterface::ACCOUNT_CONFIRMATION_REQUIRED + ); + $this->customerRepository->save($customer); + $query = <<<QUERY +query { + customer { + firstname + lastname + email + } +} +QUERY; + $this->graphQlQuery($query, [], '', $headersMap); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php index 625d027f58d2..e214d770920d 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php @@ -76,6 +76,56 @@ public function testUpdateCustomerAddress() $this->assertCustomerAddressesFields($address, $updateAddress); } + /** + * Test case for deprecated `country_id` field. + * + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/Customer/_files/customer_address.php + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function testUpdateCustomerAddressWithCountryId() + { + $userName = 'customer@example.com'; + $password = 'password'; + $addressId = 1; + + $updateAddress = $this->getAddressData(); + + $mutation = $mutation + = <<<MUTATION +mutation { + updateCustomerAddress(id: {$addressId}, input: { + region: { + region: "{$updateAddress['region']['region']}" + region_id: {$updateAddress['region']['region_id']} + region_code: "{$updateAddress['region']['region_code']}" + } + country_id: {$updateAddress['country_code']} + street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] + company: "{$updateAddress['company']}" + telephone: "{$updateAddress['telephone']}" + fax: "{$updateAddress['fax']}" + postcode: "{$updateAddress['postcode']}" + city: "{$updateAddress['city']}" + firstname: "{$updateAddress['firstname']}" + lastname: "{$updateAddress['lastname']}" + middlename: "{$updateAddress['middlename']}" + prefix: "{$updateAddress['prefix']}" + suffix: "{$updateAddress['suffix']}" + vat_id: "{$updateAddress['vat_id']}" + default_shipping: true + default_billing: true + }) { + country_id + } +} +MUTATION; + + $response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); + $this->assertArrayHasKey('updateCustomerAddress', $response); + $this->assertEquals($updateAddress['country_code'], $response['updateCustomerAddress']['country_id']); + } + /** * @expectedException Exception * @expectedExceptionMessage The current customer isn't authorized. @@ -131,12 +181,15 @@ public function testUpdateCustomerAddressWithMissingAttribute() * * @param AddressInterface $address * @param array $actualResponse + * @param string $countryFieldName */ - private function assertCustomerAddressesFields(AddressInterface $address, $actualResponse): void - { + private function assertCustomerAddressesFields( + AddressInterface $address, + $actualResponse + ): void { /** @var $addresses */ $assertionMap = [ - ['response_field' => 'country_id', 'expected_value' => $address->getCountryId()], + ['response_field' => 'country_code', 'expected_value' => $address->getCountryId()], ['response_field' => 'street', 'expected_value' => $address->getStreet()], ['response_field' => 'company', 'expected_value' => $address->getCompany()], ['response_field' => 'telephone', 'expected_value' => $address->getTelephone()], @@ -187,7 +240,7 @@ public function testUpdateCustomerAddressWithMissingId() region_id: {$updateAddress['region']['region_id']} region_code: "{$updateAddress['region']['region_code']}" } - country_id: {$updateAddress['country_id']} + country_code: {$updateAddress['country_code']} street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] company: "{$updateAddress['company']}" telephone: "{$updateAddress['telephone']}" @@ -243,7 +296,7 @@ public function testUpdateCustomerAddressWithInvalidIdType() region_id: {$updateAddress['region']['region_id']} region_code: "{$updateAddress['region']['region_code']}" } - country_id: {$updateAddress['country_id']} + country_code: {$updateAddress['country_code']} street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] company: "{$updateAddress['company']}" telephone: "{$updateAddress['telephone']}" @@ -382,11 +435,11 @@ private function getAddressData(): array { return [ 'region' => [ - 'region' => 'Alaska', - 'region_id' => 2, - 'region_code' => 'AK' + 'region' => 'Alberta', + 'region_id' => 66, + 'region_code' => 'AB' ], - 'country_id' => 'US', + 'country_code' => 'CA', 'street' => ['Line 1 Street', 'Line 2'], 'company' => 'Company Name', 'telephone' => '123456789', @@ -423,7 +476,7 @@ private function getMutation(int $addressId): string region_id: {$updateAddress['region']['region_id']} region_code: "{$updateAddress['region']['region_code']}" } - country_id: {$updateAddress['country_id']} + country_code: {$updateAddress['country_code']} street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] company: "{$updateAddress['company']}" telephone: "{$updateAddress['telephone']}" @@ -446,7 +499,7 @@ private function getMutation(int $addressId): string region_id region_code } - country_id + country_code street company telephone diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerTest.php index 178d10b3c35a..d1c6638e8d5f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerTest.php @@ -69,7 +69,7 @@ public function testUpdateCustomer() middlename: "{$newMiddlename}" lastname: "{$newLastname}" suffix: "{$newSuffix}" - dob: "{$newDob}" + date_of_birth: "{$newDob}" taxvat: "{$newTaxVat}" email: "{$newEmail}" password: "{$currentPassword}" @@ -82,7 +82,7 @@ public function testUpdateCustomer() middlename lastname suffix - dob + date_of_birth taxvat email gender @@ -102,7 +102,7 @@ public function testUpdateCustomer() $this->assertEquals($newMiddlename, $response['updateCustomer']['customer']['middlename']); $this->assertEquals($newLastname, $response['updateCustomer']['customer']['lastname']); $this->assertEquals($newSuffix, $response['updateCustomer']['customer']['suffix']); - $this->assertEquals($newDob, $response['updateCustomer']['customer']['dob']); + $this->assertEquals($newDob, $response['updateCustomer']['customer']['date_of_birth']); $this->assertEquals($newTaxVat, $response['updateCustomer']['customer']['taxvat']); $this->assertEquals($newEmail, $response['updateCustomer']['customer']['email']); $this->assertEquals($newGender, $response['updateCustomer']['customer']['gender']); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerDownloadableProduct/CustomerDownloadableProductTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerDownloadableProduct/CustomerDownloadableProductTest.php index 6b8aad83edac..d0ad772e9bb2 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerDownloadableProduct/CustomerDownloadableProductTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerDownloadableProduct/CustomerDownloadableProductTest.php @@ -63,6 +63,18 @@ public function testGuestCannotAccessDownloadableProducts() { $this->graphQlQuery($this->getQuery()); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/Downloadable/_files/product_downloadable_with_download_limit.php + * @magentoApiDataFixture Magento/Downloadable/_files/customer_order_with_downloadable_product.php + */ + public function testRemainingDownloads() + { + $query = $this->getQuery(); + $response = $this->graphQlQuery($query, [], '', $this->getHeaderMap()); + self::assertArrayHasKey('remaining_downloads', $response['customerDownloadableProducts']['items'][0]); + self::assertEquals(100, $response['customerDownloadableProducts']['items'][0]['remaining_downloads']); + } /** * @magentoApiDataFixture Magento/Customer/_files/customer.php */ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddDownloadableProductWithCustomOptionsToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddDownloadableProductWithCustomOptionsToCartTest.php index fa7d1194c7f8..8b8973ad0fd9 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddDownloadableProductWithCustomOptionsToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddDownloadableProductWithCustomOptionsToCartTest.php @@ -58,7 +58,11 @@ public function testAddDownloadableProductWithOptions() $customOptionsValues = $this->getCustomOptionsValuesForQueryBySku->execute($sku); /* Generate customizable options fragment for GraphQl request */ - $queryCustomizableOptionValues = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', json_encode($customOptionsValues)); + $queryCustomizableOptionValues = preg_replace( + '/"([^"]+)"\s*:\s*/', + '$1:', + json_encode(array_values($customOptionsValues)) + ); $customizableOptions = "customizable_options: {$queryCustomizableOptionValues}"; $query = $this->getQuery($maskedQuoteId, $qty, $sku, $customizableOptions, $linkId); @@ -68,13 +72,14 @@ public function testAddDownloadableProductWithOptions() self::assertCount($qty, $response['addDownloadableProductsToCart']['cart']); $customizableOptionsOutput = $response['addDownloadableProductsToCart']['cart']['items'][0]['customizable_options']; - $assignedOptionsCount = count($customOptionsValues); - for ($counter = 0; $counter < $assignedOptionsCount; $counter++) { - $expectedValues = $this->buildExpectedValuesArray($customOptionsValues[$counter]['value_string']); + $count = 0; + foreach ($customOptionsValues as $value) { + $expectedValues = $this->buildExpectedValuesArray($value['value_string']); self::assertEquals( $expectedValues, - $customizableOptionsOutput[$counter]['values'] + $customizableOptionsOutput[$count]['values'] ); + $count++; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductWithCustomOptionsToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductWithCustomOptionsToCartTest.php index b0b116b0cdda..5c2bc10bf771 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductWithCustomOptionsToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddSimpleProductWithCustomOptionsToCartTest.php @@ -57,7 +57,11 @@ public function testAddSimpleProductWithOptions() $customOptionsValues = $this->getCustomOptionsValuesForQueryBySku->execute($sku); /* Generate customizable options fragment for GraphQl request */ - $queryCustomizableOptionValues = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', json_encode($customOptionsValues)); + $queryCustomizableOptionValues = preg_replace( + '/"([^"]+)"\s*:\s*/', + '$1:', + json_encode(array_values($customOptionsValues)) + ); $customizableOptions = "customizable_options: {$queryCustomizableOptionValues}"; $query = $this->getQuery($maskedQuoteId, $sku, $quantity, $customizableOptions); @@ -68,13 +72,14 @@ public function testAddSimpleProductWithOptions() self::assertCount(1, $response['addSimpleProductsToCart']['cart']); $customizableOptionsOutput = $response['addSimpleProductsToCart']['cart']['items'][0]['customizable_options']; - $assignedOptionsCount = count($customOptionsValues); - for ($counter = 0; $counter < $assignedOptionsCount; $counter++) { - $expectedValues = $this->buildExpectedValuesArray($customOptionsValues[$counter]['value_string']); + $count = 0; + foreach ($customOptionsValues as $type => $value) { + $expectedValues = $this->buildExpectedValuesArray($value['value_string'], $type); self::assertEquals( $expectedValues, - $customizableOptionsOutput[$counter]['values'] + $customizableOptionsOutput[$count]['values'] ); + $count++; } } @@ -99,6 +104,33 @@ public function testAddSimpleProductWithMissedRequiredOptionsSet() $this->graphQlMutation($query); } + /** + * Test adding a simple product with wrong format value for date option + * + * @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_options.php + * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php + */ + public function testAddSimpleProductWithWrongDateOptionFormat() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1'); + $sku = 'simple'; + $quantity = 1; + + $customOptionsValues = $this->getCustomOptionsValuesForQueryBySku->execute($sku); + $customOptionsValues['date']['value_string'] = '12-12-12'; + $queryCustomizableOptionValues = preg_replace( + '/"([^"]+)"\s*:\s*/', + '$1:', + json_encode(array_values($customOptionsValues)) + ); + $customizableOptions = "customizable_options: {$queryCustomizableOptionValues}"; + $query = $this->getQuery($maskedQuoteId, $sku, $quantity, $customizableOptions); + + $this->expectExceptionMessage('Invalid format provided. Please use \'Y-m-d H:i:s\' format.'); + + $this->graphQlMutation($query); + } + /** * @param string $maskedQuoteId * @param string $sku @@ -145,10 +177,14 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity, s * Build the part of expected response. * * @param string $assignedValue + * @param string $type option type * @return array */ - private function buildExpectedValuesArray(string $assignedValue) : array + private function buildExpectedValuesArray(string $assignedValue, string $type) : array { + if ($type === 'date') { + return [['value' => date('M d, Y', strtotime($assignedValue))]]; + } $assignedOptionsArray = explode(',', trim($assignedValue, '[]')); $expectedArray = []; foreach ($assignedOptionsArray as $assignedOption) { diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddVirtualProductWithCustomOptionsToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddVirtualProductWithCustomOptionsToCartTest.php index a8088b0b46b8..561318889e32 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddVirtualProductWithCustomOptionsToCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/AddVirtualProductWithCustomOptionsToCartTest.php @@ -57,7 +57,11 @@ public function testAddVirtualProductWithOptions() $customOptionsValues = $this->getCustomOptionsValuesForQueryBySku->execute($sku); /* Generate customizable options fragment for GraphQl request */ - $queryCustomizableOptionValues = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', json_encode($customOptionsValues)); + $queryCustomizableOptionValues = preg_replace( + '/"([^"]+)"\s*:\s*/', + '$1:', + json_encode(array_values($customOptionsValues)) + ); $customizableOptions = "customizable_options: {$queryCustomizableOptionValues}"; $query = $this->getQuery($maskedQuoteId, $sku, $quantity, $customizableOptions); @@ -68,13 +72,14 @@ public function testAddVirtualProductWithOptions() self::assertCount(1, $response['addVirtualProductsToCart']['cart']); $customizableOptionsOutput = $response['addVirtualProductsToCart']['cart']['items'][0]['customizable_options']; - $assignedOptionsCount = count($customOptionsValues); - for ($counter = 0; $counter < $assignedOptionsCount; $counter++) { - $expectedValues = $this->buildExpectedValuesArray($customOptionsValues[$counter]['value_string']); + $count = 0; + foreach ($customOptionsValues as $value) { + $expectedValues = $this->buildExpectedValuesArray($value['value_string']); self::assertEquals( $expectedValues, - $customizableOptionsOutput[$counter]['values'] + $customizableOptionsOutput[$count]['values'] ); + $count++; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php index 6a06b143d5fc..ddf94fbcc1ed 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CheckoutEndToEndTest.php @@ -259,7 +259,6 @@ private function setBillingAddress(string $cartId): void telephone: "88776655" region: "TX" country_code: "US" - save_in_address_book: false } } } @@ -298,7 +297,6 @@ private function setShippingAddress(string $cartId): array postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -426,7 +424,7 @@ private function placeOrder(string $cartId): string } ) { order { - order_id + order_number } } } @@ -434,10 +432,10 @@ private function placeOrder(string $cartId): string $response = $this->graphQlMutation($query, [], '', $this->headers); self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertNotEmpty($response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertNotEmpty($response['placeOrder']['order']['order_number']); - return $response['placeOrder']['order']['order_id']; + return $response['placeOrder']['order']['order_number']; } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetSpecifiedBillingAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetSpecifiedBillingAddressTest.php index b6dde46871cb..e5353fc841c5 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetSpecifiedBillingAddressTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetSpecifiedBillingAddressTest.php @@ -91,29 +91,7 @@ public function testGetSpecifiedBillingAddressIfBillingAddressIsNotSet() $response = $this->graphQlQuery($query, [], '', $this->getHeaderMap()); self::assertArrayHasKey('cart', $response); self::assertArrayHasKey('billing_address', $response['cart']); - - $expectedBillingAddressData = [ - 'firstname' => null, - 'lastname' => null, - 'company' => null, - 'street' => [ - '' - ], - 'city' => null, - 'region' => [ - 'code' => null, - 'label' => null, - ], - 'postcode' => null, - 'country' => [ - 'code' => null, - 'label' => null, - ], - 'telephone' => null, - '__typename' => 'BillingCartAddress', - 'customer_notes' => null, - ]; - self::assertEquals($expectedBillingAddressData, $response['cart']['billing_address']); + self::assertNull($response['cart']['billing_address']); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php index cb471d8f0f93..38d9ddc4fecc 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/PlaceOrderTest.php @@ -86,8 +86,8 @@ public function testPlaceOrder() $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); self::assertArrayHasKey('placeOrder', $response); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } /** @@ -114,7 +114,7 @@ public function testPlaceOrderIfCartIdIsMissed() mutation { placeOrder(input: {}) { order { - order_id + order_number } } } @@ -313,7 +313,7 @@ private function getQuery(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php index 011930e72327..d4f23854378f 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php @@ -7,6 +7,9 @@ namespace Magento\GraphQl\Quote\Customer; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; use Magento\Integration\Api\CustomerTokenServiceInterface; use Magento\Quote\Model\QuoteFactory; @@ -45,6 +48,19 @@ class SetBillingAddressOnCartTest extends GraphQlAbstract */ private $customerTokenService; + /** + * @var AddressRepositoryInterface + */ + private $customerAddressRepository; + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + protected function setUp() { $objectManager = Bootstrap::getObjectManager(); @@ -53,6 +69,9 @@ protected function setUp() $this->quoteFactory = $objectManager->get(QuoteFactory::class); $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class); $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); + $this->customerAddressRepository = $objectManager->get(AddressRepositoryInterface::class); + $this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); + $this->customerRepository = $objectManager->get(CustomerRepositoryInterface::class); } /** @@ -81,7 +100,6 @@ public function testSetNewBillingAddress() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -140,7 +158,6 @@ public function testSetNewBillingAddressWithUseForShippingParameter() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } use_for_shipping: true } @@ -239,6 +256,42 @@ public function testSetBillingAddressFromAddressBook() $this->assertSavedBillingAddressFields($billingAddressResponse); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testVerifyBillingAddressType() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<<QUERY +mutation { + setBillingAddressOnCart( + input: { + cart_id: "$maskedQuoteId" + billing_address: { + customer_address_id: 1 + } + } + ) { + cart { + billing_address { + __typename + } + } + } +} +QUERY; + + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $billingAddress = $response['setBillingAddressOnCart']['cart']['billing_address']; + self::assertArrayHasKey('__typename', $billingAddress); + self::assertEquals('BillingCartAddress', $billingAddress['__typename']); + } + /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php @@ -301,7 +354,6 @@ public function testSetNewBillingAddressAndFromAddressBookAtSameTime() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -383,7 +435,6 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } use_for_shipping: true } @@ -620,7 +671,6 @@ public function testSetNewBillingAddressWithRedundantStreetLine() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -663,7 +713,6 @@ public function testSetBillingAddressWithLowerCaseCountry() postcode: "887766" country_code: "us" telephone: "88776655" - save_in_address_book: false } } } @@ -696,6 +745,193 @@ public function testSetBillingAddressWithLowerCaseCountry() $this->assertNewAddressFields($billingAddressResponse); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testSetNewBillingAddressWithSaveInAddressBook() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $query = <<<QUERY +mutation { + setBillingAddressOnCart( + input: { + cart_id: "$maskedQuoteId" + billing_address: { + address: { + firstname: "test firstname" + lastname: "test lastname" + company: "test company" + street: ["test street 1", "test street 2"] + city: "test city" + region: "test region" + postcode: "887766" + country_code: "US" + telephone: "88776655" + save_in_address_book: true + } + } + } + ) { + cart { + billing_address { + firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename + } + } + } +} +QUERY; + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $customer = $this->customerRepository->get('customer@example.com'); + $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $customer->getId())->create(); + $addresses = $this->customerAddressRepository->getList($searchCriteria)->getItems(); + + self::assertCount(1, $addresses); + self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']); + + $cartResponse = $response['setBillingAddressOnCart']['cart']; + self::assertArrayHasKey('billing_address', $cartResponse); + $billingAddressResponse = $cartResponse['billing_address']; + $this->assertNewAddressFields($billingAddressResponse); + + foreach ($addresses as $address) { + $this->customerAddressRepository->delete($address); + } + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testSetNewBillingAddressWithNotSaveInAddressBook() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $query = <<<QUERY +mutation { + setBillingAddressOnCart( + input: { + cart_id: "$maskedQuoteId" + billing_address: { + address: { + firstname: "test firstname" + lastname: "test lastname" + company: "test company" + street: ["test street 1", "test street 2"] + city: "test city" + region: "test region" + postcode: "887766" + country_code: "US" + telephone: "88776655" + save_in_address_book: false + } + } + } + ) { + cart { + billing_address { + firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename + } + } + } +} +QUERY; + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $customer = $this->customerRepository->get('customer@example.com'); + $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $customer->getId())->create(); + $addresses = $this->customerAddressRepository->getList($searchCriteria)->getItems(); + + self::assertCount(0, $addresses); + self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']); + + $cartResponse = $response['setBillingAddressOnCart']['cart']; + self::assertArrayHasKey('billing_address', $cartResponse); + $billingAddressResponse = $cartResponse['billing_address']; + $this->assertNewAddressFields($billingAddressResponse); + + foreach ($addresses as $address) { + $this->customerAddressRepository->delete($address); + } + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testWithInvalidBillingAddressInput() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<<QUERY +mutation { + setBillingAddressOnCart( + input: { + cart_id: "$maskedQuoteId" + billing_address: { + address: { + firstname: "test firstname" + lastname: "test lastname" + company: "test company" + street: ["test street 1", "test street 2"] + city: "test city" + region: "test region" + postcode: "887766" + country_code: "USS" + telephone: "88776655" + save_in_address_book: false + } + } + } + ) { + cart { + billing_address { + firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + } + } + } +} +QUERY; + $this->expectExceptionMessage('The address failed to save. Verify the address and try again.'); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + /** * Verify the all the whitelisted fields for a New Address Object * diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php index 192c10a67aa6..aff124c52230 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetPaymentMethodAndPlaceOrderTest.php @@ -85,7 +85,71 @@ public function testSetPaymentOnCartWithSimpleProduct() self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php + * + * @dataProvider dataProviderSetPaymentOnCartWithException + * @param string $input + * @param string $message + * @throws \Exception + */ + public function testSetPaymentOnCartWithException(string $input, string $message) + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $input = str_replace('cart_id_value', $maskedQuoteId, $input); + + $query = <<<QUERY +mutation { + setPaymentMethodAndPlaceOrder( + input: { + {$input} + } + ) { + order { + order_number + } + } +} +QUERY; + + $this->expectExceptionMessage($message); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + + /** + * @return array + */ + public function dataProviderSetPaymentOnCartWithException(): array + { + return [ + 'missed_cart_id' => [ + 'payment_method: { + code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '" + }', + 'Required parameter "cart_id" is missing', + ], + 'missed_payment_method' => [ + 'cart_id: "cart_id_value"', + 'Required parameter "code" for "payment_method" is missing.', + ], + 'place_order_with_out_of_stock_products' => [ + 'cart_id: "cart_id_value" + payment_method: { + code: "' . Checkmo::PAYMENT_METHOD_CHECKMO_CODE . '" + }', + 'Unable to place order: Some of the products are out of stock.', + ], + ]; } /** @@ -128,7 +192,7 @@ public function testSetPaymentOnCartWithVirtualProduct() self::assertEquals($methodCode, $response['setPaymentMethodOnCart']['cart']['selected_payment_method']['code']); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); } /** @@ -254,7 +318,7 @@ private function getQuery( } ) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php index e74b7c41b398..8b1b678b0b3a 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php @@ -7,6 +7,9 @@ namespace Magento\GraphQl\Quote\Customer; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; use Magento\Integration\Api\CustomerTokenServiceInterface; use Magento\Quote\Model\QuoteFactory; @@ -45,6 +48,21 @@ class SetShippingAddressOnCartTest extends GraphQlAbstract */ private $customerTokenService; + /** + * @var AddressRepositoryInterface + */ + private $customerAddressRepository; + + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + protected function setUp() { $objectManager = Bootstrap::getObjectManager(); @@ -53,6 +71,9 @@ protected function setUp() $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class); $this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); + $this->customerAddressRepository = $objectManager->get(AddressRepositoryInterface::class); + $this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); + $this->customerRepository = $objectManager->get(CustomerRepositoryInterface::class); } /** @@ -82,7 +103,6 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } customer_notes: "Test note" } @@ -148,7 +168,6 @@ public function testSetNewShippingAddressOnCartWithVirtualProduct() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -211,6 +230,43 @@ public function testSetShippingAddressFromAddressBook() $this->assertSavedShippingAddressFields($shippingAddressResponse); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testVerifyShippingAddressType() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<<QUERY +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "$maskedQuoteId" + shipping_addresses: [ + { + customer_address_id: 1 + } + ] + } + ) { + cart { + shipping_addresses { + __typename + } + } + } +} +QUERY; + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $shippingAddresses = current($response['setShippingAddressesOnCart']['cart']['shipping_addresses']); + self::assertArrayHasKey('__typename', $shippingAddresses); + self::assertEquals('ShippingCartAddress', $shippingAddresses['__typename']); + } + /** * @magentoApiDataFixture Magento/Customer/_files/customer.php * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php @@ -276,7 +332,6 @@ public function testSetNewShippingAddressAndFromAddressBookAtSameTime() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -458,7 +513,6 @@ public function testSetMultipleNewShippingAddresses() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } }, { @@ -472,7 +526,6 @@ public function testSetMultipleNewShippingAddresses() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -516,7 +569,6 @@ public function testSetNewShippingAddressOnCartWithRedundantStreetLine() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -657,6 +709,191 @@ public function testSetShippingAddressWithLowerCaseCountry() $this->assertEquals('CA', $address['region']['code']); } + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testWithInvalidShippingAddressesInput() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + + $query = <<<QUERY +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "$maskedQuoteId" + shipping_addresses: [ + { + address: { + firstname: "John" + lastname: "Doe" + street: ["6161 West Centinella Avenue"] + city: "Culver City" + region: "CA" + postcode: "90230" + country_code: "USS" + telephone: "555-555-55-55" + } + } + ] + } + ) { + cart { + shipping_addresses { + city + } + } + } +} +QUERY; + $this->expectExceptionMessage('The address failed to save. Verify the address and try again.'); + $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testSetNewShippingAddressWithSaveInAddressBook() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $query = <<<QUERY +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "$maskedQuoteId" + shipping_addresses: [ + { + address: { + firstname: "test firstname" + lastname: "test lastname" + company: "test company" + street: ["test street 1", "test street 2"] + city: "test city" + region: "test region" + postcode: "887766" + country_code: "US" + telephone: "88776655" + save_in_address_book: true + } + customer_notes: "Test note" + } + ] + } + ) { + cart { + shipping_addresses { + firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename + customer_notes + } + } + } +} +QUERY; + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $customer = $this->customerRepository->get('customer@example.com'); + $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $customer->getId())->create(); + $addresses = $this->customerAddressRepository->getList($searchCriteria)->getItems(); + + self::assertCount(1, $addresses); + self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']); + + $cartResponse = $response['setShippingAddressesOnCart']['cart']; + self::assertArrayHasKey('shipping_addresses', $cartResponse); + $shippingAddressResponse = current($cartResponse['shipping_addresses']); + $this->assertNewShippingAddressFields($shippingAddressResponse); + + foreach ($addresses as $address) { + $this->customerAddressRepository->delete($address); + } + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php + * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php + */ + public function testSetNewShippingAddressWithNotSaveInAddressBook() + { + $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote'); + $query = <<<QUERY +mutation { + setShippingAddressesOnCart( + input: { + cart_id: "$maskedQuoteId" + shipping_addresses: [ + { + address: { + firstname: "test firstname" + lastname: "test lastname" + company: "test company" + street: ["test street 1", "test street 2"] + city: "test city" + region: "test region" + postcode: "887766" + country_code: "US" + telephone: "88776655" + save_in_address_book: false + } + customer_notes: "Test note" + } + ] + } + ) { + cart { + shipping_addresses { + firstname + lastname + company + street + city + postcode + telephone + country { + code + label + } + __typename + customer_notes + } + } + } +} +QUERY; + $response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); + $customer = $this->customerRepository->get('customer@example.com'); + $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $customer->getId())->create(); + $addresses = $this->customerAddressRepository->getList($searchCriteria)->getItems(); + + self::assertCount(0, $addresses); + self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']); + + $cartResponse = $response['setShippingAddressesOnCart']['cart']; + self::assertArrayHasKey('shipping_addresses', $cartResponse); + $shippingAddressResponse = current($cartResponse['shipping_addresses']); + $this->assertNewShippingAddressFields($shippingAddressResponse); + + foreach ($addresses as $address) { + $this->customerAddressRepository->delete($address); + } + } + /** * Verify the all the whitelisted fields for a New Address Object * diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/EditQuoteItemWithCustomOptionsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/EditQuoteItemWithCustomOptionsTest.php index 62c1ae0dab3c..d1edf742931c 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/EditQuoteItemWithCustomOptionsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/EditQuoteItemWithCustomOptionsTest.php @@ -9,7 +9,7 @@ use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\Exception\NoSuchEntityException as NoSuchEntityException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Model\Quote\Item; use Magento\Quote\Model\QuoteFactory; use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCustomOptionsValuesForQueryBySku.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCustomOptionsValuesForQueryBySku.php index 7514eb1c4e1d..62cacd3e07c1 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCustomOptionsValuesForQueryBySku.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCustomOptionsValuesForQueryBySku.php @@ -40,25 +40,26 @@ public function execute(string $sku): array foreach ($customOptions as $customOption) { $optionType = $customOption->getType(); - if ($optionType == 'field' || $optionType == 'area') { - $customOptionsValues[] = [ - 'id' => (int)$customOption->getOptionId(), - 'value_string' => 'test' - ]; - } elseif ($optionType == 'drop_down') { - $optionSelectValues = $customOption->getValues(); - $customOptionsValues[] = [ - 'id' => (int)$customOption->getOptionId(), - 'value_string' => reset($optionSelectValues)->getOptionTypeId() - ]; - } elseif ($optionType == 'multiple') { - $customOptionsValues[] = [ - 'id' => (int)$customOption->getOptionId(), - 'value_string' => '[' . implode(',', array_keys($customOption->getValues())) . ']' - ]; + $customOptionsValues[$optionType]['id'] = (int)$customOption->getOptionId(); + switch ($optionType) { + case 'date': + $customOptionsValues[$optionType]['value_string'] = '2012-12-12 00:00:00'; + break; + case 'field': + case 'area': + $customOptionsValues[$optionType]['value_string'] = 'test'; + break; + case 'drop_down': + $optionSelectValues = $customOption->getValues(); + $customOptionsValues[$optionType]['value_string'] = + reset($optionSelectValues)->getOptionTypeId(); + break; + case 'multiple': + $customOptionsValues[$optionType]['value_string'] = + '[' . implode(',', array_keys($customOption->getValues())) . ']'; + break; } } - return $customOptionsValues; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php index 16f291be9107..90ebec763b22 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php @@ -108,7 +108,6 @@ public function testSetBillingAddressToGuestCustomerCart() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -221,7 +220,6 @@ public function testSetNewShippingAddressOnCartWithGuestCheckoutDisabled() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -318,7 +316,7 @@ private function getQuery(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php index 95308a350c95..315c04614850 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CheckoutEndToEndTest.php @@ -219,7 +219,6 @@ private function setBillingAddress(string $cartId): void telephone: "88776655" region: "TX" country_code: "US" - save_in_address_book: false } } } @@ -258,7 +257,6 @@ private function setShippingAddress(string $cartId): array postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -386,7 +384,7 @@ private function placeOrder(string $cartId): void } ) { order { - order_id + order_number } } } @@ -394,8 +392,8 @@ private function placeOrder(string $cartId): void $response = $this->graphQlMutation($query); self::assertArrayHasKey('placeOrder', $response); self::assertArrayHasKey('order', $response['placeOrder']); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertNotEmpty($response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertNotEmpty($response['placeOrder']['order']['order_number']); } public function tearDown() diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php index 81222a84435c..0d64d73965d2 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php @@ -67,6 +67,7 @@ public function testGetAvailableShippingMethods() 'value' => 10, 'currency' => 'USD', ], + 'base_amount' => null, ]; self::assertEquals( $expectedAddressData, @@ -135,25 +136,46 @@ private function getQuery(string $maskedQuoteId): string query { cart (cart_id: "{$maskedQuoteId}") { shipping_addresses { - available_shipping_methods { - amount { - value - currency - } - carrier_code - carrier_title - error_message - method_code - method_title - price_excl_tax { - value - currency - } - price_incl_tax { - value - currency - } + cart_items { + cart_item_id + quantity + } + available_shipping_methods { + amount { + value + currency } + carrier_code + carrier_title + error_message + method_code + method_title + price_excl_tax { + value + currency + } + price_incl_tax { + value + currency + } + base_amount { + value + currency + } + carrier_code + carrier_title + error_message + method_code + method_title + price_excl_tax { + value + currency + } + price_incl_tax { + value + currency + } + } } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetSpecifiedBillingAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetSpecifiedBillingAddressTest.php index 8ddf1641ede8..cb1565879a81 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetSpecifiedBillingAddressTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetSpecifiedBillingAddressTest.php @@ -81,28 +81,7 @@ public function testGetSpecifiedBillingAddressIfBillingAddressIsNotSet() $response = $this->graphQlQuery($query); self::assertArrayHasKey('cart', $response); self::assertArrayHasKey('billing_address', $response['cart']); - - $expectedBillingAddressData = [ - 'firstname' => null, - 'lastname' => null, - 'company' => null, - 'street' => [ - '' - ], - 'city' => null, - 'region' => [ - 'code' => null, - 'label' => null, - ], - 'postcode' => null, - 'country' => [ - 'code' => null, - 'label' => null, - ], - 'telephone' => null, - '__typename' => 'BillingCartAddress', - ]; - self::assertEquals($expectedBillingAddressData, $response['cart']['billing_address']); + self::assertNull($response['cart']['billing_address']); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php index 2dc5b53b31c7..52caf836d3b4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/PlaceOrderTest.php @@ -79,8 +79,8 @@ public function testPlaceOrder() $response = $this->graphQlMutation($query); self::assertArrayHasKey('placeOrder', $response); - self::assertArrayHasKey('order_id', $response['placeOrder']['order']); - self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_id']); + self::assertArrayHasKey('order_number', $response['placeOrder']['order']); + self::assertEquals($reservedOrderId, $response['placeOrder']['order']['order_number']); } /** @@ -105,7 +105,7 @@ public function testPlaceOrderIfCartIdIsMissed() mutation { placeOrder(input: {}) { order { - order_id + order_number } } } @@ -304,7 +304,7 @@ private function getQuery(string $maskedQuoteId): string mutation { placeOrder(input: {cart_id: "{$maskedQuoteId}"}) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php index 730e65b4ba8a..5a3d45005c91 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php @@ -52,7 +52,6 @@ public function testSetNewBillingAddress() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -110,7 +109,6 @@ public function testSetNewBillingAddressWithUseForShippingParameter() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } use_for_shipping: true } @@ -186,7 +184,6 @@ public function testSetBillingAddressToCustomerCart() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -263,7 +260,6 @@ public function testSetBillingAddressOnNonExistentCart() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -391,7 +387,6 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } use_for_shipping: true } @@ -437,7 +432,6 @@ public function testSetNewBillingAddressRedundantStreetLine() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } @@ -480,7 +474,6 @@ public function testSetBillingAddressWithLowerCaseCountry() postcode: "887766" country_code: "us" telephone: "88776655" - save_in_address_book: false } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodAndPlaceOrderTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodAndPlaceOrderTest.php index 50fd9647d7c5..e38ccf78d420 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodAndPlaceOrderTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetPaymentMethodAndPlaceOrderTest.php @@ -73,7 +73,7 @@ public function testSetPaymentOnCartWithSimpleProduct() self::assertArrayHasKey('setPaymentMethodAndPlaceOrder', $response); self::assertArrayHasKey('order', $response['setPaymentMethodAndPlaceOrder']); - self::assertArrayHasKey('order_id', $response['setPaymentMethodAndPlaceOrder']['order']); + self::assertArrayHasKey('order_number', $response['setPaymentMethodAndPlaceOrder']['order']); } /** @@ -111,7 +111,7 @@ public function testSetPaymentOnCartWithVirtualProduct() self::assertArrayHasKey('setPaymentMethodAndPlaceOrder', $response); self::assertArrayHasKey('order', $response['setPaymentMethodAndPlaceOrder']); - self::assertArrayHasKey('order_id', $response['setPaymentMethodAndPlaceOrder']['order']); + self::assertArrayHasKey('order_number', $response['setPaymentMethodAndPlaceOrder']['order']); } /** @@ -232,7 +232,7 @@ private function getQuery( } }) { order { - order_id + order_number } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php index 0351a4f58a8e..2e98773ad918 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php @@ -53,7 +53,6 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } customer_notes: "Test note" } @@ -118,7 +117,6 @@ public function testSetNewShippingAddressOnCartWithVirtualProduct() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -270,7 +268,6 @@ public function testSetNewShippingAddressOnCartWithRedundantStreetLine() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -339,7 +336,6 @@ public function testSetMultipleNewShippingAddresses() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } }, { @@ -353,7 +349,6 @@ public function testSetMultipleNewShippingAddresses() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } ] @@ -393,7 +388,6 @@ public function testSetShippingAddressOnNonExistentCart() postcode: "887766" country_code: "US" telephone: "88776655" - save_in_address_book: false } } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php index 988ead7d86df..6ac683ef77ad 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/UpdateCartItemsTest.php @@ -70,6 +70,17 @@ public function testUpdateCartItemQuantity() $this->assertEquals($itemId, $item['id']); $this->assertEquals($quantity, $item['quantity']); + + //Check that update is correctly reflected in cart + $cartQuery = $this->getCartQuery($maskedQuoteId); + $response = $this->graphQlQuery($cartQuery); + + $this->assertArrayHasKey('cart', $response); + + $responseCart = $response['cart']; + $item = current($responseCart['items']); + + $this->assertEquals($quantity, $item['quantity']); } /** @@ -91,6 +102,15 @@ public function testRemoveCartItemIfQuantityIsZero() $responseCart = $response['updateCartItems']['cart']; $this->assertCount(0, $responseCart['items']); + + //Check that update is correctly reflected in cart + $cartQuery = $this->getCartQuery($maskedQuoteId); + $response = $this->graphQlQuery($cartQuery); + + $this->assertArrayHasKey('cart', $response); + + $responseCart = $response['cart']; + $this->assertCount(0, $responseCart['items']); } /** @@ -268,6 +288,26 @@ private function getQuery(string $maskedQuoteId, int $itemId, float $quantity): } } } +QUERY; + } + + /** + * @param string $maskedQuoteId + * @return string + */ + private function getCartQuery(string $maskedQuoteId) + { + return <<<QUERY +query { + cart(cart_id: "{$maskedQuoteId}"){ + items{ + product{ + name + } + quantity + } + } +} QUERY; } } diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/ProductViewTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/ProductViewTest.php index dfbe943ecdcd..1dc5a813de2b 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/ProductViewTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/ProductViewTest.php @@ -38,6 +38,12 @@ class ProductViewTest extends GraphQlAbstract /** @var \Magento\Tax\Model\Calculation\Rule[] */ private $fixtureTaxRules; + /** @var string */ + private $defaultRegionSystemSetting; + + /** @var string */ + private $defaultPriceDisplayType; + /** * @var StoreManagerInterface */ @@ -52,19 +58,26 @@ protected function setUp() /** @var \Magento\Config\Model\ResourceModel\Config $config */ $config = $this->objectManager->get(\Magento\Config\Model\ResourceModel\Config::class); + /** @var ScopeConfigInterface $scopeConfig */ + $scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + + $this->defaultRegionSystemSetting = $scopeConfig->getValue( + Config::CONFIG_XML_PATH_DEFAULT_REGION + ); + + $this->defaultPriceDisplayType = $scopeConfig->getValue( + Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE + ); + //default state tax calculation AL $config->saveConfig( Config::CONFIG_XML_PATH_DEFAULT_REGION, - 1, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 1 ); $config->saveConfig( Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, - 3, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT, - 1 + 3 ); $this->getFixtureTaxRates(); $this->getFixtureTaxRules(); @@ -72,6 +85,9 @@ protected function setUp() /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */ $config = $this->objectManager->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class); $config->reinit(); + /** @var ScopeConfigInterface $scopeConfig */ + $scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + $scopeConfig->clean(); } public function tearDown() @@ -82,16 +98,12 @@ public function tearDown() //default state tax calculation AL $config->saveConfig( Config::CONFIG_XML_PATH_DEFAULT_REGION, - null, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT, - 1 + $this->defaultRegionSystemSetting ); $config->saveConfig( Config::CONFIG_XML_PATH_PRICE_DISPLAY_TYPE, - 1, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT, - 1 + $this->defaultPriceDisplayType ); $taxRules = $this->getFixtureTaxRules(); if (count($taxRules)) { @@ -107,6 +119,10 @@ public function tearDown() /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */ $config = $this->objectManager->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class); $config->reinit(); + + /** @var ScopeConfigInterface $scopeConfig */ + $scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + $scopeConfig->clean(); } /** @@ -253,7 +269,23 @@ private function getFixtureTaxRules() */ private function assertBaseFields($product, $actualResponse) { - // ['product_object_field_name', 'expected_value'] + $pricesTypes = [ + 'minimalPrice', + 'regularPrice', + 'maximalPrice', + ]; + foreach ($pricesTypes as $priceType) { + if (isset($actualResponse['price'][$priceType]['amount']['value'])) { + $actualResponse['price'][$priceType]['amount']['value'] = + round($actualResponse['price'][$priceType]['amount']['value'], 4); + } + + if (isset($actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'])) { + $actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'] = + round($actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'], 4); + } + } + // product_object_field_name, expected_value $assertionMap = [ ['response_field' => 'attribute_set_id', 'expected_value' => $product->getAttributeSetId()], ['response_field' => 'created_at', 'expected_value' => $product->getCreatedAt()], @@ -263,7 +295,7 @@ private function assertBaseFields($product, $actualResponse) [ 'minimalPrice' => [ 'amount' => [ - 'value' => 4.106501, + 'value' => 4.1065, 'currency' => 'USD' ], 'adjustments' => [ @@ -271,7 +303,7 @@ private function assertBaseFields($product, $actualResponse) [ 'amount' => [ - 'value' => 0.286501, + 'value' => 0.2865, 'currency' => 'USD', ], 'code' => 'TAX', @@ -281,7 +313,7 @@ private function assertBaseFields($product, $actualResponse) ], 'regularPrice' => [ 'amount' => [ - 'value' => 10.750001, + 'value' => 10.7500, 'currency' => 'USD' ], 'adjustments' => [ @@ -289,7 +321,7 @@ private function assertBaseFields($product, $actualResponse) [ 'amount' => [ - 'value' => 0.750001, + 'value' => 0.7500, 'currency' => 'USD', ], 'code' => 'TAX', @@ -299,7 +331,7 @@ private function assertBaseFields($product, $actualResponse) ], 'maximalPrice' => [ 'amount' => [ - 'value' => 4.106501, + 'value' => 4.1065, 'currency' => 'USD' ], 'adjustments' => [ @@ -307,7 +339,7 @@ private function assertBaseFields($product, $actualResponse) [ 'amount' => [ - 'value' => 0.286501, + 'value' => 0.2865, 'currency' => 'USD', ], 'code' => 'TAX', diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/UrlRewrite/UrlResolverTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/UrlRewrite/UrlResolverTest.php index bd20741fb741..5e6415f82b25 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/UrlRewrite/UrlResolverTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/UrlRewrite/UrlResolverTest.php @@ -39,6 +39,7 @@ public function testNonExistentEntityUrlRewrite() id relative_url type + redirectCode } } QUERY; diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/ProductPriceWithFPTTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/ProductPriceWithFPTTest.php new file mode 100644 index 000000000000..385e3419bbf6 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/ProductPriceWithFPTTest.php @@ -0,0 +1,733 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Weee; + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Config\Storage\WriterInterface; +use Magento\Framework\ObjectManager\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; +use Magento\Tax\Model\ClassModel as TaxClassModel; +use Magento\Tax\Model\ResourceModel\TaxClass\CollectionFactory as TaxClassCollectionFactory; + +/** + * Test for Product Price With FPT + * + * @SuppressWarnings(PHPMD.TooManyPublicMethods) + */ +class ProductPriceWithFPTTest extends GraphQlAbstract +{ + /** @var ObjectManager $objectManager */ + private $objectManager; + + /** @var string[] $objectManager */ + private $initialConfig; + + /** @var ScopeConfigInterface */ + private $scopeConfig; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->objectManager = Bootstrap::getObjectManager(); + + /** @var ScopeConfigInterface $scopeConfig */ + $this->scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + + $currentSettingsArray = [ + 'tax/display/type', + 'tax/weee/enable', + 'tax/weee/display', + 'tax/defaults/region', + 'tax/weee/apply_vat', + 'tax/calculation/price_includes_tax' + ]; + + foreach ($currentSettingsArray as $configPath) { + $this->initialConfig[$configPath] = $this->scopeConfig->getValue( + $configPath + ); + } + /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */ + $config = $this->objectManager->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class); + $config->reinit(); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->writeConfig($this->initialConfig); + } + + /** + * Write configuration for weee + * + * @param array $weeTaxSettings + * @return void + */ + private function writeConfig(array $weeTaxSettings): void + { + /** @var WriterInterface $configWriter */ + $configWriter = $this->objectManager->get(WriterInterface::class); + + foreach ($weeTaxSettings as $path => $value) { + $configWriter->save($path, $value); + } + $this->scopeConfig->clean(); + } + + /** + * Catalog Prices : Excluding Tax + * Catalog Display setting: Excluding Tax + * FPT Display setting: Including FPT only + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceExcludeTaxAndIncludeFPTOnlySettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceExcludeTaxAndIncludeFPTOnly(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + // final price and regular price are the sum of product price and FPT + $this->assertEquals(112.7, $product['price_range']['minimum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['minimum_price']['final_price']['value']); + + $this->assertEquals(112.7, $product['price_range']['maximum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['maximum_price']['final_price']['value']); + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + $fixedProductTax = $product['price_range']['minimum_price']['fixed_product_taxes'][0]; + $this->assertEquals(12.7, $fixedProductTax['amount']['value']); + $this->assertEquals('fpt_for_all_front_label', $fixedProductTax['label']); + } + + /** + * CatalogPriceExcludeTaxAndIncludeFPTOnlyProvider settings data provider + * + * @return array + */ + public function catalogPriceExcludeTaxAndIncludeFPTOnlySettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/display/type' => '1', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '0', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '0', + ] + ] + ]; + } + + /** + * Catalog Prices : Excluding Tax + * Catalog Display setting: Excluding Tax + * FPT Display setting: Including FPT and FPT description + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceExcludeTaxAndIncludeFPTWithDescriptionSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceExcludeTaxAndIncludeFPTWithDescription(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + // final price and regular price are the sum of product price and FPT + $this->assertEquals(112.7, $product['price_range']['minimum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['minimum_price']['final_price']['value']); + + $this->assertEquals(112.7, $product['price_range']['maximum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['maximum_price']['final_price']['value']); + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + $fixedProductTax = $product['price_range']['minimum_price']['fixed_product_taxes'][0]; + $this->assertEquals(12.7, $fixedProductTax['amount']['value']); + $this->assertEquals('fpt_for_all_front_label', $fixedProductTax['label']); + } + + /** + * CatalogPriceExcludeTaxAndIncludeFPTWithDescription settings data provider + * + * @return array + */ + public function catalogPriceExcludeTaxAndIncludeFPTWithDescriptionSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/display/type' => '1', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '1', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '0', + ] + ] + ]; + } + + /** + * Catalog Prices : Excluding Tax + * Catalog Display setting: Including Tax + * FPT Display setting: Including FPT only + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnlySettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnly(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + /** @var TaxClassCollectionFactory $taxClassCollectionFactory */ + $taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class); + $taxClassCollection = $taxClassCollectionFactory->create(); + /** @var TaxClassModel $taxClass */ + $taxClassCollection->addFieldToFilter('class_type', TaxClassModel::TAX_CLASS_TYPE_PRODUCT); + $taxClass = $taxClassCollection->getFirstItem(); + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + /** @var Product $prod2 */ + $product1 = $productRepository->get('simple-with-ftp'); + $product1->setCustomAttribute('tax_class_id', $taxClass->getClassId()); + $productRepository->save($product1); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + + // final price and regular price are the sum of product price, FPT and product tax + $this->assertEquals(120.2, round($product['price_range']['minimum_price']['regular_price']['value'], 2)); + $this->assertEquals(120.2, round($product['price_range']['minimum_price']['final_price']['value'], 2)); + + $this->assertEquals(120.2, round($product['price_range']['maximum_price']['regular_price']['value'], 2)); + $this->assertEquals(120.2, round($product['price_range']['maximum_price']['final_price']['value'], 2)); + } + + /** + * CatalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnly settings data provider + * + * @return array + */ + public function catalogPriceExcludeTaxCatalogDisplayIncludeTaxAndIncludeFPTOnlySettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '0', + 'tax/display/type' => '2', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '0', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '0', + ] + ] + ]; + } + + /** + * Catalog Prices : Excluding Tax + * Catalog Display setting: Including Tax + * FPT Display setting: Including FPT and FPT description + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescriptionSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescription(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + /** @var TaxClassCollectionFactory $taxClassCollectionFactory */ + $taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class); + $taxClassCollection = $taxClassCollectionFactory->create(); + /** @var TaxClassModel $taxClass */ + $taxClassCollection->addFieldToFilter('class_type', TaxClassModel::TAX_CLASS_TYPE_PRODUCT); + $taxClass = $taxClassCollection->getFirstItem(); + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + /** @var Product $product1 */ + $product1 = $productRepository->get('simple-with-ftp'); + $product1->setCustomAttribute('tax_class_id', $taxClass->getClassId()); + $productRepository->save($product1); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + // final price and regular price are the sum of product price and FPT + $this->assertEquals(120.2, round($product['price_range']['minimum_price']['regular_price']['value'], 2)); + $this->assertEquals(120.2, round($product['price_range']['minimum_price']['final_price']['value'], 2)); + + $this->assertEquals(120.2, round($product['price_range']['maximum_price']['regular_price']['value'], 2)); + $this->assertEquals(120.2, round($product['price_range']['maximum_price']['final_price']['value'], 2)); + } + + /** + * CatalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescription settings data provider + * + * @return array + */ + public function catalogPriceExclTaxCatalogDisplayInclTaxAndInclFPTWithDescriptionSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '0', + 'tax/display/type' => '2', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '1', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '0', + ] + ] + ]; + } + + /** + * Catalog Prices : Including Tax + * Catalog Display setting: Excluding Tax + * FPT Display setting: Including FPT and FPT description + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescriptionSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescription(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + // final price and regular price are the sum of product price and FPT + $this->assertEquals(112.7, $product['price_range']['minimum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['minimum_price']['final_price']['value']); + + $this->assertEquals(112.7, $product['price_range']['maximum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['maximum_price']['final_price']['value']); + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + $fixedProductTax = $product['price_range']['minimum_price']['fixed_product_taxes'][0]; + $this->assertEquals(12.7, $fixedProductTax['amount']['value']); + $this->assertEquals('fpt_for_all_front_label', $fixedProductTax['label']); + } + + /** + * CatalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescription settings data provider + * + * @return array + */ + public function catalogPriceInclTaxCatalogDisplayExclTaxAndInclFPTWithDescriptionSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '1', + 'tax/display/type' => '1', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '1', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '1', + ] + ] + ]; + } + + /** + * Catalog Prices : Including Tax + * Catalog Display setting: Including Tax + * FPT Display setting: Including FPT Only + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnlySettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnly(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + // final price and regular price are the sum of product price and FPT + $this->assertEquals(112.7, $product['price_range']['minimum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['minimum_price']['final_price']['value']); + + $this->assertEquals(112.7, $product['price_range']['maximum_price']['regular_price']['value']); + $this->assertEquals(112.7, $product['price_range']['maximum_price']['final_price']['value']); + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + $fixedProductTax = $product['price_range']['minimum_price']['fixed_product_taxes'][0]; + $this->assertEquals(12.7, $fixedProductTax['amount']['value']); + $this->assertEquals('fpt_for_all_front_label', $fixedProductTax['label']); + } + + /** + * CatalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnly settings data provider + * + * @return array + */ + public function catalogPriceInclTaxCatalogDisplayInclTaxAndInclFPTOnlySettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '1', + 'tax/display/type' => '2', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '0', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '0', + ] + ] + ]; + } + + /** + * Catalog Prices : Including Tax + * Catalog Display setting: Including Tax + * FPT Display setting: Including FPT and FPT Description + * Apply Tax to FPT = Yes + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPTSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPT( + array $weeTaxSettings + ) { + $this->writeConfig($weeTaxSettings); + + /** @var TaxClassCollectionFactory $taxClassCollectionFactory */ + $taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class); + $taxClassCollection = $taxClassCollectionFactory->create(); + /** @var TaxClassModel $taxClass */ + $taxClassCollection->addFieldToFilter('class_type', TaxClassModel::TAX_CLASS_TYPE_PRODUCT); + $taxClass = $taxClassCollection->getFirstItem(); + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + /** @var Product $product1 */ + $product1 = $productRepository->get('simple-with-ftp'); + $product1->setCustomAttribute('tax_class_id', $taxClass->getClassId()); + $productRepository->save($product1); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + + //12.7 + 7.5% of 12.7 = 13.65 + $fptWithTax = round(13.65, 2); + // final price and regular price are the sum of product price and FPT + $this->assertEquals(113.65, round($product['price_range']['minimum_price']['regular_price']['value'], 2)); + $this->assertEquals(113.65, round($product['price_range']['minimum_price']['final_price']['value'], 2)); + + $this->assertEquals(113.65, round($product['price_range']['maximum_price']['regular_price']['value'], 2)); + $this->assertEquals(113.65, round($product['price_range']['maximum_price']['final_price']['value'], 2)); + + $this->assertNotEmpty($product['price_range']['minimum_price']['fixed_product_taxes']); + $fixedProductTax = $product['price_range']['minimum_price']['fixed_product_taxes'][0]; + $this->assertEquals($fptWithTax, round($fixedProductTax['amount']['value'], 2)); + $this->assertEquals('fpt_for_all_front_label', $fixedProductTax['label']); + } + + /** + * CatalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPT settings data provider + * + * @return array + */ + public function catalogPriceIncTaxCatalogDisplayInclTaxInclFPTWithDescrWithTaxAppliedOnFPTSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '1', + 'tax/display/type' => '2', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '0', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '1', + ] + ] + ]; + } + + /** + * Use multiple FPTs per product with the below tax/fpt configurations + * + * Catalog Prices : Including Tax + * Catalog Display setting: Including Tax + * FPT Display setting: Including FPT and FPT description + * Apply tax on FPT : Yes + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_two_fpt.php + * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php + */ + public function testCatalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTs(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + /** @var TaxClassCollectionFactory $taxClassCollectionFactory */ + $taxClassCollectionFactory = $this->objectManager->get(TaxClassCollectionFactory::class); + $taxClassCollection = $taxClassCollectionFactory->create(); + /** @var TaxClassModel $taxClass */ + $taxClassCollection->addFieldToFilter('class_type', TaxClassModel::TAX_CLASS_TYPE_PRODUCT); + $taxClass = $taxClassCollection->getFirstItem(); + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + /** @var Product $product1 */ + $product1 = $productRepository->get('simple-with-ftp'); + $product1->setCustomAttribute('tax_class_id', $taxClass->getClassId()); + $product1->setFixedProductAttribute( + [['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10, 'delete' => '']] + ); + $productRepository->save($product1); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertEquals(124.40, round($product['price_range']['minimum_price']['regular_price']['value'], 2)); + $this->assertCount( + 2, + $product['price_range']['minimum_price']['fixed_product_taxes'], + 'Fixed product tax count is incorrect' + ); + $this->assertResponseFields( + $product['price_range']['minimum_price']['fixed_product_taxes'], + [ + [ + 'amount' => [ + 'value' => 13.6525 + ], + 'label' => 'fpt_for_all_front_label' + ], + [ + 'amount' => [ + 'value' => 10.75 + ], + 'label' => 'fixed_product_attribute_front_label' + ], + ] + ); + } + + /** + * CatalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSettingsProvider settings data provider + * + * @return array + */ + public function catalogPriceInclTaxCatalogDisplayIncludeTaxAndMuyltipleFPTsSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/calculation/price_includes_tax' => '1', + 'tax/display/type' => '2', + 'tax/weee/enable' => '1', + 'tax/weee/display' => '1', + 'tax/defaults/region' => '1', + 'tax/weee/apply_vat' => '1', + ] + ] + ]; + } + + /** + * Test FPT disabled feature + * + * FPT enabled : FALSE + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider catalogPriceDisabledFPTSettingsProvider + * @magentoApiDataFixture Magento/Weee/_files/product_with_fpt.php + */ + public function testCatalogPriceDisableFPT(array $weeTaxSettings) + { + $this->writeConfig($weeTaxSettings); + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + /** @var Product $product1 */ + $product1 = $productRepository->get('simple-with-ftp'); + $product1->setFixedProductAttribute( + [['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10, 'delete' => '']] + ); + $productRepository->save($product1); + + $skus = ['simple-with-ftp']; + $query = $this->getProductQuery($skus); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + $this->assertNotEmpty($result['products']['items']); + $product = $result['products']['items'][0]; + $this->assertEquals(100, round($product['price_range']['minimum_price']['regular_price']['value'], 2)); + $this->assertCount( + 0, + $product['price_range']['minimum_price']['fixed_product_taxes'], + 'Fixed product tax count is incorrect' + ); + $this->assertResponseFields( + $product['price_range']['minimum_price']['fixed_product_taxes'], + [] + ); + } + + /** + * CatalogPriceDisableFPT settings data provider + * + * @return array + */ + public function catalogPriceDisabledFPTSettingsProvider() + { + return [ + [ + 'weeTaxSettings' => [ + 'tax/weee/enable' => '0', + 'tax/weee/display' => '1', + ], + ], + ]; + } + + /** + * Get GraphQl query to fetch products by sku + * + * @param array $skus + * @return string + */ + private function getProductQuery(array $skus): string + { + $stringSkus = '"' . implode('","', $skus) . '"'; + return <<<QUERY +{ + products(filter: {sku: {in: [$stringSkus]}}, sort: {name: ASC}) { + items { + name + sku + price_range { + minimum_price { + regular_price { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + fixed_product_taxes{ + amount{value} + label + } + } + maximum_price { + regular_price { + value + currency + } + final_price { + value + currency + } + discount { + amount_off + percent_off + } + fixed_product_taxes + { + amount{value} + label + } + } + } + } + } +} +QUERY; + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/StoreConfigFPTTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/StoreConfigFPTTest.php new file mode 100644 index 000000000000..451ea78ee308 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/StoreConfigFPTTest.php @@ -0,0 +1,204 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Weee; + +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Config\Storage\WriterInterface; +use Magento\Framework\ObjectManager\ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; +use Magento\Weee\Model\Tax as WeeeDisplayConfig; +use Magento\Weee\Model\Config; + +/** + * Test for storeConfig FPT config values + */ +class StoreConfigFPTTest extends GraphQlAbstract +{ + /** @var ObjectManager $objectManager */ + private $objectManager; + + /** + * @inheritdoc + */ + protected function setUp() :void + { + $this->objectManager = Bootstrap::getObjectManager(); + } + + /** + * FPT All Display settings + * + * @param array $weeTaxSettings + * @param string $displayValue + * @return void + * + * @dataProvider sameFPTDisplaySettingsProvider + */ + public function testSameFPTDisplaySettings(array $weeTaxSettings, $displayValue) + { + /** @var WriterInterface $configWriter */ + $configWriter = $this->objectManager->get(WriterInterface::class); + + foreach ($weeTaxSettings as $path => $value) { + $configWriter->save($path, $value); + } + + /** @var ScopeConfigInterface $scopeConfig */ + $scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + $scopeConfig->clean(); + + $query = $this->getStoreConfigQuery(); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + + $this->assertNotEmpty($result['storeConfig']['product_fixed_product_tax_display_setting']); + $this->assertNotEmpty($result['storeConfig']['category_fixed_product_tax_display_setting']); + $this->assertNotEmpty($result['storeConfig']['sales_fixed_product_tax_display_setting']); + + $this->assertEquals($displayValue, $result['storeConfig']['product_fixed_product_tax_display_setting']); + $this->assertEquals($displayValue, $result['storeConfig']['category_fixed_product_tax_display_setting']); + $this->assertEquals($displayValue, $result['storeConfig']['sales_fixed_product_tax_display_setting']); + } + + /** + * SameFPTDisplaySettings settings data provider + * + * @return array + */ + public function sameFPTDisplaySettingsProvider() + { + return [ + [ + 'weeTaxSettingsDisplayIncludedOnly' => [ + 'tax/weee/enable' => '1', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_INCL, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_INCL, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_INCL, + ], + 'displayValue' => 'INCLUDE_FPT_WITHOUT_DETAILS', + ], + [ + 'weeTaxSettingsDisplayIncludedAndDescription' => [ + 'tax/weee/enable' => '1', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_INCL_DESCR, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_INCL_DESCR, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_INCL_DESCR, + ], + 'displayValue' => 'INCLUDE_FPT_WITH_DETAILS', + ], + [ + 'weeTaxSettingsDisplayIncludedAndExcludedAndDescription' => [ + 'tax/weee/enable' => '1', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + ], + 'displayValue' => 'EXCLUDE_FPT_AND_INCLUDE_WITH_DETAILS', + ], + [ + 'weeTaxSettingsDisplayExcluded' => [ + 'tax/weee/enable' => '1', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_EXCL, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_EXCL, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_EXCL, + ], + 'displayValue' => 'EXCLUDE_FPT_WITHOUT_DETAILS', + ], + [ + 'weeTaxSettingsDisplayExcluded' => [ + 'tax/weee/enable' => '0', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_EXCL, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_EXCL, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_EXCL, + ], + 'displayValue' => 'FPT_DISABLED', + ], + ]; + } + + /** + * FPT Display setting shuffled + * + * @param array $weeTaxSettings + * @return void + * + * @dataProvider differentFPTDisplaySettingsProvider + */ + public function testDifferentFPTDisplaySettings(array $weeTaxSettings) + { + /** @var WriterInterface $configWriter */ + $configWriter = $this->objectManager->get(WriterInterface::class); + + foreach ($weeTaxSettings as $path => $value) { + $configWriter->save($path, $value); + } + + /** @var ScopeConfigInterface $scopeConfig */ + $scopeConfig = $this->objectManager->get(ScopeConfigInterface::class); + $scopeConfig->clean(); + + $query = $this->getStoreConfigQuery(); + $result = $this->graphQlQuery($query); + $this->assertArrayNotHasKey('errors', $result); + + $this->assertNotEmpty($result['storeConfig']['product_fixed_product_tax_display_setting']); + $this->assertNotEmpty($result['storeConfig']['category_fixed_product_tax_display_setting']); + $this->assertNotEmpty($result['storeConfig']['sales_fixed_product_tax_display_setting']); + + $this->assertEquals( + 'INCLUDE_FPT_WITHOUT_DETAILS', + $result['storeConfig']['product_fixed_product_tax_display_setting'] + ); + $this->assertEquals( + 'INCLUDE_FPT_WITH_DETAILS', + $result['storeConfig']['category_fixed_product_tax_display_setting'] + ); + $this->assertEquals( + 'EXCLUDE_FPT_AND_INCLUDE_WITH_DETAILS', + $result['storeConfig']['sales_fixed_product_tax_display_setting'] + ); + } + + /** + * DifferentFPTDisplaySettings settings data provider + * + * @return array + */ + public function differentFPTDisplaySettingsProvider() + { + return [ + [ + 'weeTaxSettingsDisplay' => [ + 'tax/weee/enable' => '1', + Config::XML_PATH_FPT_DISPLAY_PRODUCT_VIEW => WeeeDisplayConfig::DISPLAY_INCL, + Config::XML_PATH_FPT_DISPLAY_PRODUCT_LIST => WeeeDisplayConfig::DISPLAY_INCL_DESCR, + Config::XML_PATH_FPT_DISPLAY_SALES => WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + ] + ], + ]; + } + + /** + * Get GraphQl query to fetch storeConfig and FPT serttings + * + * @return string + */ + private function getStoreConfigQuery(): string + { + return <<<QUERY +{ + storeConfig { + product_fixed_product_tax_display_setting + category_fixed_product_tax_display_setting + sales_fixed_product_tax_display_setting + } +} +QUERY; + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Multishipping/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Multishipping/Api/CartRepositoryTest.php new file mode 100644 index 000000000000..46844438fdd9 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/Multishipping/Api/CartRepositoryTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Multishipping\Api; + +use Magento\Framework\Api\FilterBuilder; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SortOrderBuilder; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Model\Quote; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; +use Magento\TestFramework\TestCase\WebapiAbstract; + +/** + * Tests web-api for multishipping quote. + */ +class CartRepositoryTest extends WebapiAbstract +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @var SortOrderBuilder + */ + private $sortOrderBuilder; + + /** + * @var FilterBuilder + */ + private $filterBuilder; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->filterBuilder = $this->objectManager->create(FilterBuilder::class); + $this->sortOrderBuilder = $this->objectManager->create(SortOrderBuilder::class); + $this->searchCriteriaBuilder = $this->objectManager->create(SearchCriteriaBuilder::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + try { + /** @var CartRepositoryInterface $quoteRepository */ + $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); + $cart = $this->getCart('multishipping_quote_id'); + $quoteRepository->delete($cart); + } catch (\InvalidArgumentException $e) { + // Do nothing if cart fixture was not used + } + parent::tearDown(); + } + + /** + * Tests that multishipping quote contains all addresses in shipping assignments. + * + * @magentoApiDataFixture Magento/Multishipping/Fixtures/quote_with_split_items.php + */ + public function testGetMultishippingCart() + { + $cart = $this->getCart('multishipping_quote_id'); + $cartId = $cart->getId(); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/carts/' . $cartId, + 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET, + ], + 'soap' => [ + 'service' => 'quoteCartRepositoryV1', + 'serviceVersion' => 'V1', + 'operation' => 'quoteCartRepositoryV1Get', + ], + ]; + + $requestData = ['cartId' => $cartId]; + $cartData = $this->_webApiCall($serviceInfo, $requestData); + + $shippingAssignments = $cart->getExtensionAttributes()->getShippingAssignments(); + foreach ($shippingAssignments as $key => $shippingAssignment) { + $address = $shippingAssignment->getShipping()->getAddress(); + $cartItem = $shippingAssignment->getItems()[0]; + $this->assertEquals( + $address->getId(), + $cartData['extension_attributes']['shipping_assignments'][$key]['shipping']['address']['id'] + ); + $this->assertEquals( + $cartItem->getSku(), + $cartData['extension_attributes']['shipping_assignments'][$key]['items'][0]['sku'] + ); + $this->assertEquals( + $cartItem->getQty(), + $cartData['extension_attributes']['shipping_assignments'][$key]['items'][0]['qty'] + ); + } + } + + /** + * Retrieve quote by given reserved order ID + * + * @param string $reservedOrderId + * @return Quote + * @throws \InvalidArgumentException + */ + private function getCart(string $reservedOrderId): Quote + { + /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); + $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId) + ->create(); + + /** @var CartRepositoryInterface $quoteRepository */ + $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); + $items = $quoteRepository->getList($searchCriteria)->getItems(); + + if (empty($items)) { + throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); + } + + return array_pop($items); + } +} diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php index 8cb82f5c8f20..5a894758dc9e 100644 --- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartRepositoryTest.php @@ -42,6 +42,9 @@ class CartRepositoryTest extends WebapiAbstract */ private $filterBuilder; + /** + * @inheritdoc + */ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -59,8 +62,10 @@ protected function setUp() protected function tearDown() { try { + /** @var CartRepositoryInterface $quoteRepository */ + $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); $cart = $this->getCart('test01'); - $cart->delete(); + $quoteRepository->delete($cart); } catch (\InvalidArgumentException $e) { // Do nothing if cart fixture was not used } @@ -74,18 +79,27 @@ protected function tearDown() * @return \Magento\Quote\Model\Quote * @throws \InvalidArgumentException */ - protected function getCart($reservedOrderId) + private function getCart($reservedOrderId) { - /** @var $cart \Magento\Quote\Model\Quote */ - $cart = $this->objectManager->get(\Magento\Quote\Model\Quote::class); - $cart->load($reservedOrderId, 'reserved_order_id'); - if (!$cart->getId()) { + /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ + $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class); + $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId) + ->create(); + + /** @var CartRepositoryInterface $quoteRepository */ + $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); + $items = $quoteRepository->getList($searchCriteria)->getItems(); + + if (empty($items)) { throw new \InvalidArgumentException('There is no quote with provided reserved order ID.'); } - return $cart; + + return array_pop($items); } /** + * Tests successfull get cart web-api call. + * * @magentoApiDataFixture Magento/Sales/_files/quote.php */ public function testGetCart() @@ -130,6 +144,8 @@ public function testGetCart() } /** + * Tests exception when cartId is not provided. + * * @expectedException \Exception * @expectedExceptionMessage No such entity with */ @@ -154,6 +170,8 @@ public function testGetCartThrowsExceptionIfThereIsNoCartWithProvidedId() } /** + * Tests carts search. + * * @magentoApiDataFixture Magento/Sales/_files/quote.php */ public function testGetList() @@ -184,6 +202,7 @@ public function testGetList() $this->searchCriteriaBuilder->addFilters([$grandTotalFilter, $subtotalFilter]); $this->searchCriteriaBuilder->addFilters([$minCreatedAtFilter]); $this->searchCriteriaBuilder->addFilters([$maxCreatedAtFilter]); + $this->searchCriteriaBuilder->addFilter('reserved_order_id', 'test01'); /** @var SortOrder $sortOrder */ $sortOrder = $this->sortOrderBuilder->setField('subtotal')->setDirection(SortOrder::SORT_ASC)->create(); $this->searchCriteriaBuilder->setSortOrders([$sortOrder]); diff --git a/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php b/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php index b1f86739786c..37cb2317b5b6 100644 --- a/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php +++ b/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php @@ -8,7 +8,7 @@ namespace Magento\WebapiAsync\Model; -use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\Data\ProductInterface as Product; use Magento\TestFramework\MessageQueue\PreconditionFailedException; use Magento\TestFramework\MessageQueue\PublisherConsumerController; use Magento\TestFramework\MessageQueue\EnvironmentPreconditionException; @@ -19,7 +19,6 @@ use Magento\Framework\Registry; use Magento\Framework\Webapi\Exception; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Catalog\Api\Data\ProductInterface as Product; use Magento\Framework\ObjectManagerInterface; use Magento\Store\Model\Store; use Magento\Framework\Webapi\Rest\Request; @@ -128,6 +127,13 @@ protected function setUp() */ public function testAsyncScheduleBulkMultistore($storeCode) { + if ($storeCode === self::STORE_CODE_FROM_FIXTURE) { + /** @var \Magento\Config\Model\Config $config */ + $config = Bootstrap::getObjectManager()->get(\Magento\Config\Model\Config::class); + if (strpos($config->getConfigDataValue('catalog/search/engine'), 'elasticsearch') !== false) { + $this->markTestSkipped('MC-20452'); + } + } $product = $this->getProductData(); $this->_markTestAsRestOnly(); @@ -277,9 +283,9 @@ public function getProductData() 'product' => $productBuilder( [ - ProductInterface::TYPE_ID => 'simple', - ProductInterface::SKU => 'multistore-sku-test-1', - ProductInterface::NAME => 'Test Name ', + Product::TYPE_ID => 'simple', + Product::SKU => 'multistore-sku-test-1', + Product::NAME => 'Test Name ', ] ), ]; @@ -303,16 +309,16 @@ public function storeProvider() private function getSimpleProductData($productData = []) { return [ - ProductInterface::SKU => isset($productData[ProductInterface::SKU]) - ? $productData[ProductInterface::SKU] : uniqid('sku-', true), - ProductInterface::NAME => isset($productData[ProductInterface::NAME]) - ? $productData[ProductInterface::NAME] : uniqid('sku-', true), - ProductInterface::VISIBILITY => 4, - ProductInterface::TYPE_ID => 'simple', - ProductInterface::PRICE => 3.62, - ProductInterface::STATUS => 1, - ProductInterface::TYPE_ID => 'simple', - ProductInterface::ATTRIBUTE_SET_ID => 4, + Product::SKU => isset($productData[Product::SKU]) + ? $productData[Product::SKU] : uniqid('sku-', true), + Product::NAME => isset($productData[Product::NAME]) + ? $productData[Product::NAME] : uniqid('sku-', true), + Product::VISIBILITY => 4, + Product::TYPE_ID => 'simple', + Product::PRICE => 3.62, + Product::STATUS => 1, + Product::TYPE_ID => 'simple', + Product::ATTRIBUTE_SET_ID => 4, ]; } diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php index 49f2577b2621..bc3ae83643d3 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/LiselectstoreElement.php @@ -9,7 +9,6 @@ use Magento\Mtf\Client\Locator; /** - * Class LiselectstoreElement * Typified element class for lists selectors */ class LiselectstoreElement extends SimpleElement @@ -76,6 +75,7 @@ public function setValue($value) $option = $this->context->find($optionSelector, Locator::SELECTOR_XPATH); if (!$option->isVisible()) { + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception('[' . implode('/', $value) . '] option is not visible in store switcher.'); } $option->click(); @@ -133,7 +133,7 @@ public function getValues() */ protected function isSubstring($haystack, $pattern) { - return preg_match("/$pattern/", $haystack) != 0 ? true : false; + return preg_match("/$pattern/", $haystack) != 0; } /** @@ -157,8 +157,8 @@ protected function findNearestElement($criteria, $key, array $elements) /** * Get selected store value * - * @throws \Exception * @return string + * @throws \Exception */ public function getValue() { diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/EnvWhitelist.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/EnvWhitelist.php new file mode 100644 index 000000000000..294cc32e8f71 --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/EnvWhitelist.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Mtf\Util\Command\Cli; + +use Magento\Mtf\Util\Command\Cli; + +/** + * Adding and removing domain to whitelist for test execution. + */ +class EnvWhitelist extends Cli +{ + /** + * Parameter domain add command. + */ + const PARAM_DOMAINS = 'downloadable:domains'; + + /** + * Add host to the whitelist. + * + * @param string $host + */ + public function addHost($host) + { + parent::execute(EnvWhitelist::PARAM_DOMAINS . ':add ' . $host); + } + + /** + * Remove host from the whitelist. + * + * @param string $host + */ + public function removeHost($host) + { + parent::execute(EnvWhitelist::PARAM_DOMAINS . ':remove ' . $host); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php index 01d8401b22fe..39f5866a3c2a 100644 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php @@ -47,6 +47,7 @@ public function persist(FixtureInterface $fixture = null) $loginForm->fill($fixture); $loginForm->submit(); $loginPage->waitForHeaderBlock(); + $loginPage->dismissAdminUsageNotification(); } } } 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 c836c4db81ef..4b72bb836523 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 @@ -40,6 +40,11 @@ class AdminAuthLogin extends Page */ protected $messagesBlock = '.messages'; + /** + * Admin Analytics selector + */ + protected $adminUsageSelector ='.modal-inner-wrap'; + /** * Constructor. */ @@ -75,13 +80,24 @@ public function getHeaderBlock() /** * Get global messages block. * - * @return \Magento\Backend\Test\Block\Messages + * @return \Magento\Ui\Test\Block\Adminhtml\Modal + */ public function getMessagesBlock() { return Factory::getBlockFactory()->getMagentoBackendMessages($this->browser->find($this->messagesBlock)); } + /** + * Get modal block + * + * @return void + */ + public function getModalBlock() + { + return Factory::getBlockFactory()->getMagentoUiAdminhtmlModal($this->browser->find($this->adminUsageSelector)); + } + /** * Wait for Header block is visible in the page. * @@ -98,4 +114,14 @@ function () use ($browser, $selector) { } ); } + + /** + * Dismiss admin usage notification + * + * @return void + */ + public function dismissAdminUsageNotification() + { + $this->getModalBlock()->dismissIfModalAppears(); + } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php index f1ab25501328..a06ee2332704 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Block/Catalog/Product/View/Type/Bundle.php @@ -311,7 +311,7 @@ public function fillBundleOptions($bundleOptions) { foreach ($bundleOptions as $option) { $selector = sprintf($this->bundleOptionBlock, $option['title']); - $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true' ? true : false; + $useDefault = isset($option['use_default']) && strtolower($option['use_default']) == 'true'; if (!$useDefault) { /** @var Option $optionBlock */ $optionBlock = $this->blockFactory->create( diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml index 525e6b47374a..028dfc6d109e 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml @@ -31,7 +31,7 @@ </category_ids> <quantity_and_stock_status composite="1"> <qty> - <selector>fieldset[data-index="container_quantity_and_stock_status_qty"] [name="product[quantity_and_stock_status][qty]"]</selector> + <selector>fieldset[data-index="quantity_and_stock_status_qty"] [name="product[quantity_and_stock_status][qty]"]</selector> </qty> <is_in_stock> <selector>[data-index="quantity_and_stock_status"] [name="product[quantity_and_stock_status][is_in_stock]"]</selector> diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php index 23e0236fe7ba..70d2730868db 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Product/TaxClass.php @@ -52,7 +52,7 @@ class TaxClass extends DataSource public function __construct(FixtureFactory $fixtureFactory, array $params, $data = []) { $this->params = $params; - if ((!isset($data['dataset']) && !isset($data['tax_product_class']))) { + if (!isset($data['dataset']) && !isset($data['tax_product_class'])) { $this->data = $data; return; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php index 5c54b366b7ab..fb9d6e9772c7 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php @@ -251,8 +251,13 @@ protected function getBlockId($landingName) $curl->write($url, [], CurlInterface::GET); $response = $curl->read(); $curl->close(); - preg_match('~\{"value":"(\d+)","label":"' . preg_quote($landingName) . '"\}~', $response, $matches); - $id = isset($matches[1]) ? (int)$matches[1] : null; + $id = null; + //Finding block option in 'Add block' options UI data. + preg_match('~\{[^\{\}]*?"label":"' . preg_quote($landingName) . '"[^\{\}]*?\}~', $response, $matches); + if (!empty($matches)) { + $blockOption = json_decode($matches[0], true); + $id = (int)$blockOption['value']; + } return $id; } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php index 90cd6bdb7632..b97accbf87a9 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnUpdateTest.php @@ -12,6 +12,7 @@ use Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Test Creation for ProductTypeSwitchingOnUpdating @@ -60,22 +61,32 @@ class ProductTypeSwitchingOnUpdateTest extends Injectable */ protected $fixtureFactory; + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Injection data. * * @param CatalogProductIndex $catalogProductIndex * @param CatalogProductEdit $catalogProductEdit * @param FixtureFactory $fixtureFactory + * @param EnvWhitelist $envWhitelist * @return void */ public function __inject( CatalogProductIndex $catalogProductIndex, CatalogProductEdit $catalogProductEdit, - FixtureFactory $fixtureFactory + FixtureFactory $fixtureFactory, + EnvWhitelist $envWhitelist ) { $this->catalogProductIndex = $catalogProductIndex; $this->catalogProductEdit = $catalogProductEdit; $this->fixtureFactory = $fixtureFactory; + $this->envWhitelist = $envWhitelist; } /** @@ -89,6 +100,7 @@ public function __inject( public function test($productOrigin, $product, $actionName) { // Preconditions + $this->envWhitelist->addHost('example.com'); list($fixtureClass, $dataset) = explode('::', $productOrigin); $productOrigin = $this->fixtureFactory->createByCode(trim($fixtureClass), ['dataset' => trim($dataset)]); $productOrigin->persist(); @@ -144,5 +156,6 @@ protected function clearDownloadableData() $downloadableInfoTab = $this->catalogProductEdit->getProductForm()->getSection('downloadable_information'); $downloadableInfoTab->getDownloadableBlock('Links')->clearDownloadableData(); $downloadableInfoTab->setIsDownloadable('No'); + $this->envWhitelist->removeHost('example.com'); } } 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 0ff402daca07..4f74b7ff554d 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 @@ -12,7 +12,7 @@ <strategy>css selector</strategy> <fields> <is_active> - <input>select</input> + <input>switcher</input> </is_active> <website_ids> <selector>[name='website_ids']</selector> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleInGrid.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleInGrid.php index 8ac13d407e43..695323990063 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleInGrid.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleInGrid.php @@ -19,7 +19,7 @@ class AssertCatalogPriceRuleInGrid extends AbstractConstraint * Fields used to filter rows in the grid. * @var array */ - protected $fieldsToFilter = ['name', 'is_active']; + protected $fieldsToFilter = ['name']; /** * Assert that data in grid on Catalog Price Rules page according to fixture diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.xml index 49bf36b0325b..1f16e28c067d 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/CreateCatalogPriceRuleEntityTest.xml @@ -10,7 +10,7 @@ <variation name="CatalogRule_Create_Active_AdminOnly"> <data name="catalogPriceRule/data/name" xsi:type="string">CatalogPriceRule %isolation%</data> <data name="catalogPriceRule/data/description" xsi:type="string">Catalog Price Rule Description</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Active</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">Yes</data> <data name="catalogPriceRule/data/website_ids/option_0" xsi:type="string">Main Website</data> <data name="catalogPriceRule/data/customer_group_ids/option_0" xsi:type="string">Wholesale</data> <data name="catalogPriceRule/data/simple_action" xsi:type="string">Apply as percentage of original</data> @@ -24,7 +24,7 @@ <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="catalogPriceRule/data/name" xsi:type="string">CatalogPriceRule %isolation%</data> <data name="catalogPriceRule/data/description" xsi:type="string">Catalog Price Rule Description</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Inactive</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">No</data> <data name="catalogPriceRule/data/website_ids/option_0" xsi:type="string">Main Website</data> <data name="catalogPriceRule/data/customer_group_ids/option_0" xsi:type="string">General</data> <data name="catalogPriceRule/data/condition" xsi:type="string">-</data> @@ -39,7 +39,7 @@ <variation name="CatalogRule_Create_ForGuestUsers_AdjustPriceToPercentage"> <data name="product" xsi:type="string">MAGETWO-23036</data> <data name="catalogPriceRule/data/name" xsi:type="string">rule_name%isolation%</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Active</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">Yes</data> <data name="catalogPriceRule/data/website_ids/option_0" xsi:type="string">Main Website</data> <data name="catalogPriceRule/data/customer_group_ids/option_0" xsi:type="string">NOT LOGGED IN</data> <data name="conditionEntity" xsi:type="string">category</data> @@ -54,7 +54,7 @@ <data name="customer/dataset" xsi:type="string">customer_with_new_customer_group</data> <data name="product" xsi:type="string">simple_10_dollar</data> <data name="catalogPriceRule/data/name" xsi:type="string">rule_name%isolation%</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Active</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">Yes</data> <data name="catalogPriceRule/data/website_ids/option_0" xsi:type="string">Main Website</data> <data name="conditionEntity" xsi:type="string">category</data> <data name="catalogPriceRule/data/conditions" xsi:type="string">[Category|is|%category_id%]</data> @@ -68,7 +68,7 @@ <data name="tag" xsi:type="string">test_type:extended_acceptance_test</data> <data name="product" xsi:type="string">product_with_custom_color_attribute</data> <data name="catalogPriceRule/data/name" xsi:type="string">Catalog Price Rule %isolation%</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Active</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">Yes</data> <data name="catalogPriceRule/data/website_ids/option_0" xsi:type="string">Main Website</data> <data name="catalogPriceRule/data/customer_group_ids/option_0" xsi:type="string">NOT LOGGED IN</data> <data name="conditionEntity" xsi:type="string">attribute</data> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.xml index 6c8e86b24ae6..e2916432c8eb 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/TestCase/UpdateCatalogPriceRuleEntityTest.xml @@ -10,7 +10,7 @@ <variation name="CatalogRule_Update_Name_Status"> <data name="catalogPriceRuleOriginal/dataset" xsi:type="string">active_catalog_price_rule_with_conditions</data> <data name="catalogPriceRule/data/name" xsi:type="string">New Catalog Price Rule Name %isolation%</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Inactive</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">No</data> <data name="saveAction" xsi:type="string">save</data> <constraint name="Magento\CatalogRule\Test\Constraint\AssertCatalogPriceRuleSuccessSaveMessage" /> <constraint name="Magento\CatalogRule\Test\Constraint\AssertCatalogPriceRuleNoticeMessage" /> @@ -24,7 +24,7 @@ <data name="catalogPriceRuleOriginal/dataset" xsi:type="string">active_catalog_price_rule_with_conditions</data> <data name="catalogPriceRule/data/name" xsi:type="string">New Catalog Price Rule Name %isolation%</data> <data name="catalogPriceRule/data/description" xsi:type="string">New Catalog Price Rule Description %isolation%</data> - <data name="catalogPriceRule/data/is_active" xsi:type="string">Active</data> + <data name="catalogPriceRule/data/is_active" xsi:type="string">Yes</data> <data name="catalogPriceRule/data/conditions" xsi:type="string">[Category|is|%category_1%]</data> <data name="catalogPriceRule/data/simple_action" xsi:type="string">Apply as fixed amount</data> <data name="catalogPriceRule/data/discount_amount" xsi:type="string">35</data> 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 4744fa7756c4..9a26386c82cb 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 @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogSearch\Test\TestCase\AdvancedSearchEntityTest" summary="Use Advanced Search" ticketId="MAGETWO-24729"> <variation name="AdvancedSearchEntityTestVariation1" summary="Use Advanced Search to Find the Product" ticketId="MAGETWO-12421"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, mftf_migrated:yes</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> <data name="productSearch/data/name" xsi:type="string">abc_dfj</data> @@ -16,6 +16,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation2"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by name</data> <data name="products/simple_1" xsi:type="string">-</data> <data name="products/simple_2" xsi:type="string">Yes</data> @@ -23,6 +24,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation3"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by partial name</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -30,6 +32,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation4"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by sku</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -37,6 +40,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation5"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by partial sku</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -44,6 +48,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation6"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by partial sku and description</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -52,6 +57,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation7"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by description</data> <data name="products/simple_1" xsi:type="string">-</data> <data name="products/simple_2" xsi:type="string">Yes</data> @@ -59,6 +65,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation8"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by short description</data> <data name="products/simple_1" xsi:type="string">-</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -66,6 +73,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation9"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by partial short description</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -73,6 +81,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation10"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by price to</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">Yes</data> @@ -80,6 +89,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation11"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by price from and price to</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -88,6 +98,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation12"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by name, sku, description, short description, price from and price to</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -100,6 +111,7 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation13"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Search product in advanced search by name, sku, description, short description, price from and price to</data> <data name="products/simple_1" xsi:type="string">Yes</data> <data name="products/simple_2" xsi:type="string">-</data> @@ -112,11 +124,13 @@ <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchProductsResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation14"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="description" xsi:type="string">Negative product search</data> <data name="productSearch/data/name" xsi:type="string">Negative_product_search</data> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchNoResult" /> </variation> <variation name="AdvancedSearchEntityTestVariation15" summary="Do Advanced Search without entering data" ticketId="MAGETWO-14859"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="issue" xsi:type="string">MAGETWO-18537: "Enter a search term and try again." error message is missed in Advanced Search</data> <data name="productSearch/data/name" xsi:type="string" /> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertAdvancedSearchEmptyTerm" /> 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 c00687d91c1e..038c41176896 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 @@ -62,6 +62,7 @@ class Item extends Sidebar */ public function removeItemFromMiniCart() { + $this->waitForDeleteButtonVisible(); $this->_rootElement->find($this->removeItem)->click(); $element = $this->browser->find($this->confirmModal); /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */ @@ -70,6 +71,23 @@ public function removeItemFromMiniCart() $modal->waitModalWindowToDisappear(); } + /** + * Wait for Delete button is visible in the block. + * + * @return bool|null + */ + private function waitForDeleteButtonVisible() + { + $rootElement = $this->_rootElement; + $deleteButtonSelector = $this->removeItem; + return $rootElement->waitUntil( + function () use ($rootElement, $deleteButtonSelector) { + $element = $rootElement->find($deleteButtonSelector); + return $element->isVisible() ? true : null; + } + ); + } + /** * Click "Edit item" button. * diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php index 7d6bd9318023..fba5a2b06234 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/AddProductsToShoppingCartEntityTest.php @@ -14,6 +14,7 @@ use Magento\Mtf\TestCase\Injectable; use Magento\Mtf\TestStep\TestStepFactory; use Magento\Mtf\Util\Command\Cli\Cache; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Preconditions: @@ -99,6 +100,13 @@ class AddProductsToShoppingCartEntityTest extends Injectable */ private $cache; + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Prepare test data. * @@ -108,6 +116,7 @@ class AddProductsToShoppingCartEntityTest extends Injectable * @param CheckoutCart $cartPage * @param TestStepFactory $testStepFactory * @param Cache $cache + * @param EnvWhitelist $envWhitelist * @return void */ public function __prepare( @@ -116,7 +125,8 @@ public function __prepare( CatalogProductView $catalogProductView, CheckoutCart $cartPage, TestStepFactory $testStepFactory, - Cache $cache + Cache $cache, + EnvWhitelist $envWhitelist ) { $this->browser = $browser; $this->fixtureFactory = $fixtureFactory; @@ -124,6 +134,7 @@ public function __prepare( $this->cartPage = $cartPage; $this->testStepFactory = $testStepFactory; $this->cache = $cache; + $this->envWhitelist = $envWhitelist; } /** @@ -146,6 +157,7 @@ public function test( // Preconditions $this->configData = $configData; $this->flushCache = $flushCache; + $this->envWhitelist->addHost('example.com'); $this->testStepFactory->create( \Magento\Config\Test\TestStep\SetupConfigurationStep::class, @@ -224,7 +236,7 @@ public function tearDown() $_ENV['app_frontend_url'] = preg_replace('/(http[s]?)/', 'http', $_ENV['app_frontend_url']); $this->cache->flush(); } - + $this->envWhitelist->removeHost('example.com'); $this->testStepFactory->create( \Magento\Config\Test\TestStep\SetupConfigurationStep::class, ['configData' => $this->configData, 'rollback' => true, 'flushCache' => $this->flushCache] diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.php index 54f59b03ef81..6f5512b2e829 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/OnePageCheckoutOfflinePaymentMethodsTest.php @@ -7,6 +7,7 @@ namespace Magento\Checkout\Test\TestCase; use Magento\Mtf\TestCase\Scenario; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Preconditions: @@ -43,6 +44,23 @@ class OnePageCheckoutOfflinePaymentMethodsTest extends Scenario const SEVERITY = 'S0'; /* end tags */ + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + + /** + * Perform needed injections + * + * @param EnvWhitelist $envWhitelist + */ + public function __inject(EnvWhitelist $envWhitelist) + { + $this->envWhitelist = $envWhitelist; + } + /** * Runs one page checkout test. * @@ -50,6 +68,17 @@ class OnePageCheckoutOfflinePaymentMethodsTest extends Scenario */ public function test() { + $this->envWhitelist->addHost('example.com'); $this->executeScenario(); } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php index af267cfa30ec..36b4f4b3eb39 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.php @@ -12,6 +12,7 @@ use Magento\Mtf\Fixture\FixtureInterface; use Magento\Mtf\TestCase\Injectable; use Magento\Customer\Test\Fixture\Customer; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Preconditions: @@ -58,22 +59,32 @@ class UpdateProductFromMiniShoppingCartEntityTest extends Injectable */ protected $fixtureFactory; + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Inject data. * * @param CmsIndex $cmsIndex * @param CatalogProductView $catalogProductView * @param FixtureFactory $fixtureFactory + * @param EnvWhitelist $envWhitelist * @return void */ public function __inject( CmsIndex $cmsIndex, CatalogProductView $catalogProductView, - FixtureFactory $fixtureFactory + FixtureFactory $fixtureFactory, + EnvWhitelist $envWhitelist ) { $this->cmsIndex = $cmsIndex; $this->catalogProductView = $catalogProductView; $this->fixtureFactory = $fixtureFactory; + $this->envWhitelist = $envWhitelist; } /** @@ -97,6 +108,7 @@ public function test( Customer $customer = null ) { // Preconditions: + $this->envWhitelist->addHost('example.com'); if ($customer !== null) { $customer->persist(); } @@ -162,4 +174,14 @@ protected function addToCart(FixtureInterface $product) ); $addToCartStep->run(); } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php index 496b7a280ca1..de71cdff7ae4 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/TestCase/CreateDownloadableProductEntityTest.php @@ -11,6 +11,7 @@ use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew; use Magento\Downloadable\Test\Fixture\DownloadableProduct; use Magento\Mtf\TestCase\Injectable; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Steps: @@ -53,6 +54,13 @@ class CreateDownloadableProductEntityTest extends Injectable */ protected $catalogProductNew; + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Persist category * @@ -73,16 +81,19 @@ public function __prepare(Category $category) * @param Category $category * @param CatalogProductIndex $catalogProductIndexNewPage * @param CatalogProductNew $catalogProductNewPage + * @param EnvWhitelist $envWhitelist * @return void */ public function __inject( Category $category, CatalogProductIndex $catalogProductIndexNewPage, - CatalogProductNew $catalogProductNewPage + CatalogProductNew $catalogProductNewPage, + EnvWhitelist $envWhitelist ) { $this->category = $category; $this->catalogProductIndex = $catalogProductIndexNewPage; $this->catalogProductNew = $catalogProductNewPage; + $this->envWhitelist = $envWhitelist; } /** @@ -95,10 +106,21 @@ public function __inject( public function test(DownloadableProduct $product, Category $category) { // Steps + $this->envWhitelist->addHost('example.com'); $this->catalogProductIndex->open(); $this->catalogProductIndex->getGridPageActionBlock()->addProduct('downloadable'); $productBlockForm = $this->catalogProductNew->getProductForm(); $productBlockForm->fill($product, null, $category); $this->catalogProductNew->getFormPageActions()->save(); } + + /** + * Clean data after running test. + * + * @return void + */ + protected function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml index 9c9c917f8a66..48129ef28749 100644 --- a/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml +++ b/dev/tests/functional/tests/app/Magento/LayeredNavigation/Test/TestCase/FilterProductListTest.xml @@ -94,7 +94,9 @@ <constraint name="Magento\LayeredNavigation\Test\Constraint\AssertFilterProductList" /> </variation> <variation name="FilterProductListTestVariation4" summary="Use sorting category filter when layered navigation is applied" ticketId="MAGETWO-42701"> + <data name="tag" xsi:type="string">test_type:mysql_search</data> <data name="configData" xsi:type="string">layered_navigation_manual_range_10</data> + <data name="runReindex" xsi:type="boolean">true</data> <data name="category/dataset" xsi:type="string">default_anchor_subcategory</data> <data name="category/data/category_products/dataset" xsi:type="string">catalogProductSimple::product_10_dollar, catalogProductSimple::product_20_dollar, configurableProduct::filterable_two_options_with_zero_price</data> <data name="layeredNavigation" xsi:type="array"> 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 e7dd72d1d426..da5e7101e4b3 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 @@ -102,7 +102,7 @@ public function test($gridActions, $gridStatus) $this->reviewIndex->getReviewGrid()->massaction( [['title' => $this->review->getTitle()]], [$gridActions => $gridStatus], - ($gridActions == 'Delete' ? true : false) + ($gridActions == 'Delete') ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php index 28bb00757dac..d98c5696c81f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php @@ -27,34 +27,6 @@ class Totals extends \Magento\Sales\Test\Block\Adminhtml\Order\Totals */ protected $capture = '[name="invoice[capture_case]"]'; - /** - * Refund Shipping css selector. - * - * @var string - */ - private $refundShippingSelector = '#shipping_amount'; - - /** - * Adjustment Refund css selector. - * - * @var string - */ - private $adjustmentRefundSelector = '#adjustment_positive'; - - /** - * Adjustment Fee css selector. - * - * @var string - */ - private $adjustmentFeeSelector = '#adjustment_negative'; - - /** - * Update Totals button css selector. - * - * @var string - */ - private $updateTotalsSelector = '.update-totals-button'; - /** * Submit invoice. * @@ -85,44 +57,4 @@ public function setCaptureOption($option) { $this->_rootElement->find($this->capture, Locator::SELECTOR_CSS, 'select')->setValue($option); } - - /** - * Get Refund Shipping input element. - * - * @return \Magento\Mtf\Client\ElementInterface - */ - public function getRefundShippingElement() - { - return $this->_rootElement->find($this->refundShippingSelector, Locator::SELECTOR_CSS); - } - - /** - * Get Adjustment Refund input element. - * - * @return \Magento\Mtf\Client\ElementInterface - */ - public function getAdjustmentRefundElement() - { - return $this->_rootElement->find($this->adjustmentRefundSelector, Locator::SELECTOR_CSS); - } - - /** - * Get Adjustment Fee input element. - * - * @return \Magento\Mtf\Client\ElementInterface - */ - public function getAdjustmentFeeElement() - { - return $this->_rootElement->find($this->adjustmentFeeSelector, Locator::SELECTOR_CSS); - } - - /** - * Click update totals button. - * - * @return void - */ - public function clickUpdateTotals() - { - $this->_rootElement->find($this->updateTotalsSelector)->click(); - } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php index 01e43defde81..9eb13734531d 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/PrintOrderFrontendGuestTest.php @@ -8,6 +8,7 @@ use Magento\Mtf\Client\BrowserInterface; use Magento\Mtf\TestCase\Scenario; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Preconditions: @@ -41,14 +42,25 @@ class PrintOrderFrontendGuestTest extends Scenario */ protected $browser; + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Prepare data. * * @param BrowserInterface $browser + * @param EnvWhitelist $envWhitelist */ - public function __prepare(BrowserInterface $browser) - { + public function __prepare( + BrowserInterface $browser, + EnvWhitelist $envWhitelist + ) { $this->browser = $browser; + $this->envWhitelist = $envWhitelist; } /** @@ -58,6 +70,7 @@ public function __prepare(BrowserInterface $browser) */ public function test() { + $this->envWhitelist->addHost('example.com'); $this->executeScenario(); } @@ -68,6 +81,7 @@ public function test() */ public function tearDown() { + $this->envWhitelist->removeHost('example.com'); $this->browser->closeWindow(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php index 25b576a06dd3..45298c5898c2 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php @@ -95,12 +95,8 @@ public function run() if ($this->compare($items, $refundData)) { $this->orderCreditMemoNew->getFormBlock()->updateQty(); } - $hasChangeTotals = $this->isTotalsDataChanged($refundData); - $this->orderCreditMemoNew->getFormBlock()->fillFormData($refundData); - if ($hasChangeTotals) { - $this->orderCreditMemoNew->getTotalsBlock()->clickUpdateTotals(); - } + $this->orderCreditMemoNew->getFormBlock()->fillFormData($refundData); $this->orderCreditMemoNew->getFormBlock()->submit(); } @@ -120,30 +116,4 @@ protected function getCreditMemoIds() $this->salesOrderView->getOrderForm()->openTab('creditmemos'); return $this->salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock()->getIds(); } - - /** - * Is totals data changed. - * - * @param array $data - * @return bool - */ - private function isTotalsDataChanged(array $data): bool - { - $compareData = [ - 'shipping_amount' => - $this->orderCreditMemoNew->getTotalsBlock()->getRefundShippingElement()->getValue(), - 'adjustment_positive' => - $this->orderCreditMemoNew->getTotalsBlock()->getAdjustmentRefundElement()->getValue(), - 'adjustment_negative' => - $this->orderCreditMemoNew->getTotalsBlock()->getAdjustmentFeeElement()->getValue(), - ]; - - foreach ($compareData as $fieldName => $fieldValue) { - if (isset($data['form_data'][$fieldName]) && $fieldValue != $data['form_data'][$fieldName]) { - return true; - } - } - - return false; - } } diff --git a/dev/tests/functional/tests/app/Magento/Setup/Test/TestCase/UpgradeSystemTest.php b/dev/tests/functional/tests/app/Magento/Setup/Test/TestCase/UpgradeSystemTest.php index c9b3ce35e84e..7a82b43dba76 100644 --- a/dev/tests/functional/tests/app/Magento/Setup/Test/TestCase/UpgradeSystemTest.php +++ b/dev/tests/functional/tests/app/Magento/Setup/Test/TestCase/UpgradeSystemTest.php @@ -132,6 +132,8 @@ public function test( // Check application version $this->adminDashboard->open(); + $this->adminDashboard->getModalMessage()->dismissIfModalAppears(); + $this->adminDashboard->getModalMessage()->waitModalWindowToDisappear(); $assertApplicationVersion->processAssert($this->adminDashboard, $version); } } 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 index 5c27776c0962..eb949dccb7ff 100644 --- 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 @@ -163,6 +163,30 @@ function () { ); } + /** + * Dismiss the modal if it appears + * + * @return void + */ + public function dismissIfModalAppears() + { + $browser = $this->browser; + $selector = $this->dismissWarningSelector; + $browser->waitUntil( + function () use ($browser, $selector) { + $item = $browser->find($selector); + if ($item->isVisible()) { + return true; + } + $this->waitModalAnimationFinished(); + return true; + } + ); + if ($this->browser->find($selector)->isVisible()) { + $this->browser->find($selector)->click(); + } + } + /** * Waiting until CSS animation is done. * Transition-duration is set at this file: "<magento_root>/lib/web/css/source/components/_modals.less" 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 42914cd697bf..81d9fe8393ae 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 @@ -117,6 +117,8 @@ public function testDeleteAdminUserEntity( $this->adminAuthLogin->open(); $this->adminAuthLogin->getLoginBlock()->fill($user); $this->adminAuthLogin->getLoginBlock()->submit(); + $this->adminAuthLogin->waitForHeaderBlock(); + $this->adminAuthLogin->dismissAdminUsageNotification(); } $this->userIndex->open(); $this->userIndex->getUserGrid()->searchAndOpen($filter); 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 47c5a4095830..2a1c9feb440b 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 @@ -117,6 +117,8 @@ public function testDeleteAdminUserRole( $this->adminAuthLogin->open(); $this->adminAuthLogin->getLoginBlock()->fill($adminUser); $this->adminAuthLogin->getLoginBlock()->submit(); + $this->adminAuthLogin->waitForHeaderBlock(); + $this->adminAuthLogin->dismissAdminUsageNotification(); } $this->userRoleIndex->open(); $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php index e8869de13462..dab4cec22c86 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.php @@ -147,6 +147,8 @@ public function testUpdateAdminUser( $this->adminAuth->open(); $this->adminAuth->getLoginBlock()->fill($initialUser); $this->adminAuth->getLoginBlock()->submit(); + $this->adminAuth->waitForHeaderBlock(); + $this->adminAuth->dismissAdminUsageNotification(); } $this->userIndex->open(); $this->userIndex->getUserGrid()->searchAndOpen($filter); diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php index 58450abc7163..c7031e9fccbe 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserRoleEntityTest.php @@ -102,6 +102,8 @@ public function testUpdateAdminUserRolesEntity( $this->adminAuthLogin->open(); $this->adminAuthLogin->getLoginBlock()->fill($user); $this->adminAuthLogin->getLoginBlock()->submit(); + $this->adminAuthLogin->waitForHeaderBlock(); + $this->adminAuthLogin->dismissAdminUsageNotification(); $this->rolePage->open(); $this->rolePage->getRoleGrid()->searchAndOpen($filter); $this->userRoleEditRole->getRoleFormTabs()->fill($role); diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php b/dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php index c244e27d4289..3e2a3a3d59fc 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestStep/LoginUserOnBackendStep.php @@ -119,6 +119,8 @@ private function login() { $this->adminAuth->getLoginBlock()->fill($this->user); $this->adminAuth->getLoginBlock()->submit(); + $this->adminAuth->waitForHeaderBlock(); + $this->adminAuth->dismissAdminUsageNotification(); $this->adminAuth->getLoginBlock()->waitFormNotVisible(); } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php index 9c5ffb9dd801..c12b2d099122 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php @@ -7,6 +7,7 @@ namespace Magento\Wishlist\Test\TestCase; use Magento\Customer\Test\Fixture\Customer; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Test Flow: @@ -30,15 +31,26 @@ class AddProductToWishlistEntityTest extends AbstractWishlistTest const MVP = 'no'; /* end tags */ + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Prepare data for test * * @param Customer $customer + * @param EnvWhitelist $envWhitelist * @return array */ - public function __prepare(Customer $customer) - { + public function __prepare( + Customer $customer, + EnvWhitelist $envWhitelist + ) { $customer->persist(); + $this->envWhitelist = $envWhitelist; return ['customer' => $customer]; } @@ -53,6 +65,7 @@ public function __prepare(Customer $customer) */ public function test(Customer $customer, $product, $configure = true) { + $this->envWhitelist->addHost('example.com'); $product = $this->createProducts($product)[0]; // Steps: @@ -61,4 +74,14 @@ public function test(Customer $customer, $product, $configure = true) return ['product' => $product]; } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.php index ee3bf77a1aa0..27c60281660b 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ConfigureProductInCustomerWishlistOnBackendTest.php @@ -9,6 +9,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Preconditions: @@ -35,15 +36,26 @@ class ConfigureProductInCustomerWishlistOnBackendTest extends AbstractWishlistTe const MVP = 'no'; /* end tags */ + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Create customer. * * @param Customer $customer + * @param EnvWhitelist $envWhitelist * @return array */ - public function __prepare(Customer $customer) - { + public function __prepare( + Customer $customer, + EnvWhitelist $envWhitelist + ) { $customer->persist(); + $this->envWhitelist = $envWhitelist; return ['customer' => $customer]; } @@ -64,6 +76,7 @@ public function test( CustomerIndexEdit $customerIndexEdit ) { // Preconditions + $this->envWhitelist->addHost('example.com'); $product = $this->createProducts($product)[0]; $this->loginCustomer($customer); $this->addToWishlist([$product]); @@ -80,4 +93,14 @@ public function test( return['product' => $product]; } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ViewProductInCustomerWishlistOnBackendTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ViewProductInCustomerWishlistOnBackendTest.php index f81f87d5b622..1bba73cdf5e9 100644 --- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ViewProductInCustomerWishlistOnBackendTest.php +++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/ViewProductInCustomerWishlistOnBackendTest.php @@ -9,6 +9,7 @@ use Magento\Customer\Test\Fixture\Customer; use Magento\Customer\Test\Page\Adminhtml\CustomerIndex; use Magento\Customer\Test\Page\Adminhtml\CustomerIndexEdit; +use Magento\Mtf\Util\Command\Cli\EnvWhitelist; /** * Test Flow: @@ -34,15 +35,26 @@ class ViewProductInCustomerWishlistOnBackendTest extends AbstractWishlistTest const MVP = 'no'; /* end tags */ + /** + * DomainWhitelist CLI + * + * @var EnvWhitelist + */ + private $envWhitelist; + /** * Prepare customer for test. * * @param Customer $customer + * @param EnvWhitelist $envWhitelist * @return array */ - public function __prepare(Customer $customer) - { + public function __prepare( + Customer $customer, + EnvWhitelist $envWhitelist + ) { $customer->persist(); + $this->envWhitelist = $envWhitelist; return ['customer' => $customer]; } @@ -63,6 +75,7 @@ public function test( CustomerIndexEdit $customerIndexEdit ) { // Preconditions + $this->envWhitelist->addHost('example.com'); $product = $this->createProducts($product)[0]; $this->loginCustomer($customer); $this->addToWishlist([$product], true); @@ -74,4 +87,14 @@ public function test( return['product' => $product]; } + + /** + * Clean data after running test. + * + * @return void + */ + public function tearDown() + { + $this->envWhitelist->removeHost('example.com'); + } } diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml index 6a8e2c615f84..2eae769416c2 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/acceptance.xml @@ -13,6 +13,7 @@ </allow> <deny> <tag group="stable" value="no" /> + <tag group="mftf_migrated" value="yes" /> </deny> </rule> <rule scope="variation"> @@ -21,6 +22,7 @@ </allow> <deny> <tag group="stable" value="no" /> + <tag group="mftf_migrated" value="yes" /> </deny> </rule> </config> diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic_green.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic_green.xml index 17578fcfe85b..614115151833 100644 --- a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic_green.xml +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/basic_green.xml @@ -22,7 +22,7 @@ </rule> <rule scope="variation"> <deny> - <tag group="test_type" value="3rd_party_test, 3rd_party_test_single_flow" /> + <tag group="test_type" value="3rd_party_test, 3rd_party_test_single_flow, mysql_search" /> <tag group="stable" value="no" /> <tag group="mftf_migrated" value="yes" /> <tag group="to_maintain" value="yes" /> diff --git a/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/mysql_search.xml b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/mysql_search.xml new file mode 100644 index 000000000000..17578fcfe85b --- /dev/null +++ b/dev/tests/functional/testsuites/Magento/Mtf/TestSuite/InjectableTests/mysql_search.xml @@ -0,0 +1,31 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../../../../../vendor/magento/mtf/Magento/Mtf/TestRunner/etc/testRunner.xsd"> + <rule scope="testcase"> + <deny> + <tag group="stable" value="no" /> + <tag group="to_maintain" value="yes" /> + <tag group="mftf_migrated" value="yes" /> + </deny> + </rule> + <rule scope="testsuite"> + <deny> + <module value="Magento_Setup" strict="1" /> + <module value="Magento_SampleData" strict="1" /> + </deny> + </rule> + <rule scope="variation"> + <deny> + <tag group="test_type" value="3rd_party_test, 3rd_party_test_single_flow" /> + <tag group="stable" value="no" /> + <tag group="mftf_migrated" value="yes" /> + <tag group="to_maintain" value="yes" /> + </deny> + </rule> +</config> diff --git a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/etc/module.xml b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/etc/module.xml new file mode 100644 index 000000000000..bae0739d237e --- /dev/null +++ b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/etc/module.xml @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> + <module name="Magento_TestModuleCatalogSearch"> + <sequence> + <module name="Magento_CatalogSearch"/> + </sequence> + </module> +</config> diff --git a/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/registration.php b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/registration.php new file mode 100644 index 000000000000..78fb97a9e113 --- /dev/null +++ b/dev/tests/integration/_files/Magento/TestModuleCatalogSearch/registration.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Framework\Component\ComponentRegistrar; + +$registrar = new ComponentRegistrar(); +if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleCatalogSearch') === null) { + ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleCatalogSearch', __DIR__); +} diff --git a/dev/tests/integration/framework/Magento/TestFramework/Mail/Template/TransportBuilderMock.php b/dev/tests/integration/framework/Magento/TestFramework/Mail/Template/TransportBuilderMock.php index 9f697a1be633..cd9512c22789 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Mail/Template/TransportBuilderMock.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Mail/Template/TransportBuilderMock.php @@ -6,6 +6,9 @@ namespace Magento\TestFramework\Mail\Template; +/** + * Class TransportBuilderMock + */ class TransportBuilderMock extends \Magento\Framework\Mail\Template\TransportBuilder { /** @@ -38,11 +41,12 @@ public function getSentMessage() * Return transport mock. * * @return \Magento\TestFramework\Mail\TransportInterfaceMock + * @throws \Magento\Framework\Exception\LocalizedException */ public function getTransport() { $this->prepareMessage(); $this->reset(); - return new \Magento\TestFramework\Mail\TransportInterfaceMock(); + return new \Magento\TestFramework\Mail\TransportInterfaceMock($this->message); } } diff --git a/dev/tests/integration/framework/Magento/TestFramework/Mail/TransportInterfaceMock.php b/dev/tests/integration/framework/Magento/TestFramework/Mail/TransportInterfaceMock.php index 8f967b501a59..5bf98b76e7d5 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Mail/TransportInterfaceMock.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Mail/TransportInterfaceMock.php @@ -6,8 +6,28 @@ namespace Magento\TestFramework\Mail; +use Magento\Framework\Mail\EmailMessageInterface; + +/** + * Class TransportInterfaceMock + */ class TransportInterfaceMock implements \Magento\Framework\Mail\TransportInterface { + /** + * @var null|EmailMessageInterface + */ + private $message; + + /** + * TransportInterfaceMock constructor. + * + * @param null|EmailMessageInterface $message + */ + public function __construct($message = null) + { + $this->message = $message; + } + /** * Mock of send a mail using transport * @@ -15,16 +35,17 @@ class TransportInterfaceMock implements \Magento\Framework\Mail\TransportInterfa */ public function sendMessage() { + //phpcs:ignore Squiz.PHP.NonExecutableCode.ReturnNotRequired return; } /** * Get message * - * @return string + * @return null|EmailMessageInterface */ public function getMessage() { - return ''; + return $this->message; } } diff --git a/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php b/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php index 794e589002e7..fa3869d49bd2 100644 --- a/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php +++ b/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Customer/PlaceOrderWithAuthorizeNetTest.php @@ -108,7 +108,7 @@ public function testDispatchToPlaceOrderWithRegisteredCustomer(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } @@ -142,12 +142,12 @@ public function testDispatchToPlaceOrderWithRegisteredCustomer(): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } diff --git a/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/PlaceOrderWithAuthorizeNetTest.php b/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/PlaceOrderWithAuthorizeNetTest.php index 070543a0880e..4946448f91cc 100644 --- a/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/PlaceOrderWithAuthorizeNetTest.php +++ b/dev/tests/integration/testsuite/Magento/AuthorizenetGraphQl/Model/Resolver/Guest/PlaceOrderWithAuthorizeNetTest.php @@ -108,7 +108,7 @@ public function testDispatchToPlaceAnOrderWithAuthorizenet(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } @@ -137,12 +137,12 @@ public function testDispatchToPlaceAnOrderWithAuthorizenet(): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php index 88662a65c742..a930244238ef 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Model/Locale/ResolverTest.php @@ -20,6 +20,9 @@ class ResolverTest extends \PHPUnit\Framework\TestCase */ protected $_model; + /** + * {@inheritDoc} + */ protected function setUp() { parent::setUp(); @@ -29,7 +32,7 @@ protected function setUp() } /** - * @covers \Magento\Backend\Model\Locale\Resolver::setLocale + * Tests setLocale() with default locale */ public function testSetLocaleWithDefaultLocale() { @@ -37,7 +40,7 @@ public function testSetLocaleWithDefaultLocale() } /** - * @covers \Magento\Backend\Model\Locale\Resolver::setLocale + * Tests setLocale() with interface locale */ public function testSetLocaleWithBaseInterfaceLocale() { @@ -55,7 +58,7 @@ public function testSetLocaleWithBaseInterfaceLocale() } /** - * @covers \Magento\Backend\Model\Locale\Resolver::setLocale + * Tests setLocale() with session locale */ public function testSetLocaleWithSessionLocale() { @@ -68,7 +71,7 @@ public function testSetLocaleWithSessionLocale() } /** - * @covers \Magento\Backend\Model\Locale\Resolver::setLocale + * Tests setLocale() with post parameter */ public function testSetLocaleWithRequestLocale() { @@ -78,13 +81,45 @@ public function testSetLocaleWithRequestLocale() $this->_checkSetLocale('de_DE'); } + /** + * Tests setLocale() with parameter + * + * @param string|null $localeParam + * @param string|null $localeRequestParam + * @param string $localeExpected + * @dataProvider setLocaleWithParameterDataProvider + */ + public function testSetLocaleWithParameter( + ?string $localeParam, + ?string $localeRequestParam, + string $localeExpected + ) { + $request = Bootstrap::getObjectManager() + ->get(\Magento\Framework\App\RequestInterface::class); + $request->setPostValue(['locale' => $localeRequestParam]); + $this->_model->setLocale($localeParam); + $this->assertEquals($localeExpected, $this->_model->getLocale()); + } + + /** + * @return array + */ + public function setLocaleWithParameterDataProvider(): array + { + return [ + ['ko_KR', 'ja_JP', 'ja_JP'], + ['ko_KR', null, 'ko_KR'], + [null, 'ja_JP', 'ja_JP'], + ]; + } + /** * Check set locale * * @param string $localeCodeToCheck * @return void */ - protected function _checkSetLocale($localeCodeToCheck) + private function _checkSetLocale($localeCodeToCheck) { $this->_model->setLocale(); $localeCode = $this->_model->getLocale(); diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php index d6ea08a2f7ca..55d8c6a6a217 100644 --- a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php @@ -62,7 +62,7 @@ protected function tearDown() * during creation second partial invoice. * * @return void - * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magneto + * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magento * @magentoConfigFixture current_store payment/braintree/merchant_account_id USA_Merchant * @magentoDataFixture Magento/Braintree/Fixtures/partial_invoice.php */ @@ -71,11 +71,14 @@ public function testCreatePartialInvoiceWithNonDefaultMerchantAccount(): void $order = $this->getOrder('100000002'); $this->adapter->method('sale') - ->with(self::callback(function ($request) { - self::assertEquals('USA_Merchant', $request['merchantAccountId']); - return true; - })) - ->willReturn($this->getTransactionStub()); + ->with( + self::callback( + function ($request) { + self::assertEquals('USA_Merchant', $request['merchantAccountId']); + return true; + } + ) + )->willReturn($this->getTransactionStub()); $uri = 'backend/sales/order_invoice/save/order_id/' . $order->getEntityId(); $this->prepareRequest($uri); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Controller/Adminhtml/ProductTest.php new file mode 100644 index 000000000000..4c598c16c3c4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/Controller/Adminhtml/ProductTest.php @@ -0,0 +1,238 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Bundle\Controller\Adminhtml; + +use Magento\Bundle\Api\Data\OptionInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Provide tests for product admin controllers. + * @magentoAppArea adminhtml + */ +class ProductTest extends AbstractBackendController +{ + /** + * Test bundle product duplicate won't remove bundle options from original product. + * + * @magentoDataFixture Magento/Catalog/_files/products_new.php + * @return void + */ + public function testDuplicateProduct() + { + $params = $this->getRequestParamsForDuplicate(); + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setParams(['type' => Type::TYPE_BUNDLE]); + $this->getRequest()->setPostValue($params); + $this->dispatch('backend/catalog/product/save'); + $this->assertSessionMessages( + $this->equalTo( + [ + 'You saved the product.', + 'You duplicated the product.', + ] + ), + MessageInterface::TYPE_SUCCESS + ); + $this->assertOptions(); + } + + /** + * Get necessary request post params for creating and duplicating bundle product. + * + * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + private function getRequestParamsForDuplicate() + { + $product = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class)->get('simple'); + return [ + 'product' => + [ + 'attribute_set_id' => '4', + 'gift_message_available' => '0', + 'use_config_gift_message_available' => '1', + 'stock_data' => + [ + 'min_qty_allowed_in_shopping_cart' => + [ + [ + 'record_id' => '0', + 'customer_group_id' => '32000', + 'min_sale_qty' => '', + ], + ], + 'min_qty' => '0', + 'max_sale_qty' => '10000', + 'notify_stock_qty' => '1', + 'min_sale_qty' => '1', + 'qty_increments' => '1', + 'use_config_manage_stock' => '1', + 'manage_stock' => '1', + 'use_config_min_qty' => '1', + 'use_config_max_sale_qty' => '1', + 'use_config_backorders' => '1', + 'backorders' => '0', + 'use_config_notify_stock_qty' => '1', + 'use_config_enable_qty_inc' => '1', + 'enable_qty_increments' => '0', + 'use_config_qty_increments' => '1', + 'use_config_min_sale_qty' => '1', + 'is_qty_decimal' => '0', + 'is_decimal_divided' => '0', + ], + 'status' => '1', + 'affect_product_custom_options' => '1', + 'name' => 'b1', + 'price' => '', + 'weight' => '', + 'url_key' => '', + 'special_price' => '', + 'quantity_and_stock_status' => + [ + 'qty' => '', + 'is_in_stock' => '1', + ], + 'sku_type' => '0', + 'price_type' => '0', + 'weight_type' => '0', + 'website_ids' => + [ + 1 => '1', + ], + 'sku' => 'b1', + 'meta_title' => 'b1', + 'meta_keyword' => 'b1', + 'meta_description' => 'b1 ', + 'tax_class_id' => '2', + 'product_has_weight' => '1', + 'visibility' => '4', + 'country_of_manufacture' => '', + 'page_layout' => '', + 'options_container' => 'container2', + 'custom_design' => '', + 'custom_layout' => '', + 'price_view' => '0', + 'shipment_type' => '0', + 'news_from_date' => '', + 'news_to_date' => '', + 'custom_design_from' => '', + 'custom_design_to' => '', + 'special_from_date' => '', + 'special_to_date' => '', + 'description' => '', + 'short_description' => '', + 'custom_layout_update' => '', + 'image' => '', + 'small_image' => '', + 'thumbnail' => '', + ], + 'bundle_options' => + [ + 'bundle_options' => + [ + [ + 'record_id' => '0', + 'type' => 'select', + 'required' => '1', + 'title' => 'test option title', + 'position' => '1', + 'option_id' => '', + 'delete' => '', + 'bundle_selections' => + [ + [ + 'product_id' => $product->getId(), + 'name' => $product->getName(), + 'sku' => $product->getSku(), + 'price' => $product->getPrice(), + 'delete' => '', + 'selection_can_change_qty' => '', + 'selection_id' => '', + 'selection_price_type' => '0', + 'selection_price_value' => '', + 'selection_qty' => '1', + 'position' => '1', + 'option_id' => '', + 'record_id' => '1', + 'is_default' => '0', + ], + ], + 'bundle_button_proxy' => + [ + [ + 'entity_id' => '1', + ], + ], + ], + ], + ], + 'affect_bundle_product_selections' => '1', + 'back' => 'duplicate', + 'form_key' => Bootstrap::getObjectManager()->get(FormKey::class)->getFormKey(), + ]; + } + + /** + * Check options in created and duplicated products. + * + * @return void + */ + private function assertOptions() + { + $createdOptions = $this->getProductOptions('b1'); + $createdOption = array_shift($createdOptions); + $duplicatedOptions = $this->getProductOptions('b1-1'); + $duplicatedOption = array_shift($duplicatedOptions); + $this->assertNotEmpty($createdOption); + $this->assertNotEmpty($duplicatedOption); + $optionFields = ['type', 'title', 'position', 'required', 'default_title']; + foreach ($optionFields as $field) { + $this->assertSame($createdOption->getData($field), $duplicatedOption->getData($field)); + } + $createdLinks = $createdOption->getProductLinks(); + $createdLink = array_shift($createdLinks); + $duplicatedLinks = $duplicatedOption->getProductLinks(); + $duplicatedLink = array_shift($duplicatedLinks); + $this->assertNotEmpty($createdLink); + $this->assertNotEmpty($duplicatedLink); + $linkFields = [ + 'entity_id', + 'sku', + 'position', + 'is_default', + 'price', + 'qty', + 'selection_can_change_quantity', + 'price_type', + ]; + foreach ($linkFields as $field) { + $this->assertSame($createdLink->getData($field), $duplicatedLink->getData($field)); + } + } + + /** + * Get options for given product. + * + * @param string $sku + * @return OptionInterface[] + */ + private function getProductOptions(string $sku) + { + $product = Bootstrap::getObjectManager()->create(Product::class); + $productId = $product->getResource()->getIdBySku($sku); + $product->load($productId); + + return $product->getExtensionAttributes()->getBundleProductOptions(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options.php new file mode 100644 index 000000000000..c00fd2435a9f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options.php @@ -0,0 +1,129 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +require __DIR__ . '/../../../Magento/Catalog/_files/multiple_products.php'; + +use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory; +use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$productIds = [10, 11, 12]; +foreach ($productIds as $productId) { + /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */ + $stockItem = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Item::class); + $stockItem->load($productId, 'product_id'); + + if (!$stockItem->getProductId()) { + $stockItem->setProductId($productId); + } + $stockItem->setUseConfigManageStock(1); + $stockItem->setQty(1000); + $stockItem->setIsQtyDecimal(0); + $stockItem->setIsInStock(1); + $stockItem->save(); +} + +/** @var $product \Magento\Catalog\Model\Product */ +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) + ->setId(3) + ->setAttributeSetId(4) + ->setWebsiteIds([1]) + ->setName('Bundle Product') + ->setSku('bundle-product') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]) + ->setPriceView(0) + ->setSkuType(1) + ->setWeightType(1) + ->setPriceType(0) + ->setPrice(10.0) + ->setSpecialPrice(10) + ->setShipmentType(0) + ->setBundleOptionsData( + [ + // Required "Drop-down" option + [ + 'title' => 'Option 1', + 'default_title' => 'Option 1', + 'type' => 'select', + 'required' => 1, + 'delete' => '', + ], + + ] + )->setBundleSelectionsData( + [ + [ + [ + 'product_id' => 10, + 'selection_qty' => 1, + 'selection_price_value' => 2.75, + 'selection_can_change_qty' => 1, + 'delete' => '', + 'option_id' => 1 + ], + [ + 'product_id' => 11, + 'selection_qty' => 1, + 'selection_price_value' => 6.75, + 'selection_can_change_qty' => 1, + 'delete' => '', + 'option_id' => 1 + ] + ] + ] + ); +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +if ($product->getBundleOptionsData()) { + $options = []; + foreach ($product->getBundleOptionsData() as $key => $optionData) { + if (!(bool)$optionData['delete']) { + $option = $objectManager->create(\Magento\Bundle\Api\Data\OptionInterfaceFactory::class) + ->create(['data' => $optionData]); + $option->setSku($product->getSku()); + $option->setOptionId(null); + + $links = []; + $bundleLinks = $product->getBundleSelectionsData(); + if (!empty($bundleLinks[$key])) { + foreach ($bundleLinks[$key] as $linkData) { + if (!(bool)$linkData['delete']) { + $link = $objectManager->create(\Magento\Bundle\Api\Data\LinkInterfaceFactory::class) + ->create(['data' => $linkData]); + $linkProduct = $productRepository->getById($linkData['product_id']); + $link->setSku($linkProduct->getSku()); + $link->setQty($linkData['selection_qty']); + $link->setPrice($linkData['selection_price_value']); + $links[] = $link; + } + } + $option->setProductLinks($links); + $options[] = $option; + } + } + } + $extension = $product->getExtensionAttributes(); + $extension->setBundleProductOptions($options); + $product->setExtensionAttributes($extension); +} +$tierPriceFactory = $objectManager->get(ProductTierPriceInterfaceFactory::class); +/** @var $tierPriceExtensionAttributesFactory */ +$tierPriceExtensionAttributesFactory = $objectManager->create(ProductTierPriceExtensionFactory::class); +$tierPriceExtensionAttribute = $tierPriceExtensionAttributesFactory->create()->setPercentageValue(10); +$tierPrices[] = $tierPriceFactory->create( + [ + 'data' => [ + 'customer_group_id' => \Magento\Customer\Model\Group::CUST_GROUP_ALL, + 'qty' => 2 + ] + ] +)->setExtensionAttributes($tierPriceExtensionAttribute); +$product->setTierPrices($tierPrices); +$product->save(); diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options_rollback.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options_rollback.php new file mode 100644 index 000000000000..a17e2604d9d0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/dynamic_bundle_product_with_multiple_options_rollback.php @@ -0,0 +1,7 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +require __DIR__ . '/../../../Magento/Bundle/_files/product_with_multiple_options_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UrlRewriteTest.php new file mode 100644 index 000000000000..90f354d90f17 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/Save/UrlRewriteTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Controller\Adminhtml\Category\Save; + +use Magento\CatalogUrlRewrite\Model\Map\DataCategoryUrlRewriteDatabaseMap; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Serialize\Serializer\Json; +use Magento\TestFramework\TestCase\AbstractBackendController; +use Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollectionFactory; +use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; + +/** + * Class defines url rewrite creation for category save controller + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class UrlRewriteTest extends AbstractBackendController +{ + /** @var $urlRewriteCollectionFactory */ + private $urlRewriteCollectionFactory; + + /** @var Json */ + private $jsonSerializer; + + /** + * @inheritDoc + */ + protected function setUp() + { + parent::setUp(); + + $this->urlRewriteCollectionFactory = $this->_objectManager->get(UrlRewriteCollectionFactory::class); + $this->jsonSerializer = $this->_objectManager->get(Json::class); + } + + /** + * @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1 + * @dataProvider categoryDataProvider + * @param array $data + * @return void + */ + public function testUrlRewrite(array $data): void + { + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue($data); + $this->dispatch('backend/catalog/category/save'); + $categoryId = $this->jsonSerializer->unserialize($this->getResponse()->getBody())['category']['entity_id']; + $this->assertNotNull($categoryId, 'The category was not created'); + $urlRewriteCollection = $this->urlRewriteCollectionFactory->create(); + $urlRewriteCollection->addFieldToFilter(UrlRewrite::ENTITY_ID, ['eq' => $categoryId]) + ->addFieldToFilter(UrlRewrite::ENTITY_TYPE, ['eq' => DataCategoryUrlRewriteDatabaseMap::ENTITY_TYPE]); + $this->assertCount( + 1, + $urlRewriteCollection->getItems(), + 'Wrong count of url rewrites was created' + ); + } + + /** + * @return array + */ + public function categoryDataProvider(): array + { + return [ + 'url_rewrite_is_created_during_category_save' => [ + [ + 'path' => '1/2', + 'name' => 'Custom Name', + 'parent' => 2, + 'is_active' => '0', + 'include_in_menu' => '1', + 'display_mode' => 'PRODUCTS', + 'is_anchor' => true, + 'return_session_messages_only' => true, + 'use_config' => [ + 'available_sort_by' => 1, + 'default_sort_by' => 1, + 'filter_price_range' => 1, + ], + ], + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php index 1001d58ee8a6..c0eeb75592a5 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php @@ -3,39 +3,58 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Controller\Adminhtml; +use Magento\Backend\App\Area\FrontNameResolver; +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Model\Category as Category; +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Serialize\Serializer\Json; +use Magento\Store\Api\StoreRepositoryInterface; +use Magento\TestFramework\TestCase\AbstractBackendController; use Magento\TestFramework\Helper\Bootstrap; -use Magento\Store\Model\Store; -use Magento\Catalog\Model\ResourceModel\Product; /** + * Test for category backend actions + * * @magentoAppArea adminhtml */ -class CategoryTest extends \Magento\TestFramework\TestCase\AbstractBackendController +class CategoryTest extends AbstractBackendController { /** - * @var \Magento\Catalog\Model\ResourceModel\Product + * @var ProductResource */ protected $productResource; + /** @var CategoryRepositoryInterface */ + private $categoryRepository; + + /** @var StoreRepositoryInterface */ + private $storeRepository; + + /** @var Json */ + private $json; + /** - * @inheritDoc - * - * @throws \Magento\Framework\Exception\AuthenticationException + * @inheritdoc */ protected function setUp() { parent::setUp(); - - /** @var Product $productResource */ - $this->productResource = Bootstrap::getObjectManager()->get( - Product::class - ); + /** @var ProductResource $productResource */ + $this->productResource = $this->_objectManager->get(ProductResource::class); + $this->categoryRepository = $this->_objectManager->get(CategoryRepositoryInterface::class); + $this->storeRepository = $this->_objectManager->get(StoreRepositoryInterface::class); + $this->json = $this->_objectManager->get(Json::class); } /** + * Test save action. + * * @magentoDataFixture Magento/Store/_files/core_fixturestore.php * @magentoDbIsolation enabled * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 @@ -43,35 +62,23 @@ protected function setUp() * @param array $inputData * @param array $defaultAttributes * @param array $attributesSaved - * @param bool $isSuccess + * @return void */ - public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = [], $isSuccess = true) + public function testSaveAction(array $inputData, array $defaultAttributes, array $attributesSaved = []): void { - /** @var $store \Magento\Store\Model\Store */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); - $store->load('fixturestore', 'code'); + $store = $this->storeRepository->get('fixturestore'); $storeId = $store->getId(); - $this->getRequest()->setMethod(HttpRequest::METHOD_POST); $this->getRequest()->setPostValue($inputData); $this->getRequest()->setParam('store', $storeId); $this->getRequest()->setParam('id', 2); $this->dispatch('backend/catalog/category/save'); - - if ($isSuccess) { - $this->assertSessionMessages( - $this->equalTo(['You saved the category.']), - \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS - ); - } - - /** @var $category \Magento\Catalog\Model\Category */ - $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Category::class + $this->assertSessionMessages( + $this->equalTo(['You saved the category.']), + MessageInterface::TYPE_SUCCESS ); - $category->setStoreId($storeId); - $category->load(2); - + /** @var $category Category */ + $category = $this->categoryRepository->get(2, $storeId); $errors = []; foreach ($attributesSaved as $attribute => $value) { $actualValue = $category->getData($attribute); @@ -95,11 +102,53 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved } /** + * Check default value for category url path + * + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories.php + * @return void + */ + public function testDefaultValueForCategoryUrlPath(): void + { + $categoryId = 3; + $category = $this->categoryRepository->get($categoryId); + $newUrlPath = 'test_url_path'; + $defaultUrlPath = $category->getData('url_path'); + + // update url_path and check it + $category->setStoreId(1); + $category->setUrlKey($newUrlPath); + $category->setUrlPath($newUrlPath); + $this->categoryRepository->save($category); + $this->assertEquals($newUrlPath, $category->getUrlPath()); + + // set default url_path and check it + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $postData = $category->getData(); + $postData['use_default'] = [ + 'available_sort_by' => 1, + 'default_sort_by' => 1, + 'url_key' => 1, + ]; + $this->getRequest()->setPostValue($postData); + $this->dispatch('backend/catalog/category/save'); + $this->assertSessionMessages( + $this->equalTo([(string)__('You saved the category.')]), + MessageInterface::TYPE_SUCCESS + ); + $category = $this->categoryRepository->get($categoryId); + $this->assertEquals($defaultUrlPath, $category->getData('url_path')); + } + + /** + * Test save action from product form page + * * @param array $postData * @dataProvider categoryCreatedFromProductCreationPageDataProvider * @magentoDbIsolation enabled + * @return void */ - public function testSaveActionFromProductCreationPage($postData) + public function testSaveActionFromProductCreationPage(array $postData): void { $this->getRequest()->setMethod(HttpRequest::METHOD_POST); $this->getRequest()->setPostValue($postData); @@ -112,11 +161,7 @@ public function testSaveActionFromProductCreationPage($postData) $this->stringContains('http://localhost/index.php/backend/catalog/category/edit/') ); } else { - $result = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\Json\Helper\Data::class - )->jsonDecode( - $body - ); + $result = $this->json->unserialize($body); $this->assertArrayHasKey('messages', $result); $this->assertFalse($result['error']); $category = $result['category']; @@ -130,10 +175,12 @@ public function testSaveActionFromProductCreationPage($postData) } /** + * Get category post data + * * @static * @return array */ - public static function categoryCreatedFromProductCreationPageDataProvider() + public static function categoryCreatedFromProductCreationPageDataProvider(): array { /* Keep in sync with new-category-dialog.js */ $postData = [ @@ -152,8 +199,10 @@ public static function categoryCreatedFromProductCreationPageDataProvider() /** * Test SuggestCategories finds any categories. + * + * @return void */ - public function testSuggestCategoriesActionDefaultCategoryFound() + public function testSuggestCategoriesActionDefaultCategoryFound(): void { $this->getRequest()->setParam('label_part', 'Default'); $this->dispatch('backend/catalog/category/suggestCategories'); @@ -165,8 +214,10 @@ public function testSuggestCategoriesActionDefaultCategoryFound() /** * Test SuggestCategories properly processes search by label. + * + * @return void */ - public function testSuggestCategoriesActionNoSuggestions() + public function testSuggestCategoriesActionNoSuggestions(): void { $this->getRequest()->setParam('label_part', strrev('Default')); $this->dispatch('backend/catalog/category/suggestCategories'); @@ -174,10 +225,12 @@ public function testSuggestCategoriesActionNoSuggestions() } /** + * Save action data provider + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @return array */ - public function saveActionDataProvider() + public function saveActionDataProvider(): array { return [ 'default values' => [ @@ -301,64 +354,39 @@ public function saveActionDataProvider() 'filter_price_range' => null ], ], - 'incorrect datefrom' => [ - [ - 'id' => '2', - 'entity_id' => '2', - 'path' => '1/2', - 'name' => 'Custom Name', - 'is_active' => '0', - 'description' => 'Custom Description', - 'meta_title' => 'Custom Title', - 'meta_keywords' => 'Custom keywords', - 'meta_description' => 'Custom meta description', - 'include_in_menu' => '0', - 'url_key' => 'default-category', - 'display_mode' => 'PRODUCTS', - 'landing_page' => '1', - 'is_anchor' => true, - 'custom_apply_to_products' => '0', - 'custom_design' => 'Magento/blank', - 'custom_design_from' => '5/29/2015', - 'custom_design_to' => '5/21/2015', - 'page_layout' => '', - 'custom_layout_update' => '', - 'use_config' => [ - 'available_sort_by' => 1, - 'default_sort_by' => 1, - 'filter_price_range' => 1, - ], - ], - [ - 'name' => false, - 'default_sort_by' => false, - 'display_mode' => false, - 'meta_title' => false, - 'custom_design' => false, - 'page_layout' => false, - 'is_active' => false, - 'include_in_menu' => false, - 'landing_page' => false, - 'custom_apply_to_products' => false, - 'available_sort_by' => false, - 'description' => false, - 'meta_keywords' => false, - 'meta_description' => false, - 'custom_layout_update' => false, - 'custom_design_from' => false, - 'custom_design_to' => false, - 'filter_price_range' => false - ], - [], - false - ] ]; } + /** + * @magentoDbIsolation enabled + * @return void + */ + public function testIncorrectDateFrom(): void + { + $data = [ + 'name' => 'Test Category', + 'attribute_set_id' => '3', + 'parent_id' => 2, + 'path' => '1/2', + 'is_active' => true, + 'custom_design_from' => '5/29/2015', + 'custom_design_to' => '5/21/2015', + ]; + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue($data); + $this->dispatch('backend/catalog/category/save'); + $this->assertSessionMessages( + $this->equalTo([(string)__('Make sure the To Date is later than or the same as the From Date.')]), + MessageInterface::TYPE_ERROR + ); + } + /** * Test validation. + * + * @return void */ - public function testSaveActionCategoryWithDangerRequest() + public function testSaveActionCategoryWithDangerRequest(): void { $this->getRequest()->setMethod(HttpRequest::METHOD_POST); $this->getRequest()->setPostValue( @@ -377,11 +405,13 @@ public function testSaveActionCategoryWithDangerRequest() $this->dispatch('backend/catalog/category/save'); $this->assertSessionMessages( $this->equalTo(['The "Name" attribute value is empty. Set the attribute and try again.']), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR + MessageInterface::TYPE_ERROR ); } /** + * Test move action. + * * @magentoDataFixture Magento/Catalog/_files/category_tree.php * @dataProvider moveActionDataProvider * @@ -391,18 +421,23 @@ public function testSaveActionCategoryWithDangerRequest() * @param int $grandChildId * @param string $grandChildUrlKey * @param boolean $error + * @return void */ - public function testMoveAction($parentId, $childId, $childUrlKey, $grandChildId, $grandChildUrlKey, $error) - { + public function testMoveAction( + int $parentId, + int $childId, + string $childUrlKey, + int $grandChildId, + string $grandChildUrlKey, + bool $error + ): void { $urlKeys = [ $childId => $childUrlKey, $grandChildId => $grandChildUrlKey, ]; foreach ($urlKeys as $categoryId => $urlKey) { - /** @var $category \Magento\Catalog\Model\Category */ - $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Category::class - ); + /** @var $category Category */ + $category = $this->_objectManager->create(Category::class); if ($categoryId > 0) { $category->load($categoryId) ->setUrlKey($urlKey) @@ -414,15 +449,17 @@ public function testMoveAction($parentId, $childId, $childUrlKey, $grandChildId, ->setPostValue('pid', $parentId) ->setMethod(HttpRequest::METHOD_POST); $this->dispatch('backend/catalog/category/move'); - $jsonResponse = json_decode($this->getResponse()->getBody()); + $jsonResponse = $this->json->unserialize($this->getResponse()->getBody()); $this->assertNotNull($jsonResponse); - $this->assertEquals($error, $jsonResponse->error); + $this->assertEquals($error, $jsonResponse['error']); } /** + * Move action data provider + * * @return array */ - public function moveActionDataProvider() + public function moveActionDataProvider(): array { return [ [400, 401, 'first_url_key', 402, 'second_url_key', false], @@ -433,17 +470,17 @@ public function moveActionDataProvider() } /** + * Test save category with product position. + * * @magentoDataFixture Magento/Catalog/_files/products_in_different_stores.php * @magentoDbIsolation disabled * @dataProvider saveActionWithDifferentWebsitesDataProvider * * @param array $postData */ - public function testSaveCategoryWithProductPosition(array $postData) + public function testSaveCategoryWithProductPosition(array $postData): void { - /** @var $store \Magento\Store\Model\Store */ - $store = Bootstrap::getObjectManager()->create(Store::class); - $store->load('fixturestore', 'code'); + $store = $this->storeRepository->get('fixturestore'); $storeId = $store->getId(); $oldCategoryProductsCount = $this->getCategoryProductsCount(); $this->getRequest()->setParam('store', $storeId); @@ -451,6 +488,10 @@ public function testSaveCategoryWithProductPosition(array $postData) $this->getRequest()->setParam('id', 96377); $this->getRequest()->setPostValue($postData); $this->dispatch('backend/catalog/category/save'); + $this->assertSessionMessages( + $this->equalTo([(string)__('You saved the category.')]), + MessageInterface::TYPE_SUCCESS + ); $newCategoryProductsCount = $this->getCategoryProductsCount(); $this->assertEquals( $oldCategoryProductsCount, @@ -460,10 +501,12 @@ public function testSaveCategoryWithProductPosition(array $postData) } /** + * Save action data provider + * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @return array */ - public function saveActionWithDifferentWebsitesDataProvider() + public function saveActionWithDifferentWebsitesDataProvider(): array { return [ 'default_values' => [ @@ -477,7 +520,6 @@ public function saveActionWithDifferentWebsitesDataProvider() 'path' => '1/2/96377', 'level' => '2', 'children_count' => '0', - 'row_id' => '96377', 'name' => 'Category 1', 'display_mode' => 'PRODUCTS', 'url_key' => 'category-1', @@ -541,7 +583,7 @@ public function saveActionWithDifferentWebsitesDataProvider() } /** - * Get items count from catalog_category_product + * Get items count from catalog_category_product. * * @return int */ @@ -555,4 +597,36 @@ private function getCategoryProductsCount(): int $this->productResource->getConnection()->fetchAll($oldCategoryProducts) ); } + + /** + * Verify that the category cannot be saved if the category url matches the admin url. + * + * @magentoConfigFixture admin/url/use_custom_path 1 + * @magentoConfigFixture admin/url/custom_path backend + */ + public function testSaveWithCustomBackendNameAction() + { + $frontNameResolver = Bootstrap::getObjectManager()->create(FrontNameResolver::class); + $urlKey = $frontNameResolver->getFrontName(); + $inputData = [ + 'id' => '2', + 'url_key' => $urlKey, + 'use_config' => [ + 'available_sort_by' => 1, + 'default_sort_by' => 1 + ] + ]; + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue($inputData); + $this->dispatch('backend/catalog/category/save'); + $this->assertSessionMessages( + $this->equalTo( + [ + 'URL key "backend" matches a reserved endpoint name ' + . '(admin, soap, rest, graphql, standard, backend). Use another URL key.' + ] + ), + MessageInterface::TYPE_ERROR + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php new file mode 100644 index 000000000000..a786e7fa821b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php @@ -0,0 +1,280 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Controller\Adminhtml\Product\Gallery; + +use Magento\Catalog\Model\Product\Media\Config; +use Magento\Framework\App\Filesystem\DirectoryList as AppDirectoryList; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\Framework\Filesystem\DirectoryList; +use Magento\Framework\Serialize\Serializer\Json; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Provide tests for admin product upload image action. + * + * @magentoAppArea adminhtml + */ +class UploadTest extends AbstractBackendController +{ + /** + * @inheritdoc + */ + protected $resource = 'Magento_Catalog::products'; + + /** + * @inheritdoc + */ + protected $uri = 'backend/catalog/product_gallery/upload'; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * @var Json + */ + private $serializer; + + /** + * @var WriteInterface + */ + private $mediaDirectory; + + /** + * @var Config + */ + private $config; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->httpMethod = HttpRequest::METHOD_POST; + $this->filesystem = $this->_objectManager->get(Filesystem::class); + $this->serializer = $this->_objectManager->get(Json::class); + $this->mediaDirectory = $this->filesystem->getDirectoryWrite(AppDirectoryList::MEDIA); + $this->config = $this->_objectManager->get(Config::class); + } + + /** + * Test upload image on admin product page. + * + * @dataProvider uploadActionDataProvider + * @magentoDbIsolation enabled + * @param array $file + * @param array $expectation + * @return void + */ + public function testUploadAction(array $file, array $expectation): void + { + $this->copyFileToSysTmpDir($file); + $this->getRequest()->setMethod($this->httpMethod); + $this->dispatch($this->uri); + $jsonBody = $this->serializer->unserialize($this->getResponse()->getBody()); + $this->assertEquals($jsonBody['name'], $expectation['name']); + $this->assertEquals($jsonBody['type'], $expectation['type']); + $this->assertEquals($jsonBody['file'], $expectation['file']); + $this->assertEquals($jsonBody['url'], $expectation['url']); + $this->assertArrayNotHasKey('error', $jsonBody); + $this->assertArrayNotHasKey('errorcode', $jsonBody); + $this->assertFileExists( + $this->getFileAbsolutePath($expectation['tmp_media_path']) + ); + } + + /** + * @return array + */ + public function uploadActionDataProvider(): array + { + return [ + 'upload_image_with_type_jpg' => [ + 'file' => [ + 'name' => 'magento_image.jpg', + 'type' => 'image/jpeg', + 'current_path' => '/../../../../_files', + ], + 'expectation' => [ + 'name' => 'magento_image.jpg', + 'type' => 'image/jpeg', + 'file' => '/m/a/magento_image.jpg.tmp', + 'url' => 'http://localhost/pub/media/tmp/catalog/product/m/a/magento_image.jpg', + 'tmp_media_path' => '/m/a/magento_image.jpg', + ], + ], + 'upload_image_with_type_png' => [ + 'file' => [ + 'name' => 'product_image.png', + 'type' => 'image/png', + 'current_path' => '/../../../../controllers/_files', + ], + 'expectation' => [ + 'name' => 'product_image.png', + 'type' => 'image/png', + 'file' => '/p/r/product_image.png.tmp', + 'url' => 'http://localhost/pub/media/tmp/catalog/product/p/r/product_image.png', + 'tmp_media_path' => '/p/r/product_image.png', + ], + ], + 'upload_image_with_type_gif' => [ + 'file' => [ + 'name' => 'magento_image.gif', + 'type' => 'image/gif', + 'current_path' => '/../../../../_files', + ], + 'expectation' => [ + 'name' => 'magento_image.gif', + 'type' => 'image/gif', + 'file' => '/m/a/magento_image.gif.tmp', + 'url' => 'http://localhost/pub/media/tmp/catalog/product/m/a/magento_image.gif', + 'tmp_media_path' => '/m/a/magento_image.gif', + ], + ], + ]; + } + + /** + * Test upload image on admin product page. + * + * @dataProvider uploadActionWithErrorsDataProvider + * @magentoDbIsolation enabled + * @param array $file + * @param array $expectation + * @return void + */ + public function testUploadActionWithErrors(array $file, array $expectation): void + { + $this->markTestSkipped('MC-21994'); + + if (!empty($file['create_file'])) { + $this->createFileInSysTmpDir($file['name']); + } elseif (!empty($file['copy_file'])) { + $this->copyFileToSysTmpDir($file); + } + + $this->getRequest()->setMethod($this->httpMethod); + $this->dispatch($this->uri); + $jsonBody = $this->serializer->unserialize($this->getResponse()->getBody()); + $this->assertEquals($jsonBody['error'], $expectation['message']); + $this->assertEquals($jsonBody['errorcode'], $expectation['errorcode']); + + if (!empty($expectation['tmp_media_path'])) { + $this->assertFileNotExists( + $this->getFileAbsolutePath($expectation['tmp_media_path']) + ); + } + } + + /** + * @return array + */ + public function uploadActionWithErrorsDataProvider(): array + { + return [ + 'upload_image_with_invalid_type' => [ + 'file' => [ + 'create_file' => true, + 'name' => 'invalid_file.txt', + ], + 'expectation' => [ + 'message' => 'Disallowed file type.', + 'errorcode' => 0, + 'tmp_media_path' => '/i/n/invalid_file.txt', + ], + ], + 'upload_empty_image' => [ + 'file' => [ + 'copy_file' => true, + 'name' => 'magento_empty.jpg', + 'type' => 'image/jpeg', + 'current_path' => '/../../../../_files', + ], + 'expectation' => [ + 'message' => 'Wrong file size.', + 'errorcode' => 0, + 'tmp_media_path' => '/m/a/magento_empty.jpg', + ], + ], + 'upload_without_image' => [ + 'file' => [], + 'expectation' => [ + 'message' => '$_FILES array is empty', + 'errorcode' => 0, + ], + ], + ]; + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $_FILES = []; + $this->mediaDirectory->delete('tmp'); + parent::tearDown(); + } + + /** + * Copies file to tmp dir. + * + * @param array $file + * @return void + */ + private function copyFileToSysTmpDir(array $file): void + { + if (!empty($file)) { + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + $fixtureDir = realpath(__DIR__ . $file['current_path']); + $filePath = $tmpDirectory->getAbsolutePath($file['name']); + copy($fixtureDir . DIRECTORY_SEPARATOR . $file['name'], $filePath); + + $_FILES['image'] = [ + 'name' => $file['name'], + 'type' => $file['type'], + 'tmp_name' => $filePath, + ]; + } + } + + /** + * Creates txt file with given name and copies to tmp dir. + * + * @param string $name + * @return void + */ + private function createFileInSysTmpDir(string $name): void + { + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + $filePath = $tmpDirectory->getAbsolutePath($name); + $file = fopen($filePath, "wb"); + fwrite($file, 'some text'); + + $_FILES['image'] = [ + 'name' => $name, + 'type' => 'text/plain', + 'tmp_name' => $filePath, + ]; + } + + /** + * Returns absolute path to file in media tmp dir. + * + * @param string $tmpPath + * @return string + */ + private function getFileAbsolutePath(string $tmpPath): string + { + return $this->mediaDirectory->getAbsolutePath($this->config->getBaseTmpMediaPath() . $tmpPath); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/CreateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/CreateCustomOptionsTest.php new file mode 100644 index 000000000000..80f15da647b2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/CreateCustomOptionsTest.php @@ -0,0 +1,271 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Controller\Adminhtml\Product\Save; + +use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Base test cases for product custom options with type "field". + * Option add via dispatch product controller action save with options data in POST data. + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class CreateCustomOptionsTest extends AbstractBackendController +{ + /** + * @var ProductRepositoryInterface + */ + private $productRepository; + + /** + * @var ProductCustomOptionRepositoryInterface + */ + private $optionRepository; + + /** + * @inheritDoc + */ + protected function setUp() + { + parent::setUp(); + + $this->productRepository = $this->_objectManager->create(ProductRepositoryInterface::class); + $this->optionRepository = $this->_objectManager->create(ProductCustomOptionRepositoryInterface::class); + } + + /** + * Test add to product custom option with type "field". + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider productWithNewOptionsDataProvider + * + * @param array $productPostData + */ + public function testSaveCustomOptionWithTypeField(array $productPostData): void + { + $this->getRequest()->setPostValue($productPostData); + $product = $this->productRepository->get('simple'); + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId()); + $this->assertSessionMessages( + $this->contains('You saved the product.'), + MessageInterface::TYPE_SUCCESS + ); + $productOptions = $this->optionRepository->getProductOptions($product); + $this->assertCount(2, $productOptions); + foreach ($productOptions as $customOption) { + $postOptionData = $productPostData['product']['options'][$customOption->getTitle()] ?? null; + $this->assertNotNull($postOptionData); + $this->assertEquals($postOptionData['title'], $customOption->getTitle()); + $this->assertEquals($postOptionData['type'], $customOption->getType()); + $this->assertEquals($postOptionData['is_require'], $customOption->getIsRequire()); + $this->assertEquals($postOptionData['sku'], $customOption->getSku()); + $this->assertEquals($postOptionData['price'], $customOption->getPrice()); + $this->assertEquals($postOptionData['price_type'], $customOption->getPriceType()); + $maxCharacters = $postOptionData['max_characters'] ?? 0; + $this->assertEquals($maxCharacters, $customOption->getMaxCharacters()); + } + } + + /** + * Return all data for add option to product for all cases. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * @return array + */ + public function productWithNewOptionsDataProvider(): array + { + return [ + 'required_options' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 1, + 'sku' => 'test-option-title-2', + 'max_characters' => 50, + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + ], + ], + ], + 'not_required_options' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 0, + 'sku' => 'test-option-title-2', + 'max_characters' => 50, + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + ], + ], + ], + 'options_with_fixed_price' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 1, + 'sku' => 'test-option-title-2', + 'max_characters' => 50, + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'percent', + ], + ], + ], + ], + ], + 'options_with_percent_price' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 1, + 'sku' => 'test-option-title-2', + 'max_characters' => 50, + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 20, + 'price_type' => 'percent', + ], + ], + ], + ], + ], + 'options_with_max_charters_configuration' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 30, + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 1, + 'sku' => 'test-option-title-2', + 'max_characters' => 50, + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + ], + ], + ], + 'options_without_max_charters_configuration' => [ + [ + 'product' => [ + 'options' => [ + 'Test option title 1' => [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + 'Test option title 2' => [ + 'record_id' => 1, + 'sort_order' => 2, + 'is_require' => 1, + 'sku' => 'test-option-title-2', + 'title' => 'Test option title 2', + 'type' => 'field', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + ], + ], + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/ImagesTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/ImagesTest.php new file mode 100644 index 000000000000..697980d75a71 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/ImagesTest.php @@ -0,0 +1,145 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Controller\Adminhtml\Product\Save; + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product\Media\Config; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Provide tests for admin product save action with images. + * + * @magentoAppArea adminhtml + */ +class ImagesTest extends AbstractBackendController +{ + /** + * @var Config + */ + private $config; + + /** + * @var WriteInterface + */ + private $mediaDirectory; + + /** + * @var ProductRepositoryInterface + */ + private $productRepository; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->config = $this->_objectManager->get(Config::class); + $this->mediaDirectory = $this->_objectManager->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA); + $this->productRepository = $this->_objectManager->create(ProductRepositoryInterface::class); + } + + /** + * Test save product with default image. + * + * @dataProvider simpleProductImagesDataProvider + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Catalog/_files/product_image.php + * @magentoDbIsolation enabled + * @param array $postData + * @param array $expectation + * @return void + */ + public function testSaveSimpleProductDefaultImage(array $postData, array $expectation): void + { + $product = $this->productRepository->get('simple'); + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue($postData); + $this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId()); + $this->assertSessionMessages( + $this->equalTo(['You saved the product.']), + MessageInterface::TYPE_SUCCESS + ); + $this->assertSuccessfulImageSave($expectation); + } + + /** + * @return array + */ + public function simpleProductImagesDataProvider(): array + { + return [ + 'simple_product_with_jpg_image' => [ + 'post_data' => [ + 'product' => [ + 'media_gallery' => [ + 'images' => [ + 'lrwuv5ukisn' => [ + 'position' => '1', + 'media_type' => 'image', + 'video_provider' => '', + 'file' => '/m/a//magento_image.jpg.tmp', + 'value_id' => '', + 'label' => '', + 'disabled' => '0', + 'removed' => '', + 'role' => '', + ], + ], + ], + 'image' => '/m/a//magento_image.jpg.tmp', + 'small_image' => '/m/a//magento_image.jpg.tmp', + 'thumbnail' => '/m/a//magento_image.jpg.tmp', + 'swatch_image' => '/m/a//magento_image.jpg.tmp', + ], + ], + 'expectation' => [ + 'media_gallery_image' => [ + 'position' => '1', + 'media_type' => 'image', + 'file' => '/m/a/magento_image.jpg', + 'label' => '', + 'disabled' => '0', + ], + 'image' => '/m/a/magento_image.jpg', + 'small_image' => '/m/a/magento_image.jpg', + 'thumbnail' => '/m/a/magento_image.jpg', + 'swatch_image' => '/m/a/magento_image.jpg', + ] + ] + ]; + } + + /** + * @param array $expectation + * @return void + */ + private function assertSuccessfulImageSave(array $expectation): void + { + $product = $this->productRepository->get('simple', false, null, true); + $galleryImage = reset($product->getData('media_gallery')['images']); + $expectedGalleryImage = $expectation['media_gallery_image']; + $this->assertEquals($expectedGalleryImage['position'], $galleryImage['position']); + $this->assertEquals($expectedGalleryImage['media_type'], $galleryImage['media_type']); + $this->assertEquals($expectedGalleryImage['label'], $galleryImage['label']); + $this->assertEquals($expectedGalleryImage['disabled'], $galleryImage['disabled']); + $this->assertEquals($expectedGalleryImage['file'], $galleryImage['file']); + $this->assertEquals($expectation['image'], $product->getData('image')); + $this->assertEquals($expectation['small_image'], $product->getData('small_image')); + $this->assertEquals($expectation['thumbnail'], $product->getData('thumbnail')); + $this->assertEquals($expectation['swatch_image'], $product->getData('swatch_image')); + $this->assertFileExists( + $this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . $expectation['image']) + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/SearchTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/SearchTest.php index 8a33543e9343..cfa8b6022963 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/SearchTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/SearchTest.php @@ -38,7 +38,8 @@ public function testExecuteNonExistingSearchKey() : void ->setPostValue('limit', 50); $this->dispatch('backend/catalog/product/search'); $responseBody = $this->getResponse()->getBody(); - $this->assertContains('{"options":[],"total":0}', $responseBody); + $jsonResponse = json_decode($responseBody, true); + $this->assertEmpty($jsonResponse['options']); } /** @@ -57,6 +58,24 @@ public function testExecuteNotVisibleIndividuallyProducts() : void ->setPostValue('limit', 50); $this->dispatch('backend/catalog/product/search'); $responseBody = $this->getResponse()->getBody(); - $this->assertContains('{"options":[],"total":0}', $responseBody); + $jsonResponse = json_decode($responseBody, true); + $this->assertEquals(1, $jsonResponse['total']); + $this->assertCount(1, $jsonResponse['options']); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/multiple_mixed_products.php + */ + public function testExecuteEnabledAndDisabledProducts() : void + { + $this->getRequest() + ->setPostValue('searchKey', 'simple') + ->setPostValue('page', 1) + ->setPostValue('limit', 50); + $this->dispatch('backend/catalog/product/search'); + $responseBody = $this->getResponse()->getBody(); + $jsonResponse = json_decode($responseBody, true); + $this->assertEquals(6, $jsonResponse['total']); + $this->assertCount(6, $jsonResponse['options']); } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php index 8ccd426424a2..187fddae1ce4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Controller\Adminhtml\Product\Set; use Magento\Eav\Api\AttributeSetRepositoryInterface; @@ -10,9 +12,86 @@ use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Eav\Api\AttributeManagementInterface; +use Magento\Catalog\Api\Data\ProductInterfaceFactory; +use Magento\Framework\Api\DataObjectHelper; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Developer\Model\Logger\Handler\Syslog; +use Magento\Framework\Logger\Monolog; +use Magento\Catalog\Model\Product\Attribute\Repository; +/** + * Test save attribute set + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController { + /** + * @var string + */ + private $systemLogPath = ''; + + /** + * @var Monolog + */ + private $logger; + + /** + * @var Syslog + */ + private $syslogHandler; + + /** + * @var AttributeManagementInterface + */ + private $attributeManagement; + + /** + * @var DataObjectHelper + */ + private $dataObjectHelper; + + /** + * @var ProductRepositoryInterface + */ + private $productRepository; + + /** + * @var Repository + */ + private $attributeRepository; + + /** + * @inheritDoc + */ + public function setUp() + { + parent::setUp(); + $this->logger = $this->_objectManager->get(Monolog::class); + $this->syslogHandler = $this->_objectManager->create( + Syslog::class, + [ + 'filePath' => Bootstrap::getInstance()->getAppTempDir(), + ] + ); + $this->attributeManagement = $this->_objectManager->get(AttributeManagementInterface::class); + $this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class); + $this->attributeRepository = $this->_objectManager->get(Repository::class); + $this->dataObjectHelper = $this->_objectManager->get(DataObjectHelper::class); + } + + /** + * @inheritdoc + * @throws \Magento\Framework\Exception\FileSystemException + */ + public function tearDown() + { + $this->attributeRepository->get('country_of_manufacture')->setIsUserDefined(false); + parent::tearDown(); + } + /** * @magentoDataFixture Magento/Catalog/_files/attribute_set_with_renamed_group.php */ @@ -22,17 +101,22 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated() $this->assertNotEmpty($attributeSet, 'Attribute set with name "attribute_set_test" is missed'); $this->getRequest()->setMethod(HttpRequest::METHOD_POST); - $this->getRequest()->setPostValue('data', json_encode([ - 'attribute_set_name' => 'attribute_set_test', - 'groups' => [ - ['ynode-418', 'attribute-group-name', 1], - ], - 'attributes' => [ - ['9999', 'ynode-418', 1, null] - ], - 'not_attributes' => [], - 'removeGroups' => [], - ])); + $this->getRequest()->setPostValue( + 'data', + json_encode( + [ + 'attribute_set_name' => 'attribute_set_test', + 'groups' => [ + ['ynode-418', 'attribute-group-name', 1], + ], + 'attributes' => [ + ['9999', 'ynode-418', 1, null] + ], + 'not_attributes' => [], + 'removeGroups' => [], + ] + ) + ); $this->dispatch('backend/catalog/product_set/save/id/' . $attributeSet->getAttributeSetId()); $jsonResponse = json_decode($this->getResponse()->getBody()); @@ -63,4 +147,64 @@ protected function getAttributeSetByName($attributeSetName) $items = $result->getItems(); return $result->getTotalCount() ? array_pop($items) : null; } + + /** + * Test behavior when attribute set was changed to a new set + * with deleted attribute from the previous set + * + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default.php + * @magentoDbIsolation disabled + */ + public function testRemoveAttributeFromAttributeSet() + { + $message = 'Attempt to load value of nonexistent EAV attribute'; + $this->removeSyslog(); + $attributeSet = $this->getAttributeSetByName('new_attribute_set'); + $product = $this->productRepository->get('simple'); + $this->attributeRepository->get('country_of_manufacture')->setIsUserDefined(true); + $this->attributeManagement->unassign($attributeSet->getId(), 'country_of_manufacture'); + $productData = [ + 'country_of_manufacture' => 'Angola' + ]; + $this->dataObjectHelper->populateWithArray($product, $productData, ProductInterface::class); + $this->productRepository->save($product); + $product->setAttributeSetId($attributeSet->getId()); + $product = $this->productRepository->save($product); + $this->dispatch('backend/catalog/product/edit/id/' . $product->getEntityId()); + $syslogPath = $this->getSyslogPath(); + $syslogContent = file_exists($syslogPath) ? file_get_contents($syslogPath) : ''; + $this->assertNotContains($message, $syslogContent); + } + + /** + * Retrieve system.log file path + * + * @return string + */ + private function getSyslogPath(): string + { + if (!$this->systemLogPath) { + foreach ($this->logger->getHandlers() as $handler) { + if ($handler instanceof \Magento\Framework\Logger\Handler\System) { + $this->systemLogPath = $handler->getUrl(); + } + } + } + + return $this->systemLogPath; + } + + /** + * Remove system.log file + * + * @return void + */ + private function removeSyslog() + { + $this->syslogHandler->close(); + if (file_exists($this->getSyslogPath())) { + unlink($this->getSyslogPath()); + } + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php index acec996d0c40..3a28801b1ace 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Controller\Adminhtml; use Magento\Framework\App\Request\DataPersistorInterface; @@ -10,8 +12,12 @@ use Magento\Framework\App\Request\Http as HttpRequest; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\Message\MessageInterface; +use Magento\Catalog\Model\Product; +use Magento\TestFramework\Helper\CacheCleaner; /** + * Test class for Product adminhtml actions + * * @magentoAppArea adminhtml */ class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendController @@ -58,11 +64,10 @@ public function testSaveActionAndNew() */ public function testSaveActionAndDuplicate() { - $this->getRequest()->setPostValue(['back' => 'duplicate']); $repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class); + /** @var Product $product */ $product = $repository->get('simple'); - $this->getRequest()->setMethod(HttpRequest::METHOD_POST); - $this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId()); + $this->assertSaveAndDuplicateAction($product); $this->assertRedirect($this->stringStartsWith('http://localhost/index.php/backend/catalog/product/edit/')); $this->assertRedirect( $this->logicalNot( @@ -71,14 +76,30 @@ public function testSaveActionAndDuplicate() ) ) ); - $this->assertSessionMessages( - $this->contains('You saved the product.'), - MessageInterface::TYPE_SUCCESS - ); - $this->assertSessionMessages( - $this->contains('You duplicated the product.'), - MessageInterface::TYPE_SUCCESS - ); + } + + /** + * Tests of saving and duplicating existing product after the script execution. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + */ + public function testSaveActionAndDuplicateWithUrlPathAttribute() + { + $repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class); + /** @var Product $product */ + $product = $repository->get('simple'); + + // set url_path attribute and check it + $product->setData('url_path', $product->getSku()); + $repository->save($product); + $urlPathAttribute = $product->getCustomAttribute('url_path'); + $this->assertEquals($urlPathAttribute->getValue(), $product->getSku()); + + // clean cache + CacheCleaner::cleanAll(); + + // dispatch Save&Duplicate action and check it + $this->assertSaveAndDuplicateAction($product); } /** @@ -355,4 +376,24 @@ private function getProductData(array $tierPrice) unset($product['entity_id']); return $product; } + + /** + * Dispatch Save&Duplicate action and check it + * + * @param Product $product + */ + private function assertSaveAndDuplicateAction(Product $product) + { + $this->getRequest()->setPostValue(['back' => 'duplicate']); + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId()); + $this->assertSessionMessages( + $this->contains('You saved the product.'), + MessageInterface::TYPE_SUCCESS + ); + $this->assertSessionMessages( + $this->contains('You duplicated the product.'), + MessageInterface::TYPE_SUCCESS + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php index 1d7936d740b8..5ec042709399 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php @@ -3,26 +3,44 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +declare(strict_types=1); + namespace Magento\Catalog\Model; +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Model\Category as Category; +use Magento\Catalog\Model\ResourceModel\Category as CategoryResource; +use Magento\Catalog\Model\ResourceModel\Category\Collection; +use Magento\Catalog\Model\ResourceModel\Category\Tree; +use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection; +use Magento\Eav\Model\Entity\Attribute\Exception as AttributeException; +use Magento\Framework\Url; +use Magento\Store\Api\StoreRepositoryInterface; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + /** * Test class for \Magento\Catalog\Model\Category. * - general behaviour is tested * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @see \Magento\Catalog\Model\CategoryTreeTest * @magentoDataFixture Magento/Catalog/_files/categories.php * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ -class CategoryTest extends \PHPUnit\Framework\TestCase +class CategoryTest extends TestCase { /** - * @var \Magento\Store\Model\Store + * @var Store */ protected $_store; /** - * @var \Magento\Catalog\Model\Category + * @var Category */ protected $_model; @@ -31,50 +49,61 @@ class CategoryTest extends \PHPUnit\Framework\TestCase */ protected $objectManager; + /** @var CategoryRepository */ + private $categoryResource; + + /** @var CategoryRepositoryInterface */ + private $categoryRepository; + + /** + * @inheritdoc + */ protected function setUp() { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $storeManager \Magento\Store\Model\StoreManagerInterface */ - $storeManager = $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); + $this->objectManager = Bootstrap::getObjectManager(); + /** @var $storeManager StoreManagerInterface */ + $storeManager = $this->objectManager->get(StoreManagerInterface::class); $this->_store = $storeManager->getStore(); - $this->_model = $this->objectManager->create(\Magento\Catalog\Model\Category::class); + $this->_model = $this->objectManager->create(Category::class); + $this->categoryResource = $this->objectManager->get(CategoryResource::class); + $this->categoryRepository = $this->objectManager->get(CategoryRepositoryInterface::class); } - public function testGetUrlInstance() + public function testGetUrlInstance(): void { $instance = $this->_model->getUrlInstance(); - $this->assertInstanceOf(\Magento\Framework\Url::class, $instance); + $this->assertInstanceOf(Url::class, $instance); $this->assertSame($instance, $this->_model->getUrlInstance()); } - public function testGetTreeModel() + public function testGetTreeModel(): void { $model = $this->_model->getTreeModel(); - $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Category\Tree::class, $model); + $this->assertInstanceOf(Tree::class, $model); $this->assertNotSame($model, $this->_model->getTreeModel()); } - public function testGetTreeModelInstance() + public function testGetTreeModelInstance(): void { $model = $this->_model->getTreeModelInstance(); - $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Category\Tree::class, $model); + $this->assertInstanceOf(Tree::class, $model); $this->assertSame($model, $this->_model->getTreeModelInstance()); } - public function testGetDefaultAttributeSetId() + public function testGetDefaultAttributeSetId(): void { /* based on value installed in DB */ $this->assertEquals(3, $this->_model->getDefaultAttributeSetId()); } - public function testGetProductCollection() + public function testGetProductCollection(): void { $collection = $this->_model->getProductCollection(); - $this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Product\Collection::class, $collection); + $this->assertInstanceOf(ProductCollection::class, $collection); $this->assertEquals($this->_model->getStoreId(), $collection->getStoreId()); } - public function testGetAttributes() + public function testGetAttributes(): void { $attributes = $this->_model->getAttributes(); $this->assertArrayHasKey('name', $attributes); @@ -85,7 +114,7 @@ public function testGetAttributes() $this->assertArrayNotHasKey('custom_design', $attributes); } - public function testGetProductsPosition() + public function testGetProductsPosition(): void { $this->assertEquals([], $this->_model->getProductsPosition()); $this->_model->unsetData(); @@ -97,23 +126,21 @@ public function testGetProductsPosition() $this->assertNotEmpty($this->_model->getProductsPosition()); } - public function testGetStoreIds() + public function testGetStoreIds(): void { $this->_model = $this->getCategoryByName('Category 1.1'); /* id from fixture */ $this->assertContains( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Store\Model\StoreManagerInterface::class - )->getStore()->getId(), + Bootstrap::getObjectManager()->get(StoreManagerInterface::class)->getStore()->getId(), $this->_model->getStoreIds() ); } - public function testSetGetStoreId() + public function testSetGetStoreId(): void { $this->assertEquals( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Store\Model\StoreManagerInterface::class + Bootstrap::getObjectManager()->get( + StoreManagerInterface::class )->getStore()->getId(), $this->_model->getStoreId() ); @@ -126,10 +153,10 @@ public function testSetGetStoreId() * @magentoAppIsolation enabled * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ - public function testSetStoreIdWithNonNumericValue() + public function testSetStoreIdWithNonNumericValue(): void { - /** @var $store \Magento\Store\Model\Store */ - $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); + /** @var $store Store */ + $store = Bootstrap::getObjectManager()->create(Store::class); $store->load('fixturestore'); $this->assertNotEquals($this->_model->getStoreId(), $store->getId()); @@ -139,7 +166,7 @@ public function testSetStoreIdWithNonNumericValue() $this->assertEquals($this->_model->getStoreId(), $store->getId()); } - public function testGetUrl() + public function testGetUrl(): void { $this->assertStringEndsWith('catalog/category/view/', $this->_model->getUrl()); @@ -156,42 +183,42 @@ public function testGetUrl() $this->assertStringEndsWith('catalog/category/view/id/1000/', $this->_model->getUrl()); } - public function testGetCategoryIdUrl() + public function testGetCategoryIdUrl(): void { $this->assertStringEndsWith('catalog/category/view/', $this->_model->getCategoryIdUrl()); $this->_model->setUrlKey('test_key'); $this->assertStringEndsWith('catalog/category/view/s/test_key/', $this->_model->getCategoryIdUrl()); } - public function testFormatUrlKey() + public function testFormatUrlKey(): void { $this->assertEquals('test', $this->_model->formatUrlKey('test')); $this->assertEquals('test-some-chars-5', $this->_model->formatUrlKey('test-some#-chars^5')); $this->assertEquals('test', $this->_model->formatUrlKey('test-????????')); } - public function testGetImageUrl() + public function testGetImageUrl(): void { $this->assertFalse($this->_model->getImageUrl()); $this->_model->setImage('test.gif'); $this->assertStringEndsWith('media/catalog/category/test.gif', $this->_model->getImageUrl()); } - public function testGetCustomDesignDate() + public function testGetCustomDesignDate(): void { $dates = $this->_model->getCustomDesignDate(); $this->assertArrayHasKey('from', $dates); $this->assertArrayHasKey('to', $dates); } - public function testGetDesignAttributes() + public function testGetDesignAttributes(): void { $attributes = $this->_model->getDesignAttributes(); $this->assertContains('custom_design_from', array_keys($attributes)); $this->assertContains('custom_design_to', array_keys($attributes)); } - public function testCheckId() + public function testCheckId(): void { $this->_model = $this->getCategoryByName('Category 1.1.1'); $categoryId = $this->_model->getId(); @@ -199,13 +226,13 @@ public function testCheckId() $this->assertFalse($this->_model->checkId(111)); } - public function testVerifyIds() + public function testVerifyIds(): void { $ids = $this->_model->verifyIds($this->_model->getParentIds()); $this->assertNotContains(100, $ids); } - public function testHasChildren() + public function testHasChildren(): void { $this->_model->load(3); $this->assertTrue($this->_model->hasChildren()); @@ -213,21 +240,21 @@ public function testHasChildren() $this->assertFalse($this->_model->hasChildren()); } - public function testGetRequestPath() + public function testGetRequestPath(): void { $this->assertNull($this->_model->getRequestPath()); $this->_model->setData('request_path', 'test'); $this->assertEquals('test', $this->_model->getRequestPath()); } - public function testGetName() + public function testGetName(): void { $this->assertNull($this->_model->getName()); $this->_model->setData('name', 'test'); $this->assertEquals('test', $this->_model->getName()); } - public function testGetProductCount() + public function testGetProductCount(): void { $this->_model->load(6); $this->assertEquals(0, $this->_model->getProductCount()); @@ -236,14 +263,14 @@ public function testGetProductCount() $this->assertEquals(1, $this->_model->getProductCount()); } - public function testGetAvailableSortBy() + public function testGetAvailableSortBy(): void { $this->assertEquals([], $this->_model->getAvailableSortBy()); $this->_model->setData('available_sort_by', 'test,and,test'); $this->assertEquals(['test', 'and', 'test'], $this->_model->getAvailableSortBy()); } - public function testGetAvailableSortByOptions() + public function testGetAvailableSortByOptions(): void { $options = $this->_model->getAvailableSortByOptions(); $this->assertContains('price', array_keys($options)); @@ -251,25 +278,27 @@ public function testGetAvailableSortByOptions() $this->assertContains('name', array_keys($options)); } - public function testGetDefaultSortBy() + public function testGetDefaultSortBy(): void { $this->assertEquals('position', $this->_model->getDefaultSortBy()); } - public function testValidate() + public function testValidate(): void { - $this->_model->addData([ - "include_in_menu" => false, - "is_active" => false, - 'name' => 'test', - ]); + $this->_model->addData( + [ + "include_in_menu" => false, + "is_active" => false, + 'name' => 'test', + ] + ); $this->assertNotEmpty($this->_model->validate()); } /** * @magentoDataFixture Magento/Catalog/_files/category_with_position.php */ - public function testSaveCategoryWithPosition() + public function testSaveCategoryWithPosition(): void { $category = $this->_model->load('444'); $this->assertEquals('5', $category->getPosition()); @@ -278,10 +307,10 @@ public function testSaveCategoryWithPosition() /** * @magentoDbIsolation enabled */ - public function testSaveCategoryWithoutImage() + public function testSaveCategoryWithoutImage(): void { - $model = $this->objectManager->create(\Magento\Catalog\Model\Category::class); - $repository = $this->objectManager->get(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + $model = $this->objectManager->create(Category::class); + $repository = $this->objectManager->get(CategoryRepositoryInterface::class); $model->setName('Test Category 100') ->setParentId(2) @@ -299,7 +328,7 @@ public function testSaveCategoryWithoutImage() /** * @magentoAppArea adminhtml */ - public function testDeleteChildren() + public function testDeleteChildren(): void { $this->_model->unsetData(); $this->_model->load(4); @@ -320,29 +349,101 @@ public function testDeleteChildren() $this->assertEquals($this->_model->getId(), null); } + /** + * @magentoDataFixture Magento/Catalog/_files/category.php + */ + public function testAddChildCategory(): void + { + $data = [ + 'name' => 'Child Category', + 'path' => '1/2/333', + 'is_active' => '1', + 'include_in_menu' => '1', + ]; + $this->_model->setData($data); + $this->categoryResource->save($this->_model); + $parentCategory = $this->categoryRepository->get(333); + $this->assertContains($this->_model->getId(), $parentCategory->getChildren()); + } + + /** + * @return void + */ + public function testMissingRequiredAttribute(): void + { + $data = [ + 'path' => '1/2', + 'is_active' => '1', + 'include_in_menu' => '1', + ]; + $this->expectException(AttributeException::class); + $this->expectExceptionMessage( + (string)__('The "Name" attribute value is empty. Set the attribute and try again.') + ); + $this->_model->setData($data); + $this->_model->validate(); + } + + /** + * @dataProvider categoryFieldsProvider + * @param array $data + */ + public function testCategoryCreateWithDifferentFields(array $data): void + { + $requiredData = [ + 'name' => 'Test Category', + 'attribute_set_id' => '3', + 'parent_id' => 2, + ]; + $this->_model->setData(array_merge($requiredData, $data)); + $this->categoryResource->save($this->_model); + $category = $this->categoryRepository->get($this->_model->getId()); + $categoryData = $category->toArray(array_keys($data)); + $this->assertSame($data, $categoryData); + } + + /** + * @return array + */ + public function categoryFieldsProvider(): array + { + return [ + [ + 'enable_fields' => [ + 'is_active' => '1', + 'include_in_menu' => '1', + ], + 'disable_fields' => [ + 'is_active' => '0', + 'include_in_menu' => '0', + ], + ], + ]; + } + /** * @magentoDataFixture Magento/Store/_files/second_store.php * @magentoDataFixture Magento/Catalog/_files/categories.php * @magentoDbIsolation disabled * @return void */ - public function testCreateSubcategoryWithMultipleStores() + public function testCreateSubcategoryWithMultipleStores(): void { $parentCategoryId = 3; - $storeManager = $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class); - $storeManager->setCurrentStore(\Magento\Store\Model\Store::ADMIN_CODE); - /** @var \Magento\Store\Api\StoreRepositoryInterface $storeRepository */ - $storeRepository = $this->objectManager->get(\Magento\Store\Api\StoreRepositoryInterface::class); + $storeManager = $this->objectManager->get(StoreManagerInterface::class); + $storeManager->setCurrentStore(Store::ADMIN_CODE); + /** @var StoreRepositoryInterface $storeRepository */ + $storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); $storeId = $storeRepository->get('fixture_second_store')->getId(); - /** @var \Magento\Catalog\Api\CategoryRepositoryInterface $repository */ - $repository = $this->objectManager->get(\Magento\Catalog\Api\CategoryRepositoryInterface::class); + /** @var CategoryRepositoryInterface $repository */ + $repository = $this->objectManager->get(CategoryRepositoryInterface::class); $parentCategory = $repository->get($parentCategoryId, $storeId); $parentAllStoresPath = $parentCategory->getUrlPath(); $parentSecondStoreKey = 'parent-category-url-key-second-store'; $parentCategory->setUrlKey($parentSecondStoreKey); $repository->save($parentCategory); - /** @var \Magento\Catalog\Model\Category $childCategory */ - $childCategory = $this->objectManager->create(\Magento\Catalog\Model\Category::class); + /** @var Category $childCategory */ + $childCategory = $this->objectManager->create(Category::class); $childCategory->setName('Test Category 100') ->setParentId($parentCategoryId) ->setLevel(2) @@ -360,10 +461,10 @@ public function testCreateSubcategoryWithMultipleStores() protected function getCategoryByName($categoryName) { - /* @var \Magento\Catalog\Model\ResourceModel\Category\Collection $collection */ - - $collection = $this->objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class); + /* @var Collection $collection */ + $collection = $this->objectManager->create(Collection::class); $collection->addNameToResult()->load(); + return $collection->getItemByColumnValue('name', $categoryName); } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/FullTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/FullTest.php index 677135092526..095fa864ccb4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/FullTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/Action/FullTest.php @@ -11,6 +11,8 @@ use Magento\Catalog\Model\Indexer\Product\Flat\Processor; use Magento\Catalog\Model\Indexer\Product\Flat\State; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory; +use Magento\CatalogSearch\Model\Indexer\Fulltext; +use Magento\Framework\Indexer\IndexerRegistry; use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; @@ -35,6 +37,22 @@ class FullTest extends \Magento\TestFramework\Indexer\TestCase */ private $objectManager; + /** + * @inheritdoc + */ + public static function setUpBeforeClass() + { + /* + * Due to insufficient search engine isolation for Elasticsearch, this class must explicitly perform + * a fulltext reindex prior to running its tests. + * + * This should be removed upon completing MC-19455. + */ + $indexRegistry = Bootstrap::getObjectManager()->get(IndexerRegistry::class); + $fulltextIndexer = $indexRegistry->get(Fulltext::INDEXER_ID); + $fulltextIndexer->reindexAll(); + } + /** * @inheritdoc */ diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php index bbaf45393870..9ae9cc6b6629 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Product/Flat/ProcessorTest.php @@ -5,8 +5,10 @@ */ namespace Magento\Catalog\Model\Indexer\Product\Flat; +use Magento\Catalog\Model\Product\Attribute\Repository; + /** - * Class FullTest + * Integration tests for \Magento\Catalog\Model\Indexer\Product\Flat\Processor. */ class ProcessorTest extends \Magento\TestFramework\Indexer\TestCase { @@ -64,22 +66,23 @@ public function testSaveAttribute() } /** - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml - * @magentoDataFixture Magento/Catalog/_files/multiple_products.php + * @magentoDataFixture Magento/Catalog/_files/product_simple_with_custom_attribute_in_flat.php * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 */ public function testDeleteAttribute() { - /** @var $product \Magento\Catalog\Model\Product */ - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); - - /** @var \Magento\Catalog\Model\ResourceModel\Product $productResource */ - $productResource = $product->getResource(); - $productResource->getAttribute('media_gallery')->delete(); + /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $model */ + $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); + /** @var Repository $productAttributeRepository */ + $productAttributeRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(Repository::class); + $productAttrubute = $productAttributeRepository->get('flat_attribute'); + $productAttributeId = $productAttrubute->getAttributeId(); + $model->load($productAttributeId)->delete(); $this->assertTrue($this->_processor->getIndexer()->isInvalid()); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php index 833d1b114a0b..b4431678b201 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php @@ -20,6 +20,7 @@ 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, + 'is_user_defined' => 1, 'option' => ['value' => ['option_0' => [0 => 'Option Label']]], 'backend_type' => 'int', ] diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php index 3fa02aebe917..98b264a8991b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Compare/ListCompareTest.php @@ -6,10 +6,6 @@ namespace Magento\Catalog\Model\Product\Compare; -/** - * @magentoDataFixture Magento/Catalog/_files/product_simple.php - * @magentoDataFixture Magento/Customer/_files/customer.php - */ class ListCompareTest extends \PHPUnit\Framework\TestCase { /** @@ -44,6 +40,10 @@ protected function tearDown() $this->_session->setCustomerId(null); } + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ public function testAddProductWithSession() { $this->_session->setCustomerId(1); @@ -51,10 +51,33 @@ public function testAddProductWithSession() $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create(\Magento\Catalog\Model\Product::class) ->load(1); - $this->_model->addProduct($product); + /** @var $product2 \Magento\Catalog\Model\Product */ + $product2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Model\Product::class) + ->load(6); + $products = [$product->getId(), $product2->getId()]; + $this->_model->addProducts($products); + $this->assertTrue($this->_model->hasItems(1, $this->_visitor->getId())); } + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testAddProductWithSessionNeg() + { + $this->_session->setCustomerId(1); + $products = ['none', 99]; + $this->_model->addProducts($products); + + $this->assertFalse($this->_model->hasItems(1, $this->_visitor->getId())); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ public function testAddProductWithoutSession() { /** @var $product \Magento\Catalog\Model\Product */ diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php new file mode 100644 index 000000000000..6510e048f0e2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php @@ -0,0 +1,47 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Product; + +use Magento\Catalog\Model\ProductRepository; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Tests product copier. + */ +class CopierTest extends TestCase +{ + /** + * Tests copying of product. + * + * Case when url_key is set for store view and has equal value to default store. + * + * @magentoDataFixture Magento/Catalog/_files/product_simple_multistore_with_url_key.php + * @magentoAppArea adminhtml + */ + public function testProductCopyWithExistingUrlKey() + { + $productSKU = 'simple_100'; + /** @var ProductRepository $productRepository */ + $productRepository = Bootstrap::getObjectManager()->get(ProductRepository::class); + $copier = Bootstrap::getObjectManager()->get(Copier::class); + + $product = $productRepository->get($productSKU); + $duplicate = $copier->copy($product); + + $duplicateStoreView = $productRepository->getById($duplicate->getId(), false, Store::DISTRO_STORE_ID); + $productStoreView = $productRepository->get($productSKU, false, Store::DISTRO_STORE_ID); + + $this->assertNotEquals( + $duplicateStoreView->getUrlKey(), + $productStoreView->getUrlKey(), + 'url_key of product duplicate should be different then url_key of the product for the same store view' + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php new file mode 100644 index 000000000000..94bbcd8bae66 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php @@ -0,0 +1,929 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Product; + +use Magento\Catalog\Api\Data\ProductCustomOptionInterface; +use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory; +use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory; +use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Validator\Exception as ValidatorException; +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test product custom options create. + * Testing option types: "Area", "File", "Drop-down", "Radio-Buttons", + * "Checkbox", "Multiple Select", "Date", "Date & Time" and "Time". + * + * @magentoAppArea adminhtml + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ +class CreateCustomOptionsTest extends TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * Product repository. + * + * @var ProductRepositoryInterface + */ + private $productRepository; + + /** + * @var ProductCustomOptionRepositoryInterface + */ + private $optionRepository; + + /** + * Custom option factory. + * + * @var ProductCustomOptionInterfaceFactory + */ + private $customOptionFactory; + + /** + * @var ProductCustomOptionValuesInterfaceFactory + */ + private $customOptionValueFactory; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $this->optionRepository = $this->objectManager->create(ProductCustomOptionRepositoryInterface::class); + $this->customOptionFactory = $this->objectManager->create(ProductCustomOptionInterfaceFactory::class); + $this->customOptionValueFactory = $this->objectManager + ->create(ProductCustomOptionValuesInterfaceFactory::class); + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); + } + + /** + * Test to save option price by store. + * + * @magentoDataFixture Magento/Catalog/_files/product_with_options.php + * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php + * + * @magentoConfigFixture default_store catalog/price/scope 1 + * @magentoConfigFixture secondstore_store catalog/price/scope 1 + */ + public function testSaveOptionPriceByStore(): void + { + $secondWebsitePrice = 22.0; + $currentStoreId = $this->storeManager->getStore()->getId(); + $customStoreId = $this->storeManager->getStore('secondstore')->getId(); + $product = $this->productRepository->get('simple'); + $option = $product->getOptions()[0]; + $defaultPrice = $option->getPrice(); + $option->setPrice($secondWebsitePrice); + $product->setStoreId($customStoreId); + // set Current store='secondstore' to correctly save product options for 'secondstore' + try { + $this->storeManager->setCurrentStore($customStoreId); + $this->productRepository->save($product); + } finally { + $this->storeManager->setCurrentStore($currentStoreId); + } + $product = $this->productRepository->get('simple', false, $currentStoreId, true); + $option = $product->getOptions()[0]; + $this->assertEquals($defaultPrice, $option->getPrice(), 'Price value by default store is wrong'); + $product = $this->productRepository->get('simple', false, $customStoreId, true); + $option = $product->getOptions()[0]; + $this->assertEquals($secondWebsitePrice, $option->getPrice(), 'Price value by custom store is wrong'); + } + + /** + * Test add to product custom options with text type. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider productCustomOptionsTypeTextDataProvider + * + * @param array $optionData + */ + public function testCreateOptionsWithTypeText(array $optionData): void + { + $option = $this->baseCreateCustomOptionAndAssert($optionData); + $this->assertEquals($optionData['price'], $option->getPrice()); + $this->assertEquals($optionData['price_type'], $option->getPriceType()); + $this->assertEquals($optionData['sku'], $option->getSku()); + $maxCharacters = $optionData['max_characters'] ?? 0; + $this->assertEquals($maxCharacters, $option->getMaxCharacters()); + } + + /** + * Tests removing ineligible characters from file_extension. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider fileExtensionsDataProvider + * + * @param string $rawExtensions + * @param string $expectedExtensions + */ + public function testFileExtensions(string $rawExtensions, string $expectedExtensions): void + { + $product = $this->productRepository->get('simple'); + $optionData = [ + 'title' => 'file option', + 'type' => 'file', + 'is_require' => true, + 'sort_order' => 3, + 'price' => 30.0, + 'price_type' => 'percent', + 'sku' => 'sku3', + 'file_extension' => $rawExtensions, + 'image_size_x' => 10, + 'image_size_y' => 20, + ]; + $fileOption = $this->customOptionFactory->create(['data' => $optionData]); + $product->addOption($fileOption); + $this->productRepository->save($product); + $product = $this->productRepository->get('simple'); + $fileOption = $product->getOptions()[0]; + $actualExtensions = $fileOption->getFileExtension(); + $this->assertEquals($expectedExtensions, $actualExtensions); + } + + /** + * Test add to product custom options with select type. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider productCustomOptionsTypeSelectDataProvider + * + * @param array $optionData + * @param array $optionValueData + */ + public function testCreateOptionsWithTypeSelect(array $optionData, array $optionValueData): void + { + $optionValue = $this->customOptionValueFactory->create(['data' => $optionValueData]); + $optionData['values'] = [$optionValue]; + $option = $this->baseCreateCustomOptionAndAssert($optionData); + $optionValues = $option->getValues(); + $this->assertCount(1, $optionValues); + $this->assertNotNull($optionValues); + $optionValue = reset($optionValues); + $this->assertEquals($optionValueData['title'], $optionValue->getTitle()); + $this->assertEquals($optionValueData['price'], $optionValue->getPrice()); + $this->assertEquals($optionValueData['price_type'], $optionValue->getPriceType()); + $this->assertEquals($optionValueData['sku'], $optionValue->getSku()); + $this->assertEquals($optionValueData['sort_order'], $optionValue->getSortOrder()); + } + + /** + * Test add to product custom options with date type. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider productCustomOptionsTypeDateDataProvider + * + * @param array $optionData + */ + public function testCreateOptionsWithTypeDate(array $optionData): void + { + $option = $this->baseCreateCustomOptionAndAssert($optionData); + $this->assertEquals($optionData['price'], $option->getPrice()); + $this->assertEquals($optionData['price_type'], $option->getPriceType()); + $this->assertEquals($optionData['sku'], $option->getSku()); + } + + /** + * Check that error throws if we save porduct with custom option without some field. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options.php + * + * @dataProvider productCustomOptionsWithErrorDataProvider + * + * @param array $optionData + * @param \Exception $expectedErrorObject + */ + public function testCreateOptionWithError(array $optionData, \Exception $expectedErrorObject): void + { + $product = $this->productRepository->get('simple'); + $createdOption = $this->customOptionFactory->create(['data' => $optionData]); + $product->setOptions([$createdOption]); + $this->expectExceptionObject($expectedErrorObject); + $this->productRepository->save($product); + } + + /** + * Add option to product with type text data provider. + * + * @return array + */ + public function productCustomOptionsTypeTextDataProvider(): array + { + return [ + 'area_field_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'area_field_not_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'area_field_options_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'area_field_options_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'percent', + ], + ], + 'area_field_options_with_max_charters_configuration' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 30, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'area_field_options_without_max_charters_configuration' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + ]; + } + + /** + * Data provider for testFileExtensions. + * + * @return array + */ + public function fileExtensionsDataProvider(): array + { + return [ + ['JPG, PNG, GIF', 'jpg, png, gif'], + ['jpg, jpg, jpg', 'jpg'], + ['jpg, png, gif', 'jpg, png, gif'], + ['jpg png gif', 'jpg, png, gif'], + ['!jpg@png#gif%', 'jpg, png, gif'], + ['jpg, png, 123', 'jpg, png, 123'], + ['', ''], + ]; + } + + /** + * Add option to product with type text data provider. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * @return array + */ + public function productCustomOptionsTypeSelectDataProvider(): array + { + return [ + 'drop_down_field_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'drop_down', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'drop_down_field_not_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'title' => 'Test option 1', + 'type' => 'drop_down', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'drop_down_field_option_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'drop_down', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'drop_down_field_option_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'drop_down', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'percent', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'radio_field_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'radio', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'radio_field_not_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'title' => 'Test option 1', + 'type' => 'radio', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'radio_field_option_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'radio', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'radio_field_option_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'radio', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'percent', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'checkbox_field_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'checkbox', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'checkbox_field_not_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'title' => 'Test option 1', + 'type' => 'checkbox', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'checkbox_field_option_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'checkbox', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'checkbox_field_option_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'checkbox', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'percent', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'multiple_field_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'multiple', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'multiple_field_not_required_option' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'title' => 'Test option 1', + 'type' => 'multiple', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'multiple_field_option_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'multiple', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'fixed', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + 'multiple_field_option_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'title' => 'Test option 1', + 'type' => 'multiple', + 'price_type' => 'fixed', + ], + [ + 'record_id' => 0, + 'title' => 'Test option 1 value 1', + 'price' => 10, + 'price_type' => 'percent', + 'sku' => 'test-option-1-value-1', + 'sort_order' => 1, + ], + ], + ]; + } + + /** + * Add option to product with type text data provider. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * @return array + */ + public function productCustomOptionsTypeDateDataProvider(): array + { + return [ + 'date_field_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_field_not_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_field_options_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_field_options_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date', + 'price' => 10, + 'price_type' => 'percent', + ], + ], + 'date_time_field_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date_time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_time_field_not_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date_time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_time_field_options_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date_time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'date_time_field_options_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'date_time', + 'price' => 10, + 'price_type' => 'percent', + ], + ], + 'time_field_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'time_field_not_required_options' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 0, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'time_field_options_with_fixed_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'time', + 'price' => 10, + 'price_type' => 'fixed', + ], + ], + 'time_field_options_with_percent_price' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'title' => 'Test option title 1', + 'type' => 'time', + 'price' => 10, + 'price_type' => 'percent', + ], + ], + ]; + } + + /** + * Add option to product for get option save error data provider. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * + * @return array + */ + public function productCustomOptionsWithErrorDataProvider(): array + { + return [ + 'error_option_without_product_sku' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + ], + new CouldNotSaveException(__('The ProductSku is empty. Set the ProductSku and try again.')), + ], + 'error_option_without_type' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'price' => 10, + 'price_type' => 'fixed', + 'product_sku' => 'simple', + ], + new ValidatorException(__("Missed values for option required fields\nInvalid option type")), + ], + 'error_option_wrong_price_type' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'test_wrong_price_type', + 'product_sku' => 'simple', + ], + new ValidatorException(__('Invalid option value')), + ], + 'error_option_without_price_type' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price' => 10, + 'product_sku' => 'simple', + ], + new ValidatorException(__('Invalid option value')), + ], + 'error_option_without_price_value' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => 'Test option title 1', + 'type' => 'area', + 'price_type' => 'fixed', + 'product_sku' => 'simple', + ], + new ValidatorException(__('Invalid option value')), + ], + 'error_option_without_title' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + 'product_sku' => 'simple', + ], + new ValidatorException(__('Missed values for option required fields')), + ], + 'error_option_with_empty_title' => [ + [ + 'record_id' => 0, + 'sort_order' => 1, + 'is_require' => 1, + 'sku' => 'test-option-title-1', + 'max_characters' => 50, + 'title' => '', + 'type' => 'area', + 'price' => 10, + 'price_type' => 'fixed', + 'product_sku' => 'simple', + ], + new ValidatorException(__('Missed values for option required fields')), + ], + ]; + } + + /** + * Create custom option and save product with created option, check base assertions. + * + * @param array $optionData + * @return ProductCustomOptionInterface + */ + private function baseCreateCustomOptionAndAssert(array $optionData): ProductCustomOptionInterface + { + $product = $this->productRepository->get('simple'); + $createdOption = $this->customOptionFactory->create(['data' => $optionData]); + $createdOption->setProductSku($product->getSku()); + $product->setOptions([$createdOption]); + $this->productRepository->save($product); + $productCustomOptions = $this->optionRepository->getProductOptions($product); + $this->assertCount(1, $productCustomOptions); + $option = reset($productCustomOptions); + $this->assertEquals($optionData['title'], $option->getTitle()); + $this->assertEquals($optionData['type'], $option->getType()); + $this->assertEquals($optionData['is_require'], $option->getIsRequire()); + + return $option; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/CreateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/CreateHandlerTest.php index 7421402455b2..03455bb341ca 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/CreateHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/CreateHandlerTest.php @@ -3,50 +3,87 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Catalog\Model\Product\Gallery; -use Magento\Framework\Exception\FileSystemException; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; +use Magento\Catalog\Model\ResourceModel\Product\Gallery; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; /** - * Test class for \Magento\Catalog\Model\Product\Gallery\CreateHandler. + * Provides tests for media gallery images creation during product save. * * @magentoDataFixture Magento/Catalog/_files/product_simple.php * @magentoDataFixture Magento/Catalog/_files/product_image.php + * @magentoDbIsolation enabled */ class CreateHandlerTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\Catalog\Model\Product\Gallery\CreateHandler + * @var string */ - protected $createHandler; - private $fileName = '/m/a/magento_image.jpg'; + /** + * @var string + */ private $fileLabel = 'Magento image'; + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var CreateHandler + */ + private $createHandler; + + /** + * @var Gallery + */ + private $galleryResource; + + /** + * @var ProductRepositoryInterface + */ + private $productRepository; + + /** + * @var ProductResource + */ + private $productResource; + + /** + * @inheritdoc + */ protected function setUp() { - $this->createHandler = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product\Gallery\CreateHandler::class - ); + $this->objectManager = Bootstrap::getObjectManager(); + $this->createHandler = $this->objectManager->create(CreateHandler::class); + $this->galleryResource = $this->objectManager->create(Gallery::class); + $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $this->productResource = Bootstrap::getObjectManager()->get(ProductResource::class); } /** + * Tests gallery processing on product duplication. + * * @covers \Magento\Catalog\Model\Product\Gallery\CreateHandler::execute + * + * @return void */ - public function testExecuteWithImageDuplicate() + public function testExecuteWithImageDuplicate(): void { - /** @var $product \Magento\Catalog\Model\Product */ - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); - $product->load(1); - $product->setData( - 'media_gallery', - ['images' => ['image' => ['file' => $this->fileName, 'label' => $this->fileLabel]]] - ); - $product->setData('image', $this->fileName); + $data = [ + 'media_gallery' => ['images' => ['image' => ['file' => $this->fileName, 'label' => $this->fileLabel]]], + 'image' => $this->fileName, + ]; + $product = $this->initProduct($data); $this->createHandler->execute($product); $this->assertStringStartsWith('/m/a/magento_image', $product->getData('media_gallery/images/image/new_file')); $this->assertEquals($this->fileLabel, $product->getData('image_label')); @@ -62,39 +99,29 @@ public function testExecuteWithImageDuplicate() } /** - * Check sanity of posted image file name + * Check sanity of posted image file name. * * @param string $imageFileName - * @throws FileSystemException * @expectedException \Magento\Framework\Exception\FileSystemException + * @expectedExceptionMessageRegExp ".+ file doesn't exist." + * @expectedExceptionMessageRegExp "/^((?!\.\.\/).)*$/" * @dataProvider illegalFilenameDataProvider + * @return void */ - public function testExecuteWithIllegalFilename($imageFileName) + public function testExecuteWithIllegalFilename(string $imageFileName): void { - /** @var $product \Magento\Catalog\Model\Product */ - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); - $product->load(1); - $product->setData( - 'media_gallery', - ['images' => ['image' => ['file' => $imageFileName, 'label' => 'New image']]] - ); + $data = [ + 'media_gallery' => ['images' => ['image' => ['file' => $imageFileName, 'label' => 'New image']]], + ]; + $product = $this->initProduct($data); $product->setData('image', $imageFileName); - - try { - $this->createHandler->execute($product); - } catch (FileSystemException $exception) { - $this->assertContains(" file doesn't exist.", $exception->getLogMessage()); - $this->assertNotContains('../', $exception->getLogMessage()); - throw $exception; - } + $this->createHandler->execute($product); } /** * @return array */ - public function illegalFilenameDataProvider() + public function illegalFilenameDataProvider(): array { return [ ['../../../../../.htaccess'], @@ -103,123 +130,170 @@ public function illegalFilenameDataProvider() } /** + * Tests gallery processing with different image roles. + * * @dataProvider executeDataProvider - * @param $image - * @param $smallImage - * @param $swatchImage - * @param $thumbnail + * @param string $image + * @param string $smallImage + * @param string $swatchImage + * @param string $thumbnail + * @return void */ - public function testExecuteWithImageRoles($image, $smallImage, $swatchImage, $thumbnail) - { - /** @var $product \Magento\Catalog\Model\Product */ - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); - $product->load(1); - $product->setData( - 'media_gallery', - ['images' => ['image' => ['file' => $this->fileName, 'label' => '']]] - ); - $product->setData('image', $image); - $product->setData('small_image', $smallImage); - $product->setData('swatch_image', $swatchImage); - $product->setData('thumbnail', $thumbnail); + public function testExecuteWithImageRoles( + string $image, + string $smallImage, + string $swatchImage, + string $thumbnail + ): void { + $data = [ + 'media_gallery' => ['images' => ['image' => ['file' => $this->fileName, 'label' => '']]], + 'image' => $image, + 'small_image' => $smallImage, + 'swatch_image' => $swatchImage, + 'thumbnail' => $thumbnail, + ]; + $product = $this->initProduct($data); $this->createHandler->execute($product); - - $resource = $product->getResource(); - $id = $product->getId(); - $storeId = $product->getStoreId(); - - $this->assertStringStartsWith('/m/a/magento_image', $product->getData('media_gallery/images/image/new_file')); - $this->assertEquals( - $image, - $resource->getAttributeRawValue($id, $resource->getAttribute('image'), $storeId) - ); - $this->assertEquals( - $smallImage, - $resource->getAttributeRawValue($id, $resource->getAttribute('small_image'), $storeId) - ); - $this->assertEquals( - $swatchImage, - $resource->getAttributeRawValue($id, $resource->getAttribute('swatch_image'), $storeId) - ); - $this->assertEquals( - $thumbnail, - $resource->getAttributeRawValue($id, $resource->getAttribute('thumbnail'), $storeId) - ); + $this->assertMediaImageRoleAttributes($product, $image, $smallImage, $swatchImage, $thumbnail); } /** + * Tests gallery processing without images. + * * @dataProvider executeDataProvider - * @param $image - * @param $smallImage - * @param $swatchImage - * @param $thumbnail + * @param string $image + * @param string $smallImage + * @param string $swatchImage + * @param string $thumbnail + * @return void */ - public function testExecuteWithoutImages($image, $smallImage, $swatchImage, $thumbnail) - { - /** @var $product \Magento\Catalog\Model\Product */ - $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); - $product->load(1); - $product->setData( - 'media_gallery', - ['images' => ['image' => ['file' => $this->fileName, 'label' => '']]] - ); - $product->setData('image', $image); - $product->setData('small_image', $smallImage); - $product->setData('swatch_image', $swatchImage); - $product->setData('thumbnail', $thumbnail); + public function testExecuteWithoutImages( + string $image, + string $smallImage, + string $swatchImage, + string $thumbnail + ): void { + $data = [ + 'media_gallery' => ['images' => ['image' => ['file' => $this->fileName, 'label' => '']]], + 'image' => $image, + 'small_image' => $smallImage, + 'swatch_image' => $swatchImage, + 'thumbnail' => $thumbnail, + ]; + $product = $this->initProduct($data); $this->createHandler->execute($product); - $product->unsetData('image'); $product->unsetData('small_image'); $product->unsetData('swatch_image'); $product->unsetData('thumbnail'); $this->createHandler->execute($product); - - $resource = $product->getResource(); - $id = $product->getId(); - $storeId = $product->getStoreId(); - - $this->assertStringStartsWith('/m/a/magento_image', $product->getData('media_gallery/images/image/new_file')); - $this->assertEquals( - $image, - $resource->getAttributeRawValue($id, $resource->getAttribute('image'), $storeId) - ); - $this->assertEquals( - $smallImage, - $resource->getAttributeRawValue($id, $resource->getAttribute('small_image'), $storeId) - ); - $this->assertEquals( - $swatchImage, - $resource->getAttributeRawValue($id, $resource->getAttribute('swatch_image'), $storeId) - ); - $this->assertEquals( - $thumbnail, - $resource->getAttributeRawValue($id, $resource->getAttribute('thumbnail'), $storeId) - ); + $this->assertMediaImageRoleAttributes($product, $image, $smallImage, $swatchImage, $thumbnail); } /** * @return array */ - public function executeDataProvider() + public function executeDataProvider(): array { return [ [ 'image' => $this->fileName, 'small_image' => $this->fileName, 'swatch_image' => $this->fileName, - 'thumbnail' => $this->fileName + 'thumbnail' => $this->fileName, ], [ 'image' => 'no_selection', 'small_image' => 'no_selection', 'swatch_image' => 'no_selection', - 'thumbnail' => 'no_selection' - ] + 'thumbnail' => 'no_selection', + ], + ]; + } + + /** + * Tests gallery processing with variations of additional gallery image fields. + * + * @dataProvider additionalGalleryFieldsProvider + * @param string $mediaField + * @param string $value + * @param string|null $expectedValue + * @return void + */ + public function testExecuteWithAdditionalGalleryFields( + string $mediaField, + string $value, + ?string $expectedValue + ): void { + $data = [ + 'media_gallery' => ['images' => ['image' => ['file' => $this->fileName, $mediaField => $value]]], ]; + $product = $this->initProduct($data); + $this->createHandler->execute($product); + $galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId(); + $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId); + $image = reset($productImages); + $this->assertEquals($image[$mediaField], $expectedValue); + } + + /** + * @return array + */ + public function additionalGalleryFieldsProvider(): array + { + return [ + ['label', '', null], + ['label', 'Some label', 'Some label'], + ['disabled', '0', '0'], + ['disabled', '1', '1'], + ['position', '1', '1'], + ['position', '2', '2'], + ]; + } + + /** + * Returns product for testing. + * + * @param array $data + * @return Product + */ + private function initProduct(array $data): Product + { + $product = $this->productRepository->getById(1); + $product->addData($data); + + return $product; + } + + /** + * Asserts product attributes related to gallery images. + * + * @param Product $product + * @param string $image + * @param string $smallImage + * @param string $swatchImage + * @param string $thumbnail + * @return void + */ + private function assertMediaImageRoleAttributes( + Product $product, + string $image, + string $smallImage, + string $swatchImage, + string $thumbnail + ): void { + $productsImageData = $this->productResource->getAttributeRawValue( + $product->getId(), + ['image', 'small_image', 'thumbnail', 'swatch_image'], + $product->getStoreId() + ); + $this->assertStringStartsWith( + '/m/a/magento_image', + $product->getData('media_gallery/images/image/new_file') + ); + $this->assertEquals($image, $productsImageData['image']); + $this->assertEquals($smallImage, $productsImageData['small_image']); + $this->assertEquals($swatchImage, $productsImageData['swatch_image']); + $this->assertEquals($thumbnail, $productsImageData['thumbnail']); } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/OptionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/OptionTest.php deleted file mode 100644 index bfb49686447c..000000000000 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/OptionTest.php +++ /dev/null @@ -1,149 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Model\Product; - -use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory; -use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Store\Model\Store; -use Magento\Store\Model\StoreManagerInterface; -use Magento\TestFramework\Helper\Bootstrap; - -/** - * @magentoAppArea adminhtml - * @magentoAppIsolation enabled - * @magentoDbIsolation enabled - */ -class OptionTest extends \PHPUnit\Framework\TestCase -{ - /** - * Product repository. - * - * @var ProductRepositoryInterface - */ - private $productRepository; - - /** - * Custom option factory. - * - * @var ProductCustomOptionInterfaceFactory - */ - private $customOptionFactory; - - /** - * @var StoreManagerInterface - */ - private $storeManager; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class); - $this->customOptionFactory = Bootstrap::getObjectManager()->create(ProductCustomOptionInterfaceFactory::class); - $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class); - } - - /** - * Tests removing ineligible characters from file_extension. - * - * @param string $rawExtensions - * @param string $expectedExtensions - * @dataProvider fileExtensionsDataProvider - * @magentoDataFixture Magento/Catalog/_files/product_without_options.php - */ - public function testFileExtensions(string $rawExtensions, string $expectedExtensions) - { - /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get('simple'); - /** @var \Magento\Catalog\Model\Product\Option $fileOption */ - $fileOption = $this->createFileOption($rawExtensions); - $product->addOption($fileOption); - $product->save(); - $product = $this->productRepository->get('simple'); - $fileOption = $product->getOptions()[0]; - $actualExtensions = $fileOption->getFileExtension(); - $this->assertEquals($expectedExtensions, $actualExtensions); - } - - /** - * Data provider for testFileExtensions. - * - * @return array - */ - public function fileExtensionsDataProvider() - { - return [ - ['JPG, PNG, GIF', 'jpg, png, gif'], - ['jpg, jpg, jpg', 'jpg'], - ['jpg, png, gif', 'jpg, png, gif'], - ['jpg png gif', 'jpg, png, gif'], - ['!jpg@png#gif%', 'jpg, png, gif'], - ['jpg, png, 123', 'jpg, png, 123'], - ['', ''], - ]; - } - - /** - * Create file type option for product. - * - * @param string $rawExtensions - * @return \Magento\Catalog\Api\Data\ProductCustomOptionInterface|void - */ - private function createFileOption(string $rawExtensions) - { - $data = [ - 'title' => 'file option', - 'type' => 'file', - 'is_require' => true, - 'sort_order' => 3, - 'price' => 30.0, - 'price_type' => 'percent', - 'sku' => 'sku3', - 'file_extension' => $rawExtensions, - 'image_size_x' => 10, - 'image_size_y' => 20, - ]; - - return $this->customOptionFactory->create(['data' => $data]); - } - - /** - * Test to save option price by store - * - * @magentoDataFixture Magento/Catalog/_files/product_with_options.php - * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php - * @magentoConfigFixture default_store catalog/price/scope 1 - * @magentoConfigFixture secondstore_store catalog/price/scope 1 - */ - public function testSaveOptionPriceByStore() - { - $secondWebsitePrice = 22.0; - $defaultStoreId = $this->storeManager->getStore()->getId(); - $secondStoreId = $this->storeManager->getStore('secondstore')->getId(); - - /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->productRepository->get('simple'); - $option = $product->getOptions()[0]; - $defaultPrice = $option->getPrice(); - - $option->setPrice($secondWebsitePrice); - $product->setStoreId($secondStoreId); - // set Current store='secondstore' to correctly save product options for 'secondstore' - $this->storeManager->setCurrentStore($secondStoreId); - $this->productRepository->save($product); - $this->storeManager->setCurrentStore($defaultStoreId); - - $product = $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID, true); - $option = $product->getOptions()[0]; - $this->assertEquals($defaultPrice, $option->getPrice(), 'Price value by default store is wrong'); - - $product = $this->productRepository->get('simple', false, $secondStoreId, true); - $option = $product->getOptions()[0]; - $this->assertEquals($secondWebsitePrice, $option->getPrice(), 'Price value by store_id=1 is wrong'); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php index 663ee986bca3..e0860897fcc2 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UrlTest.php @@ -5,11 +5,15 @@ */ namespace Magento\Catalog\Model\Product; +use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; +use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator; + /** * Test class for \Magento\Catalog\Model\Product\Url. * * @magentoDataFixture Magento/Catalog/_files/url_rewrites.php * @magentoAppArea frontend + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UrlTest extends \PHPUnit\Framework\TestCase { @@ -133,4 +137,48 @@ public function testGetUrl() $product->setId(100); $this->assertContains('catalog/product/view/id/100/', $this->_model->getUrl($product)); } + + /** + * Check that rearranging product url rewrites do not influence on whether to use category in product links + * + * @magentoConfigFixture current_store catalog/seo/product_use_categories 0 + */ + public function testGetProductUrlWithRearrangedUrlRewrites() + { + $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Catalog\Model\ProductRepository::class + ); + $categoryRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Catalog\Model\CategoryRepository::class + ); + $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\Registry::class + ); + $urlFinder = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\UrlRewrite\Model\UrlFinderInterface::class + ); + $urlPersist = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\UrlRewrite\Model\UrlPersistInterface::class + ); + + $product = $productRepository->get('simple'); + $category = $categoryRepository->get($product->getCategoryIds()[0]); + $registry->register('current_category', $category); + $this->assertNotContains($category->getUrlPath(), $this->_model->getProductUrl($product)); + + $rewrites = $urlFinder->findAllByData( + [ + UrlRewrite::ENTITY_ID => $product->getId(), + UrlRewrite::ENTITY_TYPE => ProductUrlRewriteGenerator::ENTITY_TYPE + ] + ); + $this->assertGreaterThan(1, count($rewrites)); + foreach ($rewrites as $rewrite) { + if ($rewrite->getRequestPath() === 'simple-product.html') { + $rewrite->setUrlRewriteId($rewrite->getUrlRewriteId() + 1000); + } + } + $urlPersist->replace($rewrites); + $this->assertNotContains($category->getUrlPath(), $this->_model->getProductUrl($product)); + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductHydratorTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductHydratorTest.php new file mode 100644 index 000000000000..948170218332 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductHydratorTest.php @@ -0,0 +1,75 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Model; + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Framework\EntityManager\HydratorInterface; +use Magento\Framework\EntityManager\HydratorPool; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test Product Hydrator + */ +class ProductHydratorTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var Bootstrap + */ + private $objectManager; + + /** + * @var HydratorPool + */ + private $hydratorPool; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->hydratorPool = $this->objectManager->create(HydratorPool::class); + } + + /** + * Test that Hydrator correctly populates entity with data + */ + public function testProductHydrator() + { + $addAttributes = [ + 'sku' => 'product_updated', + 'name' => 'Product (Updated)', + 'type_id' => 'simple', + 'status' => 1, + ]; + + /** @var Product $product */ + $product = $this->objectManager->create(Product::class); + $product->setId(42) + ->setSku('product') + ->setName('Product') + ->setPrice(10) + ->setQty(123); + $product->lockAttribute('sku'); + $product->lockAttribute('type_id'); + $product->lockAttribute('price'); + + /** @var HydratorInterface $hydrator */ + $hydrator = $this->hydratorPool->getHydrator(ProductInterface::class); + $hydrator->hydrate($product, $addAttributes); + + $expected = [ + 'entity_id' => 42, + 'sku' => 'product_updated', + 'name' => 'Product (Updated)', + 'type_id' => 'simple', + 'status' => 1, + 'price' => 10, + 'qty' => 123, + ]; + $this->assertEquals($expected, $product->getData()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php index c34120404a95..d7da47ef7872 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php @@ -8,7 +8,12 @@ namespace Magento\Catalog\Model; +use Magento\Catalog\Model\Product; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; /** * Tests product model: @@ -26,31 +31,32 @@ class ProductTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\Catalog\Api\ProductRepositoryInterface + * @var ProductRepositoryInterface */ protected $productRepository; /** - * @var \Magento\Catalog\Model\Product + * @var Product */ protected $_model; + /** + * @var ObjectManagerInterface + */ + private $objectManager; + /** * @inheritdoc */ protected function setUp() { - $this->productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); - - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Product::class - ); + $this->objectManager = Bootstrap::getObjectManager(); + $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $this->_model = $this->objectManager->create(Product::class); } /** - * @throws \Magento\Framework\Exception\FileSystemException - * @return void + * @inheritdoc */ public static function tearDownAfterClass() { @@ -74,6 +80,8 @@ public static function tearDownAfterClass() } /** + * Test can affect options + * * @return void */ public function testCanAffectOptions() @@ -84,6 +92,8 @@ public function testCanAffectOptions() } /** + * Test CRUD + * * @magentoDbIsolation enabled * @magentoAppIsolation enabled * @magentoAppArea adminhtml @@ -116,6 +126,8 @@ public function testCRUD() } /** + * Test clean cache + * * @return void */ public function testCleanCache() @@ -139,6 +151,8 @@ public function testCleanCache() } /** + * Test add image to media gallery + * * @return void */ public function testAddImageToMediaGallery() @@ -183,6 +197,8 @@ protected function _copyFileToBaseTmpMediaPath($sourceFile) } /** + * Test duplicate method + * * @magentoAppIsolation enabled * @magentoAppArea adminhtml */ @@ -213,6 +229,8 @@ public function testDuplicate() } /** + * Test duplicate sku generation + * * @magentoAppArea adminhtml */ public function testDuplicateSkuGeneration() @@ -244,6 +262,8 @@ protected function _undo($duplicate) } /** + * Test visibility api + * * @covers \Magento\Catalog\Model\Product::getVisibleInCatalogStatuses * @covers \Magento\Catalog\Model\Product::getVisibleStatuses * @covers \Magento\Catalog\Model\Product::isVisibleInCatalog @@ -286,6 +306,8 @@ public function testVisibilityApi() } /** + * Test isDuplicable and setIsDuplicable methods + * * @covers \Magento\Catalog\Model\Product::isDuplicable * @covers \Magento\Catalog\Model\Product::setIsDuplicable */ @@ -297,6 +319,8 @@ public function testIsDuplicable() } /** + * Test isSalable, isSaleable, isAvailable and isInStock methods + * * @covers \Magento\Catalog\Model\Product::isSalable * @covers \Magento\Catalog\Model\Product::isSaleable * @covers \Magento\Catalog\Model\Product::isAvailable @@ -314,6 +338,8 @@ public function testIsSalable() } /** + * Test isSalable method when Status is disabled + * * @covers \Magento\Catalog\Model\Product::isSalable * @covers \Magento\Catalog\Model\Product::isSaleable * @covers \Magento\Catalog\Model\Product::isAvailable @@ -331,6 +357,8 @@ public function testIsNotSalableWhenStatusDisabled() } /** + * Test isVirtual and getIsVirtual methods + * * @covers \Magento\Catalog\Model\Product::isVirtual * @covers \Magento\Catalog\Model\Product::getIsVirtual */ @@ -349,6 +377,8 @@ public function testIsVirtual() } /** + * Test toArray method + * * @return void */ public function testToArray() @@ -359,6 +389,8 @@ public function testToArray() } /** + * Test fromArray method + * * @return void */ public function testFromArray() @@ -368,6 +400,8 @@ public function testFromArray() } /** + * Test set original data backend + * * @magentoAppArea adminhtml */ public function testSetOrigDataBackend() @@ -378,6 +412,8 @@ public function testSetOrigDataBackend() } /** + * Test reset method + * * @magentoAppArea frontend */ public function testReset() @@ -418,6 +454,8 @@ protected function _assertEmpty($model) } /** + * Test is products has sku + * * @magentoDataFixture Magento/Catalog/_files/multiple_products.php */ public function testIsProductsHasSku() @@ -433,6 +471,8 @@ public function testIsProductsHasSku() } /** + * Test process by request + * * @return void */ public function testProcessBuyRequest() @@ -444,6 +484,8 @@ public function testProcessBuyRequest() } /** + * Test validate method + * * @return void */ public function testValidate() @@ -480,6 +522,8 @@ public function testValidate() } /** + * Test validate unique input attribute value + * * @magentoDbIsolation enabled * @magentoDataFixture Magento/Catalog/_files/products_with_unique_input_attribute.php */ @@ -523,6 +567,8 @@ public function testValidateUniqueInputAttributeValue() } /** + * Test validate unique input attribute value on the same product + * * @magentoDbIsolation enabled * @magentoDataFixture Magento/Catalog/_files/products_with_unique_input_attribute.php */ @@ -618,8 +664,53 @@ public function testSaveWithBackordersEnabled(int $qty, int $stockStatus, bool $ $this->assertEquals($expectedStockStatus, $stockItem->getIsInStock()); } + /** + * Checking enable/disable product when Catalog Flat Product is enabled + * + * @magentoAppArea frontend + * @magentoDbIsolation disabled + * @magentoConfigFixture current_store catalog/frontend/flat_catalog_product 1 + * @magentoDataFixture Magento/Catalog/_files/product_simple.php + * + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\InputException + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @throws \Magento\Framework\Exception\StateException + */ + public function testProductStatusWhenCatalogFlatProductIsEnabled() + { + // check if product flat table is enabled + $productFlatState = $this->objectManager->get(\Magento\Catalog\Model\Indexer\Product\Flat\State::class); + $this->assertTrue($productFlatState->isFlatEnabled()); + // run reindex to create product flat table + $productFlatProcessor = $this->objectManager->get(\Magento\Catalog\Model\Indexer\Product\Flat\Processor::class); + $productFlatProcessor->reindexAll(); + // get created simple product + $product = $this->productRepository->get('simple'); + // get db connection and the product flat table name + $resource = $this->objectManager->get(\Magento\Framework\App\ResourceConnection::class); + /** @var \Magento\Framework\DB\Adapter\AdapterInterface $connection */ + $connection = $resource->getConnection(); + $productFlatTableName = $productFlatState->getFlatIndexerHelper()->getFlatTableName(1); + // generate sql query to find created simple product in the flat table + $sql = $connection->select()->from($productFlatTableName)->where('sku =?', $product->getSku()); + // check if the product exists in the product flat table + $products = $connection->fetchAll($sql); + $this->assertEquals(Status::STATUS_ENABLED, $product->getStatus()); + $this->assertNotEmpty($products); + // disable product + $product->setStatus(Status::STATUS_DISABLED); + $product = $this->productRepository->save($product); + // check if the product exists in the product flat table + $products = $connection->fetchAll($sql); + $this->assertEquals(Status::STATUS_DISABLED, $product->getStatus()); + $this->assertEmpty($products); + } + /** * DataProvider for the testSaveWithBackordersEnabled() + * * @return array */ public function productWithBackordersDataProvider(): array diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Eav/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Eav/AttributeTest.php index 349853c8a393..498c3167ed73 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Eav/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Eav/AttributeTest.php @@ -5,6 +5,9 @@ */ namespace Magento\Catalog\Model\ResourceModel\Eav; +/** + * Test for \Magento\Catalog\Model\ResourceModel\Eav\Attribute. + */ class AttributeTest extends \PHPUnit\Framework\TestCase { /** @@ -19,6 +22,11 @@ protected function setUp() ); } + /** + * Test Create -> Read -> Update -> Delete attribute operations. + * + * @return void + */ public function testCRUD() { $this->_model->setAttributeCode( @@ -31,7 +39,7 @@ public function testCRUD() )->getId() )->setFrontendLabel( 'test' - ); + )->setIsUserDefined(1); $crud = new \Magento\TestFramework\Entity($this->_model, ['frontend_label' => uniqid()]); $crud->testCrud(); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php index 5cf6d00fe77e..78ae21b1441b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/SourceTest.php @@ -7,12 +7,17 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Eav\Api\Data\AttributeOptionInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\Catalog\_files\MultiselectSourceMock; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Store\Api\Data\StoreInterface; /** * Class SourceTest * @magentoAppIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SourceTest extends \PHPUnit\Framework\TestCase { @@ -159,6 +164,42 @@ public function testReindexMultiselectAttribute() $this->assertCount(3, $result); } + /** + * Test for indexing product attribute without "all store view" value + * + * @magentoDataFixture Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view.php + * @magentoDbIsolation disabled + */ + public function testReindexSelectAttributeWithoutDefault() + { + $objectManager = Bootstrap::getObjectManager(); + /** @var StoreInterface $store */ + $store = $objectManager->get(StoreManagerInterface::class) + ->getStore(); + /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute **/ + $attribute = $objectManager->get(\Magento\Eav\Model\Config::class) + ->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'dropdown_without_default'); + /** @var AttributeOptionInterface $option */ + $option = $attribute->getOptions()[1]; + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $objectManager->get(ProductRepositoryInterface::class); + $product = $productRepository->get('test_attribute_dropdown_without_default', false, 1); + $expected = [ + 'entity_id' => $product->getId(), + 'attribute_id' => $attribute->getId(), + 'store_id' => $store->getId(), + 'value' => $option->getValue(), + 'source_id' => $product->getId(), + ]; + $connection = $this->productResource->getConnection(); + $select = $connection->select()->from($this->productResource->getTable('catalog_product_index_eav')) + ->where('entity_id = ?', $product->getId()) + ->where('attribute_id = ?', $attribute->getId()); + + $result = $connection->fetchRow($select); + $this->assertEquals($expected, $result); + } + /** * @magentoDataFixture Magento/Catalog/_files/products_with_multiselect_attribute_with_source_model.php * @magentoDbIsolation disabled diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default.php new file mode 100644 index 000000000000..d48578aa7346 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class); +$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product'); +$defaultSetId = $objectManager->create(\Magento\Catalog\Model\Product::class)->getDefaultAttributeSetid(); +$data = [ + 'attribute_set_name' => 'new_attribute_set', + 'entity_type_id' => $entityType->getId(), + 'sort_order' => 300, +]; + +$attributeSet->setData($data); +$attributeSet->validate(); +$attributeSet->save(); +$attributeSet->initFromSkeleton($defaultSetId); +$attributeSet->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_rollback.php new file mode 100644 index 000000000000..4cd18f6d23e8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_rollback.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$entityType = $objectManager->create(\Magento\Eav\Model\Entity\Type::class)->loadByCode('catalog_product'); + +$attributeSetCollection = $objectManager->create( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory::class +)->create(); +$attributeSetCollection->addFilter('attribute_set_name', 'new_attribute_set'); +$attributeSetCollection->addFilter('entity_type_id', $entityType->getId()); +$attributeSetCollection->setOrder('attribute_set_id'); +$attributeSetCollection->setPageSize(1); +$attributeSetCollection->load(); + +$attributeSet = $attributeSetCollection->fetchItem(); +$attributeSet->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image.php new file mode 100644 index 000000000000..934abffcb9c5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +require_once 'catalog_category_image.php'; + +/** @var $category \Magento\Catalog\Model\Category */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$categoryParent = $objectManager->create(\Magento\Catalog\Model\Category::class); +$categoryParent->setName('Parent Image Category') + ->setPath('1/2') + ->setLevel(2) + ->setImage($filePath) + ->setAvailableSortBy('name') + ->setDefaultSortBy('name') + ->setIsActive(true) + ->setPosition(1) + ->save(); + +$categoryChild = $objectManager->create(\Magento\Catalog\Model\Category::class); +$categoryChild->setName('Child Image Category') + ->setPath($categoryParent->getPath()) + ->setLevel(3) + ->setImage($filePath) + ->setAvailableSortBy('name') + ->setDefaultSortBy('name') + ->setIsActive(true) + ->setPosition(2) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image_rollback.php new file mode 100644 index 000000000000..baea438e9340 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_image_rollback.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** @var \Magento\Framework\ObjectManagerInterface $objectManager */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var \Magento\Framework\Registry $registry */ +$registry = $objectManager->get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ +$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class); +$collection + ->addAttributeToFilter('name', ['in' => ['Parent Image Category', 'Child Image Category']]) + ->load() + ->delete(); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories.php index a5ab96193246..25bb55ffbc32 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories.php @@ -64,6 +64,7 @@ ->setIsActive(true) ->setIsAnchor(true) ->setPosition(1) + ->setDescription('Category 1.1 description.') ->save(); $category = $objectManager->create(\Magento\Catalog\Model\Category::class); @@ -79,6 +80,7 @@ ->setPosition(1) ->setCustomUseParentSettings(0) ->setCustomDesign('Magento/blank') + ->setDescription('This is the description for Category 1.1.1') ->save(); $category = $objectManager->create(\Magento\Catalog\Model\Category::class); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/category_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_attribute.php index 37398abdb8f7..29b4a05c4dcb 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/category_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/category_attribute.php @@ -9,5 +9,6 @@ ->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); $attribute->setAttributeCode('test_attribute_code_666') ->setEntityTypeId(3) - ->setIsGlobal(1); + ->setIsGlobal(1) + ->setIsUserDefined(1); $attribute->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/magento_image.gif b/dev/tests/integration/testsuite/Magento/Catalog/_files/magento_image.gif new file mode 100755 index 000000000000..82bccf7ba2fa Binary files /dev/null and b/dev/tests/integration/testsuite/Magento/Catalog/_files/magento_image.gif differ diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute.php index b5187d5d8076..b59675c5a28a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_attribute.php @@ -10,5 +10,6 @@ $attribute->setAttributeCode('test_attribute_code_333') ->setEntityTypeId(4) ->setIsGlobal(1) - ->setPrice(95); + ->setPrice(95) + ->setIsUserDefined(1); $attribute->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php new file mode 100644 index 000000000000..82a1cd4b98e3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Model\Product\Type; +use Magento\Catalog\Model\Product\Visibility; +use Magento\CatalogInventory\Api\Data\StockItemInterface; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); + +/** @var Product $product */ +$product = $objectManager->create(Product::class); +$product->isObjectNew(true); +$product->setTypeId(Type::TYPE_SIMPLE) + ->setStoreId(Store::DEFAULT_STORE_ID) + ->setAttributeSetId(4) + ->setWebsiteIds([1]) + ->setName('Simple Product 100') + ->setSku('simple_100') + ->setUrlKey('url-key') + ->setPrice(10) + ->setWeight(1) + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED); + +/** @var StockItemInterface $stockItem */ +$stockItem = $objectManager->create(StockItemInterface::class); +$stockItem->setQty(100) + ->setIsInStock(true); +$extensionAttributes = $product->getExtensionAttributes(); +$extensionAttributes->setStockItem($stockItem); + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$product = $productRepository->save($product); + +$product->setStoreId(Store::DISTRO_STORE_ID) + ->setName('StoreTitle') + ->setUrlKey('url-key'); +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php new file mode 100644 index 000000000000..7130a7c4a561 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +try { + $productRepository->deleteById('simple_100'); +} catch (NoSuchEntityException $e) { + //Entity already deleted +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories.php new file mode 100644 index 000000000000..6ae4af61bc51 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Type; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\TestFramework\ObjectManager; + +Bootstrap::getInstance()->reinitialize(); + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); + +/** @var $product Product */ +$product = $objectManager->create(Product::class); +$product->isObjectNew(true); +$product->setTypeId(Type::TYPE_SIMPLE) + ->setId(1) + ->setAttributeSetId(4) + ->setWebsiteIds([1]) + ->setName('Simple Product') + ->setSku('simple') + ->setPrice(10) + ->setWeight(1) + ->setShortDescription('Short description') + ->setTaxClassId(0) + ->setDescription('Description with <b>html tag</b>') + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData( + [ + 'use_config_manage_stock' => 1, + 'qty' => 0, + 'is_qty_decimal' => 0, + 'is_in_stock' => 0, + ] + )->setCanSaveCustomOptions(true) + ->setHasOptions(true); + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->create(ProductRepositoryInterface::class); +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories_rollback.php new file mode 100644 index 000000000000..4c858f322f8a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_out_of_stock_without_categories_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +include __DIR__ . '/product_simple_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php index 23fd8d7fe324..928c036e8fb4 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_non_latin_url_key.php @@ -41,7 +41,7 @@ $productRepository->save($product); } catch (\Exception $e) { // problems during save -}; +} /** @var ProductInterface $product */ $product = $objectManager->create(ProductInterface::class); @@ -60,4 +60,4 @@ $productRepository->save($product); } catch (\Exception $e) { // problems during save -}; +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_options.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_options.php index 93c7ba61c6f4..67288bec86ad 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_options.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_options.php @@ -106,6 +106,15 @@ 'sort_order' => 2, ], ], + ], + [ + 'title' => 'date option', + 'type' => 'date', + 'price' => 80.0, + 'price_type' => 'fixed', + 'sku' => 'date option sku', + 'is_require' => false, + 'sort_order' => 6 ] ]; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute.php new file mode 100644 index 000000000000..1e7429cc831f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute.php @@ -0,0 +1,16 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +// phpcs:ignore Magento2.Security.IncludeFile +require __DIR__ . '/product_attribute.php'; +/** @var $attributeRepository \Magento\Catalog\Model\Product\Attribute\Repository */ +$attributeRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Model\Product\Attribute\Repository::class); +/** @var $attribute \Magento\Eav\Api\Data\AttributeInterface */ +$attribute = $attributeRepository->get('test_attribute_code_333'); + +$attributeRepository->save($attribute->setIsUserDefined(0)); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute_rollback.php new file mode 100644 index 000000000000..0f997ff4b494 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_system_attribute_rollback.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Exception\NoSuchEntityException; + +/** @var $attributeRepository \Magento\Catalog\Model\Product\Attribute\Repository */ +$attributeRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Catalog\Model\Product\Attribute\Repository::class); + +try { + /** @var $attribute \Magento\Eav\Api\Data\AttributeInterface */ + $attribute = $attributeRepository->get('test_attribute_code_333'); + $attributeRepository->save($attribute->setIsUserDefined(1)); + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch +} catch (NoSuchEntityException $e) { +} +/** @var \Magento\Framework\Registry $registry */ +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +try { + $attribute = $attributeRepository->get('test_attribute_code_333'); + if ($attribute->getId()) { + $attribute->delete(); + } + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch +} catch (\Exception $e) { +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types.php new file mode 100644 index 000000000000..4176e14209ed --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; + +require __DIR__ . '/product_image.php'; +require __DIR__ . '/product_simple.php'; + +$objectManager = Bootstrap::getObjectManager(); +$productRepository = $objectManager->create(ProductRepositoryInterface::class); +$product = $productRepository->get('simple'); +$imageData = [ + 'file' => '/m/a/magento_image.jpg', + 'position' => 1, + 'label' => 'Image Alt Text', + 'disabled' => 0, + 'media_type' => 'image' +]; + +/** @var $product Product */ +$product->setStoreId(0) + ->setData('media_gallery', ['images' => [$imageData]]) + ->setCanSaveCustomOptions(true) + ->save(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types_rollback.php new file mode 100644 index 000000000000..2033f092b397 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_image_without_types_rollback.php @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/product_simple_rollback.php'; +require __DIR__ . '/product_image_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view.php new file mode 100644 index 000000000000..7c872a66f60d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Eav\Model\Config as EavConfig; +use Magento\Catalog\Setup\CategorySetup; +use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Model\Product\Type as ProductType; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Eav\Api\AttributeOptionManagementInterface; +use Magento\Eav\Api\Data\AttributeOptionInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Store\Api\Data\StoreInterface; + +$objectManager = Bootstrap::getObjectManager(); +$storeManager = $objectManager->get(StoreManagerInterface::class); +/** @var StoreInterface $store */ +$store = $storeManager->getStore(); +$eavConfig = $objectManager->get(EavConfig::class); +$eavConfig->clear(); +$attribute = $eavConfig->getAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'dropdown_without_default'); +/** @var CategorySetup $installer */ +$installer = $objectManager->get(CategorySetup::class); +$attributeSetId = $installer->getAttributeSetId(ProductAttributeInterface::ENTITY_TYPE_CODE, 'Default'); + +/** @var ProductInterface $product */ +$product = $objectManager->get(ProductInterface::class); +$product->setTypeId(ProductType::TYPE_SIMPLE) + ->setAttributeSetId($attributeSetId) + ->setName('Simple Product1') + ->setSku('test_attribute_dropdown_without_default') + ->setPrice(10) + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$product = $productRepository->save($product); + +if (!$attribute->getId()) { + /** @var $attribute */ + $attribute = $objectManager->get(EavAttribute::class); + /** @var AttributeRepositoryInterface $attributeRepository */ + $attributeRepository = $objectManager->get(AttributeRepositoryInterface::class); + $attribute->setData( + [ + 'attribute_code' => 'dropdown_without_default', + 'entity_type_id' => $installer->getEntityTypeId(ProductAttributeInterface::ENTITY_TYPE_CODE), + 'is_global' => 0, + 'is_user_defined' => 1, + 'frontend_input' => 'select', + 'is_unique' => 0, + 'is_required' => 0, + 'is_searchable' => 1, + 'is_visible_in_advanced_search' => 1, + 'is_comparable' => 1, + 'is_filterable' => 1, + 'is_filterable_in_search' => 1, + 'is_used_for_promo_rules' => 0, + 'is_html_allowed_on_front' => 1, + 'is_visible_on_front' => 1, + 'used_in_product_listing' => 1, + 'used_for_sort_by' => 1, + 'frontend_label' => ['Test Configurable'], + 'backend_type' => 'int', + 'option' => [ + 'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']], + 'order' => ['option_0' => 1, 'option_1' => 2], + ], + ] + ); + $attributeRepository->save($attribute); + /* Assign attribute to attribute set */ + $installer->addAttributeToGroup( + ProductAttributeInterface::ENTITY_TYPE_CODE, + 'Default', + 'General', + $attribute->getId() + ); +} +/** @var AttributeOptionManagementInterface $options */ +$attributeOption = $objectManager->get(AttributeOptionManagementInterface::class); +/* Getting the first nonempty option */ +/** @var AttributeOptionInterface $option */ +$option = $attributeOption->getItems($attribute->getEntityTypeId(), $attribute->getAttributeCode())[1]; +$product->setStoreId($store->getId()) + ->setData('dropdown_without_default', $option->getValue()); +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view_rollback.php new file mode 100644 index 000000000000..a60588c16ab6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_dropdown_attribute_without_all_store_view_rollback.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Eav\Api\AttributeRepositoryInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Eav\Model\Config as EavConfig; +use Magento\Eav\Api\Data\AttributeInterface; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Catalog\Model\Indexer\Product\Eav as ProductEav; +use Magento\Framework\Registry; + +$objectManager = Bootstrap::getObjectManager(); +/** @var \Magento\Framework\Registry $registry */ +$registry = $objectManager->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$eavConfig = $objectManager->get(EavConfig::class); +$eavConfig->clear(); +/** @var AttributeRepositoryInterface $attributeRepository */ +$attributeRepository = $objectManager->get(AttributeRepositoryInterface::class); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +try { + /** @var AttributeInterface $attribute */ + $attribute = $attributeRepository->get(ProductAttributeInterface::ENTITY_TYPE_CODE, 'dropdown_without_default'); + $attributeRepository->delete($attribute); +} catch (NoSuchEntityException $e) { + //Attribute already deleted +} +try { + /** @var ProductInterface $product */ + $product = $productRepository->get('test_attribute_dropdown_without_default'); + $productRepository->delete($product); +} catch (NoSuchEntityException $e) { + //Product already deleted +} +$objectManager->get(ProductEav::class)->executeRow($product->getId()); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 1b33cd695d06..76e1c640b9fb 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -24,10 +24,10 @@ use Magento\Framework\Filesystem; use Magento\Framework\Registry; use Magento\ImportExport\Model\Import; +use Magento\ImportExport\Model\Import\Source\Csv; use Magento\Store\Model\Store; use Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollection; use Psr\Log\LoggerInterface; -use Magento\ImportExport\Model\Import\Source\Csv; /** * Class ProductTest @@ -98,7 +98,7 @@ protected function tearDown() try { $product = $productRepository->get($productSku, false, null, true); $productRepository->delete($product); - // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock + // phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch } catch (NoSuchEntityException $e) { // nothing to delete } @@ -1744,7 +1744,11 @@ public function testUpdateUrlRewritesOnImport() /** @var \Magento\Catalog\Model\Product $product */ $product = $this->objectManager->create(\Magento\Catalog\Model\ProductRepository::class)->get('simple'); - + $listOfProductUrlKeys = [ + sprintf('%s.html', $product->getUrlKey()), + sprintf('men/tops/%s.html', $product->getUrlKey()), + sprintf('men/%s.html', $product->getUrlKey()) + ]; $repUrlRewriteCol = $this->objectManager->create( UrlRewriteCollection::class ); @@ -1754,18 +1758,15 @@ public function testUpdateUrlRewritesOnImport() ->addFieldToFilter('entity_id', ['eq'=> $product->getEntityId()]) ->addFieldToFilter('entity_type', ['eq'=> 'product']) ->load(); + $listOfUrlRewriteIds = $collUrlRewrite->getAllIds(); + $this->assertCount(3, $collUrlRewrite); - $this->assertCount(2, $collUrlRewrite); - - $this->assertEquals( - sprintf('%s.html', $product->getUrlKey()), - $collUrlRewrite->getFirstItem()->getRequestPath() - ); - - $this->assertContains( - sprintf('men/tops/%s.html', $product->getUrlKey()), - $collUrlRewrite->getLastItem()->getRequestPath() - ); + foreach ($listOfUrlRewriteIds as $key => $id) { + $this->assertEquals( + $listOfProductUrlKeys[$key], + $collUrlRewrite->getItemById($id)->getRequestPath() + ); + } } /** @@ -2498,6 +2499,8 @@ public function testImportImageForNonDefaultStore() */ public function testProductsWithMultipleStoresWhenMediaIsDisabled(): void { + $this->loginAdminUserWithUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); + $filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class); $directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT); $source = $this->objectManager->create( @@ -2580,4 +2583,22 @@ private function importFile(string $fileName): void $this->_model->importData(); } + + /** + * Set the current admin session user based on a username + * + * @param string $username + */ + private function loginAdminUserWithUsername(string $username) + { + $user = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\User\Model\User::class + )->loadByUsername($username); + + /** @var $session \Magento\Backend\Model\Auth\Session */ + $session = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Backend\Model\Auth\Session::class + ); + $session->setUser($user); + } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/UploaderTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/UploaderTest.php index f61aa7578d4a..3961a7792731 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/UploaderTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/UploaderTest.php @@ -68,11 +68,34 @@ public function testMoveWithValidFile(): void { $fileName = 'magento_additional_image_one.jpg'; $filePath = $this->directory->getAbsolutePath($this->uploader->getTmpDir() . '/' . $fileName); + //phpcs:ignore copy(__DIR__ . '/_files/' . $fileName, $filePath); $this->uploader->move($fileName); $this->assertTrue($this->directory->isExist($this->uploader->getTmpDir() . '/' . $fileName)); } + /** + * Check validation against temporary directory. + * + * @magentoAppIsolation enabled + * @return void + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testMoveWithFileOutsideTemp(): void + { + $tmpDir = $this->uploader->getTmpDir(); + if (!$this->directory->create($newTmpDir = $tmpDir .'/test1')) { + throw new \RuntimeException('Failed to create temp dir'); + } + $this->uploader->setTmpDir($newTmpDir); + $fileName = 'magento_additional_image_one.jpg'; + $filePath = $this->directory->getAbsolutePath($tmpDir . '/' . $fileName); + //phpcs:ignore + copy(__DIR__ . '/_files/' . $fileName, $filePath); + $this->uploader->move('../' .$fileName); + $this->assertTrue($this->directory->isExist($tmpDir . '/' . $fileName)); + } + /** * @magentoAppIsolation enabled * @return void @@ -83,6 +106,7 @@ public function testMoveWithInvalidFile(): void { $fileName = 'media_import_image.php'; $filePath = $this->directory->getAbsolutePath($this->uploader->getTmpDir() . '/' . $fileName); + //phpcs:ignore copy(__DIR__ . '/_files/' . $fileName, $filePath); $this->uploader->move($fileName); $this->assertFalse($this->directory->isExist($this->uploader->getTmpDir() . '/' . $fileName)); diff --git a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action/FullTest.php b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action/FullTest.php index 00c13619ff2c..6bf1f5fbf0be 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action/FullTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/Indexer/Stock/Action/FullTest.php @@ -5,42 +5,24 @@ */ namespace Magento\CatalogInventory\Model\Indexer\Stock\Action; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\Framework\ObjectManagerInterface; -use Magento\CatalogInventory\Model\Indexer\Stock\Processor; -use Magento\Catalog\Model\CategoryFactory; -use Magento\Catalog\Block\Product\ListProduct; -use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; -use Magento\Catalog\Model\Product; -use PHPUnit\Framework\TestCase; - /** * Full reindex Test */ -class FullTest extends TestCase +class FullTest extends \PHPUnit\Framework\TestCase { /** - * @var ObjectManagerInterface - */ - private $objectManager; - - /** - * @var Processor + * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor */ protected $_processor; - /** - * @inheritdoc - */ protected function setUp() { - $this->objectManager = Bootstrap::getObjectManager(); - $this->_processor = $this->objectManager->get(Processor::class); + $this->_processor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class + ); } /** - * Reindex all - * * @magentoDbIsolation disabled * @magentoAppIsolation enabled * @magentoDataFixture Magento/Catalog/_files/product_simple.php @@ -49,9 +31,13 @@ public function testReindexAll() { $this->_processor->reindexAll(); - $categoryFactory = $this->objectManager->get(CategoryFactory::class); - /** @var ListProduct $listProduct */ - $listProduct = $this->objectManager->get(ListProduct::class); + $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Catalog\Model\CategoryFactory::class + ); + /** @var \Magento\Catalog\Block\Product\ListProduct $listProduct */ + $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Catalog\Block\Product\ListProduct::class + ); $category = $categoryFactory->create()->load(2); $layer = $listProduct->getLayer(); @@ -75,37 +61,4 @@ public function testReindexAll() $this->assertEquals(100, $product->getQty()); } } - - /** - * Reindex with disabled product - * - * @return void - * @magentoDbIsolation disabled - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Catalog/_files/products_with_layered_navigation_attribute.php - */ - public function testReindexAllWithDisabledProduct(): void - { - $productCollectionFactory = $this->objectManager->get(CollectionFactory::class); - $productCollection = $productCollectionFactory - ->create() - ->addAttributeToSelect('*') - ->addAttributeToFilter('sku', ['eq' => 'simple3']) - ->addAttributeToSort('created_at', 'DESC') - ->joinField( - 'stock_status', - 'cataloginventory_stock_status', - 'stock_status', - 'product_id=entity_id', - '{{table}}.stock_id=1', - 'left' - )->load(); - - $this->assertCount(1, $productCollection); - - /** @var Product $product */ - foreach ($productCollection as $product) { - $this->assertEquals(1, $product->getData('stock_status')); - } - } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/ResourceModel/Stock/ItemTest.php b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/ResourceModel/Stock/ItemTest.php deleted file mode 100644 index 460f43d816e3..000000000000 --- a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/ResourceModel/Stock/ItemTest.php +++ /dev/null @@ -1,376 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\CatalogInventory\Model\ResourceModel\Stock; - -use PHPUnit\Framework\TestCase; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\CatalogInventory\Api\StockItemRepositoryInterface; -use Magento\CatalogInventory\Api\StockItemCriteriaInterfaceFactory; -use Magento\CatalogInventory\Api\Data\StockItemInterface; -use Magento\CatalogInventory\Api\StockConfigurationInterface; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\CatalogInventory\Model\Stock; -use Magento\TestFramework\App\Config; -use Magento\Store\Model\ScopeInterface; -use Magento\CatalogInventory\Model\Configuration; - -/** - * Item test. - * - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class ItemTest extends TestCase -{ - /** - * @var \Magento\Framework\ObjectManagerInterface - */ - private $objectManager; - - /** - * @var Item - */ - private $stockItemResourceModel; - - /** - * @var ProductRepositoryInterface - */ - private $productRepository; - - /** - * @var StockItemRepositoryInterface - */ - private $stockItemRepository; - - /** - * @var StockItemCriteriaInterfaceFactory - */ - private $stockItemCriteriaFactory; - - /** - * @var StockConfigurationInterface - */ - private $stockConfiguration; - - /** - * @var Config - */ - private $config; - - /** - * Saved Stock Status Item data. - * - * @var array - */ - private $stockStatusData; - - /** - * Saved system config data. - * - * @var array - */ - private $configData; - - /** - * @inheritdoc - */ - protected function setUp() - { - $this->objectManager = Bootstrap::getObjectManager(); - - $this->stockItemResourceModel = $this->objectManager->get(Item::class); - $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); - $this->stockItemRepository = $this->objectManager->get(StockItemRepositoryInterface::class); - $this->stockItemCriteriaFactory = $this->objectManager->get(StockItemCriteriaInterfaceFactory::class); - $this->stockConfiguration = $this->objectManager->get(StockConfigurationInterface::class); - $this->config = $this->objectManager->get(Config::class); - - $this->storeSystemConfig(); - } - - /** - * @inheritdoc - */ - protected function tearDown() - { - $this->restoreSystemConfig(); - } - - /** - * Tests updateSetOutOfStock method. - * - * @return void - * - * @magentoDataFixture Magento/Catalog/_files/product_simple.php - */ - public function testUpdateSetOutOfStock(): void - { - $stockItem = $this->getStockItem(1); - $this->saveStockItemData($stockItem); - $this->storeSystemConfig(); - - foreach ($this->stockStatusVariations() as $variation) { - /** - * Check when Stock Item use it's own configuration of backorders. - */ - $this->configureStockItem($stockItem, $variation); - $this->stockItemResourceModel->updateSetOutOfStock($this->stockConfiguration->getDefaultScopeId()); - $stockItem = $this->getStockItem(1); - - self::assertEquals($variation['is_in_stock'], $stockItem->getIsInStock(), $variation['message']); - $stockItem = $this->resetStockItem($stockItem); - - /** - * Check when Stock Item use system configuration of backorders. - */ - $this->configureStockItemWithSystemConfig($stockItem, $variation); - $this->stockItemResourceModel->updateSetOutOfStock($this->stockConfiguration->getDefaultScopeId()); - $stockItem = $this->getStockItem(1); - - self::assertEquals($variation['is_in_stock'], $stockItem->getIsInStock(), $variation['message']); - $stockItem = $this->resetStockItem($stockItem); - $this->restoreSystemConfig(); - } - } - - /** - * Tests updateSetInOfStock method. - * - * @return void - * - * @magentoDataFixture Magento/Catalog/_files/product_simple_out_of_stock.php - */ - public function testUpdateSetInStock(): void - { - $product = $this->productRepository->get('simple-out-of-stock'); - $stockItem = $this->getStockItem((int)$product->getId()); - $this->saveStockItemData($stockItem); - $this->storeSystemConfig(); - - foreach ($this->stockStatusVariations() as $variation) { - /** - * Check when Stock Item use it's own configuration of backorders. - */ - $stockItem->setStockStatusChangedAutomaticallyFlag(true); - $this->configureStockItem($stockItem, $variation); - $this->stockItemResourceModel->updateSetInStock($this->stockConfiguration->getDefaultScopeId()); - $stockItem = $this->getStockItem((int)$product->getId()); - - self::assertEquals($variation['is_in_stock'], $stockItem->getIsInStock(), $variation['message']); - $stockItem = $this->resetStockItem($stockItem); - - /** - * Check when Stock Item use the system configuration of backorders. - */ - $stockItem->setStockStatusChangedAuto(1); - $this->configureStockItemWithSystemConfig($stockItem, $variation); - $this->stockItemResourceModel->updateSetInStock($this->stockConfiguration->getDefaultScopeId()); - $stockItem = $this->getStockItem((int)$product->getId()); - - self::assertEquals($variation['is_in_stock'], $stockItem->getIsInStock(), $variation['message']); - $stockItem = $this->resetStockItem($stockItem); - $this->restoreSystemConfig(); - } - } - - /** - * Configure backorders feature for Stock Item. - * - * @param StockItemInterface $stockItem - * @param array $config - * @return void - */ - private function configureStockItem(StockItemInterface $stockItem, array $config): void - { - /** - * Configuring Stock Item to use it's own configuration. - */ - $stockItem->setUseConfigBackorders(0); - $stockItem->setUseConfigMinQty(0); - $stockItem->setQty($config['qty']); - $stockItem->setMinQty($config['min_qty']); - $stockItem->setBackorders($config['backorders']); - - $this->stockItemRepository->save($stockItem); - } - - /** - * Configure backorders feature using the system configuration for Stock Item. - * - * @param StockItemInterface $stockItem - * @param array $config - * @return void - */ - private function configureStockItemWithSystemConfig(StockItemInterface $stockItem, array $config): void - { - /** - * Configuring Stock Item to use the system configuration. - */ - $stockItem->setUseConfigBackorders(1); - $stockItem->setUseConfigMinQty(1); - - $this->config->setValue( - Configuration::XML_PATH_BACKORDERS, - $config['backorders'], - ScopeInterface::SCOPE_STORE - ); - $this->config->setValue( - Configuration::XML_PATH_MIN_QTY, - $config['min_qty'], - ScopeInterface::SCOPE_STORE - ); - - $stockItem->setQty($config['qty']); - - $this->stockItemRepository->save($stockItem); - } - - /** - * Stock status variations. - * - * @return array - */ - private function stockStatusVariations(): array - { - return [ - // Quantity has not reached Threshold - [ - 'qty' => 3, - 'min_qty' => 2, - 'backorders' => Stock::BACKORDERS_NO, - 'is_in_stock' => true, - 'message' => "Stock status should be In Stock - v.1", - ], - // Quantity has reached Threshold - [ - 'qty' => 3, - 'min_qty' => 3, - 'backorders' => Stock::BACKORDERS_NO, - 'is_in_stock' => false, - 'message' => "Stock status should be Out of Stock - v.2", - ], - // Infinite backorders - [ - 'qty' => -100, - 'min_qty' => 0, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - 'is_in_stock' => true, - 'message' => "Stock status should be In Stock for infinite backorders - v.3", - ], - // Quantity has not reached Threshold's negative value - [ - 'qty' => -99, - 'min_qty' => -100, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - 'is_in_stock' => true, - 'message' => "Stock status should be In Stock - v.4", - ], - // Quantity has reached Threshold's negative value - [ - 'qty' => -100, - 'min_qty' => -99, - 'backorders' => Stock::BACKORDERS_YES_NOTIFY, - 'is_in_stock' => false, - 'message' => "Stock status should be Out of Stock - v.5", - ], - ]; - } - - /** - * Stores Stock Item values. - * - * @param StockItemInterface $stockItem - * @return void - */ - private function saveStockItemData(StockItemInterface $stockItem): void - { - $this->stockStatusData = $stockItem->getData(); - } - - /** - * Resets Stock Item to previous saved values and prepare for new test variation. - * - * @param StockItemInterface $stockItem - * @return StockItemInterface - */ - private function resetStockItem(StockItemInterface $stockItem): StockItemInterface - { - $stockItem->setData($this->stockStatusData); - - return $this->stockItemRepository->save($stockItem); - } - - /** - * Get Stock Item by product id. - * - * @param int $productId - * @param int|null $scope - * @return StockItemInterface - * @throws NoSuchEntityException - */ - private function getStockItem(int $productId, ?int $scope = null): StockItemInterface - { - $scope = $scope ?? $this->stockConfiguration->getDefaultScopeId(); - $stockItemCriteria = $this->stockItemCriteriaFactory->create(); - $stockItemCriteria->setScopeFilter($scope); - $stockItemCriteria->setProductsFilter([$productId]); - $stockItems = $this->stockItemRepository->getList($stockItemCriteria); - $stockItems = $stockItems->getItems(); - - if (empty($stockItems)) { - throw new NoSuchEntityException(); - } - - $stockItem = reset($stockItems); - - return $stockItem; - } - - /** - * Stores system configuration. - * - * @return void - */ - private function storeSystemConfig(): void - { - /** - * Save system configuration data. - */ - $backorders = $this->config->getValue( - Configuration::XML_PATH_BACKORDERS, - ScopeInterface::SCOPE_STORE - ); - $minQty = $this->config->getValue(Configuration::XML_PATH_MIN_QTY, ScopeInterface::SCOPE_STORE); - $this->configData = [ - 'backorders' => $backorders, - 'min_qty' => $minQty, - ]; - } - - /** - * Restores system configuration. - * - * @return void - */ - private function restoreSystemConfig(): void - { - /** - * Turn back system configuration. - */ - $this->config->setValue( - Configuration::XML_PATH_BACKORDERS, - $this->configData['backorders'], - ScopeInterface::SCOPE_STORE - ); - $this->config->setValue( - Configuration::XML_PATH_MIN_QTY, - $this->configData['min_qty'], - ScopeInterface::SCOPE_STORE - ); - } -} diff --git a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/System/Config/Backend/MinqtyTest.php b/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/System/Config/Backend/MinqtyTest.php deleted file mode 100644 index c053d38fea1f..000000000000 --- a/dev/tests/integration/testsuite/Magento/CatalogInventory/Model/System/Config/Backend/MinqtyTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\CatalogInventory\Model\System\Config\Backend; - -use PHPUnit\Framework\TestCase; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\CatalogInventory\Model\Stock; - -/** - * Minqty test. - */ -class MinqtyTest extends TestCase -{ - /** - * @var Minqty - */ - private $minQtyConfig; - - /** - * @inheritdoc - */ - protected function setUp() - { - $objectManager = Bootstrap::getObjectManager(); - $this->minQtyConfig = $objectManager->create(Minqty::class); - $this->minQtyConfig->setPath('cataloginventory/item_options/min_qty'); - } - - /** - * Tests beforeSave method. - * - * @param string $value - * @param array $fieldSetData - * @param string $expected - * @return void - * - * @dataProvider minQtyConfigDataProvider - */ - public function testBeforeSave(string $value, array $fieldSetData, string $expected): void - { - $this->minQtyConfig->setData('fieldset_data', $fieldSetData); - $this->minQtyConfig->setValue($value); - $this->minQtyConfig->beforeSave(); - $this->assertEquals($expected, $this->minQtyConfig->getValue()); - } - - /** - * Minqty config data provider. - * - * @return array - */ - public function minQtyConfigDataProvider(): array - { - return [ - 'straight' => ['3', ['backorders' => Stock::BACKORDERS_NO], '3'], - 'straight2' => ['3.5', ['backorders' => Stock::BACKORDERS_NO], '3.5'], - 'negative_value_disabled_backorders' => ['-3', ['backorders' => Stock::BACKORDERS_NO], '0'], - 'negative_value_enabled_backorders' => ['-3', ['backorders' => Stock::BACKORDERS_YES_NOTIFY], '-3'], - 'negative_value_enabled_backorders2' => ['-3.05', ['backorders' => Stock::BACKORDERS_YES_NOTIFY], '-3.05'], - ]; - } -} diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProviderTest.php index c2c316ecf45c..d503c9678dfd 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Indexer/Fulltext/Action/DataProviderTest.php @@ -7,38 +7,71 @@ namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Action; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ProductRepository as ProductRepository; +use Magento\CatalogSearch\Model\Indexer\Fulltext; +use Magento\Framework\Api\Search\Document as SearchDocument; +use Magento\Framework\Indexer\IndexerRegistry; +use Magento\Framework\Search\AdapterInterface as AdapterInterface; +use Magento\Framework\Search\Request\Builder as SearchRequestBuilder; +use Magento\Framework\Search\Request\Config as SearchRequestConfig; +use Magento\Search\Model\AdapterFactory as AdapterFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + class DataProviderTest extends \PHPUnit\Framework\TestCase { + /** + * @inheritdoc + */ + public static function setUpBeforeClass() + { + /* + * Due to insufficient search engine isolation for Elasticsearch, this class must explicitly perform + * a fulltext reindex prior to running its tests. + * + * This should be removed upon completing MC-19455. + */ + $indexRegistry = Bootstrap::getObjectManager()->get(IndexerRegistry::class); + $fulltextIndexer = $indexRegistry->get(Fulltext::INDEXER_ID); + $fulltextIndexer->reindexAll(); + } + /** * @magentoDataFixture Magento/CatalogSearch/_files/product_for_search.php * @magentoDbIsolation disabled */ public function testSearchProductByAttribute() { - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var ObjectManager $objectManager */ + $objectManager = Bootstrap::getObjectManager(); + + /** @var SearchRequestConfig $config */ + $config = $objectManager->create(SearchRequestConfig::class); - $config = $objectManager->create(\Magento\Framework\Search\Request\Config::class); - /** @var \Magento\Framework\Search\Request\Builder $requestBuilder */ + /** @var SearchRequestBuilder $requestBuilder */ $requestBuilder = $objectManager->create( - \Magento\Framework\Search\Request\Builder::class, + SearchRequestBuilder::class, ['config' => $config] ); + $requestBuilder->bind('search_term', 'VALUE1'); $requestBuilder->setRequestName('quick_search_container'); $queryRequest = $requestBuilder->create(); - /** @var \Magento\Framework\Search\Adapter\Mysql\Adapter $adapter */ - $adapterFactory = $objectManager->create(\Magento\Search\Model\AdapterFactory::class); + + /** @var AdapterInterface $adapter */ + $adapterFactory = $objectManager->create(AdapterFactory::class); $adapter = $adapterFactory->create(); $queryResponse = $adapter->query($queryRequest); $actualIds = []; + foreach ($queryResponse as $document) { - /** @var \Magento\Framework\Api\Search\Document $document */ + /** @var SearchDocument $document */ $actualIds[] = $document->getId(); } - /** @var \Magento\Catalog\Model\Product $product */ - $product = $objectManager->create(\Magento\Catalog\Model\ProductRepository::class)->get('simple'); + /** @var Product $product */ + $product = $objectManager->create(ProductRepository::class)->get('simple'); $this->assertContains($product->getId(), $actualIds, 'Product not found by searchable attribute.'); } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteTest.php new file mode 100644 index 000000000000..687b997eedde --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteTest.php @@ -0,0 +1,124 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogUrlRewrite\Model; + +use Magento\Catalog\Model\CategoryFactory; +use Magento\Catalog\Model\CategoryRepository; +use Magento\Catalog\Model\ResourceModel\Category as CategoryResource; +use Magento\CatalogUrlRewrite\Model\Map\DataCategoryUrlRewriteDatabaseMap; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\UrlRewrite\Model\ResourceModel\UrlRewriteCollectionFactory; +use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; +use PHPUnit\Framework\TestCase; + +/** + * Class for category url rewrites tests + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class CategoryUrlRewriteTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var CategoryFactory */ + private $categoryFactory; + + /** @var UrlRewriteCollectionFactory */ + private $urlRewriteCollectionFactory; + + /** @var CategoryRepository */ + private $categoryRepository; + + /** @var CategoryResource */ + private $categoryResource; + + /** + * @inheritDoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->categoryFactory = $this->objectManager->get(CategoryFactory::class); + $this->urlRewriteCollectionFactory = $this->objectManager->get(UrlRewriteCollectionFactory::class); + $this->categoryRepository = $this->objectManager->get(CategoryRepository::class); + $this->categoryResource = $this->objectManager->get(CategoryResource::class); + } + + /** + * @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1 + * @magentoDataFixture Magento/Catalog/_files/category_with_position.php + * @dataProvider categoryProvider + * @param array $data + * @return void + */ + public function testUrlRewriteOnCategorySave(array $data): void + { + $categoryModel = $this->categoryFactory->create(); + $categoryModel->isObjectNew(true); + $categoryModel->setData($data['data']); + $this->categoryResource->save($categoryModel); + $this->assertNotNull($categoryModel->getId(), 'The category was not created'); + $urlRewriteCollection = $this->urlRewriteCollectionFactory->create(); + $urlRewriteCollection->addFieldToFilter(UrlRewrite::ENTITY_ID, ['eq' => $categoryModel->getId()]) + ->addFieldToFilter(UrlRewrite::ENTITY_TYPE, ['eq' => DataCategoryUrlRewriteDatabaseMap::ENTITY_TYPE]); + + foreach ($urlRewriteCollection as $item) { + foreach ($data['expected_data'] as $field => $expectedItem) { + $this->assertEquals( + sprintf($expectedItem, $categoryModel->getId()), + $item[$field], + 'The expected data does not match actual value' + ); + } + } + } + + /** + * @return array + */ + public function categoryProvider(): array + { + return [ + 'without_url_key' => [ + [ + 'data' => [ + 'name' => 'Test Category', + 'attribute_set_id' => '3', + 'parent_id' => 2, + 'path' => '1/2', + 'is_active' => true, + ], + 'expected_data' => [ + 'request_path' => 'test-category.html', + 'target_path' => 'catalog/category/view/id/%s', + ], + ], + ], + 'subcategory_without_url_key' => [ + [ + 'data' => [ + 'name' => 'Test Sub Category', + 'attribute_set_id' => '3', + 'parent_id' => 444, + 'path' => '1/2/444', + 'is_active' => true, + ], + 'expected_data' => [ + 'request_path' => 'category-1/test-sub-category.html', + 'target_path' => 'catalog/category/view/id/%s', + ], + ], + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_downloadable_product_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_downloadable_product_rollback.php new file mode 100644 index 000000000000..4048c672037b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_downloadable_product_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +// @codingStandardsIgnoreLine +require __DIR__ . '/../../../Magento/Downloadable/_files/product_downloadable_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php new file mode 100644 index 000000000000..aba813148512 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/ConfigurableTest.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\ConfigurableProduct\Block\Cart\Item\Renderer; + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable as ConfigurableRenderer; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; + +/** + * Test \Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable block + * + * @magentoAppArea frontend + */ +class ConfigurableTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var ConfigurableRenderer + */ + private $block; + + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class) + ->createBlock(ConfigurableRenderer::class); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php + */ + public function testGetProductPriceHtml() + { + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $configurableProduct = $productRepository->getById(1); + + $layout = $this->objectManager->get(LayoutInterface::class); + $layout->createBlock( + \Magento\Framework\Pricing\Render::class, + 'product.price.render.default', + [ + 'data' => [ + 'price_render_handle' => 'catalog_product_prices', + 'use_link_for_as_low_as' => true + ] + ] + ); + + $this->block->setItem( + $this->block->getCheckoutSession()->getQuote()->getAllVisibleItems()[0] + ); + $html = $this->block->getProductPriceHtml($configurableProduct); + $this->assertContains('<span class="price">$10.00</span>', $html); + } +} diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_12345.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_12345.php index 9a2f5c49ac29..70aa7c07ed53 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_12345.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_12345.php @@ -121,7 +121,7 @@ $registry->register('isSecureArea', false); $product->setTypeId(Configurable::TYPE_CODE) - ->setId(11) + ->setId(111) ->setAttributeSetId($attributeSetId) ->setWebsiteIds([1]) ->setName('Configurable Product 12345') diff --git a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php index 8e25e5960a4b..15111b27783d 100644 --- a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php +++ b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php @@ -6,11 +6,30 @@ namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currency; +use Magento\Framework\Escaper; + /** * Fetch Rates Test */ class FetchRatesTest extends \Magento\TestFramework\TestCase\AbstractBackendController { + /** + * @var Escaper + */ + private $escaper; + + /** + * Initial setup + */ + protected function setUp() + { + $this->escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + Escaper::class + ); + + parent::setUp(); + } + /** * Test fetch action without service * @@ -46,7 +65,11 @@ public function testFetchRatesActionWithNonexistentService(): void $this->dispatch('backend/admin/system_currency/fetchRates'); $this->assertSessionMessages( - $this->contains("The import model can't be initialized. Verify the model and try again."), + $this->contains( + $this->escaper->escapeHtml( + "The import model can't be initialized. Verify the model and try again." + ) + ), \Magento\Framework\Message\MessageInterface::TYPE_ERROR ); } diff --git a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php index fefd1a7b250c..536aadd190c0 100644 --- a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php +++ b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php @@ -3,9 +3,11 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currency; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Escaper; class SaveRatesTest extends \Magento\TestFramework\TestCase\AbstractBackendController { @@ -13,6 +15,11 @@ class SaveRatesTest extends \Magento\TestFramework\TestCase\AbstractBackendContr /** @var \Magento\Directory\Model\Currency $currencyRate */ protected $currencyRate; + /** + * @var Escaper + */ + private $escaper; + /** * Initial setup */ @@ -21,6 +28,10 @@ protected function setUp() $this->currencyRate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Directory\Model\Currency::class ); + $this->escaper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + Escaper::class + ); + parent::setUp(); } @@ -89,7 +100,9 @@ public function testSaveWithWarningAction() $this->assertSessionMessages( $this->contains( - (string)__('Please correct the input data for "%1 => %2" rate.', $currencyCode, $currencyTo) + $this->escaper->escapeHtml( + (string)__('Please correct the input data for "%1 => %2" rate.', $currencyCode, $currencyTo) + ) ), \Magento\Framework\Message\MessageInterface::TYPE_WARNING ); diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php index b159dceadfb7..c5b76807f1ff 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Account/Dashboard/AddressTest.php @@ -69,7 +69,7 @@ public function testGetCustomer() public function testGetCustomerMissingCustomer() { - $moduleManager = $this->objectManager->get(\Magento\Framework\Module\ModuleManagerInterface::class); + $moduleManager = $this->objectManager->get(\Magento\Framework\Module\Manager::class); if ($moduleManager->isEnabled('Magento_PageCache')) { $customerDataFactory = $this->objectManager->create( \Magento\Customer\Api\Data\CustomerInterfaceFactory::class diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php index 566dfbadedd2..d106fed69c2e 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -769,9 +769,21 @@ public function testConfirmationEmailWithSpecialCharacters(): void $message = $this->transportBuilderMock->getSentMessage(); $rawMessage = $message->getRawMessage(); - $this->assertContains('To: John Smith <' . $email . '>', $rawMessage); + /** @var \Zend\Mime\Part $messageBodyPart */ + $messageBodyParts = $message->getBody()->getParts(); + $messageBodyPart = reset($messageBodyParts); + $messageEncoding = $messageBodyPart->getCharset(); + $name = 'John Smith'; + + if (strtoupper($messageEncoding) !== 'ASCII') { + $name = \Zend\Mail\Header\HeaderWrap::mimeEncodeValue($name, $messageEncoding); + } + + $nameEmail = sprintf('%s <%s>', $name, $email); + + $this->assertContains('To: ' . $nameEmail, $rawMessage); - $content = $message->getBody()->getParts()[0]->getRawContent(); + $content = $messageBodyPart->getRawContent(); $confirmationUrl = $this->getConfirmationUrlFromMessageContent($content); $this->setRequestInfo($confirmationUrl, 'confirm'); $this->clearCookieMessagesList(); @@ -798,21 +810,6 @@ public function loginPostRedirectDataProvider() ]; } - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - * @magentoDataFixture Magento/Customer/_files/customer_address.php - * @magentoAppArea frontend - */ - public function testCheckVisitorModel() - { - /** @var \Magento\Customer\Model\Visitor $visitor */ - $visitor = $this->_objectManager->get(\Magento\Customer\Model\Visitor::class); - $this->login(1); - $this->assertNull($visitor->getId()); - $this->dispatch('customer/account/index'); - $this->assertNotNull($visitor->getId()); - } - /** * @param string $email * @return void diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php index 516e26692717..61f92070923c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php @@ -4,55 +4,37 @@ * See COPYING.txt for license details. */ -$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class); -$model->setName( - 'custom_attribute1' -)->setEntityTypeId( - 2 -)->setAttributeSetId( - 2 -)->setAttributeGroupId( - 1 -)->setFrontendInput( - 'text' -)->setFrontendLabel( - 'custom_attribute_frontend_label' -)->setIsUserDefined( - 1 -); -$model->save(); - -$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class); -$model2->setName( - 'custom_attribute2' -)->setEntityTypeId( - 2 -)->setAttributeSetId( - 2 -)->setAttributeGroupId( - 1 -)->setFrontendInput( - 'text' -)->setFrontendLabel( - 'custom_attribute_frontend_label' -)->setIsUserDefined( - 1 -); -$model2->save(); +/** @var \Magento\Framework\ObjectManagerInterface $objectManager */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var \Magento\Customer\Model\AttributeFactory $attributeFactory */ +$attributeFactory = $objectManager->create(\Magento\Customer\Model\AttributeFactory::class); + +/** @var \Magento\Eav\Api\AttributeRepositoryInterface $attributeRepository */ +$attributeRepository = $objectManager->create(\Magento\Eav\Api\AttributeRepositoryInterface::class); /** @var \Magento\Customer\Setup\CustomerSetup $setupResource */ -$setupResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Customer\Setup\CustomerSetup::class -); - -$data = [['form_code' => 'customer_address_edit', 'attribute_id' => $model->getAttributeId()]]; -$setupResource->getSetup()->getConnection()->insertMultiple( - $setupResource->getSetup()->getTable('customer_form_attribute'), - $data -); - -$data2 = [['form_code' => 'customer_address_edit', 'attribute_id' => $model2->getAttributeId()]]; -$setupResource->getSetup()->getConnection()->insertMultiple( - $setupResource->getSetup()->getTable('customer_form_attribute'), - $data2 -); +$setupResource = $objectManager->create(\Magento\Customer\Setup\CustomerSetup::class); + +$attributeNames = ['custom_attribute1', 'custom_attribute2']; +foreach ($attributeNames as $attributeName) { + /** @var \Magento\Customer\Model\Attribute $attribute */ + $attribute = $attributeFactory->create(); + + $attribute->setName($attributeName) + ->setEntityTypeId(2) + ->setAttributeSetId(2) + ->setAttributeGroupId(1) + ->setFrontendInput('text') + ->setFrontendLabel('custom_attribute_frontend_label') + ->setIsUserDefined(true); + + $attributeRepository->save($attribute); + + $setupResource->getSetup() + ->getConnection() + ->insertMultiple( + $setupResource->getSetup()->getTable('customer_form_attribute'), + [['form_code' => 'customer_address_edit', 'attribute_id' => $attribute->getAttributeId()]] + ); +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute_rollback.php index 915b3da19783..467356a9d914 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/attribute_user_defined_address_custom_attribute_rollback.php @@ -5,8 +5,9 @@ * See COPYING.txt for license details. */ -$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class); -$model->load('custom_attribute_test', 'attribute_code')->delete(); - -$model2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Attribute::class); -$model2->load('custom_attributes_test', 'attribute_code')->delete(); +/** @var \Magento\Customer\Model\Attribute $attributeModel */ +$attributeModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + \Magento\Customer\Model\Attribute::class +); +$attributeModel->load('custom_attribute1', 'attribute_code')->delete(); +$attributeModel->load('custom_attribute2', 'attribute_code')->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php new file mode 100644 index 000000000000..d8c56b7bf6f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Customer\Api\CustomerRepositoryInterface; + +require __DIR__ . '/customer.php'; + +$objectManager = Bootstrap::getObjectManager(); +$repository = $objectManager->create(CustomerRepositoryInterface::class); +$customer = $repository->get('customer@example.com'); +$customer->setStoreId(2); +$repository->save($customer); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store_rollback.php new file mode 100644 index 000000000000..61cce9dbcc8d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +include __DIR__ . '/customer_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php b/dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php index ea155894d729..a9591f1968ef 100644 --- a/dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php +++ b/dev/tests/integration/testsuite/Magento/Deploy/DeployTest.php @@ -71,6 +71,7 @@ class DeployTest extends \PHPUnit\Framework\TestCase private $options = [ Options::DRY_RUN => false, Options::NO_JAVASCRIPT => false, + Options::NO_JS_BUNDLE => false, Options::NO_CSS => false, Options::NO_LESS => false, Options::NO_IMAGES => false, @@ -100,9 +101,10 @@ protected function setUp() $this->rootDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT); $logger = $objectManager->get(\Psr\Log\LoggerInterface::class); - $this->deployService = $objectManager->create(DeployStaticContent::class, [ - 'logger' => $logger - ]); + $this->deployService = $objectManager->create( + DeployStaticContent::class, + ['logger' => $logger] + ); $this->bundleConfig = $objectManager->create(BundleConfig::class); $this->config = $objectManager->create(View::class); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php b/dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php index 60c2a41fae49..6333d60da3cf 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/Controller/Adminhtml/Downloadable/FileTest.php @@ -1,36 +1,59 @@ <?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + namespace Magento\Downloadable\Controller\Adminhtml\Downloadable; use Magento\Framework\Serialize\Serializer\Json; -use Magento\TestFramework\Helper\Bootstrap; /** * Magento\Downloadable\Controller\Adminhtml\Downloadable\File * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. * @magentoAppArea adminhtml */ class FileTest extends \Magento\TestFramework\TestCase\AbstractBackendController { + /** + * @var Json + */ + private $jsonSerializer; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->jsonSerializer = $this->_objectManager->get(Json::class); + } + /** * @inheritdoc */ protected function tearDown() { + // phpcs:ignore Magento2.Functions.DiscouragedFunction $filePath = dirname(__DIR__) . '/_files/sample.tmp'; + // phpcs:ignore Magento2.Functions.DiscouragedFunction if (is_file($filePath)) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction unlink($filePath); } } public function testUploadAction() { + // phpcs:ignore Magento2.Functions.DiscouragedFunction copy(dirname(__DIR__) . '/_files/sample.txt', dirname(__DIR__) . '/_files/sample.tmp'); + // phpcs:ignore Magento2.Security.Superglobal $_FILES = [ 'samples' => [ 'name' => 'sample.txt', 'type' => 'text/plain', + // phpcs:ignore Magento2.Functions.DiscouragedFunction 'tmp_name' => dirname(__DIR__) . '/_files/sample.tmp', 'error' => 0, 'size' => 0, @@ -40,7 +63,7 @@ public function testUploadAction() $this->getRequest()->setMethod('POST'); $this->dispatch('backend/admin/downloadable_file/upload/type/samples'); $body = $this->getResponse()->getBody(); - $result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body); + $result = $this->jsonSerializer->unserialize($body); $this->assertEquals(0, $result['error']); } @@ -52,9 +75,11 @@ public function testUploadAction() */ public function testUploadProhibitedExtensions($fileName) { + // phpcs:ignore Magento2.Functions.DiscouragedFunction $path = dirname(__DIR__) . '/_files/'; + // phpcs:ignore Magento2.Functions.DiscouragedFunction copy($path . 'sample.txt', $path . 'sample.tmp'); - + // phpcs:ignore Magento2.Security.Superglobal $_FILES = [ 'samples' => [ 'name' => $fileName, @@ -68,7 +93,7 @@ public function testUploadProhibitedExtensions($fileName) $this->getRequest()->setMethod('POST'); $this->dispatch('backend/admin/downloadable_file/upload/type/samples'); $body = $this->getResponse()->getBody(); - $result = Bootstrap::getObjectManager()->get(Json::class)->unserialize($body); + $result = $this->jsonSerializer->unserialize($body); self::assertArrayHasKey('errorcode', $result); self::assertEquals(0, $result['errorcode']); @@ -90,4 +115,37 @@ public function extensionsDataProvider() ['sample.php7'], ]; } + + /** + * @dataProvider uploadWrongUploadTypeDataProvider + * @return void + */ + public function testUploadWrongUploadType($postData): void + { + $this->getRequest()->setPostValue($postData); + $this->getRequest()->setMethod('POST'); + + $this->dispatch('backend/admin/downloadable_file/upload'); + + $body = $this->getResponse()->getBody(); + $result = $this->jsonSerializer->unserialize($body); + $this->assertEquals('Upload type can not be determined.', $result['error']); + $this->assertEquals(0, $result['errorcode']); + } + + public function uploadWrongUploadTypeDataProvider(): array + { + return [ + [ + ['type' => 'test'], + ], + [ + [ + 'type' => [ + 'type1' => 'test', + ], + ], + ], + ]; + } } diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/Model/Url/DomainValidatorTest.php b/dev/tests/integration/testsuite/Magento/Downloadable/Model/Url/DomainValidatorTest.php new file mode 100644 index 000000000000..86b5bf3ed05c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/Model/Url/DomainValidatorTest.php @@ -0,0 +1,98 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Downloadable\Model\Url; + +use Magento\Downloadable\Model\DomainManager; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Framework\App\DeploymentConfig; + +/** + * Test for Magento\Downloadable\Model\Url\DomainValidator + */ +class DomainValidatorTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var DomainValidator + */ + private $model; + + /** + * @var DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + */ + private $deploymentConfig; + + protected function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + + $this->deploymentConfig = $this->createPartialMock( + DeploymentConfig::class, + ['get'] + ); + + $domainManager = $objectManager->create( + DomainManager::class, + ['deploymentConfig' => $this->deploymentConfig] + ); + + $this->model = $objectManager->create( + DomainValidator::class, + ['domainManager' => $domainManager] + ); + } + + /** + * @param string $urlInput + * @param array $envDomainWhitelist + * @param bool $isValid + * + * @magentoDataFixture Magento/Store/_files/second_store.php + * @magentoConfigFixture current_store web/unsecure/base_url http://example.com/ + * @magentoConfigFixture current_store web/secure/base_url https://secure.example.com/ + * @magentoConfigFixture fixture_second_store_store web/unsecure/base_url http://example2.com/ + * @magentoConfigFixture fixture_second_store_store web/secure/base_url https://secure.example2.com/ + * @dataProvider isValidDataProvider + */ + public function testIsValid(string $urlInput, array $envDomainWhitelist, bool $isValid) + { + $this->deploymentConfig + ->method('get') + ->with(DomainValidator::PARAM_DOWNLOADABLE_DOMAINS) + ->willReturn($envDomainWhitelist); + + $this->assertEquals( + $isValid, + $this->model->isValid($urlInput), + 'Failed asserting is ' . ($isValid ? 'valid' : 'not valid') . ': ' . $urlInput . + PHP_EOL . + 'Domain whitelist: ' . implode(', ', $envDomainWhitelist) + ); + } + + public function isValidDataProvider() + { + return [ + ['http://example.com', ['example.co'], false], + [' http://example.com ', ['example.com'], false], + ['http://example.com', ['example.com'], true], + ['https://example.com', ['example.com'], true], + ['https://example.com/downloadable.pdf', ['example.com'], true], + ['https://example.com:8080/downloadable.pdf', ['example.com'], true], + ['http://secure.example.com', ['secure.example.com'], true], + ['https://secure.example.com', ['secure.example.com'], true], + ['https://ultra.secure.example.com', ['secure.example.com'], false], + ['http://example2.com', ['example2.com'], true], + ['https://example2.com', ['example2.com'], true], + ['http://subdomain.example2.com', ['example2.com'], false], + ['https://adobe.com', ['adobe.com'], true], + ['https://subdomain.adobe.com', ['adobe.com'], false], + ['https://ADOBE.COm', ['adobe.com'], true], + ['https://adobe.com', ['ADOBE.COm'], true], + ['http://127.0.0.1', ['127.0.0.1'], false], + ['http://[::1]', ['::1'], false], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url.php index 9c0b328fc166..e312d973aeb1 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url.php @@ -3,10 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -declare(strict_types=1); + +use Magento\Downloadable\Api\DomainManagerInterface; $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +/** @var DomainManagerInterface $domainManager */ +$domainManager = $objectManager->get(DomainManagerInterface::class); +$domainManager->addDomains(['example.com', 'sampleurl.com']); + /** * @var \Magento\Catalog\Model\Product $product */ @@ -74,6 +79,7 @@ */ $sampleContent = $objectManager->create(\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class)->create(); $sampleContent->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $sampleContent->setName('jellyfish_1_3.jpg'); @@ -92,10 +98,10 @@ */ $content = $objectManager->create(\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class)->create(); $content->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $content->setName('jellyfish_2_4.jpg'); -//$content->setName(''); $sampleLink->setLinkFileContent($content); $links[] = $sampleLink; @@ -146,6 +152,7 @@ \Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class )->create(); $content->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $content->setName('jellyfish_1_4.jpg'); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url_rollback.php index 9ad910eed873..48d6966fb90d 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/downloadable_product_with_files_and_sample_url_rollback.php @@ -3,4 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +use Magento\Downloadable\Api\DomainManagerInterface; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var DomainManagerInterface $domainManager */ +$domainManager = $objectManager->get(DomainManagerInterface::class); +$domainManager->removeDomains(['sampleurl.com']); + +// @codingStandardsIgnoreLine require __DIR__ . '/product_downloadable_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable.php index 19cf449912b6..25344ea447d9 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable.php @@ -3,10 +3,24 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -/** - * @var \Magento\Catalog\Model\Product $product - */ -$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); + +use Magento\Downloadable\Api\DomainManagerInterface; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var DomainManagerInterface $domainManager */ +$domainManager = $objectManager->get(DomainManagerInterface::class); +$domainManager->addDomains( + [ + 'example.com', + 'www.example.com', + 'www.sample.example.com', + 'google.com' + ] +); + +/** @var \Magento\Catalog\Model\Product $product */ +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); $product ->setTypeId(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) ->setId(1) diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php index 996fbb01d72c..9a2e1c74fcd3 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_rollback.php @@ -3,23 +3,38 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +use Magento\Downloadable\Api\DomainManagerInterface; use Magento\Framework\Exception\NoSuchEntityException; \Magento\TestFramework\Helper\Bootstrap::getInstance()->getInstance()->reinitialize(); +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var DomainManagerInterface $domainManager */ +$domainManager = $objectManager->get(DomainManagerInterface::class); +$domainManager->removeDomains( + [ + 'example.com', + 'www.example.com', + 'www.sample.example.com', + 'google.com' + ] +); + /** @var \Magento\Framework\Registry $registry */ -$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); +$registry = $objectManager->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ -$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() +$productRepository = $objectManager ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); try { $product = $productRepository->get('downloadable-product', false, null, true); $productRepository->delete($product); -} catch (NoSuchEntityException $e) { +} catch (NoSuchEntityException $e) { // @codingStandardsIgnoreLine } $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_custom_options.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_custom_options.php index b5528dd27ee7..f0a26f8a36d9 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_custom_options.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_custom_options.php @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -use Magento\TestFramework\Helper\Bootstrap as Bootstrap; +use Magento\TestFramework\Helper\Bootstrap; require __DIR__ . '/product_downloadable_with_purchased_separately_links.php'; diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit.php new file mode 100644 index 000000000000..f0c6e013a9d9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Downloadable\Api\Data\LinkInterface; +use Magento\Downloadable\Api\LinkRepositoryInterface; +use Magento\Downloadable\Helper\Download; +use Magento\Downloadable\Model\Link; +use Magento\Downloadable\Model\Product\Type; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Downloadable\Api\DomainManagerInterface; + +/** @var DomainManagerInterface $domainManager */ +$domainManager = Bootstrap::getObjectManager()->get(DomainManagerInterface::class); +$domainManager->addDomains(['example.com']); + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = Bootstrap::getObjectManager() + ->get(ProductRepositoryInterface::class); +/** @var LinkRepositoryInterface $linkRepository */ +$linkRepository = Bootstrap::getObjectManager() + ->create(LinkRepositoryInterface::class); +/** @var ProductInterface $product */ +$product = Bootstrap::getObjectManager() + ->create(ProductInterface::class); +/** @var LinkInterface $downloadableProductLink */ +$downloadableProductLink = Bootstrap::getObjectManager() + ->create(LinkInterface::class); + +$downloadableProductLink +// ->setId(null) + ->setLinkType(Download::LINK_TYPE_URL) + ->setTitle('Downloadable Product Link') + ->setIsShareable(Link::LINK_SHAREABLE_CONFIG) + ->setLinkUrl('http://example.com/downloadable.txt') + ->setNumberOfDownloads(100) + ->setSortOrder(1) + ->setPrice(0); + +$downloadableProductLinks[] = $downloadableProductLink; + +$product + ->setId(1) + ->setTypeId(Type::TYPE_DOWNLOADABLE) + ->setExtensionAttributes( + $product->getExtensionAttributes() + ->setDownloadableProductLinks($downloadableProductLinks) + ) + ->setSku('downloadable-product') + ->setAttributeSetId(4) + ->setWebsiteIds([1]) + ->setName('Downloadable Product Limited') + ->setPrice(10) + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setLinksPurchasedSeparately(true) + ->setStockData( + [ + 'qty' => 100, + 'is_in_stock' => 1, + 'manage_stock' => 1, + ] + ); + +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit_rollback.php new file mode 100644 index 000000000000..d88f6f180343 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_download_limit_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/product_downloadable_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_files.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_files.php index 86aa61a99e1e..a6c58c586ea1 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_files.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_files.php @@ -4,8 +4,22 @@ * See COPYING.txt for license details. */ +use Magento\Downloadable\Api\DomainManagerInterface; + \Magento\TestFramework\Helper\Bootstrap::getInstance()->getInstance()->reinitialize(); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var DomainManagerInterface $domainManager */ +$domainManager = $objectManager->get(DomainManagerInterface::class); +$domainManager->addDomains( + [ + 'example.com', + 'www.example.com', + 'www.sample.example.com', + 'google.com' + ] +); + /** * @var \Magento\Catalog\Model\Product $product */ @@ -81,10 +95,10 @@ */ $content = $objectManager->create(\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class)->create(); $content->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $content->setName('jellyfish_2_4.jpg'); -//$content->setName(''); $link->setLinkFileContent($content); /** @@ -92,6 +106,7 @@ */ $sampleContent = $objectManager->create(\Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class)->create(); $sampleContent->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $sampleContent->setName('jellyfish_1_3.jpg'); @@ -136,6 +151,7 @@ \Magento\Downloadable\Api\Data\File\ContentInterfaceFactory::class )->create(); $content->setFileData( + // @codingStandardsIgnoreLine base64_encode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'test_image.jpg')) ); $content->setName('jellyfish_1_4.jpg'); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links.php index 6ceb4d90787e..0101fb74200b 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links.php @@ -5,10 +5,15 @@ */ declare(strict_types=1); -use Magento\TestFramework\Helper\Bootstrap as Bootstrap; +use Magento\TestFramework\Helper\Bootstrap; use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; use Magento\Downloadable\Model\Product\Type as ProductType; use Magento\Catalog\Model\Product\Visibility as ProductVisibility; +use Magento\Downloadable\Api\DomainManagerInterface; + +/** @var DomainManagerInterface $domainManager */ +$domainManager = Bootstrap::getObjectManager()->get(DomainManagerInterface::class); +$domainManager->addDomains(['example.com']); /** * @var \Magento\Catalog\Model\Product $product diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links_rollback.php index 308a48c144e2..5fcab9af5eb7 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_with_purchased_separately_links_rollback.php @@ -7,6 +7,11 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Downloadable\Api\DomainManagerInterface; + +/** @var DomainManagerInterface $domainManager */ +$domainManager = Bootstrap::getObjectManager()->get(DomainManagerInterface::class); +$domainManager->removeDomains(['example.com']); /** @var \Magento\Framework\Registry $registry */ $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links.php index f55261be04ce..254e388c3903 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links.php @@ -5,10 +5,15 @@ */ declare(strict_types=1); -use Magento\TestFramework\Helper\Bootstrap as Bootstrap; +use Magento\TestFramework\Helper\Bootstrap; use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus; use Magento\Downloadable\Model\Product\Type as ProductType; use Magento\Catalog\Model\Product\Visibility as ProductVisibility; +use Magento\Downloadable\Api\DomainManagerInterface; + +/** @var DomainManagerInterface $domainManager */ +$domainManager = Bootstrap::getObjectManager()->get(DomainManagerInterface::class); +$domainManager->addDomains(['example.com']); /** * @var \Magento\Catalog\Model\Product $product diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links_rollback.php index 4569460b1018..498fab815cdb 100644 --- a/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/product_downloadable_without_purchased_separately_links_rollback.php @@ -7,6 +7,11 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Downloadable\Api\DomainManagerInterface; + +/** @var DomainManagerInterface $domainManager */ +$domainManager = Bootstrap::getObjectManager()->get(DomainManagerInterface::class); +$domainManager->removeDomains(['example.com']); /** @var \Magento\Framework\Registry $registry */ $registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class); diff --git a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php index 776ec9f990f5..15dd157a3154 100644 --- a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php +++ b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php @@ -5,10 +5,12 @@ */ namespace Magento\DownloadableImportExport\Model\Import\Product\Type; +use Magento\Downloadable\Api\DomainManagerInterface; use Magento\Framework\App\Filesystem\DirectoryList; /** * @magentoAppArea adminhtml + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DownloadableTest extends \PHPUnit\Framework\TestCase { @@ -32,6 +34,11 @@ class DownloadableTest extends \PHPUnit\Framework\TestCase */ const TEST_PRODUCT_SAMPLES_GROUP_NAME = 'TEST Import Samples'; + /** + * @var DomainManagerInterface + */ + private $domainManager; + /** * @var \Magento\CatalogImportExport\Model\Import\Product */ @@ -47,6 +54,9 @@ class DownloadableTest extends \PHPUnit\Framework\TestCase */ protected $productMetadata; + /** + * @inheritDoc + */ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -56,6 +66,17 @@ protected function setUp() /** @var \Magento\Framework\EntityManager\MetadataPool $metadataPool */ $metadataPool = $this->objectManager->get(\Magento\Framework\EntityManager\MetadataPool::class); $this->productMetadata = $metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class); + + $this->domainManager = $this->objectManager->get(DomainManagerInterface::class); + $this->domainManager->addDomains(['www.bing.com', 'www.google.com', 'www.yahoo.com']); + } + + /** + * @inheritDoc + */ + protected function tearDown() + { + $this->domainManager->removeDomains(['www.bing.com', 'www.google.com', 'www.yahoo.com']); } /** @@ -112,7 +133,7 @@ public function testDownloadableImport() $downloadableSamples = $product->getDownloadableSamples(); //TODO: Track Fields: id, link_id, link_file and sample_file) - $expectedLinks= [ + $expectedLinks = [ 'file' => [ 'title' => 'TEST Import Link Title File', 'sort_order' => '78', @@ -154,7 +175,7 @@ public function testDownloadableImport() } //TODO: Track Fields: id, sample_id and sample_file) - $expectedSamples= [ + $expectedSamples = [ 'file' => [ 'title' => 'TEST Import Sample File', 'sort_order' => '178', diff --git a/dev/tests/integration/testsuite/Magento/Elasticsearch6/SearchAdapter/ConnectionManagerTest.php b/dev/tests/integration/testsuite/Magento/Elasticsearch6/SearchAdapter/ConnectionManagerTest.php new file mode 100644 index 000000000000..2b531eac4e42 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Elasticsearch6/SearchAdapter/ConnectionManagerTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Elasticsearch6\SearchAdapter; + +use Magento\Elasticsearch\Elasticsearch5\SearchAdapter\ConnectionManager; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test for \Magento\Elasticsearch\SearchAdapter\ConnectionManager class. + */ +class ConnectionManagerTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * @var \Magento\Elasticsearch\SearchAdapter\ConnectionManager + */ + private $connectionManager; + + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + $this->connectionManager = $this->objectManager->create(ConnectionManager::class); + } + + /** + * Test if 'elasticsearch5' search engine returned by connection manager. + * + * @magentoAppIsolation enabled + * @magentoConfigFixture default/catalog/search/engine elasticsearch5 + */ + public function testCorrectElasticsearchClientEs5() + { + $connection = $this->connectionManager->getConnection(); + $this->assertInstanceOf( + \Magento\Elasticsearch\Elasticsearch5\Model\Client\Elasticsearch::class, + $connection + ); + } + + /** + * Test if 'elasticsearch6' search engine returned by connection manager. + * + * @magentoAppIsolation enabled + * @magentoConfigFixture default/catalog/search/engine elasticsearch6 + */ + public function testCorrectElasticsearchClientEs6() + { + $connection = $this->connectionManager->getConnection(); + $this->assertInstanceOf( + \Magento\Elasticsearch6\Model\Client\Elasticsearch::class, + $connection + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php index bbbcc3133d4b..6d5f760d7894 100644 --- a/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template.php @@ -10,9 +10,9 @@ $template->setOptions(['area' => 'test area', 'store' => 1]); $template->setData( [ - 'template_text' => - file_get_contents(__DIR__ . '/template_fixture.html'), - 'template_code' => \Magento\Theme\Model\Config\ValidatorTest::TEMPLATE_CODE + 'template_text' => file_get_contents(__DIR__ . '/template_fixture.html'), + 'template_code' => \Magento\Theme\Model\Config\ValidatorTest::TEMPLATE_CODE, + 'template_type' => \Magento\Email\Model\Template::TYPE_TEXT ] ); $template->save(); diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/Cache/Frontend/PoolTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/Cache/Frontend/PoolTest.php new file mode 100644 index 000000000000..3324da008a84 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/App/Cache/Frontend/PoolTest.php @@ -0,0 +1,55 @@ +<?php declare(strict_types=1); + +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\App\Cache\Frontend; + +use Magento\Framework\ObjectManager\ConfigInterface as ObjectManagerConfig; +use Magento\TestFramework\ObjectManager; +use PHPUnit\Framework\TestCase; + +/** + * This superfluous comment can be removed as soon as the sniffs have been updated to match the coding guide lines. + */ +class PoolTest extends TestCase +{ + public function testPageCacheNotSameAsDefaultCacheDirectory(): void + { + /** @var ObjectManagerConfig $diConfig */ + $diConfig = ObjectManager::getInstance()->get(ObjectManagerConfig::class); + $argumentConfig = $diConfig->getArguments(\Magento\Framework\App\Cache\Frontend\Pool::class); + + $pageCacheDir = $argumentConfig['frontendSettings']['page_cache']['backend_options']['cache_dir'] ?? null; + $defaultCacheDir = $argumentConfig['frontendSettings']['default']['backend_options']['cache_dir'] ?? null; + + $noPageCacheMessage = "No default page_cache directory set in di.xml: \n" . var_export($argumentConfig, true); + $this->assertNotEmpty($pageCacheDir, $noPageCacheMessage); + + $sameCacheDirMessage = 'The page_cache and default cache storages share the same cache directory'; + $this->assertNotSame($pageCacheDir, $defaultCacheDir, $sameCacheDirMessage); + } + + /** + * @covers \Magento\Framework\App\Cache\Frontend\Pool::_getCacheSettings + * @depends testPageCacheNotSameAsDefaultCacheDirectory + */ + public function testCleaningDefaultCachePreservesPageCache() + { + $testData = 'test data'; + $testKey = 'test-key'; + + /** @var \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool */ + $cacheFrontendPool = ObjectManager::getInstance()->get(\Magento\Framework\App\Cache\Frontend\Pool::class); + + $pageCache = $cacheFrontendPool->get('page_cache'); + $pageCache->save($testData, $testKey); + + $defaultCache = $cacheFrontendPool->get('default'); + $defaultCache->clean(); + + $this->assertSame($testData, $pageCache->load($testKey)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Async/ProxyDeferredFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Async/ProxyDeferredFactoryTest.php index e4385b598c60..21392e5f7b12 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Async/ProxyDeferredFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Async/ProxyDeferredFactoryTest.php @@ -18,7 +18,7 @@ class ProxyDeferredFactoryTest extends TestCase { /** - * @var ProxyDeferredFactory + * @var \TestDeferred\TestClass\ProxyDeferredFactory */ private $factory; @@ -43,6 +43,7 @@ protected function setUp() //phpcs:ignore include_once __DIR__ .'/_files/test_class.php'; \TestDeferred\TestClass::$created = 0; + $this->factory = Bootstrap::getObjectManager()->get(\TestDeferred\TestClass\ProxyDeferredFactory::class); } /* @@ -57,9 +58,10 @@ public function testCreate(): void return new \TestDeferred\TestClass($value); }; /** @var \TestDeferred\TestClass $proxy */ - $proxy = $this->factory->createFor( - \TestDeferred\TestClass::class, - $this->callbackDeferredFactory->create(['callback' => $callback]) + $proxy = $this->factory->create( + [ + 'deferred' => $this->callbackDeferredFactory->create(['callback' => $callback]) + ] ); $this->assertInstanceOf(\TestDeferred\TestClass::class, $proxy); $this->assertEmpty(\TestDeferred\TestClass::$created); @@ -80,9 +82,10 @@ public function testSerialize(): void return new \TestDeferred\TestClass($value); }; /** @var \TestDeferred\TestClass $proxy */ - $proxy = $this->factory->createFor( - \TestDeferred\TestClass::class, - $this->callbackDeferredFactory->create(['callback' => $callback]) + $proxy = $this->factory->create( + [ + 'deferred' => $this->callbackDeferredFactory->create(['callback' => $callback]) + ] ); //phpcs:disable /** @var \TestDeferred\TestClass $unserialized */ @@ -106,9 +109,10 @@ public function testClone(): void return new \TestDeferred\TestClass($value); }; /** @var \TestDeferred\TestClass $proxy */ - $proxy = $this->factory->createFor( - \TestDeferred\TestClass::class, - $this->callbackDeferredFactory->create(['callback' => $callback]) + $proxy = $this->factory->create( + [ + 'deferred' => $this->callbackDeferredFactory->create(['callback' => $callback]) + ] ); $this->assertEquals(0, \TestDeferred\TestClass::$created); $this->assertEquals(0, $called); @@ -137,9 +141,10 @@ public function getValue() }; }; /** @var \TestDeferred\TestClass $proxy */ - $proxy = $this->factory->createFor( - \TestDeferred\TestClass::class, - $this->callbackDeferredFactory->create(['callback' => $callback]) + $proxy = $this->factory->create( + [ + 'deferred' => $this->callbackDeferredFactory->create(['callback' => $callback]) + ] ); $this->assertInstanceOf(\TestDeferred\TestClass::class, $proxy); $this->assertEmpty(\TestDeferred\TestClass::$created); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromClone/composer.json b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromClone/composer.json index fe1d382b361f..404db202c6e7 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromClone/composer.json +++ b/dev/tests/integration/testsuite/Magento/Framework/Composer/_files/testFromClone/composer.json @@ -17,7 +17,6 @@ "ext-intl": "*", "ext-mcrypt": "*", "ext-simplexml": "*", - "ext-spl": "*", "lib-libxml": "*", "composer/composer": "1.0.0-alpha9", "magento/magento-composer-installer": "*", diff --git a/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php b/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php new file mode 100644 index 000000000000..15e52f5b1756 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\File; + +use Magento\Framework\App\Filesystem\DirectoryList; + +/** + * Test for \Magento\Framework\File\Uploader + */ +class UploaderTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\MediaStorage\Model\File\UploaderFactory + */ + private $uploaderFactory; + + /** + * @var \Magento\Framework\Filesystem + */ + private $filesystem; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->uploaderFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\MediaStorage\Model\File\UploaderFactory::class); + + $this->filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Filesystem::class); + } + + /** + * @return void + */ + public function testUploadFileFromAllowedFolder(): void + { + $mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + + $fileName = 'text.txt'; + $tmpDir = 'tmp'; + $filePath = $tmpDirectory->getAbsolutePath($fileName); + + $tmpDirectory->writeFile($fileName, 'just a text'); + + $type = [ + 'tmp_name' => $filePath, + 'name' => $fileName, + ]; + + $uploader = $this->uploaderFactory->create(['fileId' => $type]); + $uploader->save($mediaDirectory->getAbsolutePath($tmpDir)); + + $this->assertTrue($mediaDirectory->isFile($tmpDir . DIRECTORY_SEPARATOR . $fileName)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid parameter given. A valid $fileId[tmp_name] is expected. + * + * @return void + */ + public function testUploadFileFromNotAllowedFolder(): void + { + $fileName = 'text.txt'; + $tmpDir = 'tmp'; + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::LOG); + $filePath = $tmpDirectory->getAbsolutePath() . $tmpDir . DIRECTORY_SEPARATOR . $fileName; + + $tmpDirectory->writeFile($tmpDir . DIRECTORY_SEPARATOR . $fileName, 'just a text'); + + $type = [ + 'tmp_name' => $filePath, + 'name' => $fileName, + ]; + + $this->uploaderFactory->create(['fileId' => $type]); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + parent::tearDown(); + + $tmpDir = 'tmp'; + $mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $mediaDirectory->delete($tmpDir); + + $logDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::LOG); + $logDirectory->delete($tmpDir); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php index bc8281d55ac4..3b7273e08810 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php @@ -703,12 +703,47 @@ public function testValidateUploadFile() } /** + * @dataProvider testValidateUploadFileExceptionDataProvider * @expectedException \InvalidArgumentException + * @param string $fileName + * @param string $expectedErrorMsg + * @param bool $useFixture */ - public function testValidateUploadFileException() + public function testValidateUploadFileException($fileName, $expectedErrorMsg, $useFixture) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $imageAdapter = $objectManager->get(\Magento\Framework\Image\AdapterFactory::class)->create(); - $imageAdapter->validateUploadFile(__FILE__); + $filePath = $useFixture ? $this->_getFixture($fileName) : $fileName; + + try { + $imageAdapter->validateUploadFile($filePath); + } catch (\InvalidArgumentException $e) { + $this->assertEquals($expectedErrorMsg, $e->getMessage()); + throw $e; + } + } + + /** + * @return array + */ + public function testValidateUploadFileExceptionDataProvider() + { + return [ + 'image_notfound' => [ + 'fileName' => 'notfound.png', + 'expectedErrorMsg' => 'Upload file does not exist.', + 'useFixture' => false + ], + 'image_empty' => [ + 'fileName' => 'empty.png', + 'expectedErrorMsg' => 'Wrong file size.', + 'useFixture' => true + ], + 'notanimage' => [ + 'fileName' => 'notanimage.txt', + 'expectedErrorMsg' => 'Disallowed file type.', + 'useFixture' => true + ] + ]; } } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Image/_files/empty.png b/dev/tests/integration/testsuite/Magento/Framework/Image/_files/empty.png new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/dev/tests/integration/testsuite/Magento/Framework/Image/_files/notanimage.txt b/dev/tests/integration/testsuite/Magento/Framework/Image/_files/notanimage.txt new file mode 100644 index 000000000000..81bc3abd3712 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Image/_files/notanimage.txt @@ -0,0 +1 @@ +Not an image. diff --git a/dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php b/dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php index 10a54b4e1b87..186c3e2796c8 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Mail/EmailMessageTest.php @@ -14,6 +14,7 @@ /** * Class EmailMessageTest + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class EmailMessageTest extends TestCase { @@ -164,23 +165,42 @@ public function testEmailMessage($content, $type): void 'cc' => $cc, 'replyTo' => $replyTo, 'bcc' => $bcc, - 'sender' => $sender + 'sender' => $sender, ]; $message = $this->messageFactory->create($data); $this->assertContains($content, $message->toString()); $this->assertContains('Content-Type: ' . $type, $message->toString()); - $senderString = 'Sender: ' . $sender->getName() . ' <' . $sender->getEmail() . '>'; + $senderString = 'Sender: =?utf-8?Q?' + . str_replace(' ', '=20', $sender->getName()) + . '?= <' + . $sender->getEmail() + . '>'; $this->assertContains($senderString, $message->toString()); $this->assertContains('From: ' . $from[0]->getEmail(), $message->toString()); - $replyToString = 'Reply-To: ' . $replyTo[0]->getName() . ' <' . $replyTo[0]->getEmail() . '>'; + $replyToString = 'Reply-To: =?utf-8?Q?' + . str_replace(' ', '=20', $replyTo[0]->getName()) + . '?= <' + . $replyTo[0]->getEmail() + . '>'; $this->assertContains($replyToString, $message->toString()); - $toString = 'To: ' . $to[0]->getName() . ' <' . $to[0]->getEmail() . '>'; + $toString = 'To: =?utf-8?Q?' + . str_replace(' ', '=20', $to[0]->getName()) + . '?= <' + . $to[0]->getEmail() + . '>'; $this->assertContains($toString, $message->toString()); - $ccString = 'Cc: ' . $cc[0]->getName() . ' <' . $cc[0]->getEmail() . '>'; + $ccString = 'Cc: =?utf-8?Q?' + . str_replace(' ', '=20', $cc[0]->getName()) + . '?= <' + . $cc[0]->getEmail() + . '>'; $this->assertContains($ccString, $message->toString()); $this->assertContains('Bcc: ' . $bcc[0]->getEmail(), $message->toString()); - $this->assertContains('Content-Description: ' . $this->description, $message->toString()); + $contentDescription = 'Content-Description: =?utf-8?Q?' + . str_replace(' ', '=20', $this->description) + . '?='; + $this->assertContains($contentDescription, $message->toString()); $this->assertContains('Subject: ' . $this->subject, $message->toString()); $this->assertContains($content, $message->toString()); //tests address factory @@ -235,6 +255,7 @@ public function testEmailMessageWithAttachment(): void 'body' => $mimeMessage, 'subject' => $this->subject, 'to' => [$addressTo], + 'encoding' => '', ]; $message = $this->messageFactory->create($data); diff --git a/dev/tests/integration/testsuite/Magento/Framework/Mail/TransportBuilderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Mail/TransportBuilderTest.php new file mode 100644 index 000000000000..03bdc9a36552 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Mail/TransportBuilderTest.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Mail; + +use Magento\Email\Model\BackendTemplate; +use Magento\Email\Model\Template; +use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Class EmailMessageTest + */ +class TransportBuilderTest extends TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $di; + + /** + * @var TransportBuilder + */ + protected $builder; + + /** + * @var Template + */ + protected $template; + + protected function setUp() + { + $this->di = Bootstrap::getObjectManager(); + $this->builder = $this->di->get(TransportBuilder::class); + $this->template = $this->di->get(Template::class); + } + + /** + * @magentoDataFixture Magento/Email/Model/_files/email_template.php + * @magentoDbIsolation enabled + * + * @param string|array $email + * @dataProvider emailDataProvider + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function testAddToEmail($email) + { + $templateId = $this->template->load('email_exception_fixture', 'template_code')->getId(); + + $this->builder->setTemplateModel(BackendTemplate::class); + + $vars = ['reason' => 'Reason', 'customer' => 'Customer']; + $options = ['area' => 'frontend', 'store' => 1]; + $this->builder->setTemplateIdentifier($templateId)->setTemplateVars($vars)->setTemplateOptions($options); + + $this->builder->addTo($email); + + /** @var EmailMessage $emailMessage */ + $emailMessage = $this->builder->getTransport(); + + $addresses = $emailMessage->getMessage()->getTo(); + + $emails = []; + /** @var Address $toAddress */ + foreach ($addresses as $address) { + $emails[] = $address->getEmail(); + } + + if (is_string($email)) { + $this->assertCount(1, $emails); + $this->assertEquals($email, $emails[0]); + } else { + $this->assertEquals($email, $emails); + } + } + + /** + * @return array + */ + public function emailDataProvider(): array + { + return [ + [ + 'billy.everything@someserver.com', + ], + [ + [ + 'billy.everything@someserver.com', + 'john.doe@someserver.com', + ] + ] + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php index c7e118f4a4e2..d11248a47a0c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/date_attribute.php @@ -25,6 +25,7 @@ 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'is_filterable' => 1, + 'is_user_defined' => 1, 'backend_type' => 'datetime', 'frontend_input' => 'date', 'frontend_label' => 'Test Date', diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attribute.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attribute.php index 9188bb965763..a74669e9890a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attribute.php @@ -21,6 +21,7 @@ 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, + 'is_user_defined' => 1, 'option' => [ 'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']], 'order' => ['option_0' => 1, 'option_1' => 2], @@ -48,6 +49,7 @@ 'is_global' => 1, 'frontend_input' => 'multiselect', 'is_filterable' => 1, + 'is_user_defined' => 1, 'option' => [ 'value' => ['option_0' => ['Option 1'], 'option_1' => ['Option 2']], 'order' => ['option_0' => 1, 'option_1' => 2], diff --git a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attributes.php b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attributes.php index f4f3337a253c..03269b88ee2a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attributes.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Search/_files/filterable_attributes.php @@ -78,6 +78,7 @@ 'entity_type_id' => $productEntityTypeId, 'is_global' => 1, 'is_filterable' => 1, + 'is_user_defined' => 1, 'backend_type' => 'datetime', 'frontend_input' => 'date', 'frontend_label' => 'Test Date', diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php deleted file mode 100644 index 5e70eb491b50..000000000000 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/SidResolverTest.php +++ /dev/null @@ -1,210 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Framework\Session; - -use Magento\Framework\App\State; -use Zend\Stdlib\Parameters; - -class SidResolverTest extends \PHPUnit\Framework\TestCase -{ - /** - * @var \Magento\Framework\Session\SidResolver - */ - protected $model; - - /** - * @var \Magento\Framework\Session\Generic - */ - protected $session; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store - */ - protected $store; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\Config\ScopeConfigInterface - */ - protected $scopeConfig; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\UrlInterface - */ - protected $urlBuilder; - - /** - * @var string - */ - protected $customSessionName = 'csn'; - - /** - * @var string - */ - protected $customSessionQueryParam = 'csqp'; - - /** - * @var \Magento\Framework\App\RequestInterface - */ - protected $request; - - /** - * @var State|\PHPUnit_Framework_MockObject_MockObject - */ - private $appState; - - protected function setUp() - { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - /** @var \Magento\Framework\Session\Generic _model */ - $this->session = $objectManager->get(\Magento\Framework\Session\Generic::class); - - $this->scopeConfig = $this->getMockBuilder( - \Magento\Framework\App\Config\ScopeConfigInterface::class - )->setMethods( - ['getValue'] - )->disableOriginalConstructor()->getMockForAbstractClass(); - - $this->urlBuilder = $this->getMockBuilder( - \Magento\Framework\Url::class - )->setMethods( - ['isOwnOriginUrl'] - )->disableOriginalConstructor()->getMockForAbstractClass(); - - $this->request = $objectManager->get(\Magento\Framework\App\RequestInterface::class); - - $this->appState = $this->getMockBuilder(State::class) - ->setMethods(['getAreaCode']) - ->disableOriginalConstructor() - ->getMock(); - - $this->model = $objectManager->create( - \Magento\Framework\Session\SidResolver::class, - [ - 'scopeConfig' => $this->scopeConfig, - 'urlBuilder' => $this->urlBuilder, - 'sidNameMap' => [$this->customSessionName => $this->customSessionQueryParam], - 'request' => $this->request, - 'appState' => $this->appState, - ] - ); - } - - public function tearDown() - { - $this->request->setQuery(new Parameters()); - } - - /** - * @param mixed $sid - * @param bool $useFrontedSid - * @param bool $isOwnOriginUrl - * @param mixed $testSid - * @dataProvider dataProviderTestGetSid - */ - public function testGetSid($sid, $useFrontedSid, $isOwnOriginUrl, $testSid) - { - $this->appState->expects($this->atLeastOnce()) - ->method('getAreaCode') - ->willReturn(\Magento\Framework\App\Area::AREA_FRONTEND); - - $this->scopeConfig->expects( - $this->any() - )->method( - 'isSetFlag' - )->with( - \Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will( - $this->returnValue($useFrontedSid) - ); - - $this->urlBuilder->expects($this->any())->method('isOwnOriginUrl')->will($this->returnValue($isOwnOriginUrl)); - - if ($testSid) { - $this->request->getQuery()->set($this->model->getSessionIdQueryParam($this->session), $testSid); - } - $this->assertEquals($sid, $this->model->getSid($this->session)); - $this->assertEquals($useFrontedSid, $this->model->getUseSessionInUrl()); - } - - /** - * @return array - */ - public function dataProviderTestGetSid() - { - return [ - [null, false, false, 'test-sid'], - [null, false, true, 'test-sid'], - [null, false, false, 'test-sid'], - [null, true, false, 'test-sid'], - [null, false, true, 'test-sid'], - ['test-sid', true, true, 'test-sid'], - [null, true, true, null] - ]; - } - - public function testGetSessionIdQueryParam() - { - $this->assertEquals(SidResolver::SESSION_ID_QUERY_PARAM, $this->model->getSessionIdQueryParam($this->session)); - } - - public function testGetSessionIdQueryParamCustom() - { - $this->session->destroy(); - $oldSessionName = $this->session->getName(); - $this->session->setName($this->customSessionName); - $this->assertEquals($this->customSessionQueryParam, $this->model->getSessionIdQueryParam($this->session)); - $this->session->setName($oldSessionName); - $this->session->start(); - } - - public function testSetGetUseSessionVar() - { - $this->assertFalse($this->model->getUseSessionVar()); - $this->model->setUseSessionVar(true); - $this->assertTrue($this->model->getUseSessionVar()); - } - - /** - * Variations of Use SID on frontend value. - * - * @return array - */ - public function dataProviderSessionInUrl() - { - return [ - [true], - [false], - ]; - } - - /** - * Testing "Use SID in URLs" flag. - * Checking that the method returns config value if not explicitly - * overridden. - * - * @param bool $configValue Use SID on frontend config value. - * @dataProvider dataProviderSessionInUrl - */ - public function testSetGetUseSessionInUrl($configValue) - { - $this->scopeConfig->expects( - $this->any() - )->method( - 'isSetFlag' - )->with( - \Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - )->will( - $this->returnValue($configValue) - ); - - $this->assertEquals($configValue, $this->model->getUseSessionInUrl()); - $this->model->setUseSessionInUrl(!$configValue); - $this->assertEquals(!$configValue, $this->model->getUseSessionInUrl()); - } -} diff --git a/dev/tests/integration/testsuite/Magento/Framework/UrlTest.php b/dev/tests/integration/testsuite/Magento/Framework/UrlTest.php index 9d1d8761a16a..db830d228201 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/UrlTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/UrlTest.php @@ -8,6 +8,9 @@ use Zend\Stdlib\Parameters; use Magento\TestFramework\Helper\Bootstrap; +/** + * Test class for \Magento\Framework\Url + */ class UrlTest extends \PHPUnit\Framework\TestCase { /** @@ -22,7 +25,7 @@ protected function setUp() public function testSetGetUseSession() { - $this->assertTrue((bool)$this->model->getUseSession()); + $this->assertFalse((bool)$this->model->getUseSession()); $this->model->setUseSession(false); $this->assertFalse($this->model->getUseSession()); } @@ -491,6 +494,7 @@ public function testSessionUrlVar() public function testUseSessionIdForUrl() { + // phpcs:ignore $_SERVER['HTTP_HOST'] = 'localhost'; $this->assertFalse($this->model->useSessionIdForUrl(true)); $this->assertFalse($this->model->useSessionIdForUrl(false)); diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/expected/styles.magento.min.css b/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/expected/styles.magento.min.css index 7bb283e0b351..bb901988c5b8 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/expected/styles.magento.min.css +++ b/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/expected/styles.magento.min.css @@ -1 +1 @@ -table>caption{margin-bottom:5px}table thead{background:#676056;color:#f7f3eb}table thead .headings{background:#807a6e}table thead a{color:#f7f3eb;display:block}table thead a label{color:#f7f3eb;cursor:pointer;display:block}table thead a:hover,table thead a:focus{color:#dac7a2;text-decoration:none}table tfoot{background:#f2ebde;color:#676056}table tfoot tr th,table tfoot tr td{text-align:left}table th{background:0 0;border:solid #cac3b4;border-width:0 1px;font-size:14px;padding:6px 10px;text-align:center}table td{border:solid #cac3b4;border-width:0 1px;padding:6px 10px 7px;vertical-align:top}table tbody tr td{background:#fff;color:#676056;padding-top:12px}table tbody tr td:first-child{border-left:0}table tbody tr td:first-child input[type=checkbox]{margin:0}table tbody tr td:last-child{border-right:0}table tbody tr:last-child th,table tbody tr:last-child td{border-bottom-width:1px}table tbody tr:nth-child(odd) td,table tbody tr:nth-child(odd) th{background-color:#f7f3eb}table tbody.even tr td{background:#fff}table tbody.odd tr td{background:#f7f3eb}table .dropdown-menu li{padding:7px 15px;line-height:14px;cursor:pointer}table .col-draggable .draggable-handle{float:left;position:relative;top:0}.not-sort{padding-right:10px}.sort-arrow-asc,.sort-arrow-desc{padding-right:10px;position:relative}.sort-arrow-asc:after,.sort-arrow-desc:after{right:-11px;top:-1px;position:absolute;width:23px}.sort-arrow-asc:hover:after,.sort-arrow-desc:hover:after{color:#dac7a2}.sort-arrow-asc{display:inline-block;text-decoration:none}.sort-arrow-asc:after{font-family:'icons-blank-theme';content:'\e626';font-size:13px;line-height:inherit;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.sort-arrow-asc:hover:after{color:#dac7a2}.sort-arrow-desc{display:inline-block;text-decoration:none}.sort-arrow-desc:after{font-family:'icons-blank-theme';content:'\e623';font-size:13px;line-height:inherit;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.sort-arrow-desc:hover:after{color:#dac7a2}.grid-actions .input-text,.pager .input-text,.massaction .input-text,.filter .input-text,.grid-actions select,.pager select,.massaction select,.filter select,.grid-actions .select,.pager .select,.massaction .select,.filter .select{border-color:#989287;box-shadow:none;border-radius:1px;height:28px;margin:0 10px 0 0}.filter th{border:0 solid #676056;padding:6px 3px;vertical-align:top}.filter .ui-datepicker-trigger{cursor:pointer;margin-top:2px}.filter .input-text{padding:0 5px}.filter .range-line:not(:last-child){margin-bottom:5px}.filter .date{padding-right:28px;position:relative;display:inline-block;text-decoration:none}.filter .date .hasDatepicker{vertical-align:top;width:99%}.filter .date img{cursor:pointer;height:25px;width:25px;right:0;position:absolute;vertical-align:middle;z-index:2;opacity:0}.filter .date:before{font-family:'icons-blank-theme';content:'\e612';font-size:42px;line-height:30px;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filter .date:hover:before{color:#dac7a2}.filter .date:before{height:29px;margin-left:5px;position:absolute;right:-3px;top:-3px;width:35px}.filter select{border-color:#cac3b4;margin:0;padding:0;width:99%}.filter input.input-text{border-color:#cac3b4;margin:0;width:99%}.filter input.input-text::-webkit-input-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text::-moz-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text:-moz-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text:-ms-input-placeholder{color:#989287 !important;text-transform:lowercase}.grid{background:#fff;color:#676056;font-size:13px;font-weight:400;padding:15px}.grid table{width:100%}.grid tbody tr.selected th,.grid tbody tr.selected td,.grid tbody tr:hover th,.grid tbody tr:hover td,.grid tbody tr:nth-child(odd):hover th,.grid tbody tr:nth-child(odd):hover td{background-color:#f2ebde;cursor:pointer}.grid tbody tr.selected th.empty-text,.grid tbody tr.selected td.empty-text,.grid tbody tr:hover th.empty-text,.grid tbody tr:hover td.empty-text,.grid tbody tr:nth-child(odd):hover th.empty-text,.grid tbody tr:nth-child(odd):hover td.empty-text{background-color:#f7f3eb;cursor:default}.grid .empty-text{font:400 20px/1.2 'Open Sans',sans-serif;text-align:center;white-space:nowrap}.grid .col-sku{max-width:100px;width:100px}.grid .col-select,.grid .col-massaction{text-align:center}.grid .editable .input-text{width:65px}.grid .col-actions .action-select{background:#fff;border-color:#989287;height:28px;margin:0;padding:4px 4px 5px;width:80px}.grid .col-position.editable{white-space:nowrap}.grid .col-position.editable .input-text{margin:-7px 5px 0;width:70%}.eq-ie9 .hor-scroll{display:inline-block;min-height:0;overflow-y:hidden;overflow-x:auto;width:100%}.data-table{border-collapse:separate;width:100%}.data-table thead,.data-table tfoot,.data-table th,.accordion .config .data-table thead th,.accordion .config .data-table tfoot td,.accordion .config .accordion .config .data-table tfoot td th{background:#fff;color:#676056;font-size:13px;font-weight:600}.data-table th{text-align:left}.data-table thead th,.accordion .config .data-table thead th th,.accordion .config .data-table tfoot td th,.accordion .config .accordion .config .data-table tfoot td th th{border:solid #c9c2b8;border-width:0 0 1px;padding:7px}.data-table td,.data-table tbody tr th,.data-table tbody tr td,.accordion .config .data-table td{background:#fff;border-width:0;padding:5px 7px;vertical-align:middle}.data-table tbody tr:nth-child(odd) th,.data-table tbody tr:nth-child(odd) td,.accordion .config .data-table tbody tr:nth-child(odd) td{background:#fbfaf6}.data-table tbody.odd tr th,.data-table tbody.odd tr td{background:#fbfaf6}.data-table tbody.even tr th,.data-table tbody.even tr td{background:#fff}.data-table tfoot tr:last-child th,.data-table tfoot tr:last-child td,.data-table .accordion .config .data-table tfoot tr:last-child td{border:0}.data-table.order-tables tbody td{vertical-align:top}.data-table.order-tables tbody:hover tr th,.data-table.order-tables tbody:hover tr td{background:#f7f3eb}.data-table.order-tables tfoot td{background:#f2ebde;color:#676056;font-size:13px;font-weight:600}.data-table input[type=text]{width:98%;padding-left:1%;padding-right:1%}.data-table select{margin:0;box-sizing:border-box}.data-table .col-actions .actions-split{margin-top:4px}.data-table .col-actions .actions-split [class^=action-]{background:0 0;border:1px solid #c8c3b5;padding:3px 5px;color:#bbb3a6;font-size:12px}.data-table .col-actions .actions-split [class^=action-]:first-child{border-right:0}.data-table .col-actions .actions-split .dropdown-menu{margin-top:-1px}.data-table .col-actions .actions-split .dropdown-menu a{display:block;color:#333;text-decoration:none}.data-table .col-actions .actions-split.active .action-toggle{position:relative;border-bottom-right-radius:0;box-shadow:none;background:#fff}.data-table .col-actions .actions-split.active .action-toggle:after{position:absolute;top:100%;left:0;right:0;height:2px;margin-top:-1px;background:#fff;content:'';z-index:2}.data-table .col-actions .actions-split.active .action-toggle .dropdown-menu{border-top-right-radius:0}.data-table .col-default{white-space:nowrap;text-align:center;vertical-align:middle}.data-table .col-delete{text-align:center;width:32px}.data-table .col-file{white-space:nowrap}.data-table .col-file input,.data-table .col-file .input-text{margin:0 5px;width:40%}.data-table .col-file input:first-child,.data-table .col-file .input-text:first-child{margin-left:0}.data-table .col-actions-add{padding:10px 0}.grid-actions{background:#fff;font-size:13px;line-height:28px;padding:10px 15px;position:relative}.grid-actions+.grid{padding-top:5px}.grid-actions .export,.grid-actions .filter-actions{float:right;margin-left:10px;vertical-align:top}.grid-actions .import{display:block;vertical-align:top}.grid-actions .action-reset{background:0 0;border:0;display:inline;line-height:1.42857143;margin:0;padding:0;color:#1979c3;text-decoration:none;margin:6px 10px 0 0;vertical-align:top}.grid-actions .action-reset:visited{color:purple;text-decoration:none}.grid-actions .action-reset:hover{color:#006bb4;text-decoration:underline}.grid-actions .action-reset:active{color:#ff5501;text-decoration:underline}.grid-actions .action-reset:hover{color:#006bb4}.grid-actions .action-reset:hover,.grid-actions .action-reset:active,.grid-actions .action-reset:focus{background:0 0;border:0}.grid-actions .action-reset.disabled,.grid-actions .action-reset[disabled],fieldset[disabled] .grid-actions .action-reset{color:#1979c3;text-decoration:underline;cursor:default;pointer-events:none;opacity:.5}.grid-actions .import .label,.grid-actions .export .label,.massaction>.entry-edit .label{margin:0 14px 0 0;vertical-align:inherit}.grid-actions .import .action-,.grid-actions .export .action-,.grid-actions .filter-actions .action-,.massaction>.entry-edit .action-{vertical-align:inherit}.grid-actions .filter .date{float:left;margin:0 15px 0 0;position:relative}.grid-actions .filter .date:before{color:#676056;top:1px}.grid-actions .filter .date:hover:before{color:#31302b}.grid-actions .filter .label{margin:0}.grid-actions .filter .hasDatepicker{margin:0 5px;width:80px}.grid-actions .filter .show-by .select{margin-left:5px;padding:4px 4px 5px;vertical-align:top;width:auto}.grid-actions .filter.required:after{content:''}.grid-actions img{vertical-align:middle;height:22px;width:22px}.grid-actions .validation-advice{background:#f9d4d4;border:1px solid #e22626;border-radius:3px;color:#e22626;margin:5px 0 0;padding:3px 7px;position:absolute;white-space:nowrap;z-index:5}.grid-actions .validation-advice:before{width:0;height:0;border:5px solid transparent;border-bottom-color:#e22626;content:'';left:50%;margin-left:-5px;position:absolute;top:-11px}.grid-actions input[type=text].validation-failed{border-color:#e22626;box-shadow:0 0 8px rgba(226,38,38,.6)}.grid-actions .link-feed{white-space:nowrap}.pager{font-size:13px}.grid .pager{margin:15px 0 0;position:relative;text-align:center}.pager .pages-total-found{margin-right:25px}.pager .view-pages .select{margin:0 5px}.pager .link-feed{font-size:12px;margin:7px 15px 0 0;position:absolute;right:0;top:0}.pager .action-previous,.pager .action-next{background:0 0;border:0;display:inline;line-height:1.42857143;margin:0;padding:0;color:#1979c3;text-decoration:none;line-height:.6;overflow:hidden;width:20px}.pager .action-previous:visited,.pager .action-next:visited{color:purple;text-decoration:none}.pager .action-previous:hover,.pager .action-next:hover{color:#006bb4;text-decoration:underline}.pager .action-previous:active,.pager .action-next:active{color:#ff5501;text-decoration:underline}.pager .action-previous:hover,.pager .action-next:hover{color:#006bb4}.pager .action-previous:hover,.pager .action-next:hover,.pager .action-previous:active,.pager .action-next:active,.pager .action-previous:focus,.pager .action-next:focus{background:0 0;border:0}.pager .action-previous.disabled,.pager .action-next.disabled,.pager .action-previous[disabled],.pager .action-next[disabled],fieldset[disabled] .pager .action-previous,fieldset[disabled] .pager .action-next{color:#1979c3;text-decoration:underline;cursor:default;pointer-events:none;opacity:.5}.pager .action-previous:before,.pager .action-next:before{margin-left:-10px}.pager .action-previous.disabled,.pager .action-next.disabled{opacity:.3}.pager .action-previous{display:inline-block;text-decoration:none}.pager .action-previous>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.pager .action-previous>span.focusable:active,.pager .action-previous>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-previous>span.focusable:active,.pager .action-previous>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-previous:before{font-family:'icons-blank-theme';content:'\e617';font-size:40px;line-height:inherit;color:#026294;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.pager .action-previous:hover:before{color:#007dbd}.pager .action-next{display:inline-block;text-decoration:none}.pager .action-next>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.pager .action-next>span.focusable:active,.pager .action-next>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-next>span.focusable:active,.pager .action-next>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-next:before{font-family:'icons-blank-theme';content:'\e608';font-size:40px;line-height:inherit;color:#026294;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.pager .action-next:hover:before{color:#007dbd}.pager .input-text{height:25px;line-height:16px;margin-right:5px;text-align:center;width:25px;vertical-align:top}.pager .pages-total{line-height:25px;vertical-align:top}.massaction{background:#fff;border-top:1px solid #f2ebde;font-size:13px;line-height:28px;padding:15px 15px 0}.massaction>.entry-edit{float:right}.massaction>.entry-edit .field-row{display:inline-block;vertical-align:top}.massaction>.entry-edit .validation-advice{display:none !important}.massaction>.entry-edit .form-inline{display:inline-block}.massaction>.entry-edit .label{padding:0;width:auto}.massaction>.entry-edit .action-{vertical-align:top}.massaction .select.validation-failed{border:1px dashed #e22626;background:#f9d4d4}.grid-severity-critical,.grid-severity-major,.grid-severity-notice,.grid-severity-minor{background:#feeee1;border:1px solid #ed4f2e;color:#ed4f2e;display:block;padding:0 3px;font-weight:700;line-height:17px;text-transform:uppercase;text-align:center}.grid-severity-critical,.grid-severity-major{border-color:#e22626;background:#f9d4d4;color:#e22626}.grid-severity-notice{border-color:#5b8116;background:#d0e5a9;color:#185b00}.grid tbody td input[type=text],.data-table tbody td input[type=text],.grid tbody th input[type=text],.data-table tbody th input[type=text],.grid tbody td .input-text,.data-table tbody td .input-text,.grid tbody th .input-text,.data-table tbody th .input-text,.grid tbody td select,.data-table tbody td select,.grid tbody th select,.data-table tbody th select,.grid tbody td .select,.data-table tbody td .select,.grid tbody th .select,.data-table tbody th .select{width:99%}.ui-tabs-panel .grid .col-sku{max-width:150px;width:150px}.col-indexer_status,.col-indexer_mode{width:160px}.fieldset-wrapper .grid-actions+.grid{padding-top:15px}.fieldset-wrapper .grid-actions{padding:10px 0 0}.fieldset-wrapper .grid{padding:0}.fieldset-wrapper .massaction{padding:0;border-top:none;margin-bottom:15px}.accordion .grid{padding:0}.ui-dialog-content .grid-actions,.ui-dialog-content .grid{padding-left:0;padding-right:0}.qty-table td{border:0;padding:0 5px 3px}.sales-order-create-index .sales-order-create-index .grid table .action-configure{float:right}.sales-order-create-index .data-table .border td{padding-bottom:15px}.sales-order-create-index .actions.update{margin:10px 0}.adminhtml-order-shipment-new .grid .col-product{max-width:770px;width:770px}.customer-index-index .grid .col-name{max-width:90px;width:90px}.customer-index-index .grid .col-billing_region{width:70px}.adminhtml-cms-hierarchy-index .col-title,.adminhtml-cms-hierarchy-index .col-identifier{max-width:410px;width:410px}.adminhtml-widget-instance-edit .grid-chooser .control{margin-top:-19px;width:80%}.eq-ie9 .adminhtml-widget-instance-edit .grid-chooser .control{margin-top:-18px}.adminhtml-widget-instance-edit .grid-chooser .control .grid-actions{padding:0 0 15px}.adminhtml-widget-instance-edit .grid-chooser .control .grid{padding:0}.adminhtml-widget-instance-edit .grid-chooser .control .addon input:last-child,.adminhtml-widget-instance-edit .grid-chooser .control .addon select:last-child{border-radius:0}.reports-report-product-sold .grid .col-name{max-width:720px;width:720px}.adminhtml-system-store-index .grid td{max-width:310px}.adminhtml-system-currency-index .grid{padding-top:0}.adminhtml-system-currency-index .col-currency-edit-rate{min-width:40px}.adminhtml-system-currency-index .col-base-currency{font-weight:700}.adminhtml-system-currency-index .old-rate{display:block;margin-top:3px;text-align:center}.adminhtml-system-currency-index .hor-scroll{overflow-x:auto;min-width:970px}.adminhtml-system-currencysymbol-index .col-currency{width:35%}.adminhtml-system-currencysymbol-index .grid .input-text{margin:0 10px 0 0;width:50%}.catalog-product-set-index .col-set_name{max-width:930px;width:930px}.adminhtml-export-index .grid td{vertical-align:middle}.adminhtml-export-index .grid .input-text-range{margin:0 10px 0 5px;width:37%}.adminhtml-export-index .grid .input-text-range-date{margin:0 5px;width:32%}.adminhtml-export-index .ui-datepicker-trigger{display:inline-block;margin:-3px 10px 0 0;vertical-align:middle}.adminhtml-notification-index .grid .col-select,.adminhtml-cache-index .grid .col-select,.adminhtml-process-list .grid .col-select,.indexer-indexer-list .grid .col-select{width:10px}@font-face{font-family:'icons-blank-theme';src:url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff2') format('woff2'),url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff') format('woff');font-weight:400;font-style:normal}@font-face{font-family:'icons-blank-theme';src:url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff2') format('woff2'),url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff') format('woff');font-weight:400;font-style:normal}.navigation{background-color:#676056;position:relative;z-index:5}.navigation .level-0.reverse>.submenu{right:1px}.navigation>ul{position:relative;text-align:right}.navigation .level-0>.submenu{display:none;position:absolute;top:100%;padding:19px 13px}.navigation .level-0>.submenu a{display:block;color:#676056;font-size:13px;font-weight:400;line-height:1.385;padding:3px 12px 3px;text-decoration:none}.navigation .level-0>.submenu a:focus,.navigation .level-0>.submenu a:hover{text-decoration:underline}.navigation .level-0>.submenu a:hover{color:#fff;background:#989287;text-decoration:none}.navigation .level-0>.submenu li{margin-bottom:1px}.navigation .level-0>.submenu a[href="#"]{cursor:default;display:block;color:#676056;font-size:14px;font-weight:700;line-height:1;margin:7px 0 6px;padding:0 12px}.navigation .level-0>.submenu a[href="#"]:focus,.navigation .level-0>.submenu a[href="#"]:hover{color:#676056;font-size:14px;font-weight:700;background:0 0;text-decoration:none}.navigation .level-0{display:inline-block;float:left;text-align:left;transition:display .15s ease-out}.navigation .level-0>a{background:0 0;display:block;padding:12px 13px 0;color:#f2ebde;font-size:13px;font-weight:600;text-transform:uppercase;text-decoration:none;transition:background .15s ease-out}.navigation .level-0>a:after{content:"";display:block;margin-top:10px;height:3px;font-size:0}.navigation .level-0.active>a{font-weight:700}.navigation .level-0.active>a:after{background:#ef672f}.navigation .level-0.hover.recent>a{background:#fff;color:#676056;font-size:13px;font-weight:600}.navigation .level-0.hover.recent>a:after{background:0 0}.navigation .level-0.hover.recent.active>a{font-weight:700}.navigation .level-0>.submenu{opacity:0;visibility:hidden}.navigation .level-0.recent.hover>.submenu{opacity:1;visibility:visible}.no-js .navigation .level-0:hover>.submenu,.no-js .navigation .level-0.hover>.submenu,.no-js .navigation .level-0>a:focus+.submenu{display:block}.navigation .level-0>.submenu{background:#fff;box-shadow:0 3px 3px rgba(50,50,50,.15)}.navigation .level-0>.submenu li{max-width:200px}.navigation .level-0>.submenu>ul{white-space:nowrap}.navigation .level-0>.submenu .column{display:inline-block;margin-left:40px;vertical-align:top}.navigation .level-0>.submenu .column:first-child{margin-left:0}.navigation .level-0 .submenu .level-1{white-space:normal}.navigation .level-0.parent .submenu .level-1.parent{margin:17px 0 25px}.navigation .level-0.parent .level-1.parent:first-child{margin-top:0}.navigation .level-2 .submenu{margin-left:7px}.navigation .level-0>.submenu .level-2>a[href="#"]{font-size:13px;margin-top:10px;margin-left:7px}.navigation .level-2>.submenu a{font-size:12px;line-height:1.231}.navigation .level-0>.submenu .level-3>a[href="#"],.navigation .level-3 .submenu{margin-left:15px}.navigation .level-0.item-system,.navigation .level-0.item-stores{float:none}.navigation .level-0.item-system>.submenu,.navigation .level-0.item-stores>.submenu{left:auto;right:1px}.adminhtml-dashboard-index .col-1-layout{max-width:1300px;border:none;border-radius:0;padding:0;background:#f7f3eb}.dashboard-inner{padding-top:35px}.dashboard-inner:before,.dashboard-inner:after{content:"";display:table}.dashboard-inner:after{clear:both}.dashboard-inner:before,.dashboard-inner:after{content:"";display:table}.dashboard-inner:after{clear:both}.dashboard-secondary{float:left;width:32%;margin:0 1.5%}.dashboard-main{float:right;width:65%}.dashboard-diagram-chart{max-width:100%;height:auto}.dashboard-diagram-nodata,.dashboard-diagram-switcher{padding:20px 0}.dashboard-diagram-image{background:#fff url(../mui/images/ajax-loader-small.gif) no-repeat 50% 50%}.dashboard-container .ui-tabs-panel{background-color:#fff;min-height:40px;padding:15px}.dashboard-store-stats{margin-top:35px}.dashboard-store-stats .ui-tabs-panel{background:#fff url(../mui/images/ajax-loader-small.gif) no-repeat 50% 50%}.dashboard-item{margin-bottom:30px}.dashboard-item-header{margin-left:5px}.dashboard-item.dashboard-item-primary{margin-bottom:35px}.dashboard-item.dashboard-item-primary .title{font-size:22px;margin-bottom:5px}.dashboard-item.dashboard-item-primary .dashboard-sales-value{display:block;text-align:right;font-weight:600;font-size:30px;margin-right:12px;padding-bottom:5px}.dashboard-item.dashboard-item-primary:first-child{color:#ef672f}.dashboard-item.dashboard-item-primary:first-child .title{color:#ef672f}.dashboard-totals{background:#fff;padding:50px 15px 25px}.dashboard-totals-list{margin:0;padding:0;list-style:none none}.dashboard-totals-list:before,.dashboard-totals-list:after{content:"";display:table}.dashboard-totals-list:after{clear:both}.dashboard-totals-list:before,.dashboard-totals-list:after{content:"";display:table}.dashboard-totals-list:after{clear:both}.dashboard-totals-item{float:left;width:18%;margin-left:7%;padding-top:15px;border-top:2px solid #cac3b4}.dashboard-totals-item:first-child{margin-left:0}.dashboard-totals-label{display:block;font-size:16px;font-weight:600;padding-bottom:2px}.dashboard-totals-value{color:#ef672f;font-size:20px}.dashboard-data{width:100%}.dashboard-data thead{background:0 0}.dashboard-data thead tr{background:0 0}.dashboard-data th,.dashboard-data td{border:none;padding:10px 12px;text-align:right}.dashboard-data th:first-child,.dashboard-data td:first-child{text-align:left}.dashboard-data th{color:#676056;font-weight:600}.dashboard-data td{background-color:transparent}.dashboard-data tbody tr:hover td{background-color:transparent}.dashboard-data tbody tr:nth-child(odd) td,.dashboard-data tbody tr:nth-child(odd):hover td,.dashboard-data tbody tr:nth-child(odd) th,.dashboard-data tbody tr:nth-child(odd):hover th{background-color:#e1dbcf}.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd) td,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd):hover td,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd) th,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd):hover th{background-color:#f7f3eb}.dashboard-data td.empty-text{text-align:center}.ui-tabs-panel .dashboard-data{background-color:#fff}.mage-dropdown-dialog.ui-dialog .ui-dialog-content{overflow:visible}.mage-dropdown-dialog.ui-dialog .ui-dialog-buttonpane{padding:0}.message-system-inner{background:#f7f3eb;border:1px solid #c0bbaf;border-top:0;border-radius:0 0 5px 5px;float:right;overflow:hidden}.message-system-unread .message-system-inner{float:none}.message-system-list{margin:0;padding:0;list-style:none;float:left}.message-system .message-system-list{width:75%}.message-system-list li{padding:5px 13px 7px 36px;position:relative}.message-system-short{padding:5px 13px 7px;float:right}.message-system-short span{display:inline-block;margin-left:7px;border-left:1px #d1ccc3 solid}.message-system-short span:first-child{border:0;margin-left:0}.message-system-short a{padding-left:27px;position:relative;height:16px}.message-system .message-system-short a:before,.message-system-list li:before{font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;height:16px;width:16px;font-size:16px;line-height:16px;text-align:center;position:absolute;left:7px;top:2px}.message-system-list li:before{top:5px;left:13px}.message-system .message-system-short .warning a:before,.message-system-list li.warning:before{content:"\e006";color:#f2a825}.message-system .message-system-short .error a:before,.message-system-list li.error:before{content:"\e086";font-family:'MUI-Icons';color:#c00815}.ui-dialog .message-system-list{margin-bottom:25px}.sales-order-create-index .order-errors .notice{color:#ed4f2e;font-size:11px;margin:5px 0 0}.order-errors .fieldset-wrapper-title .title{box-sizing:border-box;background:#fffbf0;border:1px solid #d87e34;border-radius:5px;color:#676056;font-size:14px;margin:20px 0;padding:10px 26px 10px 35px;position:relative}.order-errors .fieldset-wrapper-title .title:before{position:absolute;left:11px;top:50%;margin-top:-11px;width:auto;height:auto;font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;font-size:16px;line-height:inherit;content:'\e046';color:#d87e34}.search-global.miniform{position:relative;z-index:1000;display:inline-block;vertical-align:top;margin:6px 10px 0}.search-global.miniform .mage-suggest{border:0;border-radius:0}.search-global-actions{display:none}.search-global-field{margin:0}.search-global-field .label{position:absolute;right:4px;z-index:2;cursor:pointer;display:inline-block;text-decoration:none}.search-global-field .label>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.search-global-field .label>span.focusable:active,.search-global-field .label>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.search-global-field .label>span.focusable:active,.search-global-field .label>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.search-global-field .label:before{font-family:'MUI-Icons';content:"\e01f";font-size:18px;line-height:29px;color:#cac3b4;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.search-global-field .control{width:48px;overflow:hidden;opacity:0;transition:all .3s ease}.search-global-field .control input[type=text]{background:0 0;border:none;width:100%}.search-global-field.active{z-index:2}.search-global-field.active .label:before{display:none}.search-global-field.active .control{overflow:visible;opacity:1;transition:all .3s ease;width:300px}.search-global-menu{box-sizing:border-box;display:block;width:100%}.notifications-summary{display:inline-block;text-align:left;position:relative;z-index:1}.notifications-summary.active{z-index:999}.notifications-action{color:#f2ebde;padding:12px 22px 11px;text-transform:capitalize;display:inline-block;text-decoration:none}.notifications-action:before{font-family:"MUI-Icons";content:"\e06e";font-size:18px;line-height:18px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-action:visited,.notifications-action:focus,.notifications-action:active,.notifications-action:hover{color:#f2ebde;text-decoration:none}.notifications-action.active{background-color:#fff;color:#676056}.notifications-action .text{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-action .text.focusable:active,.notifications-action .text.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-action .text.focusable:active,.notifications-action .text.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-action .qty.counter{display:inline-block;background:#ed4f2e;color:#f2ebde;font-size:12px;line-height:12px;font-weight:700;padding:1px 3px;position:absolute;top:6px;left:50%;border-radius:4px}.notifications-list{width:300px;padding:0;margin:0}.notifications-list .last{padding:10px;text-align:center;font-size:12px}.notifications-summary .notifications-entry{padding:15px;color:#676056;font-size:11px;font-weight:400}.notifications-entry{position:relative;z-index:1}.notifications-entry:hover .action{display:block}.notifications-entry-title{padding-right:15px;color:#ed4f2e;font-size:12px;font-weight:600;display:block;margin-bottom:10px}.notifications-entry-description{line-height:1.3;display:block;max-height:3.9em;overflow:hidden;margin-bottom:10px;text-overflow:ellipsis}.notifications-close.action{position:absolute;z-index:1;top:12px;right:12px;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400;display:none}.notifications-close.action>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-close.action>span.focusable:active,.notifications-close.action>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-close.action>span.focusable:active,.notifications-close.action>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-close.action:before{font-family:'MUI-Icons';content:"\e07f";font-size:16px;line-height:inherit;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-close.action:focus,.notifications-close.action:active{background:0 0;border:none}.notifications-close.action:hover{background:0 0;border:none}.notifications-close.action.disabled,.notifications-close.action[disabled],fieldset[disabled] .notifications-close.action{cursor:not-allowed;pointer-events:none;opacity:.5}.notifications-dialog-content{display:none}.notifications-critical .notifications-entry-title{padding-left:25px;display:inline-block;text-decoration:none}.notifications-critical .notifications-entry-title:before{font-family:'MUI-Icons';content:"\e086";font-size:18px;line-height:18px;color:#c00815;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-critical .notifications-entry-title:before{position:absolute;margin-left:-25px}.notifications-dialog-content .notifications-entry-time{color:#8c867e;font-size:13px;font-family:Helvetica,Arial,sans-serif;position:absolute;right:17px;bottom:27px;text-align:right}.notifications-url{display:inline-block;text-decoration:none}.notifications-url>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-url>span.focusable:active,.notifications-url>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-url>span.focusable:active,.notifications-url>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-url:after{font-family:'MUI-Icons';content:"\e084";font-size:16px;line-height:inherit;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-2px 0 0 10px}.notifications-dialog-content .notifications-entry-title{font-size:15px}.locale-switcher-field{white-space:nowrap;float:left}.locale-switcher-field .control,.locale-switcher-field .label{vertical-align:middle;margin:0 10px 0 0;display:inline-block}.locale-switcher-select{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;border:1px solid #ada89e;max-width:200px;height:31px;background:url("../images/select-bg.svg") no-repeat 100% 50%;background-size:30px 60px;padding-right:29px;text-indent:.01px;text-overflow:''}.locale-switcher-select::-ms-expand{display:none}.lt-ie10 .locale-switcher-select{background-image:none;padding-right:4px}@-moz-document url-prefix(){.locale-switcher-select{background-image:none}}@-moz-document url-prefix(){.locale-switcher-select{background-image:none}}.mage-suggest{text-align:left;box-sizing:border-box;position:relative;display:inline-block;vertical-align:top;width:100%;background-color:#fff;border:1px solid #ada89e;border-radius:2px}.mage-suggest:after{position:absolute;top:3px;right:3px;bottom:0;width:22px;text-align:center;font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;content:'\e01f';font-size:18px;color:#b2b2b2}.mage-suggest input[type=search],.mage-suggest input.search{width:100%;border:none;background:0 0;padding-right:30px}.mage-suggest.category-select input[type=search],.mage-suggest.category-select input.search{height:26px}.mage-suggest-dropdown{position:absolute;left:0;right:0;top:100%;margin:1px -1px 0;border:1px solid #cac2b5;background:#fff;box-shadow:0 2px 4px rgba(0,0,0,.2);z-index:990}.mage-suggest-dropdown ul{margin:0;padding:0;list-style:none}.mage-suggest-dropdown li{border-bottom:1px solid #e5e5e5;padding:0}.mage-suggest-dropdown li a{display:block}.mage-suggest-dropdown li a.ui-state-focus{background:#f5f5f5}.mage-suggest-dropdown li a,.mage-suggest-dropdown .jstree li a:hover,.mage-suggest-dropdown .jstree .jstree-hovered,.mage-suggest-dropdown .jstree .jstree-clicked{padding:6px 12px 5px;text-decoration:none;color:#333}.mage-suggest-dropdown .jstree li a:hover,.mage-suggest-dropdown .jstree .jstree-hovered,.mage-suggest-dropdown .jstree .jstree-clicked{border:none}.mage-suggest-dropdown .jstree li{border-bottom:0}.mage-suggest-dropdown .jstree li a{display:inline-block}.mage-suggest-dropdown .jstree .mage-suggest-selected>a{color:#000;background:#f1ffeb}.field-category_ids .mage-suggest-dropdown,.field-new_category_parent .mage-suggest-dropdown{max-height:200px;overflow:auto}.mage-suggest-dropdown .jstree .mage-suggest-selected>a:hover,.mage-suggest-dropdown .jstree .mage-suggest-selected>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-selected>.jstree-clicked,.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active>.jstree-clicked{background:#e5ffd9}.mage-suggest-dropdown .jstree .mage-suggest-not-active>a{color:#d4d4d4}.mage-suggest-dropdown .jstree .mage-suggest-not-active>a:hover,.mage-suggest-dropdown .jstree .mage-suggest-not-active>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-not-active>.jstree-clicked{background:#f5f5f5}.mage-suggest-dropdown .category-path{font-size:11px;margin-left:10px;color:#9ba8b5}.suggest-expandable .action-dropdown .action-toggle{display:inline-block;max-width:500px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;box-shadow:none;color:#676056;font-size:12px;padding:5px 4px;filter:none}.suggest-expandable .action-dropdown .action-toggle span{display:inline}.suggest-expandable .action-dropdown .action-toggle:before{display:inline-block;float:right;margin-left:4px;font-size:13px;color:#b2b0ad}.suggest-expandable .action-dropdown .action-toggle:hover:before{color:#7e7e7e}.suggest-expandable .dropdown-menu{margin:1px 0 0;left:0;right:auto;width:245px;z-index:4}.suggest-expandable .mage-suggest{border:none;border-radius:3px 3px 0 0}.suggest-expandable .mage-suggest:after{top:10px;right:8px}.suggest-expandable .mage-suggest-inner .title{margin:0;padding:0 10px 4px;text-transform:uppercase;color:#a6a098;font-size:12px;border-bottom:1px solid #e5e5e5}.suggest-expandable .mage-suggest-inner>input[type=search],.suggest-expandable .mage-suggest-inner>input.search{position:relative;margin:6px 5px 5px;padding-right:20px;border:1px solid #ada89e;width:236px;z-index:1}.suggest-expandable .mage-suggest-inner>input.ui-autocomplete-loading,.suggest-expandable .mage-suggest-inner>input.mage-suggest-state-loading{background:#fff url("../mui/images/ajax-loader-small.gif") no-repeat 190px 50%}.suggest-expandable .mage-suggest-dropdown{margin-top:0;border-top:0;border-radius:0 0 3px 3px;max-height:300px;overflow:auto;width:100%;float:left}.suggest-expandable .mage-suggest-dropdown ul{margin:0;padding:0;list-style:none}.suggest-expandable .action-show-all:hover,.suggest-expandable .action-show-all:active,.suggest-expandable .action-show-all:focus,.suggest-expandable .action-show-all[disabled]{border-top:1px solid #e5e5e5;display:block;width:100%;padding:8px 10px 10px;text-align:left;font:12px/1.333 Arial,Verdana,sans-serif;color:#676056}.product-actions .suggest-expandable{max-width:500px;float:left;margin-top:1px}.page-actions.fixed #product-template-suggest-container{display:none}.catalog-category-edit .col-2-left-layout:before{display:none}.category-content .ui-tabs-panel .fieldset{padding-top:40px}.category-content .ui-tabs-panel .fieldset .legend{display:none}.attributes-edit-form .field:not(.field-weight) .addon{display:block;position:relative}.attributes-edit-form .field:not(.field-weight) .addon input[type=text]{border-width:1px}.attributes-edit-form .field:not(.field-weight) .addon .addafter{display:block;border:0;height:auto;width:auto}.attributes-edit-form .field:not(.field-weight) .addon input:focus~.addafter{box-shadow:none}.attributes-edit-form .with-addon .textarea{margin:0}.attributes-edit-form .attribute-change-checkbox{display:block;margin-top:5px}.attributes-edit-form .attribute-change-checkbox .label{float:none;padding:0;width:auto}.attributes-edit-form .attribute-change-checkbox .checkbox{margin-right:5px;width:auto}.attributes-edit-form .field-price .addon>input,.attributes-edit-form .field-special_price .addon>input,.attributes-edit-form .field-gift_wrapping_price .addon>input,.attributes-edit-form .field-msrp .addon>input,.attributes-edit-form .field-gift_wrapping_price .addon>input{padding-left:23px}.attributes-edit-form .field-price .addafter>strong,.attributes-edit-form .field-special_price .addafter>strong,.attributes-edit-form .field-gift_wrapping_price .addafter>strong,.attributes-edit-form .field-msrp .addafter>strong,.attributes-edit-form .field-gift_wrapping_price .addafter>strong{left:5px;position:absolute;top:3px}.attributes-edit-form .field.type-price input:focus+label,.attributes-edit-form .field-price input:focus+label,.attributes-edit-form .field-special_price input:focus+label,.attributes-edit-form .field-msrp input:focus+label,.attributes-edit-form .field-weight input:focus+label{box-shadow:none}.attributes-edit-form .field-special_from_date>.control .input-text,.attributes-edit-form .field-special_to_date>.control .input-text,.attributes-edit-form .field-news_from_date>.control .input-text,.attributes-edit-form .field-news_to_date>.control .input-text,.attributes-edit-form .field-custom_design_from>.control .input-text,.attributes-edit-form .field-custom_design_to>.control .input-text{border-width:1px;width:130px}.attributes-edit-form .field-weight .fields-group-2 .control{padding-right:27px}.attributes-edit-form .field-weight .fields-group-2 .control .addafter+.addafter{border-width:1px 1px 1px 0;border-style:solid;height:28px;right:0;position:absolute;top:0}.attributes-edit-form .field-weight .fields-group-2 .control .addafter strong{line-height:28px}.attributes-edit-form .field-weight .fields-group-2 .control>input:focus+.addafter+.addafter{box-shadow:0 0 8px rgba(82,168,236,.6)}.attributes-edit-form .field-gift_message_available .addon>input[type=checkbox],.attributes-edit-form .field-gift_wrapping_available .addon>input[type=checkbox]{width:auto;margin-right:5px}.attributes-edit-form .fieldset>.addafter{display:none}.advanced-inventory-edit .field.choice{display:block;margin:3px 0 0}.advanced-inventory-edit .field.choice .label{padding-top:1px}.product-actions:before,.product-actions:after{content:"";display:table}.product-actions:after{clear:both}.product-actions:before,.product-actions:after{content:"";display:table}.product-actions:after{clear:both}.product-actions .switcher{float:right}#configurable-attributes-container .actions-select{display:inline-block;position:relative}#configurable-attributes-container .actions-select:before,#configurable-attributes-container .actions-select:after{content:"";display:table}#configurable-attributes-container .actions-select:after{clear:both}#configurable-attributes-container .actions-select:before,#configurable-attributes-container .actions-select:after{content:"";display:table}#configurable-attributes-container .actions-select:after{clear:both}#configurable-attributes-container .actions-select .action.toggle{cursor:pointer;display:inline-block;text-decoration:none}#configurable-attributes-container .actions-select .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:22px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#configurable-attributes-container .actions-select .action.toggle:hover:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle:active:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle.active{display:inline-block;text-decoration:none}#configurable-attributes-container .actions-select .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:22px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#configurable-attributes-container .actions-select .action.toggle.active:hover:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle.active:active:after{color:inherit}#configurable-attributes-container .actions-select ul.dropdown{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:100%;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}#configurable-attributes-container .actions-select ul.dropdown li{margin:0;padding:3px 5px}#configurable-attributes-container .actions-select ul.dropdown li:hover{background:#e8e8e8;cursor:pointer}#configurable-attributes-container .actions-select.active{overflow:visible}#configurable-attributes-container .actions-select.active ul.dropdown{display:block}#configurable-attributes-container .actions-select .action.toggle{padding:1px 8px;border:1px solid #ada89e;background:#fff;border-radius:0 2px 2px 0}#configurable-attributes-container .actions-select .action.toggle:after{width:14px;text-indent:-2px}#configurable-attributes-container .actions-select ul.dropdown li:hover{background:#eef8fc}#configurable-attributes-container .actions-select ul.dropdown a{color:#333;text-decoration:none}#product-variations-matrix .actions-image-uploader{display:inline-block;position:relative;display:block;width:50px}#product-variations-matrix .actions-image-uploader:before,#product-variations-matrix .actions-image-uploader:after{content:"";display:table}#product-variations-matrix .actions-image-uploader:after{clear:both}#product-variations-matrix .actions-image-uploader:before,#product-variations-matrix .actions-image-uploader:after{content:"";display:table}#product-variations-matrix .actions-image-uploader:after{clear:both}#product-variations-matrix .actions-image-uploader .action.split{float:left;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle{float:right;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle{padding:6px 5px;display:inline-block;text-decoration:none}#product-variations-matrix .actions-image-uploader .action.toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle:hover:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle:active:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle.active{display:inline-block;text-decoration:none}#product-variations-matrix .actions-image-uploader .action.toggle.active>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle.active:hover:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle.active:active:after{color:inherit}#product-variations-matrix .actions-image-uploader ul.dropdown{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:100%;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}#product-variations-matrix .actions-image-uploader ul.dropdown li{margin:0;padding:3px 5px}#product-variations-matrix .actions-image-uploader ul.dropdown li:hover{background:#e8e8e8;cursor:pointer}#product-variations-matrix .actions-image-uploader.active{overflow:visible}#product-variations-matrix .actions-image-uploader.active ul.dropdown{display:block}#product-variations-matrix .actions-image-uploader .action.toggle{padding:0 2px;border:1px solid #b7b2a7;background:#fff;border-radius:0 4px 4px 0;border-left:none;height:33px}#product-variations-matrix .actions-image-uploader .action.toggle.no-display{display:none}#product-variations-matrix .actions-image-uploader .action.toggle:after{width:12px;text-indent:-5px}#product-variations-matrix .actions-image-uploader ul.dropdown{left:0;margin-left:0;width:100px}#product-variations-matrix .actions-image-uploader ul.dropdown li:hover{background:#eef8fc}#product-variations-matrix .actions-image-uploader ul.dropdown a{color:#333;text-decoration:none}.debugging-hints .page-actions{position:relative;z-index:1}.debugging-hints .page-actions .debugging-hint-template-file{left:auto !important;right:0 !important}.filter-segments{list-style:none;padding:0}.adminhtml-report-customer-test-detail .col-id{width:35px}.adminhtml-report-customer-test-detail .col-period{white-space:nowrap;width:70px}.adminhtml-report-customer-test-detail .col-zip{width:50px}.adminhtml-report-customer-test-segment .col-id{width:35px}.adminhtml-report-customer-test-segment .col-status{width:65px}.adminhtml-report-customer-test-segment .col-qty{width:145px}.adminhtml-report-customer-test-segment .col-segment,.adminhtml-report-customer-test-segment .col-website{width:35%}.adminhtml-report-customer-test-segment .col-select{width:45px}.test-custom-attributes{margin-bottom:20px}.adminhtml-test-index th.col-id{text-align:left}.adminhtml-test-index .col-price{text-align:right;width:50px}.adminhtml-test-index .col-actions{width:50px}.adminhtml-test-index .col-select{width:60px}.adminhtml-test-edit .field-image .control{line-height:28px}.adminhtml-test-edit .field-image a{display:inline-block;margin:0 5px 0 0}.adminhtml-test-edit .field-image img{vertical-align:middle}.adminhtml-test-new .field-image .input-file,.adminhtml-test-edit .field-image .input-file{display:inline-block;margin:0 15px 0 0;width:auto}.adminhtml-test-new .field-image .addafter,.adminhtml-test-edit .field-image .addafter{border:0;box-shadow:none;display:inline-block;margin:0 15px 0 0;height:auto;width:auto}.adminhtml-test-new .field-image .delete-image,.adminhtml-test-edit .field-image .delete-image{display:inline-block;white-space:nowrap}.adminhtml-test-edit .field-image .delete-image input{margin:-3px 5px 0 0;width:auto;display:inline-block}.adminhtml-test-edit .field-image .addon .delete-image input:focus+label{border:0;box-shadow:none}.adminhtml-test-index .col-id{width:35px}.adminhtml-test-index .col-status{white-space:normal;width:75px}.adminhtml-test-index .col-websites{white-space:nowrap;width:200px}.adminhtml-test-index .col-price .label{display:inline-block;min-width:60px;white-space:nowrap}.adminhtml-test-index .col-price .price-excl-tax .price,.adminhtml-test-index .col-price .price-incl-tax .price{font-weight:700}.invitee_information,.inviter_information{width:48.9362%}.invitee_information{float:left}.inviter_information{float:right}.test_information .data-table th,.invitee_information .data-table th,.inviter_information .data-table th{width:20%;white-space:nowrap}.test_information .data-table textarea,.test_information .data-table input{width:100%}.tests-history ul{margin:0;padding-left:25px}.tests-history ul .status:before{display:inline-block;content:"|";margin:0 10px}.adminhtml-report-test-order .col-period{white-space:nowrap;width:70px}.adminhtml-report-test-order .col-inv-sent,.adminhtml-report-test-order .col-inv-acc,.adminhtml-report-test-order .col-acc,.adminhtml-report-test-order .col-rate{text-align:right;width:23%}.adminhtml-report-test-customer .col-id{width:35px}.adminhtml-report-test-customer .col-period{white-space:nowrap;width:70px}.adminhtml-report-test-customer .col-inv-sent,.adminhtml-report-test-customer .col-inv-acc{text-align:right;width:120px}.adminhtml-report-test-index .col-period{white-space:nowrap}.adminhtml-report-test-index .col-inv-sent,.adminhtml-report-test-index .col-inv-acc,.adminhtml-report-test-index .col-inv-disc,.adminhtml-report-test-index .col-inv-acc-rate,.adminhtml-report-test-index .col-inv-disc-rate{text-align:right;width:19%}.test_information .data-table,.invitee_information .data-table,.inviter_information .data-table{width:100%}.test_information .data-table tbody tr th,.invitee_information .data-table tbody tr th,.inviter_information .data-table tbody tr th{font-weight:700}.test_information .data-table tbody tr td,.test_information .data-table tbody tr th,.invitee_information .data-table tbody tr td,.invitee_information .data-table tbody tr th,.inviter_information .data-table tbody tr td,.inviter_information .data-table tbody tr th{background-color:#fff;border:0;padding:9px 10px 10px;color:#666;vertical-align:top}.test_information .data-table tbody tr:nth-child(2n+1) td,.test_information .data-table tbody tr:nth-child(2n+1) th,.invitee_information .data-table tbody tr:nth-child(2n+1) td,.invitee_information .data-table tbody tr:nth-child(2n+1) th,.inviter_information .data-table tbody tr:nth-child(2n+1) td,.inviter_information .data-table tbody tr:nth-child(2n+1) th{background-color:#fbfaf6}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table .col-sort-order{width:80px}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td{vertical-align:top}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td select,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td select{display:block;width:100%}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td .input-radio.global-scope,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td .input-radio.global-scope{margin-top:9px}.sales-order-create-index .ui-dialog .content>.test .field.text .input-text{width:100%}.sales-order-create-index .ui-dialog .content>.test .note .price{font-weight:600}.sales-order-create-index .ui-dialog .content>.test .note .price:before{content:": "}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .label:after{content:": "}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .control{display:inline-block;font-weight:600}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .control .control-value{margin:-2px 0 0;padding:0}.eq-ie9 [class^=" adminhtml-test-"] .custom-options .data-table{word-wrap:normal;table-layout:auto}.rma-items .col-actions a.disabled,.newRma .col-actions a.disabled{cursor:default;opacity:.5}.rma-items .col-actions a.disabled:hover,.newRma .col-actions a.disabled:hover{text-decoration:none}.block.mselect-list .mselect-input{width:100%}.block.mselect-list .mselect-input-container .mselect-save{top:4px}.block.mselect-list .mselect-input-container .mselect-cancel{top:4px}html{font-size:62.5%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-size-adjust:100%}body,html{height:100%;min-height:100%}body{color:#676056;font-family:'Open Sans',sans-serif;line-height:1.33;font-weight:400;font-size:1.4rem;background:#f2ebde;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}body>*{-webkit-flex-grow:0;flex-grow:0;-webkit-flex-shrink:0;flex-shrink:0;-webkit-flex-basis:auto;flex-basis:auto}.page-wrapper{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;min-height:100%;width:100%;max-width:100%;min-width:990px}.page-wrapper>*{-webkit-flex-grow:0;flex-grow:0;-webkit-flex-shrink:0;flex-shrink:0;-webkit-flex-basis:auto;flex-basis:auto}.page-header{text-align:right}.page-header-wrapper{background-color:#31302b}.page-header:after{content:"";display:table;clear:both}.page-header .logo{margin-top:5px;float:left;text-decoration:none;display:inline-block}.page-header .logo:before{content:"";display:inline-block;vertical-align:middle;width:109px;height:35px;background-image:url("../images/logo.svg");background-size:109px 70px;background-repeat:no-repeat}.page-header .logo:after{display:inline-block;vertical-align:middle;margin-left:10px;content:attr(data-edition);font-weight:600;font-size:16px;color:#ef672f;margin-top:-2px}.page-header .logo span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.page-header .logo span.focusable:active,.page-header .logo span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.page-header .logo span.focusable:active,.page-header .logo span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.page-header .dropdown-menu{border:0}.admin-user{display:inline-block;vertical-align:top;position:relative;text-align:left}.admin-user-account{text-decoration:none;display:inline-block;padding:12px 14px;color:#f2ebde}.admin-user-account:after{font-family:"MUI-Icons";content:"\e02c";font-size:13px;line-height:13px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-3px 0 0}.admin-user-account:link,.admin-user-account:visited{color:#f2ebde}.admin-user-account:focus,.admin-user-account:active,.admin-user-account:hover{color:#f2ebde;text-decoration:none}.active .admin-user-account{background-color:#fff;color:#676056}.admin-user-menu{padding:15px;white-space:nowrap;margin-top:0}.admin-user-menu li{border:0;padding:0}.admin-user-menu li:hover{background:0 0}.admin-user-menu a{display:block;color:#676056;font-size:13px;font-weight:400;line-height:1.385;padding:3px 12px 3px;text-decoration:none}.admin-user-menu a:focus,.admin-user-menu a:hover{text-decoration:underline}.admin-user-menu a:hover{color:#fff;background:#989287;text-decoration:none}.admin-user-menu a span:before{content:"("}.admin-user-menu a span:after{content:")"}.page-actions.fixed .page-actions-buttons{padding-right:15px}.page-main-actions{background:#e0dace;color:#645d53;padding:15px;margin-left:auto;margin-right:auto;box-sizing:border-box}.page-main-actions:before,.page-main-actions:after{content:"";display:table}.page-main-actions:after{clear:both}.page-main-actions:before,.page-main-actions:after{content:"";display:table}.page-main-actions:after{clear:both}.page-main-actions .page-actions{float:right}.page-main-actions .page-actions .page-actions-buttons{float:right;display:-webkit-flex;display:-ms-flexbox;display:flex;justify-content:flex-end}.page-main-actions .page-actions button,.page-main-actions .page-actions .action-add.mselect-button-add{margin-left:13px}.page-main-actions .page-actions button.primary,.page-main-actions .page-actions .action-add.mselect-button-add.primary{float:right;-ms-flex-order:2;-webkit-order:2;order:2}.page-main-actions .page-actions button.save:not(.primary),.page-main-actions .page-actions .action-add.mselect-button-add.save:not(.primary){float:right;-ms-flex-order:1;-webkit-order:1;order:1}.page-main-actions .page-actions button.back,.page-main-actions .page-actions button.action-back,.page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.back,.page-main-actions .page-actions .action-add.mselect-button-add.action-back,.page-main-actions .page-actions .action-add.mselect-button-add.delete{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400;margin:0 13px}.page-main-actions .page-actions button.back:focus,.page-main-actions .page-actions button.action-back:focus,.page-main-actions .page-actions button.delete:focus,.page-main-actions .page-actions button.back:active,.page-main-actions .page-actions button.action-back:active,.page-main-actions .page-actions button.delete:active,.page-main-actions .page-actions .action-add.mselect-button-add.back:focus,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:focus,.page-main-actions .page-actions .action-add.mselect-button-add.delete:focus,.page-main-actions .page-actions .action-add.mselect-button-add.back:active,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:active,.page-main-actions .page-actions .action-add.mselect-button-add.delete:active{background:0 0;border:none}.page-main-actions .page-actions button.back:hover,.page-main-actions .page-actions button.action-back:hover,.page-main-actions .page-actions button.delete:hover,.page-main-actions .page-actions .action-add.mselect-button-add.back:hover,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:hover,.page-main-actions .page-actions .action-add.mselect-button-add.delete:hover{background:0 0;border:none}.page-main-actions .page-actions button.back.disabled,.page-main-actions .page-actions button.action-back.disabled,.page-main-actions .page-actions button.delete.disabled,.page-main-actions .page-actions button.back[disabled],.page-main-actions .page-actions button.action-back[disabled],.page-main-actions .page-actions button.delete[disabled],fieldset[disabled] .page-main-actions .page-actions button.back,fieldset[disabled] .page-main-actions .page-actions button.action-back,fieldset[disabled] .page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.back.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.action-back.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.delete.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.back[disabled],.page-main-actions .page-actions .action-add.mselect-button-add.action-back[disabled],.page-main-actions .page-actions .action-add.mselect-button-add.delete[disabled],fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.back,fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.action-back,fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.delete{cursor:not-allowed;pointer-events:none;opacity:.5}.ie .page-main-actions .page-actions button.back,.ie .page-main-actions .page-actions button.action-back,.ie .page-main-actions .page-actions button.delete,.ie .page-main-actions .page-actions .action-add.mselect-button-add.back,.ie .page-main-actions .page-actions .action-add.mselect-button-add.action-back,.ie .page-main-actions .page-actions .action-add.mselect-button-add.delete{margin-top:6px}.page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.delete{color:#e22626;float:left;-ms-flex-order:-1;-webkit-order:-1;order:-1}.page-main-actions .page-actions button.back,.page-main-actions .page-actions button.action-back,.page-main-actions .page-actions .action-add.mselect-button-add.back,.page-main-actions .page-actions .action-add.mselect-button-add.action-back{float:left;-ms-flex-order:-1;-webkit-order:-1;order:-1;display:inline-block;text-decoration:none}.page-main-actions .page-actions button.back:before,.page-main-actions .page-actions button.action-back:before,.page-main-actions .page-actions .action-add.mselect-button-add.back:before,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:before{font-family:'icons-blank-theme';content:'\e625';font-size:inherit;line-height:normal;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:0 2px 0 0}.page-main-actions .page-actions .actions-split{margin-left:13px;float:right;-ms-flex-order:2;-webkit-order:2;order:2}.page-main-actions .page-actions .actions-split button.primary,.page-main-actions .page-actions .actions-split .action-add.mselect-button-add.primary{float:left}.page-main-actions .page-actions .actions-split .dropdown-menu{text-align:left}.page-main-actions .page-actions .actions-split .dropdown-menu .item{display:block}.page-main-actions .page-actions.fixed{position:fixed;top:0;left:0;right:0;z-index:10;padding:0;background:-webkit-linear-gradient(top,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:-ms-linear-gradient(top,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:linear-gradient(to bottom,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:#e0dace}.page-main-actions .page-actions.fixed .page-actions-inner{position:relative;padding-top:15px;padding-bottom:15px;min-height:36px;text-align:right;box-sizing:border-box}.page-main-actions .page-actions.fixed .page-actions-inner:before,.page-main-actions .page-actions.fixed .page-actions-inner:after{content:"";display:table}.page-main-actions .page-actions.fixed .page-actions-inner:after{clear:both}.page-main-actions .page-actions.fixed .page-actions-inner:before,.page-main-actions .page-actions.fixed .page-actions-inner:after{content:"";display:table}.page-main-actions .page-actions.fixed .page-actions-inner:after{clear:both}.page-main-actions .page-actions.fixed .page-actions-inner:before{text-align:left;content:attr(data-title);float:left;font-size:20px;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lt-ie10 .page-main-actions .page-actions.fixed .page-actions-inner{background:#f5f2ed}.page-main-actions .store-switcher{margin-top:5px}.store-switcher{display:inline-block;font-size:13px}.store-switcher .label{margin-right:5px}.store-switcher .actions.dropdown{display:inline-block;position:relative}.store-switcher .actions.dropdown:before,.store-switcher .actions.dropdown:after{content:"";display:table}.store-switcher .actions.dropdown:after{clear:both}.store-switcher .actions.dropdown:before,.store-switcher .actions.dropdown:after{content:"";display:table}.store-switcher .actions.dropdown:after{clear:both}.store-switcher .actions.dropdown .action.toggle{cursor:pointer;display:inline-block;text-decoration:none}.store-switcher .actions.dropdown .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:20px;color:#645d53;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.store-switcher .actions.dropdown .action.toggle:hover:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle:active:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle.active{display:inline-block;text-decoration:none}.store-switcher .actions.dropdown .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:20px;color:#645d53;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.store-switcher .actions.dropdown .action.toggle.active:hover:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle.active:active:after{color:#645d53}.store-switcher .actions.dropdown .dropdown-menu{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px #ada89e solid;position:absolute;z-index:100;top:100%;min-width:195px;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}.store-switcher .actions.dropdown .dropdown-menu li{margin:0;padding:0}.store-switcher .actions.dropdown .dropdown-menu li:hover{background:0 0;cursor:pointer}.store-switcher .actions.dropdown.active{overflow:visible}.store-switcher .actions.dropdown.active .dropdown-menu{display:block}.store-switcher .actions.dropdown .action.toggle{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400;color:#026294;line-height:normal;margin-top:2px;vertical-align:middle}.store-switcher .actions.dropdown .action.toggle:focus,.store-switcher .actions.dropdown .action.toggle:active{background:0 0;border:none}.store-switcher .actions.dropdown .action.toggle:hover{background:0 0;border:none}.store-switcher .actions.dropdown .action.toggle.disabled,.store-switcher .actions.dropdown .action.toggle[disabled],fieldset[disabled] .store-switcher .actions.dropdown .action.toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.store-switcher .actions.dropdown ul.dropdown-menu{margin-top:4px;padding-top:5px;left:0}.store-switcher .actions.dropdown ul.dropdown-menu li{border:0;cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li:hover{cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li a,.store-switcher .actions.dropdown ul.dropdown-menu li span{padding:5px 13px;display:block;color:#645d53}.store-switcher .actions.dropdown ul.dropdown-menu li a{text-decoration:none}.store-switcher .actions.dropdown ul.dropdown-menu li a:hover{background:#edf9fb}.store-switcher .actions.dropdown ul.dropdown-menu li span{color:#ababab;cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li.current span{color:#645d53;background:#eee}.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store a,.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store span{padding-left:26px}.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store-view a,.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store-view span{padding-left:39px}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar{border-top:1px #ededed solid;margin-top:10px}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar a{display:inline-block;text-decoration:none;display:block}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar a:before{font-family:'icons-blank-theme';content:'\e606';font-size:20px;line-height:normal;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:text-top;text-align:center;margin:0 3px 0 -4px}.tooltip{display:inline-block;margin-left:5px}.tooltip .help span,.tooltip .help a{width:16px;height:16px;text-align:center;background:rgba(194,186,169,.5);cursor:pointer;border-radius:10px;vertical-align:middle;display:inline-block;text-decoration:none}.tooltip .help span:hover,.tooltip .help a:hover{background:#c2baa9}.tooltip .help span>span,.tooltip .help a>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.tooltip .help span>span.focusable:active,.tooltip .help a>span.focusable:active,.tooltip .help span>span.focusable:focus,.tooltip .help a>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.tooltip .help span>span.focusable:active,.tooltip .help a>span.focusable:active,.tooltip .help span>span.focusable:focus,.tooltip .help a>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.tooltip .help span:before,.tooltip .help a:before{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;content:'?';font-size:13px;line-height:16px;color:#5a534a;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center}.tooltip .help span:before,.tooltip .help a:before{font-weight:700}.tooltip .tooltip-content{display:none;position:absolute;max-width:200px;margin-top:10px;margin-left:-19px;padding:4px 8px;border-radius:3px;background:#000;background:rgba(49,48,43,.8);color:#fff;text-shadow:none;z-index:20}.tooltip .tooltip-content:before{content:'';position:absolute;width:0;height:0;top:-5px;left:20px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000;opacity:.8}.tooltip .tooltip-content.loading{position:absolute}.tooltip .tooltip-content.loading:before{border-bottom-color:rgba(0,0,0,.3)}.tooltip:hover>.tooltip-content{display:block}button,.action-add.mselect-button-add{border-radius:2px;background-image:none;background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;display:inline-block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:0;vertical-align:middle}button:focus,button:active,.action-add.mselect-button-add:focus,.action-add.mselect-button-add:active{background:#cac3b4;border:1px solid #989287}button:hover,.action-add.mselect-button-add:hover{background:#cac3b4}button.disabled,button[disabled],fieldset[disabled] button,.action-add.mselect-button-add.disabled,.action-add.mselect-button-add[disabled],fieldset[disabled] .action-add.mselect-button-add{cursor:default;pointer-events:none;opacity:.5}button.primary,.action-add.mselect-button-add.primary{background-image:none;background:#007dbd;padding:6px 13px;color:#fff;border:1px solid #0a6c9f;cursor:pointer;display:inline-block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;box-sizing:border-box;vertical-align:middle}button.primary:focus,button.primary:active,.action-add.mselect-button-add.primary:focus,.action-add.mselect-button-add.primary:active{background:#026294;border:1px solid #004c74;color:#fff}button.primary:hover,.action-add.mselect-button-add.primary:hover{background:#026294;border:1px solid #026294}button.primary.disabled,button.primary[disabled],fieldset[disabled] button.primary,.action-add.mselect-button-add.primary.disabled,.action-add.mselect-button-add.primary[disabled],fieldset[disabled] .action-add.mselect-button-add.primary{cursor:default;pointer-events:none;opacity:.5}.actions-split{display:inline-block;position:relative;vertical-align:middle}.actions-split button,.actions-split .action-add.mselect-button-add{margin-left:0!important}.actions-split:before,.actions-split:after{content:"";display:table}.actions-split:after{clear:both}.actions-split:before,.actions-split:after{content:"";display:table}.actions-split:after{clear:both}.actions-split .action-default{float:left;margin:0}.actions-split .action-toggle{float:right;margin:0}.actions-split button.action-default,.actions-split .action-add.mselect-button-add.action-default{border-top-right-radius:0;border-bottom-right-radius:0}.actions-split button+.action-toggle,.actions-split .action-add.mselect-button-add+.action-toggle{border-left:0;border-top-left-radius:0;border-bottom-left-radius:0}.actions-split .action-toggle{padding:6px 5px;display:inline-block;text-decoration:none}.actions-split .action-toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.actions-split .action-toggle>span.focusable:active,.actions-split .action-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle>span.focusable:active,.actions-split .action-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.actions-split .action-toggle:hover:after{color:inherit}.actions-split .action-toggle:active:after{color:inherit}.actions-split .action-toggle.active{display:inline-block;text-decoration:none}.actions-split .action-toggle.active>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.actions-split .action-toggle.active>span.focusable:active,.actions-split .action-toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle.active>span.focusable:active,.actions-split .action-toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.actions-split .action-toggle.active:hover:after{color:inherit}.actions-split .action-toggle.active:active:after{color:inherit}.actions-split .dropdown-menu{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:175px;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}.actions-split .dropdown-menu li{margin:0;padding:3px 5px}.actions-split .dropdown-menu li:hover{background:#e8e8e8;cursor:pointer}.actions-split .dropdown-menu:before,.actions-split .dropdown-menu:after{content:"";position:absolute;display:block;width:0;height:0;border-bottom-style:solid}.actions-split .dropdown-menu:before{z-index:99;border:solid 6px;border-color:transparent transparent #fff}.actions-split .dropdown-menu:after{z-index:98;border:solid 7px;border-color:transparent transparent #bbb}.actions-split .dropdown-menu:before{top:-12px;right:10px}.actions-split .dropdown-menu:after{top:-14px;right:9px}.actions-split.active{overflow:visible}.actions-split.active .dropdown-menu{display:block}.actions-split .action-toggle:after{height:13px}.page-content:after{content:"";display:table;clear:both}.page-wrapper>.page-content{margin-bottom:20px}.page-footer{padding:15px 0}.page-footer-wrapper{background-color:#e0dacf;margin-top:auto}.page-footer:after{content:"";display:table;clear:both}.footer-legal{float:right;width:550px}.footer-legal .link-report,.footer-legal .magento-version,.footer-legal .copyright{font-size:13px}.footer-legal:before{content:"";display:inline-block;vertical-align:middle;position:absolute;z-index:1;margin-top:2px;margin-left:-35px;width:30px;height:35px;background-size:109px 70px;background:url("../images/logo.svg") no-repeat 0 -21px}.icon-error{margin-left:15px;color:#c00815;font-size:11px}.icon-error:before{font-family:'MUI-Icons';content:"\e086";font-size:13px;line-height:13px;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-1px 5px 0 0}.ui-widget-overlay{position:fixed}.control .nested{padding:0}.control *:first-child{margin-bottom:0}.field-tooltip{display:inline-block;vertical-align:top;margin-top:5px;position:relative;z-index:1;width:0;overflow:visible}.field-choice .field-tooltip{margin-top:10px}.field-tooltip:hover{z-index:99}.field-tooltip-action{position:relative;z-index:2;margin-left:18px;width:22px;height:22px;display:inline-block;cursor:pointer}.field-tooltip-action:before{content:"?";font-weight:500;font-size:18px;display:inline-block;overflow:hidden;height:22px;border-radius:11px;line-height:22px;width:22px;text-align:center;color:#fff;background-color:#514943}.field-tooltip-action span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.field-tooltip-action span.focusable:active,.field-tooltip-action span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.field-tooltip-action span.focusable:active,.field-tooltip-action span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text:focus+.field-tooltip-content,.field-tooltip:hover .field-tooltip-content{display:block}.field-tooltip-content{display:none;position:absolute;z-index:1;width:320px;background:#fff8d7;padding:15px 25px;right:-66px;border:1px solid #adadad;border-radius:1px;bottom:42px;box-shadow:0 2px 8px 0 rgba(0,0,0,.3)}.field-tooltip-content:after,.field-tooltip-content:before{content:"";display:block;width:0;height:0;border:16px solid transparent;border-top-color:#adadad;position:absolute;right:20px;top:100%;z-index:3}.field-tooltip-content:after{border-top-color:#fff8d7;margin-top:-1px;z-index:4}.form__field.field-error .control [class*=control-]{border-color:#e22626}.form__field.field-error .control [class*=control-]:before{border-color:#e22626}.form__field .mage-error{border:1px solid #e22626;display:block;margin:2px 0 0;padding:6px 10px 10px;background:#fff8d6;color:#555;font-size:12px;font-weight:500;box-sizing:border-box;max-width:380px}.no-flexbox.no-flexboxlegacy .form__field .control-addon+.mage-error{display:inline-block;width:100%}.form__field{position:relative;z-index:1}.form__field:hover{z-index:2}.control .form__field{position:static}.form__field[data-config-scope]:before{content:attr(data-config-scope);display:inline-block;position:absolute;color:gray;right:0;top:6px}.control .form__field[data-config-scope]:nth-child(n+2):before{content:""}.form__field.field-disabled>.label{color:#999}.form__field.field-disabled.field .control [class*=control-][disabled]{background-color:#e9e9e9;opacity:.5;color:#303030;border-color:#adadad}.control-fields .label~.control{width:100%}.form__field{border:0;padding:0}.form__field .note{color:#303030;padding:0;margin:10px 0 0;max-width:380px}.form__field .note:before{display:none}.form__field.form__field{margin-bottom:0}.form__field.form__field+.form__field.form__field{margin-top:15px}.form__field.form__field:not(.choice)~.choice{margin-left:20px;margin-top:5px}.form__field.form__field.choice~.choice{margin-top:9px}.form__field.form__field~.choice:last-child{margin-bottom:8px}.fieldset>.form__field{margin-bottom:30px}.form__field .label{color:#303030}.form__field:not(.choice)>.label{font-size:14px;font-weight:600;width:30%;padding-right:30px;padding-top:0;line-height:33px;white-space:nowrap}.form__field:not(.choice)>.label:before{content:".";visibility:hidden;width:0;margin-left:-7px;overflow:hidden}.form__field:not(.choice)>.label span{white-space:normal;display:inline-block;vertical-align:middle;line-height:1.2}.form__field.required>.label:after{content:"";margin-left:0}.form__field.required>.label span:after{content:"*";color:#eb5202;display:inline;font-weight:500;font-size:16px;margin-top:2px;position:absolute;z-index:1;margin-left:10px}.form__field .control-file{margin-top:6px}.form__field .control-select{line-height:33px}.form__field .control-select:not([multiple]),.form__field .control-text{height:33px;max-width:380px}.form__field .control-addon{max-width:380px}.form__field .control-textarea,.form__field .control-select,.form__field .control-text{border:1px solid #adadad;border-radius:1px;padding:0 10px;color:#303030;background-color:#fff;font-weight:500;font-size:15px;min-width:11em}.form__field .control-textarea:focus,.form__field .control-select:focus,.form__field .control-text:focus{outline:0;border-color:#007bdb;box-shadow:none}.form__field .control-text{line-height:auto}.form__field .control-textarea{padding-top:6px;padding-bottom:6px;line-height:1.18em}.form__field .control-select[multiple],.form__field .control-textarea{width:100%;height:calc(6*1.2em + 14px)}.form__field .control-value{display:inline-block;padding:6px 10px}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:active,.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:active,.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field .control-select{padding:0}.form__field .control-select option{box-sizing:border-box;padding:4px 10px;display:block}.form__field .control-select optgroup{font-weight:600;display:block;padding:4px 10px;line-height:33px;list-style:inside;font-style:normal}.form__field .control-range>.form__field:nth-child(2):before{content:"\2014";content:":";display:inline-block;margin-left:-25px;float:left;width:20px;line-height:33px;text-align:center}.form__field.choice{position:relative;z-index:1;padding-top:8px;padding-left:26px;padding-right:0}.form__field.choice .label{font-weight:500;padding:0;display:inline;float:none;line-height:18px}.form__field.choice input{position:absolute;top:8px;margin-top:3px!important}.form__field.choice input[disabled]+.label{opacity:.5;cursor:not-allowed}.control>.form__field.choice{max-width:380px}.control>.form__field.choice:nth-child(1):nth-last-child(2),.control>.form__field.choice:nth-child(2):nth-last-child(1){display:inline-block}.control>.form__field.choice:nth-child(1):nth-last-child(2)+.choice,.control>.form__field.choice:nth-child(2):nth-last-child(1)+.choice{margin-left:41px;margin-top:0}.control>.form__field.choice:nth-child(1):nth-last-child(2)+.choice:before,.control>.form__field.choice:nth-child(2):nth-last-child(1)+.choice:before{content:"";position:absolute;display:inline-block;height:20px;top:8px;left:-20px;width:1px;background:#ccc}.form__field.choice .label{cursor:pointer}.form__field.choice .label:before{content:"";position:absolute;z-index:1;border:1px solid #adadad;width:14px;height:14px;top:10px;left:0;border-radius:2px;background:url("../Magento_Ui/images/choice_bkg.png") no-repeat -100% -100%}.form__field.choice input:focus+.label:before{outline:0;border-color:#007bdb}.form__field.choice .control-radio+.label:before{border-radius:8px}.form__field.choice .control-radio:checked+.label:before{background-position:-26px -1px}.form__field.choice .control-checkbox:checked+.label:before{background-position:-1px -1px}.form__field.choice input{opacity:0}.fieldset>.form__field.choice{margin-left:30%}.form__field .control-after,.form__field .control-before{border:0;color:#858585;font-weight:300;font-size:15px;line-height:33px;display:inline-block;height:33px;box-sizing:border-box;padding:0 3px}.no-flexbox.no-flexboxlegacy .form__field .control-before,.no-flexbox.no-flexboxlegacy .form__field .control-addon{float:left;white-space:nowrap}.form__field .control-addon{display:inline-flex;max-width:380px;width:100%;flex-flow:row nowrap;position:relative;z-index:1}.form__field .control-addon>*{position:relative;z-index:1}.form__field .control-addon .control-text[disabled][type],.form__field .control-addon .control-select[disabled][type],.form__field .control-addon .control-select,.form__field .control-addon .control-text{background:transparent!important;border:0;width:auto;vertical-align:top;order:1;flex:1}.form__field .control-addon .control-text[disabled][type]:focus,.form__field .control-addon .control-select[disabled][type]:focus,.form__field .control-addon .control-select:focus,.form__field .control-addon .control-text:focus{box-shadow:none}.form__field .control-addon .control-text[disabled][type]:focus+label:before,.form__field .control-addon .control-select[disabled][type]:focus+label:before,.form__field .control-addon .control-select:focus+label:before,.form__field .control-addon .control-text:focus+label:before{outline:0;border-color:#007bdb}.form__field .control-addon .control-text[disabled][type]+label,.form__field .control-addon .control-select[disabled][type]+label,.form__field .control-addon .control-select+label,.form__field .control-addon .control-text+label{padding-left:10px;position:static!important;z-index:0}.form__field .control-addon .control-text[disabled][type]+label>*,.form__field .control-addon .control-select[disabled][type]+label>*,.form__field .control-addon .control-select+label>*,.form__field .control-addon .control-text+label>*{vertical-align:top;position:relative;z-index:2}.form__field .control-addon .control-text[disabled][type]+label:before,.form__field .control-addon .control-select[disabled][type]+label:before,.form__field .control-addon .control-select+label:before,.form__field .control-addon .control-text+label:before{box-sizing:border-box;border-radius:1px;border:1px solid #adadad;content:"";display:block;position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;background:#fff}.form__field .control-addon .control-text[disabled][type][disabled]+label:before,.form__field .control-addon .control-select[disabled][type][disabled]+label:before,.form__field .control-addon .control-select[disabled]+label:before,.form__field .control-addon .control-text[disabled]+label:before{opacity:.5;background:#e9e9e9}.form__field .control-after{order:3}.form__field .control-after:last-child{padding-right:10px}.form__field .control-before{order:0}.form__field .control-some{display:flex}.form__field [class*=control-grouped]{display:table;width:100%;table-layout:fixed;box-sizing:border-box}.form__field [class*=control-grouped]>.form__field{display:table-cell;width:50%;vertical-align:top}.form__field [class*=control-grouped]>.form__field>.control{width:100%;float:none}.form__field [class*=control-grouped]>.form__field:nth-child(n+2){padding-left:20px}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:active,.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:active,.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field [required]{box-shadow:none}fieldset.form__field{position:relative}fieldset.form__field [class*=control-grouped]>.form__field:first-child>.label,fieldset.form__field .control-fields>.form__field:first-child>.label{position:absolute;left:0;top:0;opacity:0;cursor:pointer;width:30%}.control-text+.ui-datepicker-trigger{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;line-height:inherit;font-weight:400;text-decoration:none;margin-left:-40px;display:inline-block}.control-text+.ui-datepicker-trigger img{display:none}.control-text+.ui-datepicker-trigger:focus,.control-text+.ui-datepicker-trigger:active{background:0 0;border:none}.control-text+.ui-datepicker-trigger:hover{background:0 0;border:none}.control-text+.ui-datepicker-trigger.disabled,.control-text+.ui-datepicker-trigger[disabled],fieldset[disabled] .control-text+.ui-datepicker-trigger{cursor:not-allowed;pointer-events:none;opacity:.5}.control-text+.ui-datepicker-trigger>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.control-text+.ui-datepicker-trigger>span.focusable:active,.control-text+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text+.ui-datepicker-trigger>span.focusable:active,.control-text+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text+.ui-datepicker-trigger:after{font-family:'icons-blank-theme';content:'\e612';font-size:38px;line-height:33px;color:#514943;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}[class*=tab-nav-item]:not(ul):active,[class*=tab-nav-item]:not(ul):focus{box-shadow:none;outline:none}.customer-index-edit .col-2-left-layout,.customer-index-edit .col-1-layout{background:#fff}.customer-index-edit{background:#fff}.customer-index-edit .col-2-left-layout{background:#fff}.customer-index-edit .main-col{padding-left:40px}.customer-index-edit .page-main-actions{background:0 0}.tab-nav.block{margin-bottom:40px}.tab-nav.block:first-child{margin-top:16px}.tab-nav.block .block-title{padding:7px 20px}.tab-nav-items{padding:0;border:1px solid #d3d3d3;box-shadow:0 0 4px rgba(50,50,50,.35);margin:0 0 40px;background:#f7f7f7}.tab-nav-item{padding:0;list-style-type:none;border-bottom:1px solid #e0e0e0;position:relative;margin:0 15px;z-index:1}.tab-nav-item:last-child{border-bottom:0}.tab-nav-item.ui-state-active{z-index:2;background:#fff;padding:1px 14px;border:2px solid #eb5202;margin:-1px}.tab-nav-item.ui-state-active .tab-nav-item-link{padding:13px 15px 13px;color:#eb5202}.tab-nav-item.ui-tabs-loading{position:relative;z-index:1}.tab-nav-item.ui-tabs-loading:before{content:"";display:block;position:absolute;z-index:2;background:url("../images/loader-2.gif") no-repeat 50% 50%;background-size:120px;width:20px;height:20px;top:13px;left:-10px}.tab-nav-item.ui-tabs-loading.ui-state-active:before{top:12px;left:4px}.tab-nav-item-link{display:block;padding:15px;color:#666;line-height:1}.tab-nav-item-link:focus,.tab-nav-item-link:active,.tab-nav-item-link:hover{outline:0;color:#eb5202;text-decoration:none}.ui-state-active .tab-nav-item-link{color:#666;font-weight:600}.tab-nav-item-link.changed{font-style:italic}.listing-tiles{overflow:hidden;margin-top:-10px;margin-left:-10px}.listing-tiles .listing-tile{background-color:#f2ebde;display:block;width:238px;height:200px;float:left;border:1px solid #676056;margin-top:10px;margin-left:10px;border-radius:4px;text-align:center}.listing-tiles .listing-tile.disabled{border-color:red}.listing-tiles .listing-tile.enabled{border-color:green}.listing .disabled{color:red}.listing .enabled{color:green}.pager{text-align:left;padding-bottom:10px}.pager:before,.pager:after{content:"";display:table}.pager:after{clear:both}.pager:before,.pager:after{content:"";display:table}.pager:after{clear:both}.pager [data-part=left]{display:inline-block;width:45%;float:left;text-align:left}.pager [data-part=right]{display:inline-block;width:45%;text-align:right;float:right;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.pager .action-next{cursor:pointer}.pager .action-previous{cursor:pointer}.pager{text-align:left}.pager [data-part=left]{display:inline-block;width:45%;text-align:left}.pager [data-part=right]{display:inline-block;width:45%;text-align:right;float:right}.grid .col-title{min-width:90px;text-align:center}.grid-actions [data-part=search]{display:inline-block;margin:0 30px}.grid-actions [data-part=search] input[type=text]{vertical-align:bottom;width:460px}.grid .actions-split .dropdown-menu{right:auto;left:auto;text-align:left;color:#676056;font-weight:400}.grid .actions-split .dropdown-menu:after{right:auto;left:9px}.grid .actions-split .dropdown-menu:before{right:auto;left:10px}.grid .grid-actions{padding:10px 0}.grid .hor-scroll{padding-top:10px}.grid .select-box{display:inline-block;vertical-align:top;margin:-12px -10px -7px;padding:12px 10px 7px;width:100%}.filters-toggle{background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:3px;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.filters-toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:30px;line-height:15px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-toggle:hover:after{color:inherit}.filters-toggle:active:after{color:inherit}.filters-toggle:focus,.filters-toggle:active{background:#cac3b4;border:1px solid #989287}.filters-toggle:hover{background:#cac3b4}.filters-toggle.disabled,.filters-toggle[disabled],fieldset[disabled] .filters-toggle{cursor:default;pointer-events:none;opacity:.5}.filters-toggle:focus,.filters-toggle:active{background:0 0;border:none}.filters-toggle:hover{background:0 0;border:none}.filters-toggle.disabled,.filters-toggle[disabled],fieldset[disabled] .filters-toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.filters-toggle:after{margin-top:2px;margin-left:-3px}.filters-toggle.active:after{content:'\e618'}.filters-current{padding:10px 0;display:none}.filters-current.active{display:block}.filters-items{margin:0;padding:0;list-style:none none;display:inline}.filters-item{display:inline-block;margin:0 5px 5px 0;padding:2px 2px 2px 4px;border-radius:3px;background:#f7f3eb}.filters-item .item-label{font-weight:600}.filters-item .item-label:after{content:": "}.filters-item .action-remove{background-image:none;background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:3px;vertical-align:middle;display:inline-block;text-decoration:none;padding:0}.filters-item .action-remove>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters-item .action-remove>span.focusable:active,.filters-item .action-remove>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-item .action-remove>span.focusable:active,.filters-item .action-remove>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-item .action-remove:before{font-family:'icons-blank-theme';content:'\e616';font-size:16px;line-height:16px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-item .action-remove:hover:before{color:inherit}.filters-item .action-remove:active:before{color:inherit}.filters-item .action-remove:focus,.filters-item .action-remove:active{background:#cac3b4;border:1px solid #989287}.filters-item .action-remove:hover{background:#cac3b4}.filters-item .action-remove.disabled,.filters-item .action-remove[disabled],fieldset[disabled] .filters-item .action-remove{cursor:default;pointer-events:none;opacity:.5}.filters-form{position:relative;z-index:1;margin:14px 0;background:#fff;border:1px solid #bbb;box-shadow:0 3px 3px rgba(0,0,0,.15)}.filters-form .action-close{position:absolute;top:3px;right:7px;background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:3px;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.filters-form .action-close>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters-form .action-close>span.focusable:active,.filters-form .action-close>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-form .action-close>span.focusable:active,.filters-form .action-close>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-form .action-close:before{font-family:'icons-blank-theme';content:'\e616';font-size:42px;line-height:42px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-form .action-close:hover:before{color:inherit}.filters-form .action-close:active:before{color:inherit}.filters-form .action-close:focus,.filters-form .action-close:active{background:#cac3b4;border:1px solid #989287}.filters-form .action-close:hover{background:#cac3b4}.filters-form .action-close.disabled,.filters-form .action-close[disabled],fieldset[disabled] .filters-form .action-close{cursor:default;pointer-events:none;opacity:.5}.filters-form .action-close:focus,.filters-form .action-close:active{background:0 0;border:none}.filters-form .action-close:hover{background:0 0;border:none}.filters-form .action-close.disabled,.filters-form .action-close[disabled],fieldset[disabled] .filters-form .action-close{cursor:not-allowed;pointer-events:none;opacity:.5}.filters-actions{margin:18px;text-align:right}.filters-fieldset{padding-bottom:0}.filters-fieldset .field{border:0;margin:0 0 20px;box-sizing:border-box;display:inline-block;padding:0 12px 0 0;width:33.33333333%;vertical-align:top}.filters-fieldset .field:before,.filters-fieldset .field:after{content:"";display:table}.filters-fieldset .field:after{clear:both}.filters-fieldset .field:before,.filters-fieldset .field:after{content:"";display:table}.filters-fieldset .field:after{clear:both}.filters-fieldset .field.choice:before,.filters-fieldset .field.no-label:before{box-sizing:border-box;content:" ";height:1px;float:left;padding:6px 15px 0 0;width:35%}.filters-fieldset .field .description{box-sizing:border-box;float:left;padding:6px 15px 0 0;text-align:right;width:35%}.filters-fieldset .field:not(.choice)>.label{box-sizing:border-box;float:left;padding:6px 15px 0 0;text-align:right;width:35%}.filters-fieldset .field:not(.choice)>.control{float:left;width:65%}.filters-fieldset .field:last-child{margin-bottom:0}.filters-fieldset .field+.fieldset{clear:both}.filters-fieldset .field>.label{font-weight:700}.filters-fieldset .field>.label+br{display:none}.filters-fieldset .field .choice input{vertical-align:top}.filters-fieldset .field .fields.group:before,.filters-fieldset .field .fields.group:after{content:"";display:table}.filters-fieldset .field .fields.group:after{clear:both}.filters-fieldset .field .fields.group:before,.filters-fieldset .field .fields.group:after{content:"";display:table}.filters-fieldset .field .fields.group:after{clear:both}.filters-fieldset .field .fields.group .field{box-sizing:border-box;float:left}.filters-fieldset .field .fields.group.group-2 .field{width:50% !important}.filters-fieldset .field .fields.group.group-3 .field{width:33.3% !important}.filters-fieldset .field .fields.group.group-4 .field{width:25% !important}.filters-fieldset .field .fields.group.group-5 .field{width:20% !important}.filters-fieldset .field .addon{display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-wrap:nowrap;flex-wrap:nowrap;padding:0;width:100%}.filters-fieldset .field .addon textarea,.filters-fieldset .field .addon select,.filters-fieldset .field .addon input{-ms-flex-order:2;-webkit-order:2;order:2;-webkit-flex-basis:100%;flex-basis:100%;box-shadow:none;display:inline-block;margin:0;width:auto}.filters-fieldset .field .addon .addbefore,.filters-fieldset .field .addon .addafter{-ms-flex-order:3;-webkit-order:3;order:3;display:inline-block;box-sizing:border-box;background:#fff;border:1px solid #c2c2c2;border-radius:1px;height:32px;width:100%;padding:0 9px;font-size:14px;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;line-height:1.428571429;background-clip:padding-box;vertical-align:baseline;width:auto;white-space:nowrap;vertical-align:middle}.filters-fieldset .field .addon .addbefore:disabled,.filters-fieldset .field .addon .addafter:disabled{opacity:.5}.filters-fieldset .field .addon .addbefore::-moz-placeholder,.filters-fieldset .field .addon .addafter::-moz-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore::-webkit-input-placeholder,.filters-fieldset .field .addon .addafter::-webkit-input-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore:-ms-input-placeholder,.filters-fieldset .field .addon .addafter:-ms-input-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore{float:left;-ms-flex-order:1;-webkit-order:1;order:1}.filters-fieldset .field .additional{margin-top:10px}.filters-fieldset .field.required>.label:after{content:'*';font-size:1.2rem;color:#e02b27;margin:0 0 0 5px}.filters-fieldset .field .note{font-size:1.2rem;margin:3px 0 0;padding:0;display:inline-block;text-decoration:none}.filters-fieldset .field .note:before{font-family:'icons-blank-theme';content:'\e618';font-size:24px;line-height:12px;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filters-fieldset .field .label{color:#676056;font-size:13px;font-weight:600;margin:0}.filters .field-date .group .hasDatepicker{width:100%;padding-right:30px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;line-height:inherit;font-weight:400;text-decoration:none;margin-left:-33px;display:inline-block;width:30px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger img{display:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:focus,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:active{background:0 0;border:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:hover{background:0 0;border:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger.disabled,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger[disabled],fieldset[disabled] .filters .field-date .group .hasDatepicker+.ui-datepicker-trigger{cursor:not-allowed;pointer-events:none;opacity:.5}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:active,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:active,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:after{font-family:'icons-blank-theme';content:'\e612';font-size:35px;line-height:30px;color:#514943;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filters .field-range .group .field{margin-bottom:0}.filters .field-range .group .control{width:100%;box-sizing:border-box;padding-right:0;position:relative;z-index:1}.mass-select{position:relative;margin:-6px -10px;padding:6px 2px 6px 10px;z-index:1;white-space:nowrap}.mass-select.active{background:rgba(0,0,0,.2)}.mass-select-toggle{background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:3px;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.mass-select-toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.mass-select-toggle>span.focusable:active,.mass-select-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.mass-select-toggle>span.focusable:active,.mass-select-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.mass-select-toggle:before{font-family:'icons-blank-theme';content:'\e607';font-size:30px;line-height:15px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.mass-select-toggle:hover:before{color:inherit}.mass-select-toggle:active:before{color:inherit}.mass-select-toggle:focus,.mass-select-toggle:active{background:#cac3b4;border:1px solid #989287}.mass-select-toggle:hover{background:#cac3b4}.mass-select-toggle.disabled,.mass-select-toggle[disabled],fieldset[disabled] .mass-select-toggle{cursor:default;pointer-events:none;opacity:.5}.mass-select-toggle:focus,.mass-select-toggle:active{background:0 0;border:none}.mass-select-toggle:hover{background:0 0;border:none}.mass-select-toggle.disabled,.mass-select-toggle[disabled],fieldset[disabled] .mass-select-toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.mass-select-toggle:before{margin-top:-2px;text-indent:-5px;color:#fff}.mass-select-toggle:hover:before{color:#fff}.mass-select-toggle:active:before,.mass-select-toggle.active:before{content:'\e618'}.mass-select-field{display:inline}.mass-select-menu{display:none;position:absolute;top:100%;left:0;text-align:left;margin:0;padding:0;list-style:none none;background:#fff;border:1px solid #bbb;min-width:175px;box-shadow:0 3px 3px rgba(0,0,0,.15)}.mass-select-menu li{margin:0;padding:4px 15px;border-bottom:1px solid #e5e5e5}.mass-select-menu li:hover{background:#e8e8e8;cursor:pointer}.mass-select-menu span{font-weight:400;font-size:13px;color:#645d53}.mass-select-menu.active{display:block}.grid-loading-mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(255,255,255,.5);z-index:100}.grid-loading-mask .grid-loader{position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;width:218px;height:149px;background:url('../images/loader-2.gif') 50% 50% no-repeat}.addon input{border-width:1px 0 1px 1px}.addon input~.addafter strong{display:inline-block;background:#fff;line-height:24px;margin:0 3px 0 -2px;padding-left:4px;padding-right:4px;position:relative;font-size:12px;top:0}.addon input:focus~.addafter{border-color:#75b9f0;box-shadow:0 0 8px rgba(82,168,236,.6)}.addon input:focus~.addafter strong{margin-top:0}.addon .addafter{background:0 0;color:#a6a6a6;border-width:1px 1px 1px 0;border-radius:2px 2px 0 0;padding:0;border-color:#ada89e}.addon .pager input{border-width:1px}.field .control input[type=text][disabled],.field .control input[type=text][disabled]~.addafter,.field .control select[disabled],.field .control select[disabled]~.addafter{background-color:#fff;border-color:#eee;box-shadow:none;color:#999}.field .control input[type=text][disabled]~.addafter strong,.field .control select[disabled]~.addafter strong{background-color:#fff}.field-price.addon{direction:rtl}.field-price.addon>*{direction:ltr}.field-price.addon .addafter{border-width:1px 0 1px 1px;border-radius:2px 0 0 2px}.field-price.addon input:first-child{border-radius:0 2px 2px 0}.field-price input{border-width:1px 1px 1px 0}.field-price input:focus{box-shadow:0 0 8px rgba(82,168,236,.6)}.field-price input:focus~label.addafter{box-shadow:0 0 8px rgba(82,168,236,.6)}.field-price input~label.addafter strong{margin-left:2px;margin-right:-2px}.field-price.addon>input{width:99px;float:left}.field-price .control{position:relative}.field-price label.mage-error{position:absolute;left:0;top:30px}.version-fieldset .grid-actions{border-bottom:1px solid #f2ebde;margin:0 0 15px;padding:0 0 15px}.navigation>ul,.message-system,.page-header,.page-actions.fixed .page-actions-inner,.page-content,.page-footer{width:auto;min-width:960px;max-width:1300px;margin:0 auto;padding-left:15px;padding-right:15px;box-sizing:border-box;width:100%}.pager label.page,.filters .field-range .group .label,.mass-select-field .label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visually-hidden.focusable:active,.visually-hidden.focusable:focus,.pager label.page.focusable:active,.pager label.page.focusable:focus,.filters .field-range .group .label.focusable:active,.filters .field-range .group .label.focusable:focus,.mass-select-field .label.focusable:active,.mass-select-field .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}table th.required:after,.data-table th.required-entry:after,.data-table td.required-entry:after,.grid-actions .filter.required .label span:after,.grid-actions .required:after,.accordion .config .data-table td.required-entry:after{content:'*';color:#e22626;font-weight:400;margin-left:3px}.grid th.required:after,.grid th .required:after{content:'*';color:#f9d4d4;font-weight:400;margin-left:3px}.grid td.col-period,.grid td.col-date,.grid td.col-date_to,.grid td.col-date_from,.grid td.col-ended_at,.grid td.col-created_at,.grid td.col-updated_at,.grid td.col-customer_since,.grid td.col-session_start_time,.grid td.col-last_activity,.grid td.col-email,.grid td.col-name,.grid td.col-sku,.grid td.col-firstname,.grid td.col-lastname,.grid td.col-title,.grid td.col-label,.grid td.col-product,.grid td.col-set_name,.grid td.col-websites,.grid td.col-time,.grid td.col-billing_name,.grid td.col-shipping_name,.grid td.col-phone,.grid td.col-type,.product-options .grouped-items-table .col-name,.product-options .grouped-items-table .col-sku,.sales-order-create-index .data-table .col-product,[class^=' adminhtml-rma-'] .fieldset-wrapper .data-table td,[class^=' adminhtml-rma-'] .grid .col-product_sku,[class^=' adminhtml-rma-'] .grid .col-product_name,.col-grid_segment_name,.adminhtml-catalog-event-index .col-category,[class^=' catalog-search'] .col-search_query,[class^=' catalog-search'] .col-synonym_for,[class^=' catalog-search'] .col-redirect,.adminhtml-urlrewrite-index .col-request_path,.adminhtml-cms-page-index .col-title,.adminhtml-cms-page-index .col-identifier,.adminhtml-cms-hierarchy-index .col-title,.adminhtml-cms-hierarchy-index .col-identifier,.col-banner_name,.adminhtml-widget-instance-index .col-title,.reports-index-search .col-query_text,.adminhtml-rma-item-attribute-index .grid .col-attr-code,.adminhtml-system-store-index .grid td,.catalog-product-attribute-index .col-attr-code,.catalog-product-attribute-index .col-label,.adminhtml-export-index .col-code,.adminhtml-logging-index .grid .col-fullaction,.adminhtml-system-variable-index .grid .col-code,.adminhtml-logging-index .grid .col-info,.dashboard-secondary .dashboard-item tr>td:first-child,.ui-tabs-panel .dashboard-data .col-name,.data-table-td-max .data-table td,[class^=' adminhtml-rma-'] .fieldset-wrapper .accordion .config .data-table td,.data-table-td-max .accordion .config .data-table td,.order-account-information .data-table td,[class^=' adminhtml-rma-'] .rma-request-details .data-table td{overflow:hidden;text-overflow:ellipsis}td.col-period,td.col-date,td.col-date_to,td.col-date_from,td.col-ended_at,td.col-created_at,td.col-updated_at,td.col-customer_since,td.col-session_start_time,td.col-time,td.col-sku,td.col-type,[class^=' adminhtml-rma-'] #rma_items_grid_table .headings th,.adminhtml-process-list .col-action a,.adminhtml-process-list .col-mode{white-space:nowrap}table thead tr th:first-child,table tfoot tr th:first-child,table tfoot tr td:first-child{border-left:0}table thead tr th:last-child,table tfoot tr th:last-child,table tfoot tr td:last-child{border-right:0}.form-inline .grid-actions .label,.form-inline .massaction .label{padding:0;width:auto}.grid .col-action,.grid .col-actions,.grid .col-qty,.grid .col-purchases,.catalog-product-edit .ui-tabs-panel .grid .col-price,.catalog-product-edit .ui-tabs-panel .grid .col-position{width:50px}.grid .col-order-number,.grid .col-real_order_id,.grid .col-invoice-number,.grid .col-increment_id,.grid .col-transaction-id,.grid .col-parent-transaction-id,.grid .col-reference_id,.grid .col-status,.grid .col-price,.grid .col-position,.grid .col-base_grand_total,.grid .col-grand_total,.grid .col-sort_order,.grid .col-carts,.grid .col-priority,.grid .col-severity,.sales-order-create-index .col-in_products,[class^=' reports-'] [class^=col-total],[class^=' reports-'] [class^=col-average],[class^=' reports-'] [class^=col-ref-],[class^=' reports-'] [class^=col-rate],[class^=' reports-'] [class^=col-tax-amount],[class^=' adminhtml-customer-'] .col-required,.adminhtml-rma-item-attribute-index .col-required,[class^=' adminhtml-customer-'] .col-system,.adminhtml-rma-item-attribute-index .col-system,[class^=' adminhtml-customer-'] .col-is_visible,.adminhtml-rma-item-attribute-index .col-is_visible,[class^=' adminhtml-customer-'] .col-sort_order,.adminhtml-rma-item-attribute-index .col-sort_order,.catalog-product-attribute-index [class^=' col-is_'],.catalog-product-attribute-index .col-required,.catalog-product-attribute-index .col-system,.adminhtml-test-index .col-is_listed,[class^=' tests-report-test'] [class^=col-inv-]{width:70px}.grid .col-phone,.sales-order-view .grid .col-period,.sales-order-create-index .col-phone,[class^=' adminhtml-rma-'] .grid .col-product_sku,.adminhtml-rma-edit .col-product,.adminhtml-rma-edit .col-sku,.catalog-product-edit .ui-tabs-panel .grid .col-name,.catalog-product-edit .ui-tabs-panel .grid .col-type,.catalog-product-edit .ui-tabs-panel .grid .col-sku,.customer-index-index .grid .col-customer_since,.customer-index-index .grid .col-billing_country_id,[class^=' customer-index-'] .fieldset-wrapper .grid .col-created_at,[class^=' customer-index-'] .accordion .grid .col-created_at{max-width:70px;width:70px}.sales-order-view .grid .col-name,.sales-order-create-index .data-table .col-product,[class^=' adminhtml-rma-'] .grid .col-name,[class^=' adminhtml-rma-'] .grid .col-product,[class^=' catalog-search'] .col-search_query,[class^=' catalog-search'] .col-synonym_for,[class^=' catalog-search'] .col-redirect,.adminhtml-urlrewrite-index .col-request_path,.reports-report-shopcart-abandoned .grid .col-name,.tax-rule-index .grid .col-title,.adminhtml-rma-item-attribute-index .grid .col-attr-code,.dashboard-secondary .dashboard-item tr>td:first-child{max-width:150px;width:150px}[class^=' sales-order-'] .grid .col-name,.catalog-category-edit .grid .col-name,.adminhtml-catalog-event-index .col-category,.adminhtml-banner-edit .grid .col-name,.reports-report-product-lowstock .grid .col-sku,.newsletter-problem-index .grid .col-name,.newsletter-problem-index .grid .col-subject,.newsletter-problem-index .grid .col-product,.adminhtml-rma-item-attribute-index .grid .col-label,.adminhtml-export-index .col-label,.adminhtml-export-index .col-code,.adminhtml-scheduled-operation-index .grid .col-name,.adminhtml-logging-index .grid .col-fullaction,.test-report-customer-wishlist-wishlist .grid .col-name,.test-report-customer-wishlist-wishlist .grid .col-subject,.test-report-customer-wishlist-wishlist .grid .col-product{max-width:220px;width:220px}.grid .col-period,.grid .col-date,.grid .col-date_to,.grid .col-date_from,.grid .col-ended_at,.grid .col-created_at,.grid .col-updated_at,.grid .col-customer_since,.grid .col-session_start_time,.grid .col-last_activity,.grid .col-email,.grid .col-items_total,.grid .col-firstname,.grid .col-lastname,.grid .col-status-default,.grid .col-websites,.grid .col-time,.grid .col-billing_name,.grid .col-shipping_name,.sales-order-index .grid .col-name,.product-options .grouped-items-table .col-name,.product-options .grouped-items-table .col-sku,[class^=' sales-order-view'] .grid .col-customer_name,[class^=' adminhtml-rma-'] .grid .col-product_name,.catalog-product-index .grid .col-name,.catalog-product-review-index .grid .col-name,.catalog-product-review-index .grid .col-title,.customer-index-edit .ui-tabs-panel .grid .col-name,.review-product-index .grid .col-name,.adminhtml-cms-page-index .col-title,.adminhtml-cms-page-index .col-identifier,.catalog-product-attribute-index .col-attr-code,.catalog-product-attribute-index .col-label,.adminhtml-logging-index .grid .col-info{max-width:110px;width:110px}.grid .col-name,.grid .col-product,.col-banner_name,.adminhtml-widget-instance-index .col-title,[class^=' adminhtml-customer-'] .col-label,.adminhtml-rma-item-attribute-index .col-label,.adminhtml-system-variable-index .grid .col-code,.ui-tabs-panel .dashboard-data .col-name,.adminhtml-test-index .col-label{max-width:370px;width:370px}.col-grid_segment_name,.reports-index-search .col-query_text{max-width:570px;width:570px}[class^=' adminhtml-rma-'] .fieldset-wrapper .data-table td,.reports-report-product-lowstock .grid .col-name,.reports-report-shopcart-product .grid .col-name,.reports-report-review-customer .grid .col-name,[class^=' adminhtml-rma-'] .fieldset-wrapper .accordion .config .data-table td{max-width:670px;width:670px}.reports-report-sales-invoiced .grid .col-period,.reports-report-sales-refunde .grid .col-period,[class^=' tests-report-test'] .grid .col-period{width:auto}.grid .col-select,.grid .col-id,.grid .col-number{width:40px}.sales-order-create-index .grid,.sales-order-create-index .grid-actions,.adminhtml-export-index .grid-actions,.adminhtml-export-index .grid{padding-left:0;padding-right:0}[class^=' adminhtml-rma-'] .col-actions a,[class^=' customer-index-'] .col-action a,.adminhtml-notification-index .col-actions a{display:block;margin:0 0 3px;white-space:nowrap}.data-table-td-max .accordion .config .data-table td,.order-account-information .data-table td,[class^=' adminhtml-rma-'] .rma-request-details .data-table td{max-width:250px;width:250px}.catalog-product-edit .ui-tabs-panel .grid .hor-scroll,.catalog-product-index .grid .hor-scroll,.review-product-index .grid .hor-scroll,.adminhtml-rma-edit .hor-scroll{overflow-x:auto}.add-clearer:after,.massaction:after,.navigation>ul:after{content:"";display:table;clear:both}.test-content{width:calc(20px + 100*0.2)}.test-content:before{content:'.test {\A ' attr(data-attribute) ': 0.2em;' '\A content:\'';white-space:pre}.test-content:after{content:' Test\';\A}' "\A" '\A.test + .test._other ~ ul > li' " {\A height: @var;\A content: ' + ';\A}";white-space:pre}.test-content-calc{width:calc((100%/12*2) - 10px)}.test-svg-xml-image{background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 38 40"><style>.st0{fill:none;stroke:%23ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}</style><circle cx="14.7" cy="14.7" r="13.7" class="st0"/><path d="M23.9 24.7L37 39" class="st0"/></svg>') no-repeat left center} \ No newline at end of file +table>caption{margin-bottom:5px}table thead{background:#676056;color:#f7f3eb}table thead .headings{background:#807a6e}table thead a{color:#f7f3eb;display:block}table thead a label{color:#f7f3eb;cursor:pointer;display:block}table thead a:hover,table thead a:focus{color:#dac7a2;text-decoration:none}table tfoot{background:#f2ebde;color:#676056}table tfoot tr th,table tfoot tr td{text-align:left}table th{background:0 0;border:solid #cac3b4;border-width:0 1px;font-size:14px;padding:6px 10px;text-align:center}table td{border:solid #cac3b4;border-width:0 1px;padding:6px 10px 7px;vertical-align:top}table tbody tr td{background:#fff;color:#676056;padding-top:12px}table tbody tr td:first-child{border-left:0}table tbody tr td:first-child input[type=checkbox]{margin:0}table tbody tr td:last-child{border-right:0}table tbody tr:last-child th,table tbody tr:last-child td{border-bottom-width:1px}table tbody tr:nth-child(odd) td,table tbody tr:nth-child(odd) th{background-color:#f7f3eb}table tbody.even tr td{background:#fff}table tbody.odd tr td{background:#f7f3eb}table .dropdown-menu li{padding:7px 15px;line-height:14px;cursor:pointer}table .col-draggable .draggable-handle{float:left;position:relative;top:0}.not-sort{padding-right:10px}.sort-arrow-asc,.sort-arrow-desc{padding-right:10px;position:relative}.sort-arrow-asc:after,.sort-arrow-desc:after{right:-11px;top:-1px;position:absolute;width:23px}.sort-arrow-asc:hover:after,.sort-arrow-desc:hover:after{color:#dac7a2}.sort-arrow-asc{display:inline-block;text-decoration:none}.sort-arrow-asc:after{font-family:'icons-blank-theme';content:'\e626';font-size:13px;line-height:inherit;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.sort-arrow-asc:hover:after{color:#dac7a2}.sort-arrow-desc{display:inline-block;text-decoration:none}.sort-arrow-desc:after{font-family:'icons-blank-theme';content:'\e623';font-size:13px;line-height:inherit;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.sort-arrow-desc:hover:after{color:#dac7a2}.grid-actions .input-text,.pager .input-text,.massaction .input-text,.filter .input-text,.grid-actions select,.pager select,.massaction select,.filter select,.grid-actions .select,.pager .select,.massaction .select,.filter .select{border-color:#989287;box-shadow:none;border-radius:1px;height:28px;margin:0 10px 0 0}.filter th{border:0 solid #676056;padding:6px 3px;vertical-align:top}.filter .ui-datepicker-trigger{cursor:pointer;margin-top:2px}.filter .input-text{padding:0 5px}.filter .range-line:not(:last-child){margin-bottom:5px}.filter .date{padding-right:28px;position:relative;display:inline-block;text-decoration:none}.filter .date .hasDatepicker{vertical-align:top;width:99%}.filter .date img{cursor:pointer;height:25px;width:25px;right:0;position:absolute;vertical-align:middle;z-index:2;opacity:0}.filter .date:before{font-family:'icons-blank-theme';content:'\e612';font-size:42px;line-height:30px;color:#f7f3eb;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filter .date:hover:before{color:#dac7a2}.filter .date:before{height:29px;margin-left:5px;position:absolute;right:-3px;top:-3px;width:35px}.filter select{border-color:#cac3b4;margin:0;padding:0;width:99%}.filter input.input-text{border-color:#cac3b4;margin:0;width:99%}.filter input.input-text::-webkit-input-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text::-moz-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text:-moz-placeholder{color:#989287 !important;text-transform:lowercase}.filter input.input-text:-ms-input-placeholder{color:#989287 !important;text-transform:lowercase}.grid{background:#fff;color:#676056;font-size:13px;font-weight:400;padding:15px}.grid table{width:100%}.grid tbody tr.selected th,.grid tbody tr.selected td,.grid tbody tr:hover th,.grid tbody tr:hover td,.grid tbody tr:nth-child(odd):hover th,.grid tbody tr:nth-child(odd):hover td{background-color:#f2ebde;cursor:pointer}.grid tbody tr.selected th.empty-text,.grid tbody tr.selected td.empty-text,.grid tbody tr:hover th.empty-text,.grid tbody tr:hover td.empty-text,.grid tbody tr:nth-child(odd):hover th.empty-text,.grid tbody tr:nth-child(odd):hover td.empty-text{background-color:#f7f3eb;cursor:default}.grid .empty-text{font:400 20px/1.2 'Open Sans',sans-serif;text-align:center;white-space:nowrap}.grid .col-sku{max-width:100px;width:100px}.grid .col-select,.grid .col-massaction{text-align:center}.grid .editable .input-text{width:65px}.grid .col-actions .action-select{background:#fff;border-color:#989287;height:28px;margin:0;padding:4px 4px 5px;width:80px}.grid .col-position.editable{white-space:nowrap}.grid .col-position.editable .input-text{margin:-7px 5px 0;width:70%}.eq-ie9 .hor-scroll{display:inline-block;min-height:0;overflow-y:hidden;overflow-x:auto;width:100%}.data-table{border-collapse:separate;width:100%}.data-table thead,.data-table tfoot,.data-table th,.accordion .config .data-table thead th,.accordion .config .data-table tfoot td,.accordion .config .accordion .config .data-table tfoot td th{background:#fff;color:#676056;font-size:13px;font-weight:600}.data-table th{text-align:left}.data-table thead th,.accordion .config .data-table thead th th,.accordion .config .data-table tfoot td th,.accordion .config .accordion .config .data-table tfoot td th th{border:solid #c9c2b8;border-width:0 0 1px;padding:7px}.data-table td,.data-table tbody tr th,.data-table tbody tr td,.accordion .config .data-table td{background:#fff;border-width:0;padding:5px 7px;vertical-align:middle}.data-table tbody tr:nth-child(odd) th,.data-table tbody tr:nth-child(odd) td,.accordion .config .data-table tbody tr:nth-child(odd) td{background:#fbfaf6}.data-table tbody.odd tr th,.data-table tbody.odd tr td{background:#fbfaf6}.data-table tbody.even tr th,.data-table tbody.even tr td{background:#fff}.data-table tfoot tr:last-child th,.data-table tfoot tr:last-child td,.data-table .accordion .config .data-table tfoot tr:last-child td{border:0}.data-table.order-tables tbody td{vertical-align:top}.data-table.order-tables tbody:hover tr th,.data-table.order-tables tbody:hover tr td{background:#f7f3eb}.data-table.order-tables tfoot td{background:#f2ebde;color:#676056;font-size:13px;font-weight:600}.data-table input[type=text]{width:98%;padding-left:1%;padding-right:1%}.data-table select{margin:0;box-sizing:border-box}.data-table .col-actions .actions-split{margin-top:4px}.data-table .col-actions .actions-split [class^=action-]{background:0 0;border:1px solid #c8c3b5;padding:3px 5px;color:#bbb3a6;font-size:12px}.data-table .col-actions .actions-split [class^=action-]:first-child{border-right:0}.data-table .col-actions .actions-split .dropdown-menu{margin-top:-1px}.data-table .col-actions .actions-split .dropdown-menu a{display:block;color:#333;text-decoration:none}.data-table .col-actions .actions-split.active .action-toggle{position:relative;border-bottom-right-radius:0;box-shadow:none;background:#fff}.data-table .col-actions .actions-split.active .action-toggle:after{position:absolute;top:100%;left:0;right:0;height:2px;margin-top:-1px;background:#fff;content:'';z-index:2}.data-table .col-actions .actions-split.active .action-toggle .dropdown-menu{border-top-right-radius:0}.data-table .col-default{white-space:nowrap;text-align:center;vertical-align:middle}.data-table .col-delete{text-align:center;width:32px}.data-table .col-file{white-space:nowrap}.data-table .col-file input,.data-table .col-file .input-text{margin:0 5px;width:40%}.data-table .col-file input:first-child,.data-table .col-file .input-text:first-child{margin-left:0}.data-table .col-actions-add{padding:10px 0}.grid-actions{background:#fff;font-size:13px;line-height:28px;padding:10px 15px;position:relative}.grid-actions+.grid{padding-top:5px}.grid-actions .export,.grid-actions .filter-actions{float:right;margin-left:10px;vertical-align:top}.grid-actions .import{display:block;vertical-align:top}.grid-actions .action-reset{background:0 0;border:0;display:inline;line-height:1.42857143;padding:0;color:#1979c3;text-decoration:none;margin:6px 10px 0 0;vertical-align:top}.grid-actions .action-reset:visited{color:purple;text-decoration:none}.grid-actions .action-reset:hover{color:#006bb4;text-decoration:underline}.grid-actions .action-reset:active{color:#ff5501;text-decoration:underline}.grid-actions .action-reset:hover{color:#006bb4}.grid-actions .action-reset:hover,.grid-actions .action-reset:active,.grid-actions .action-reset:focus{background:0 0;border:0}.grid-actions .action-reset.disabled,.grid-actions .action-reset[disabled],fieldset[disabled] .grid-actions .action-reset{color:#1979c3;text-decoration:underline;cursor:default;pointer-events:none;opacity:.5}.grid-actions .import .label,.grid-actions .export .label,.massaction>.entry-edit .label{margin:0 14px 0 0;vertical-align:inherit}.grid-actions .import .action-,.grid-actions .export .action-,.grid-actions .filter-actions .action-,.massaction>.entry-edit .action-{vertical-align:inherit}.grid-actions .filter .date{float:left;margin:0 15px 0 0;position:relative}.grid-actions .filter .date:before{color:#676056;top:1px}.grid-actions .filter .date:hover:before{color:#31302b}.grid-actions .filter .label{margin:0}.grid-actions .filter .hasDatepicker{margin:0 5px;width:80px}.grid-actions .filter .show-by .select{margin-left:5px;padding:4px 4px 5px;vertical-align:top;width:auto}.grid-actions .filter.required:after{content:''}.grid-actions img{vertical-align:middle;height:22px;width:22px}.grid-actions .validation-advice{background:#f9d4d4;border:1px solid #e22626;border-radius:3px;color:#e22626;margin:5px 0 0;padding:3px 7px;position:absolute;white-space:nowrap;z-index:5}.grid-actions .validation-advice:before{width:0;height:0;border:5px solid transparent;border-bottom-color:#e22626;content:'';left:50%;margin-left:-5px;position:absolute;top:-11px}.grid-actions input[type=text].validation-failed{border-color:#e22626;box-shadow:0 0 8px rgba(226,38,38,.6)}.grid-actions .link-feed{white-space:nowrap}.pager{font-size:13px}.grid .pager{margin:15px 0 0;position:relative;text-align:center}.pager .pages-total-found{margin-right:25px}.pager .view-pages .select{margin:0 5px}.pager .link-feed{font-size:12px;margin:7px 15px 0 0;position:absolute;right:0;top:0}.pager .action-previous,.pager .action-next{background:0 0;border:0;display:inline;margin:0;padding:0;color:#1979c3;text-decoration:none;line-height:.6;overflow:hidden;width:20px}.pager .action-previous:visited,.pager .action-next:visited{color:purple;text-decoration:none}.pager .action-previous:hover,.pager .action-next:hover{color:#006bb4;text-decoration:underline}.pager .action-previous:active,.pager .action-next:active{color:#ff5501;text-decoration:underline}.pager .action-previous:hover,.pager .action-next:hover{color:#006bb4}.pager .action-previous:hover,.pager .action-next:hover,.pager .action-previous:active,.pager .action-next:active,.pager .action-previous:focus,.pager .action-next:focus{background:0 0;border:0}.pager .action-previous.disabled,.pager .action-next.disabled,.pager .action-previous[disabled],.pager .action-next[disabled],fieldset[disabled] .pager .action-previous,fieldset[disabled] .pager .action-next{color:#1979c3;text-decoration:underline;cursor:default;pointer-events:none;opacity:.5}.pager .action-previous:before,.pager .action-next:before{margin-left:-10px}.pager .action-previous.disabled,.pager .action-next.disabled{opacity:.3}.pager .action-previous{display:inline-block;text-decoration:none}.pager .action-previous>span{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.pager .action-previous>span.focusable:active,.pager .action-previous>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-previous>span.focusable:active,.pager .action-previous>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-previous:before{font-family:'icons-blank-theme';content:'\e617';font-size:40px;line-height:inherit;color:#026294;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.pager .action-previous:hover:before{color:#007dbd}.pager .action-next{display:inline-block;text-decoration:none}.pager .action-next>span{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.pager .action-next>span.focusable:active,.pager .action-next>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-next>span.focusable:active,.pager .action-next>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.pager .action-next:before{font-family:'icons-blank-theme';content:'\e608';font-size:40px;line-height:inherit;color:#026294;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.pager .action-next:hover:before{color:#007dbd}.pager .input-text{height:25px;line-height:16px;margin-right:5px;text-align:center;width:25px;vertical-align:top}.pager .pages-total{line-height:25px;vertical-align:top}.massaction{background:#fff;border-top:1px solid #f2ebde;font-size:13px;line-height:28px;padding:15px 15px 0}.massaction>.entry-edit{float:right}.massaction>.entry-edit .field-row{display:inline-block;vertical-align:top}.massaction>.entry-edit .validation-advice{display:none !important}.massaction>.entry-edit .form-inline{display:inline-block}.massaction>.entry-edit .label{padding:0;width:auto}.massaction>.entry-edit .action-{vertical-align:top}.massaction .select.validation-failed{border:1px dashed #e22626;background:#f9d4d4}.grid-severity-critical,.grid-severity-major,.grid-severity-notice,.grid-severity-minor{background:#feeee1;border:1px solid #ed4f2e;color:#ed4f2e;display:block;padding:0 3px;font-weight:700;line-height:17px;text-transform:uppercase;text-align:center}.grid-severity-critical,.grid-severity-major{border-color:#e22626;background:#f9d4d4;color:#e22626}.grid-severity-notice{border-color:#5b8116;background:#d0e5a9;color:#185b00}.grid tbody td input[type=text],.data-table tbody td input[type=text],.grid tbody th input[type=text],.data-table tbody th input[type=text],.grid tbody td .input-text,.data-table tbody td .input-text,.grid tbody th .input-text,.data-table tbody th .input-text,.grid tbody td select,.data-table tbody td select,.grid tbody th select,.data-table tbody th select,.grid tbody td .select,.data-table tbody td .select,.grid tbody th .select,.data-table tbody th .select{width:99%}.ui-tabs-panel .grid .col-sku{max-width:150px;width:150px}.col-indexer_status,.col-indexer_mode{width:160px}.fieldset-wrapper .grid-actions+.grid{padding-top:15px}.fieldset-wrapper .grid-actions{padding:10px 0 0}.fieldset-wrapper .grid{padding:0}.fieldset-wrapper .massaction{padding:0;border-top:none;margin-bottom:15px}.accordion .grid{padding:0}.ui-dialog-content .grid-actions,.ui-dialog-content .grid{padding-left:0;padding-right:0}.qty-table td{border:0;padding:0 5px 3px}.sales-order-create-index .sales-order-create-index .grid table .action-configure{float:right}.sales-order-create-index .data-table .border td{padding-bottom:15px}.sales-order-create-index .actions.update{margin:10px 0}.adminhtml-order-shipment-new .grid .col-product{max-width:770px;width:770px}.customer-index-index .grid .col-name{max-width:90px;width:90px}.customer-index-index .grid .col-billing_region{width:70px}.adminhtml-cms-hierarchy-index .col-title,.adminhtml-cms-hierarchy-index .col-identifier{max-width:410px;width:410px}.adminhtml-widget-instance-edit .grid-chooser .control{margin-top:-19px;width:80%}.eq-ie9 .adminhtml-widget-instance-edit .grid-chooser .control{margin-top:-18px}.adminhtml-widget-instance-edit .grid-chooser .control .grid-actions{padding:0 0 15px}.adminhtml-widget-instance-edit .grid-chooser .control .grid{padding:0}.adminhtml-widget-instance-edit .grid-chooser .control .addon input:last-child,.adminhtml-widget-instance-edit .grid-chooser .control .addon select:last-child{border-radius:0}.reports-report-product-sold .grid .col-name{max-width:720px;width:720px}.adminhtml-system-store-index .grid td{max-width:310px}.adminhtml-system-currency-index .grid{padding-top:0}.adminhtml-system-currency-index .col-currency-edit-rate{min-width:40px}.adminhtml-system-currency-index .col-base-currency{font-weight:700}.adminhtml-system-currency-index .old-rate{display:block;margin-top:3px;text-align:center}.adminhtml-system-currency-index .hor-scroll{overflow-x:auto;min-width:970px}.adminhtml-system-currencysymbol-index .col-currency{width:35%}.adminhtml-system-currencysymbol-index .grid .input-text{margin:0 10px 0 0;width:50%}.catalog-product-set-index .col-set_name{max-width:930px;width:930px}.adminhtml-export-index .grid td{vertical-align:middle}.adminhtml-export-index .grid .input-text-range{margin:0 10px 0 5px;width:37%}.adminhtml-export-index .grid .input-text-range-date{margin:0 5px;width:32%}.adminhtml-export-index .ui-datepicker-trigger{display:inline-block;margin:-3px 10px 0 0;vertical-align:middle}.adminhtml-notification-index .grid .col-select,.adminhtml-cache-index .grid .col-select,.adminhtml-process-list .grid .col-select,.indexer-indexer-list .grid .col-select{width:10px}@font-face{font-family:'icons-blank-theme';src:url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff2') format('woff2'),url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff') format('woff');font-weight:400;font-style:normal}@font-face{font-family:'icons-blank-theme';src:url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff2') format('woff2'),url('../fonts/Blank-Theme-Icons/Blank-Theme-Icons.woff') format('woff');font-weight:400;font-style:normal}.navigation{background-color:#676056;position:relative;z-index:5}.navigation .level-0.reverse>.submenu{right:1px}.navigation>ul{position:relative;text-align:right}.navigation .level-0>.submenu{display:none;position:absolute;top:100%;padding:19px 13px}.navigation .level-0>.submenu a{display:block;color:#676056;font-size:13px;font-weight:400;line-height:1.385;padding:3px 12px 3px;text-decoration:none}.navigation .level-0>.submenu a:focus,.navigation .level-0>.submenu a:hover{text-decoration:underline}.navigation .level-0>.submenu a:hover{color:#fff;background:#989287;text-decoration:none}.navigation .level-0>.submenu li{margin-bottom:1px}.navigation .level-0>.submenu a[href="#"]{cursor:default;display:block;color:#676056;font-size:14px;font-weight:700;line-height:1;margin:7px 0 6px;padding:0 12px}.navigation .level-0>.submenu a[href="#"]:focus,.navigation .level-0>.submenu a[href="#"]:hover{color:#676056;font-size:14px;font-weight:700;background:0 0;text-decoration:none}.navigation .level-0{display:inline-block;float:left;text-align:left;transition:display .15s ease-out}.navigation .level-0>a{background:0 0;display:block;padding:12px 13px 0;color:#f2ebde;font-size:13px;font-weight:600;text-transform:uppercase;text-decoration:none;transition:background .15s ease-out}.navigation .level-0>a:after{content:"";display:block;margin-top:10px;height:3px;font-size:0}.navigation .level-0.active>a{font-weight:700}.navigation .level-0.active>a:after{background:#ef672f}.navigation .level-0.hover.recent>a{background:#fff;color:#676056;font-size:13px;font-weight:600}.navigation .level-0.hover.recent>a:after{background:0 0}.navigation .level-0.hover.recent.active>a{font-weight:700}.navigation .level-0>.submenu{opacity:0;visibility:hidden}.navigation .level-0.recent.hover>.submenu{opacity:1;visibility:visible}.no-js .navigation .level-0:hover>.submenu,.no-js .navigation .level-0.hover>.submenu,.no-js .navigation .level-0>a:focus+.submenu{display:block}.navigation .level-0>.submenu{background:#fff;box-shadow:0 3px 3px rgba(50,50,50,.15)}.navigation .level-0>.submenu li{max-width:200px}.navigation .level-0>.submenu>ul{white-space:nowrap}.navigation .level-0>.submenu .column{display:inline-block;margin-left:40px;vertical-align:top}.navigation .level-0>.submenu .column:first-child{margin-left:0}.navigation .level-0 .submenu .level-1{white-space:normal}.navigation .level-0.parent .submenu .level-1.parent{margin:17px 0 25px}.navigation .level-0.parent .level-1.parent:first-child{margin-top:0}.navigation .level-2 .submenu{margin-left:7px}.navigation .level-0>.submenu .level-2>a[href="#"]{font-size:13px;margin-top:10px;margin-left:7px}.navigation .level-2>.submenu a{font-size:12px;line-height:1.231}.navigation .level-0>.submenu .level-3>a[href="#"],.navigation .level-3 .submenu{margin-left:15px}.navigation .level-0.item-system,.navigation .level-0.item-stores{float:none}.navigation .level-0.item-system>.submenu,.navigation .level-0.item-stores>.submenu{left:auto;right:1px}.adminhtml-dashboard-index .col-1-layout{max-width:1300px;border:none;border-radius:0;padding:0;background:#f7f3eb}.dashboard-inner{padding-top:35px}.dashboard-inner:before,.dashboard-inner:after{content:"";display:table}.dashboard-inner:after{clear:both}.dashboard-inner:before,.dashboard-inner:after{content:"";display:table}.dashboard-inner:after{clear:both}.dashboard-secondary{float:left;width:32%;margin:0 1.5%}.dashboard-main{float:right;width:65%}.dashboard-diagram-chart{max-width:100%;height:auto}.dashboard-diagram-nodata,.dashboard-diagram-switcher{padding:20px 0}.dashboard-diagram-image{background:#fff url(../mui/images/ajax-loader-small.gif) no-repeat 50% 50%}.dashboard-container .ui-tabs-panel{background-color:#fff;min-height:40px;padding:15px}.dashboard-store-stats{margin-top:35px}.dashboard-store-stats .ui-tabs-panel{background:#fff url(../mui/images/ajax-loader-small.gif) no-repeat 50% 50%}.dashboard-item{margin-bottom:30px}.dashboard-item-header{margin-left:5px}.dashboard-item.dashboard-item-primary{margin-bottom:35px}.dashboard-item.dashboard-item-primary .title{font-size:22px;margin-bottom:5px}.dashboard-item.dashboard-item-primary .dashboard-sales-value{display:block;text-align:right;font-weight:600;font-size:30px;margin-right:12px;padding-bottom:5px}.dashboard-item.dashboard-item-primary:first-child{color:#ef672f}.dashboard-item.dashboard-item-primary:first-child .title{color:#ef672f}.dashboard-totals{background:#fff;padding:50px 15px 25px}.dashboard-totals-list{margin:0;padding:0;list-style:none none}.dashboard-totals-list:before,.dashboard-totals-list:after{content:"";display:table}.dashboard-totals-list:after{clear:both}.dashboard-totals-list:before,.dashboard-totals-list:after{content:"";display:table}.dashboard-totals-list:after{clear:both}.dashboard-totals-item{float:left;width:18%;margin-left:7%;padding-top:15px;border-top:2px solid #cac3b4}.dashboard-totals-item:first-child{margin-left:0}.dashboard-totals-label{display:block;font-size:16px;font-weight:600;padding-bottom:2px}.dashboard-totals-value{color:#ef672f;font-size:20px}.dashboard-data{width:100%}.dashboard-data thead{background:0 0}.dashboard-data thead tr{background:0 0}.dashboard-data th,.dashboard-data td{border:none;padding:10px 12px;text-align:right}.dashboard-data th:first-child,.dashboard-data td:first-child{text-align:left}.dashboard-data th{color:#676056;font-weight:600}.dashboard-data td{background-color:transparent}.dashboard-data tbody tr:hover td{background-color:transparent}.dashboard-data tbody tr:nth-child(odd) td,.dashboard-data tbody tr:nth-child(odd):hover td,.dashboard-data tbody tr:nth-child(odd) th,.dashboard-data tbody tr:nth-child(odd):hover th{background-color:#e1dbcf}.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd) td,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd):hover td,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd) th,.ui-tabs-panel .dashboard-data tbody tr:nth-child(odd):hover th{background-color:#f7f3eb}.dashboard-data td.empty-text{text-align:center}.ui-tabs-panel .dashboard-data{background-color:#fff}.mage-dropdown-dialog.ui-dialog .ui-dialog-content{overflow:visible}.mage-dropdown-dialog.ui-dialog .ui-dialog-buttonpane{padding:0}.message-system-inner{background:#f7f3eb;border:1px solid #c0bbaf;border-top:0;border-radius:0 0 5px 5px;float:right;overflow:hidden}.message-system-unread .message-system-inner{float:none}.message-system-list{margin:0;padding:0;list-style:none;float:left}.message-system .message-system-list{width:75%}.message-system-list li{padding:5px 13px 7px 36px;position:relative}.message-system-short{padding:5px 13px 7px;float:right}.message-system-short span{display:inline-block;margin-left:7px;border-left:1px #d1ccc3 solid}.message-system-short span:first-child{border:0;margin-left:0}.message-system-short a{padding-left:27px;position:relative;height:16px}.message-system .message-system-short a:before,.message-system-list li:before{font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;height:16px;width:16px;font-size:16px;line-height:16px;text-align:center;position:absolute;left:7px;top:2px}.message-system-list li:before{top:5px;left:13px}.message-system .message-system-short .warning a:before,.message-system-list li.warning:before{content:"\e006";color:#f2a825}.message-system .message-system-short .error a:before,.message-system-list li.error:before{content:"\e086";font-family:'MUI-Icons';color:#c00815}.ui-dialog .message-system-list{margin-bottom:25px}.sales-order-create-index .order-errors .notice{color:#ed4f2e;font-size:11px;margin:5px 0 0}.order-errors .fieldset-wrapper-title .title{box-sizing:border-box;background:#fffbf0;border:1px solid #d87e34;border-radius:5px;color:#676056;font-size:14px;margin:20px 0;padding:10px 26px 10px 35px;position:relative}.order-errors .fieldset-wrapper-title .title:before{position:absolute;left:11px;top:50%;margin-top:-11px;width:auto;height:auto;font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;font-size:16px;line-height:inherit;content:'\e046';color:#d87e34}.search-global.miniform{position:relative;z-index:1000;display:inline-block;vertical-align:top;margin:6px 10px 0}.search-global.miniform .mage-suggest{border:0;border-radius:0}.search-global-actions{display:none}.search-global-field{margin:0}.search-global-field .label{position:absolute;right:4px;z-index:2;cursor:pointer;display:inline-block;text-decoration:none}.search-global-field .label>span{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.search-global-field .label>span.focusable:active,.search-global-field .label>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.search-global-field .label>span.focusable:active,.search-global-field .label>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.search-global-field .label:before{font-family:'MUI-Icons';content:"\e01f";font-size:18px;line-height:29px;color:#cac3b4;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.search-global-field .control{width:48px;overflow:hidden;opacity:0;transition:all .3s ease}.search-global-field .control input[type=text]{background:0 0;border:none;width:100%}.search-global-field.active{z-index:2}.search-global-field.active .label:before{display:none}.search-global-field.active .control{overflow:visible;opacity:1;transition:all .3s ease;width:300px}.search-global-menu{box-sizing:border-box;display:block;width:100%}.notifications-summary{display:inline-block;text-align:left;position:relative;z-index:1}.notifications-summary.active{z-index:999}.notifications-action{color:#f2ebde;padding:12px 22px 11px;text-transform:capitalize;display:inline-block;text-decoration:none}.notifications-action:before{font-family:"MUI-Icons";content:"\e06e";font-size:18px;line-height:18px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-action:visited,.notifications-action:focus,.notifications-action:active,.notifications-action:hover{color:#f2ebde;text-decoration:none}.notifications-action.active{background-color:#fff;color:#676056}.notifications-action .text{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-action .text.focusable:active,.notifications-action .text.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-action .text.focusable:active,.notifications-action .text.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-action .qty.counter{display:inline-block;background:#ed4f2e;color:#f2ebde;font-size:12px;line-height:12px;font-weight:700;padding:1px 3px;position:absolute;top:6px;left:50%;border-radius:4px}.notifications-list{width:300px;padding:0;margin:0}.notifications-list .last{padding:10px;text-align:center;font-size:12px}.notifications-summary .notifications-entry{padding:15px;color:#676056;font-size:11px;font-weight:400}.notifications-entry{position:relative;z-index:1}.notifications-entry:hover .action{display:block}.notifications-entry-title{padding-right:15px;color:#ed4f2e;font-size:12px;font-weight:600;display:block;margin-bottom:10px}.notifications-entry-description{line-height:1.3;display:block;max-height:3.9em;overflow:hidden;margin-bottom:10px;text-overflow:ellipsis}.notifications-close.action{position:absolute;z-index:1;top:12px;right:12px;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400;display:none}.notifications-close.action>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-close.action>span.focusable:active,.notifications-close.action>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-close.action>span.focusable:active,.notifications-close.action>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-close.action:before{font-family:'MUI-Icons';content:"\e07f";font-size:16px;line-height:inherit;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-close.action:focus,.notifications-close.action:active{background:0 0;border:none}.notifications-close.action:hover{background:0 0;border:none}.notifications-close.action.disabled,.notifications-close.action[disabled],fieldset[disabled] .notifications-close.action{cursor:not-allowed;pointer-events:none;opacity:.5}.notifications-dialog-content{display:none}.notifications-critical .notifications-entry-title{padding-left:25px;display:inline-block;text-decoration:none}.notifications-critical .notifications-entry-title:before{font-family:'MUI-Icons';content:"\e086";font-size:18px;line-height:18px;color:#c00815;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.notifications-critical .notifications-entry-title:before{position:absolute;margin-left:-25px}.notifications-dialog-content .notifications-entry-time{color:#8c867e;font-size:13px;font-family:Helvetica,Arial,sans-serif;position:absolute;right:17px;bottom:27px;text-align:right}.notifications-url{display:inline-block;text-decoration:none}.notifications-url>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.notifications-url>span.focusable:active,.notifications-url>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-url>span.focusable:active,.notifications-url>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.notifications-url:after{font-family:'MUI-Icons';content:"\e084";font-size:16px;line-height:inherit;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-2px 0 0 10px}.notifications-dialog-content .notifications-entry-title{font-size:15px}.locale-switcher-field{white-space:nowrap;float:left}.locale-switcher-field .control,.locale-switcher-field .label{vertical-align:middle;margin:0 10px 0 0;display:inline-block}.locale-switcher-select{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none;border:1px solid #ada89e;max-width:200px;height:31px;background:url("../images/select-bg.svg") no-repeat 100% 50%;background-size:30px 60px;padding-right:29px;text-indent:.01px;text-overflow:''}.locale-switcher-select::-ms-expand{display:none}.lt-ie10 .locale-switcher-select{background-image:none;padding-right:4px}@-moz-document url-prefix(){.locale-switcher-select{background-image:none}}@-moz-document url-prefix(){.locale-switcher-select{background-image:none}}.mage-suggest{text-align:left;box-sizing:border-box;position:relative;display:inline-block;vertical-align:top;width:100%;background-color:#fff;border:1px solid #ada89e;border-radius:2px}.mage-suggest:after{position:absolute;top:3px;right:3px;bottom:0;width:22px;text-align:center;font-family:'MUI-Icons';font-style:normal;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;content:'\e01f';font-size:18px;color:#b2b2b2}.mage-suggest input[type=search],.mage-suggest input.search{width:100%;border:none;background:0 0;padding-right:30px}.mage-suggest.category-select input[type=search],.mage-suggest.category-select input.search{height:26px}.mage-suggest-dropdown{position:absolute;left:0;right:0;top:100%;margin:1px -1px 0;border:1px solid #cac2b5;background:#fff;box-shadow:0 2px 4px rgba(0,0,0,.2);z-index:990}.mage-suggest-dropdown ul{margin:0;padding:0;list-style:none}.mage-suggest-dropdown li{border-bottom:1px solid #e5e5e5;padding:0}.mage-suggest-dropdown li a{display:block}.mage-suggest-dropdown li a.ui-state-focus{background:#f5f5f5}.mage-suggest-dropdown li a,.mage-suggest-dropdown .jstree li a:hover,.mage-suggest-dropdown .jstree .jstree-hovered,.mage-suggest-dropdown .jstree .jstree-clicked{padding:6px 12px 5px;text-decoration:none;color:#333}.mage-suggest-dropdown .jstree li a:hover,.mage-suggest-dropdown .jstree .jstree-hovered,.mage-suggest-dropdown .jstree .jstree-clicked{border:none}.mage-suggest-dropdown .jstree li{border-bottom:0}.mage-suggest-dropdown .jstree li a{display:inline-block}.mage-suggest-dropdown .jstree .mage-suggest-selected>a{color:#000;background:#f1ffeb}.field-category_ids .mage-suggest-dropdown,.field-new_category_parent .mage-suggest-dropdown{max-height:200px;overflow:auto}.mage-suggest-dropdown .jstree .mage-suggest-selected>a:hover,.mage-suggest-dropdown .jstree .mage-suggest-selected>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-selected>.jstree-clicked,.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-selected.mage-suggest-not-active>.jstree-clicked{background:#e5ffd9}.mage-suggest-dropdown .jstree .mage-suggest-not-active>a{color:#d4d4d4}.mage-suggest-dropdown .jstree .mage-suggest-not-active>a:hover,.mage-suggest-dropdown .jstree .mage-suggest-not-active>.jstree-hovered,.mage-suggest-dropdown .jstree .mage-suggest-not-active>.jstree-clicked{background:#f5f5f5}.mage-suggest-dropdown .category-path{font-size:11px;margin-left:10px;color:#9ba8b5}.suggest-expandable .action-dropdown .action-toggle{display:inline-block;max-width:500px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:none;box-shadow:none;color:#676056;font-size:12px;padding:5px 4px;filter:none}.suggest-expandable .action-dropdown .action-toggle span{display:inline}.suggest-expandable .action-dropdown .action-toggle:before{display:inline-block;float:right;margin-left:4px;font-size:13px;color:#b2b0ad}.suggest-expandable .action-dropdown .action-toggle:hover:before{color:#7e7e7e}.suggest-expandable .dropdown-menu{margin:1px 0 0;left:0;right:auto;width:245px;z-index:4}.suggest-expandable .mage-suggest{border:none;border-radius:3px 3px 0 0}.suggest-expandable .mage-suggest:after{top:10px;right:8px}.suggest-expandable .mage-suggest-inner .title{margin:0;padding:0 10px 4px;text-transform:uppercase;color:#a6a098;font-size:12px;border-bottom:1px solid #e5e5e5}.suggest-expandable .mage-suggest-inner>input[type=search],.suggest-expandable .mage-suggest-inner>input.search{position:relative;margin:6px 5px 5px;padding-right:20px;border:1px solid #ada89e;width:236px;z-index:1}.suggest-expandable .mage-suggest-inner>input.ui-autocomplete-loading,.suggest-expandable .mage-suggest-inner>input.mage-suggest-state-loading{background:#fff url("../mui/images/ajax-loader-small.gif") no-repeat 190px 50%}.suggest-expandable .mage-suggest-dropdown{margin-top:0;border-top:0;border-radius:0 0 3px 3px;max-height:300px;overflow:auto;width:100%;float:left}.suggest-expandable .mage-suggest-dropdown ul{margin:0;padding:0;list-style:none}.suggest-expandable .action-show-all:hover,.suggest-expandable .action-show-all:active,.suggest-expandable .action-show-all:focus,.suggest-expandable .action-show-all[disabled]{border-top:1px solid #e5e5e5;display:block;width:100%;padding:8px 10px 10px;text-align:left;font:12px/1.333 Arial,Verdana,sans-serif;color:#676056}.product-actions .suggest-expandable{max-width:500px;float:left;margin-top:1px}.page-actions.fixed #product-template-suggest-container{display:none}.catalog-category-edit .col-2-left-layout:before{display:none}.category-content .ui-tabs-panel .fieldset{padding-top:40px}.category-content .ui-tabs-panel .fieldset .legend{display:none}.attributes-edit-form .field:not(.field-weight) .addon{display:block;position:relative}.attributes-edit-form .field:not(.field-weight) .addon input[type=text]{border-width:1px}.attributes-edit-form .field:not(.field-weight) .addon .addafter{display:block;border:0;height:auto;width:auto}.attributes-edit-form .field:not(.field-weight) .addon input:focus~.addafter{box-shadow:none}.attributes-edit-form .with-addon .textarea{margin:0}.attributes-edit-form .attribute-change-checkbox{display:block;margin-top:5px}.attributes-edit-form .attribute-change-checkbox .label{float:none;padding:0;width:auto}.attributes-edit-form .attribute-change-checkbox .checkbox{margin-right:5px;width:auto}.attributes-edit-form .field-price .addon>input,.attributes-edit-form .field-special_price .addon>input,.attributes-edit-form .field-gift_wrapping_price .addon>input,.attributes-edit-form .field-msrp .addon>input,.attributes-edit-form .field-gift_wrapping_price .addon>input{padding-left:23px}.attributes-edit-form .field-price .addafter>strong,.attributes-edit-form .field-special_price .addafter>strong,.attributes-edit-form .field-gift_wrapping_price .addafter>strong,.attributes-edit-form .field-msrp .addafter>strong,.attributes-edit-form .field-gift_wrapping_price .addafter>strong{left:5px;position:absolute;top:3px}.attributes-edit-form .field.type-price input:focus+label,.attributes-edit-form .field-price input:focus+label,.attributes-edit-form .field-special_price input:focus+label,.attributes-edit-form .field-msrp input:focus+label,.attributes-edit-form .field-weight input:focus+label{box-shadow:none}.attributes-edit-form .field-special_from_date>.control .input-text,.attributes-edit-form .field-special_to_date>.control .input-text,.attributes-edit-form .field-news_from_date>.control .input-text,.attributes-edit-form .field-news_to_date>.control .input-text,.attributes-edit-form .field-custom_design_from>.control .input-text,.attributes-edit-form .field-custom_design_to>.control .input-text{border-width:1px;width:130px}.attributes-edit-form .field-weight .fields-group-2 .control{padding-right:27px}.attributes-edit-form .field-weight .fields-group-2 .control .addafter+.addafter{border-width:1px 1px 1px 0;border-style:solid;height:28px;right:0;position:absolute;top:0}.attributes-edit-form .field-weight .fields-group-2 .control .addafter strong{line-height:28px}.attributes-edit-form .field-weight .fields-group-2 .control>input:focus+.addafter+.addafter{box-shadow:0 0 8px rgba(82,168,236,.6)}.attributes-edit-form .field-gift_message_available .addon>input[type=checkbox],.attributes-edit-form .field-gift_wrapping_available .addon>input[type=checkbox]{width:auto;margin-right:5px}.attributes-edit-form .fieldset>.addafter{display:none}.advanced-inventory-edit .field.choice{display:block;margin:3px 0 0}.advanced-inventory-edit .field.choice .label{padding-top:1px}.product-actions:before,.product-actions:after{content:"";display:table}.product-actions:after{clear:both}.product-actions:before,.product-actions:after{content:"";display:table}.product-actions:after{clear:both}.product-actions .switcher{float:right}#configurable-attributes-container .actions-select{display:inline-block;position:relative}#configurable-attributes-container .actions-select:before,#configurable-attributes-container .actions-select:after{content:"";display:table}#configurable-attributes-container .actions-select:after{clear:both}#configurable-attributes-container .actions-select:before,#configurable-attributes-container .actions-select:after{content:"";display:table}#configurable-attributes-container .actions-select:after{clear:both}#configurable-attributes-container .actions-select .action.toggle{cursor:pointer;display:inline-block;text-decoration:none}#configurable-attributes-container .actions-select .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:22px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#configurable-attributes-container .actions-select .action.toggle:hover:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle:active:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle.active{display:inline-block;text-decoration:none}#configurable-attributes-container .actions-select .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:22px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#configurable-attributes-container .actions-select .action.toggle.active:hover:after{color:inherit}#configurable-attributes-container .actions-select .action.toggle.active:active:after{color:inherit}#configurable-attributes-container .actions-select ul.dropdown{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:100%;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}#configurable-attributes-container .actions-select ul.dropdown li{margin:0;padding:3px 5px}#configurable-attributes-container .actions-select ul.dropdown li:hover{background:#e8e8e8;cursor:pointer}#configurable-attributes-container .actions-select.active{overflow:visible}#configurable-attributes-container .actions-select.active ul.dropdown{display:block}#configurable-attributes-container .actions-select .action.toggle{padding:1px 8px;border:1px solid #ada89e;background:#fff;border-radius:0 2px 2px 0}#configurable-attributes-container .actions-select .action.toggle:after{width:14px;text-indent:-2px}#configurable-attributes-container .actions-select ul.dropdown li:hover{background:#eef8fc}#configurable-attributes-container .actions-select ul.dropdown a{color:#333;text-decoration:none}#product-variations-matrix .actions-image-uploader{position:relative;display:block;width:50px}#product-variations-matrix .actions-image-uploader:before,#product-variations-matrix .actions-image-uploader:after{content:"";display:table}#product-variations-matrix .actions-image-uploader:after{clear:both}#product-variations-matrix .actions-image-uploader:before,#product-variations-matrix .actions-image-uploader:after{content:"";display:table}#product-variations-matrix .actions-image-uploader:after{clear:both}#product-variations-matrix .actions-image-uploader .action.split{float:left;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle{float:right;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle{padding:6px 5px;display:inline-block;text-decoration:none}#product-variations-matrix .actions-image-uploader .action.toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle:hover:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle:active:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle.active{display:inline-block;text-decoration:none}#product-variations-matrix .actions-image-uploader .action.toggle.active>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:active,#product-variations-matrix .actions-image-uploader .action.toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}#product-variations-matrix .actions-image-uploader .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}#product-variations-matrix .actions-image-uploader .action.toggle.active:hover:after{color:inherit}#product-variations-matrix .actions-image-uploader .action.toggle.active:active:after{color:inherit}#product-variations-matrix .actions-image-uploader ul.dropdown{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:100%;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}#product-variations-matrix .actions-image-uploader ul.dropdown li{margin:0;padding:3px 5px}#product-variations-matrix .actions-image-uploader ul.dropdown li:hover{background:#e8e8e8;cursor:pointer}#product-variations-matrix .actions-image-uploader.active{overflow:visible}#product-variations-matrix .actions-image-uploader.active ul.dropdown{display:block}#product-variations-matrix .actions-image-uploader .action.toggle{padding:0 2px;border:1px solid #b7b2a7;background:#fff;border-radius:0 4px 4px 0;border-left:none;height:33px}#product-variations-matrix .actions-image-uploader .action.toggle.no-display{display:none}#product-variations-matrix .actions-image-uploader .action.toggle:after{width:12px;text-indent:-5px}#product-variations-matrix .actions-image-uploader ul.dropdown{left:0;margin-left:0;width:100px}#product-variations-matrix .actions-image-uploader ul.dropdown li:hover{background:#eef8fc}#product-variations-matrix .actions-image-uploader ul.dropdown a{color:#333;text-decoration:none}.debugging-hints .page-actions{position:relative;z-index:1}.debugging-hints .page-actions .debugging-hint-template-file{left:auto !important;right:0 !important}.filter-segments{list-style:none;padding:0}.adminhtml-report-customer-test-detail .col-id{width:35px}.adminhtml-report-customer-test-detail .col-period{white-space:nowrap;width:70px}.adminhtml-report-customer-test-detail .col-zip{width:50px}.adminhtml-report-customer-test-segment .col-id{width:35px}.adminhtml-report-customer-test-segment .col-status{width:65px}.adminhtml-report-customer-test-segment .col-qty{width:145px}.adminhtml-report-customer-test-segment .col-segment,.adminhtml-report-customer-test-segment .col-website{width:35%}.adminhtml-report-customer-test-segment .col-select{width:45px}.test-custom-attributes{margin-bottom:20px}.adminhtml-test-index th.col-id{text-align:left}.adminhtml-test-index .col-price{text-align:right;width:50px}.adminhtml-test-index .col-actions{width:50px}.adminhtml-test-index .col-select{width:60px}.adminhtml-test-edit .field-image .control{line-height:28px}.adminhtml-test-edit .field-image a{display:inline-block;margin:0 5px 0 0}.adminhtml-test-edit .field-image img{vertical-align:middle}.adminhtml-test-new .field-image .input-file,.adminhtml-test-edit .field-image .input-file{display:inline-block;margin:0 15px 0 0;width:auto}.adminhtml-test-new .field-image .addafter,.adminhtml-test-edit .field-image .addafter{border:0;box-shadow:none;display:inline-block;margin:0 15px 0 0;height:auto;width:auto}.adminhtml-test-new .field-image .delete-image,.adminhtml-test-edit .field-image .delete-image{display:inline-block;white-space:nowrap}.adminhtml-test-edit .field-image .delete-image input{margin:-3px 5px 0 0;width:auto;display:inline-block}.adminhtml-test-edit .field-image .addon .delete-image input:focus+label{border:0;box-shadow:none}.adminhtml-test-index .col-id{width:35px}.adminhtml-test-index .col-status{white-space:normal;width:75px}.adminhtml-test-index .col-websites{white-space:nowrap;width:200px}.adminhtml-test-index .col-price .label{display:inline-block;min-width:60px;white-space:nowrap}.adminhtml-test-index .col-price .price-excl-tax .price,.adminhtml-test-index .col-price .price-incl-tax .price{font-weight:700}.invitee_information,.inviter_information{width:48.9362%}.invitee_information{float:left}.inviter_information{float:right}.test_information .data-table th,.invitee_information .data-table th,.inviter_information .data-table th{width:20%;white-space:nowrap}.test_information .data-table textarea,.test_information .data-table input{width:100%}.tests-history ul{margin:0;padding-left:25px}.tests-history ul .status:before{display:inline-block;content:"|";margin:0 10px}.adminhtml-report-test-order .col-period{white-space:nowrap;width:70px}.adminhtml-report-test-order .col-inv-sent,.adminhtml-report-test-order .col-inv-acc,.adminhtml-report-test-order .col-acc,.adminhtml-report-test-order .col-rate{text-align:right;width:23%}.adminhtml-report-test-customer .col-id{width:35px}.adminhtml-report-test-customer .col-period{white-space:nowrap;width:70px}.adminhtml-report-test-customer .col-inv-sent,.adminhtml-report-test-customer .col-inv-acc{text-align:right;width:120px}.adminhtml-report-test-index .col-period{white-space:nowrap}.adminhtml-report-test-index .col-inv-sent,.adminhtml-report-test-index .col-inv-acc,.adminhtml-report-test-index .col-inv-disc,.adminhtml-report-test-index .col-inv-acc-rate,.adminhtml-report-test-index .col-inv-disc-rate{text-align:right;width:19%}.test_information .data-table,.invitee_information .data-table,.inviter_information .data-table{width:100%}.test_information .data-table tbody tr th,.invitee_information .data-table tbody tr th,.inviter_information .data-table tbody tr th{font-weight:700}.test_information .data-table tbody tr td,.test_information .data-table tbody tr th,.invitee_information .data-table tbody tr td,.invitee_information .data-table tbody tr th,.inviter_information .data-table tbody tr td,.inviter_information .data-table tbody tr th{background-color:#fff;border:0;padding:9px 10px 10px;color:#666;vertical-align:top}.test_information .data-table tbody tr:nth-child(2n+1) td,.test_information .data-table tbody tr:nth-child(2n+1) th,.invitee_information .data-table tbody tr:nth-child(2n+1) td,.invitee_information .data-table tbody tr:nth-child(2n+1) th,.inviter_information .data-table tbody tr:nth-child(2n+1) td,.inviter_information .data-table tbody tr:nth-child(2n+1) th{background-color:#fbfaf6}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table .col-sort-order{width:80px}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td{vertical-align:top}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td select,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td select{display:block;width:100%}[class^=" adminhtml-test-"] .fieldset-wrapper-content .data-table td .input-radio.global-scope,[class^=" adminhtml-test-"] .fieldset-wrapper-content .accordion .config .data-table td .input-radio.global-scope{margin-top:9px}.sales-order-create-index .ui-dialog .content>.test .field.text .input-text{width:100%}.sales-order-create-index .ui-dialog .content>.test .note .price{font-weight:600}.sales-order-create-index .ui-dialog .content>.test .note .price:before{content:": "}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .label:after{content:": "}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .control{display:inline-block;font-weight:600}.sales-order-create-index .ui-dialog .content>.test .fixed.amount .control .control-value{margin:-2px 0 0;padding:0}.eq-ie9 [class^=" adminhtml-test-"] .custom-options .data-table{word-wrap:normal;table-layout:auto}.rma-items .col-actions a.disabled,.newRma .col-actions a.disabled{cursor:default;opacity:.5}.rma-items .col-actions a.disabled:hover,.newRma .col-actions a.disabled:hover{text-decoration:none}.block.mselect-list .mselect-input{width:100%}.block.mselect-list .mselect-input-container .mselect-save{top:4px}.block.mselect-list .mselect-input-container .mselect-cancel{top:4px}html{font-size:62.5%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;font-size-adjust:100%}body,html{height:100%;min-height:100%}body{color:#676056;font-family:'Open Sans',sans-serif;line-height:1.33;font-weight:400;font-size:1.4rem;background:#f2ebde;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column}body>*{-webkit-flex-grow:0;flex-grow:0;-webkit-flex-shrink:0;flex-shrink:0;-webkit-flex-basis:auto;flex-basis:auto}.page-wrapper{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;min-height:100%;width:100%;max-width:100%;min-width:990px}.page-wrapper>*{-webkit-flex-grow:0;flex-grow:0;-webkit-flex-shrink:0;flex-shrink:0;-webkit-flex-basis:auto;flex-basis:auto}.page-header{text-align:right}.page-header-wrapper{background-color:#31302b}.page-header:after{content:"";display:table;clear:both}.page-header .logo{margin-top:5px;float:left;text-decoration:none;display:inline-block}.page-header .logo:before{content:"";display:inline-block;vertical-align:middle;width:109px;height:35px;background-image:url("../images/logo.svg");background-size:109px 70px;background-repeat:no-repeat}.page-header .logo:after{display:inline-block;vertical-align:middle;margin-left:10px;content:attr(data-edition);font-weight:600;font-size:16px;color:#ef672f;margin-top:-2px}.page-header .logo span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.page-header .logo span.focusable:active,.page-header .logo span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.page-header .logo span.focusable:active,.page-header .logo span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.page-header .dropdown-menu{border:0}.admin-user{display:inline-block;vertical-align:top;position:relative;text-align:left}.admin-user-account{text-decoration:none;display:inline-block;padding:12px 14px;color:#f2ebde}.admin-user-account:after{font-family:"MUI-Icons";content:"\e02c";font-size:13px;line-height:13px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-3px 0 0}.admin-user-account:link,.admin-user-account:visited{color:#f2ebde}.admin-user-account:focus,.admin-user-account:active,.admin-user-account:hover{color:#f2ebde;text-decoration:none}.active .admin-user-account{background-color:#fff;color:#676056}.admin-user-menu{padding:15px;white-space:nowrap;margin-top:0}.admin-user-menu li{border:0;padding:0}.admin-user-menu li:hover{background:0 0}.admin-user-menu a{display:block;color:#676056;font-size:13px;font-weight:400;line-height:1.385;padding:3px 12px 3px;text-decoration:none}.admin-user-menu a:focus,.admin-user-menu a:hover{text-decoration:underline}.admin-user-menu a:hover{color:#fff;background:#989287;text-decoration:none}.admin-user-menu a span:before{content:"("}.admin-user-menu a span:after{content:")"}.page-actions.fixed .page-actions-buttons{padding-right:15px}.page-main-actions{background:#e0dace;color:#645d53;padding:15px;margin-left:auto;margin-right:auto;box-sizing:border-box}.page-main-actions:before,.page-main-actions:after{content:"";display:table}.page-main-actions:after{clear:both}.page-main-actions:before,.page-main-actions:after{content:"";display:table}.page-main-actions:after{clear:both}.page-main-actions .page-actions{float:right}.page-main-actions .page-actions .page-actions-buttons{float:right;display:-webkit-flex;display:-ms-flexbox;display:flex;justify-content:flex-end}.page-main-actions .page-actions button,.page-main-actions .page-actions .action-add.mselect-button-add{margin-left:13px}.page-main-actions .page-actions button.primary,.page-main-actions .page-actions .action-add.mselect-button-add.primary{float:right;-ms-flex-order:2;-webkit-order:2;order:2}.page-main-actions .page-actions button.save:not(.primary),.page-main-actions .page-actions .action-add.mselect-button-add.save:not(.primary){float:right;-ms-flex-order:1;-webkit-order:1;order:1}.page-main-actions .page-actions button.back,.page-main-actions .page-actions button.action-back,.page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.back,.page-main-actions .page-actions .action-add.mselect-button-add.action-back,.page-main-actions .page-actions .action-add.mselect-button-add.delete{background-image:none;background:0 0;border:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400;margin:0 13px}.page-main-actions .page-actions button.back:focus,.page-main-actions .page-actions button.action-back:focus,.page-main-actions .page-actions button.delete:focus,.page-main-actions .page-actions button.back:active,.page-main-actions .page-actions button.action-back:active,.page-main-actions .page-actions button.delete:active,.page-main-actions .page-actions .action-add.mselect-button-add.back:focus,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:focus,.page-main-actions .page-actions .action-add.mselect-button-add.delete:focus,.page-main-actions .page-actions .action-add.mselect-button-add.back:active,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:active,.page-main-actions .page-actions .action-add.mselect-button-add.delete:active{background:0 0;border:none}.page-main-actions .page-actions button.back:hover,.page-main-actions .page-actions button.action-back:hover,.page-main-actions .page-actions button.delete:hover,.page-main-actions .page-actions .action-add.mselect-button-add.back:hover,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:hover,.page-main-actions .page-actions .action-add.mselect-button-add.delete:hover{background:0 0;border:none}.page-main-actions .page-actions button.back.disabled,.page-main-actions .page-actions button.action-back.disabled,.page-main-actions .page-actions button.delete.disabled,.page-main-actions .page-actions button.back[disabled],.page-main-actions .page-actions button.action-back[disabled],.page-main-actions .page-actions button.delete[disabled],fieldset[disabled] .page-main-actions .page-actions button.back,fieldset[disabled] .page-main-actions .page-actions button.action-back,fieldset[disabled] .page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.back.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.action-back.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.delete.disabled,.page-main-actions .page-actions .action-add.mselect-button-add.back[disabled],.page-main-actions .page-actions .action-add.mselect-button-add.action-back[disabled],.page-main-actions .page-actions .action-add.mselect-button-add.delete[disabled],fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.back,fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.action-back,fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-add.delete{cursor:not-allowed;pointer-events:none;opacity:.5}.ie .page-main-actions .page-actions button.back,.ie .page-main-actions .page-actions button.action-back,.ie .page-main-actions .page-actions button.delete,.ie .page-main-actions .page-actions .action-add.mselect-button-add.back,.ie .page-main-actions .page-actions .action-add.mselect-button-add.action-back,.ie .page-main-actions .page-actions .action-add.mselect-button-add.delete{margin-top:6px}.page-main-actions .page-actions button.delete,.page-main-actions .page-actions .action-add.mselect-button-add.delete{color:#e22626;float:left;-ms-flex-order:-1;-webkit-order:-1;order:-1}.page-main-actions .page-actions button.back,.page-main-actions .page-actions button.action-back,.page-main-actions .page-actions .action-add.mselect-button-add.back,.page-main-actions .page-actions .action-add.mselect-button-add.action-back{float:left;-ms-flex-order:-1;-webkit-order:-1;order:-1;display:inline-block;text-decoration:none}.page-main-actions .page-actions button.back:before,.page-main-actions .page-actions button.action-back:before,.page-main-actions .page-actions .action-add.mselect-button-add.back:before,.page-main-actions .page-actions .action-add.mselect-button-add.action-back:before{font-family:'icons-blank-theme';content:'\e625';font-size:inherit;line-height:normal;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:0 2px 0 0}.page-main-actions .page-actions .actions-split{margin-left:13px;float:right;-ms-flex-order:2;-webkit-order:2;order:2}.page-main-actions .page-actions .actions-split button.primary,.page-main-actions .page-actions .actions-split .action-add.mselect-button-add.primary{float:left}.page-main-actions .page-actions .actions-split .dropdown-menu{text-align:left}.page-main-actions .page-actions .actions-split .dropdown-menu .item{display:block}.page-main-actions .page-actions.fixed{position:fixed;top:0;left:0;right:0;z-index:10;padding:0;background:-webkit-linear-gradient(top,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:-ms-linear-gradient(top,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:linear-gradient(to bottom,#f5f2ed 0%,#f5f2ed 56%,rgba(245,242,237,0) 100%);background:#e0dace}.page-main-actions .page-actions.fixed .page-actions-inner{position:relative;padding-top:15px;padding-bottom:15px;min-height:36px;text-align:right;box-sizing:border-box}.page-main-actions .page-actions.fixed .page-actions-inner:before,.page-main-actions .page-actions.fixed .page-actions-inner:after{content:"";display:table}.page-main-actions .page-actions.fixed .page-actions-inner:after{clear:both}.page-main-actions .page-actions.fixed .page-actions-inner:before,.page-main-actions .page-actions.fixed .page-actions-inner:after{content:"";display:table}.page-main-actions .page-actions.fixed .page-actions-inner:after{clear:both}.page-main-actions .page-actions.fixed .page-actions-inner:before{text-align:left;content:attr(data-title);float:left;font-size:20px;max-width:50%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.lt-ie10 .page-main-actions .page-actions.fixed .page-actions-inner{background:#f5f2ed}.page-main-actions .store-switcher{margin-top:5px}.store-switcher{display:inline-block;font-size:13px}.store-switcher .label{margin-right:5px}.store-switcher .actions.dropdown{display:inline-block;position:relative}.store-switcher .actions.dropdown:before,.store-switcher .actions.dropdown:after{content:"";display:table}.store-switcher .actions.dropdown:after{clear:both}.store-switcher .actions.dropdown:before,.store-switcher .actions.dropdown:after{content:"";display:table}.store-switcher .actions.dropdown:after{clear:both}.store-switcher .actions.dropdown .action.toggle{cursor:pointer;display:inline-block;text-decoration:none}.store-switcher .actions.dropdown .action.toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:20px;color:#645d53;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.store-switcher .actions.dropdown .action.toggle:hover:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle:active:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle.active{display:inline-block;text-decoration:none}.store-switcher .actions.dropdown .action.toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:20px;color:#645d53;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.store-switcher .actions.dropdown .action.toggle.active:hover:after{color:#645d53}.store-switcher .actions.dropdown .action.toggle.active:active:after{color:#645d53}.store-switcher .actions.dropdown .dropdown-menu{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px #ada89e solid;position:absolute;z-index:100;top:100%;min-width:195px;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}.store-switcher .actions.dropdown .dropdown-menu li{margin:0;padding:0}.store-switcher .actions.dropdown .dropdown-menu li:hover{background:0 0;cursor:pointer}.store-switcher .actions.dropdown.active{overflow:visible}.store-switcher .actions.dropdown.active .dropdown-menu{display:block}.store-switcher .actions.dropdown .action.toggle{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;font-weight:400;color:#026294;line-height:normal;margin-top:2px;vertical-align:middle}.store-switcher .actions.dropdown .action.toggle:focus,.store-switcher .actions.dropdown .action.toggle:active{background:0 0;border:none}.store-switcher .actions.dropdown .action.toggle:hover{background:0 0;border:none}.store-switcher .actions.dropdown .action.toggle.disabled,.store-switcher .actions.dropdown .action.toggle[disabled],fieldset[disabled] .store-switcher .actions.dropdown .action.toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.store-switcher .actions.dropdown ul.dropdown-menu{margin-top:4px;padding-top:5px;left:0}.store-switcher .actions.dropdown ul.dropdown-menu li{border:0;cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li:hover{cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li a,.store-switcher .actions.dropdown ul.dropdown-menu li span{padding:5px 13px;display:block;color:#645d53}.store-switcher .actions.dropdown ul.dropdown-menu li a{text-decoration:none}.store-switcher .actions.dropdown ul.dropdown-menu li a:hover{background:#edf9fb}.store-switcher .actions.dropdown ul.dropdown-menu li span{color:#ababab;cursor:default}.store-switcher .actions.dropdown ul.dropdown-menu li.current span{color:#645d53;background:#eee}.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store a,.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store span{padding-left:26px}.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store-view a,.store-switcher .actions.dropdown ul.dropdown-menu .store-switcher-store-view span{padding-left:39px}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar{border-top:1px #ededed solid;margin-top:10px}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar a{text-decoration:none;display:block}.store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar a:before{font-family:'icons-blank-theme';content:'\e606';font-size:20px;line-height:normal;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:text-top;text-align:center;margin:0 3px 0 -4px}.tooltip{display:inline-block;margin-left:5px}.tooltip .help span,.tooltip .help a{width:16px;height:16px;text-align:center;background:rgba(194,186,169,.5);cursor:pointer;border-radius:10px;vertical-align:middle;display:inline-block;text-decoration:none}.tooltip .help span:hover,.tooltip .help a:hover{background:#c2baa9}.tooltip .help span>span,.tooltip .help a>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.tooltip .help span>span.focusable:active,.tooltip .help a>span.focusable:active,.tooltip .help span>span.focusable:focus,.tooltip .help a>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.tooltip .help span>span.focusable:active,.tooltip .help a>span.focusable:active,.tooltip .help span>span.focusable:focus,.tooltip .help a>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.tooltip .help span:before,.tooltip .help a:before{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;content:'?';font-size:13px;line-height:16px;color:#5a534a;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center}.tooltip .help span:before,.tooltip .help a:before{font-weight:700}.tooltip .tooltip-content{display:none;position:absolute;max-width:200px;margin-top:10px;margin-left:-19px;padding:4px 8px;border-radius:3px;background:#000;background:rgba(49,48,43,.8);color:#fff;text-shadow:none;z-index:20}.tooltip .tooltip-content:before{content:'';position:absolute;width:0;height:0;top:-5px;left:20px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000;opacity:.8}.tooltip .tooltip-content.loading{position:absolute}.tooltip .tooltip-content.loading:before{border-bottom-color:rgba(0,0,0,.3)}.tooltip:hover>.tooltip-content{display:block}button,.action-add.mselect-button-add{border-radius:2px;background-image:none;background:#f2ebde;padding:6px 13px;color:#645d53;border:1px solid #ada89e;cursor:pointer;display:inline-block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:0;vertical-align:middle}button:focus,button:active,.action-add.mselect-button-add:focus,.action-add.mselect-button-add:active{background:#cac3b4;border:1px solid #989287}button:hover,.action-add.mselect-button-add:hover{background:#cac3b4}button.disabled,button[disabled],fieldset[disabled] button,.action-add.mselect-button-add.disabled,.action-add.mselect-button-add[disabled],fieldset[disabled] .action-add.mselect-button-add{cursor:default;pointer-events:none;opacity:.5}button.primary,.action-add.mselect-button-add.primary{background-image:none;background:#007dbd;padding:6px 13px;color:#fff;border:1px solid #0a6c9f;cursor:pointer;display:inline-block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;box-sizing:border-box;vertical-align:middle}button.primary:focus,button.primary:active,.action-add.mselect-button-add.primary:focus,.action-add.mselect-button-add.primary:active{background:#026294;border:1px solid #004c74;color:#fff}button.primary:hover,.action-add.mselect-button-add.primary:hover{background:#026294;border:1px solid #026294}button.primary.disabled,button.primary[disabled],fieldset[disabled] button.primary,.action-add.mselect-button-add.primary.disabled,.action-add.mselect-button-add.primary[disabled],fieldset[disabled] .action-add.mselect-button-add.primary{cursor:default;pointer-events:none;opacity:.5}.actions-split{display:inline-block;position:relative;vertical-align:middle}.actions-split button,.actions-split .action-add.mselect-button-add{margin-left:0!important}.actions-split:before,.actions-split:after{content:"";display:table}.actions-split:after{clear:both}.actions-split:before,.actions-split:after{content:"";display:table}.actions-split:after{clear:both}.actions-split .action-default{float:left;margin:0}.actions-split .action-toggle{float:right;margin:0}.actions-split button.action-default,.actions-split .action-add.mselect-button-add.action-default{border-top-right-radius:0;border-bottom-right-radius:0}.actions-split button+.action-toggle,.actions-split .action-add.mselect-button-add+.action-toggle{border-left:0;border-top-left-radius:0;border-bottom-left-radius:0}.actions-split .action-toggle{padding:6px 5px;display:inline-block;text-decoration:none}.actions-split .action-toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.actions-split .action-toggle>span.focusable:active,.actions-split .action-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle>span.focusable:active,.actions-split .action-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.actions-split .action-toggle:hover:after{color:inherit}.actions-split .action-toggle:active:after{color:inherit}.actions-split .action-toggle.active{display:inline-block;text-decoration:none}.actions-split .action-toggle.active>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.actions-split .action-toggle.active>span.focusable:active,.actions-split .action-toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle.active>span.focusable:active,.actions-split .action-toggle.active>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.actions-split .action-toggle.active:after{font-family:'icons-blank-theme';content:'\e618';font-size:22px;line-height:14px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.actions-split .action-toggle.active:hover:after{color:inherit}.actions-split .action-toggle.active:active:after{color:inherit}.actions-split .dropdown-menu{margin:0;padding:0;list-style:none none;box-sizing:border-box;background:#fff;border:1px solid #bbb;position:absolute;z-index:100;top:100%;min-width:175px;margin-top:4px;display:none;box-shadow:0 3px 3px rgba(0,0,0,.15)}.actions-split .dropdown-menu li{margin:0;padding:3px 5px}.actions-split .dropdown-menu li:hover{background:#e8e8e8;cursor:pointer}.actions-split .dropdown-menu:before,.actions-split .dropdown-menu:after{content:"";position:absolute;display:block;width:0;height:0;border-bottom-style:solid}.actions-split .dropdown-menu:before{z-index:99;border:solid 6px;border-color:transparent transparent #fff}.actions-split .dropdown-menu:after{z-index:98;border:solid 7px;border-color:transparent transparent #bbb}.actions-split .dropdown-menu:before{top:-12px;right:10px}.actions-split .dropdown-menu:after{top:-14px;right:9px}.actions-split.active{overflow:visible}.actions-split.active .dropdown-menu{display:block}.actions-split .action-toggle:after{height:13px}.page-content:after{content:"";display:table;clear:both}.page-wrapper>.page-content{margin-bottom:20px}.page-footer{padding:15px 0}.page-footer-wrapper{background-color:#e0dacf;margin-top:auto}.page-footer:after{content:"";display:table;clear:both}.footer-legal{float:right;width:550px}.footer-legal .link-report,.footer-legal .magento-version,.footer-legal .copyright{font-size:13px}.footer-legal:before{content:"";display:inline-block;vertical-align:middle;position:absolute;z-index:1;margin-top:2px;margin-left:-35px;width:30px;height:35px;background-size:109px 70px;background:url("../images/logo.svg") no-repeat 0 -21px}.icon-error{margin-left:15px;color:#c00815;font-size:11px}.icon-error:before{font-family:'MUI-Icons';content:"\e086";font-size:13px;line-height:13px;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center;margin:-1px 5px 0 0}.ui-widget-overlay{position:fixed}.control .nested{padding:0}.control *:first-child{margin-bottom:0}.field-tooltip{display:inline-block;vertical-align:top;margin-top:5px;position:relative;z-index:1;width:0;overflow:visible}.field-choice .field-tooltip{margin-top:10px}.field-tooltip:hover{z-index:99}.field-tooltip-action{position:relative;z-index:2;margin-left:18px;width:22px;height:22px;display:inline-block;cursor:pointer}.field-tooltip-action:before{content:"?";font-weight:500;font-size:18px;display:inline-block;overflow:hidden;height:22px;border-radius:11px;line-height:22px;width:22px;text-align:center;color:#fff;background-color:#514943}.field-tooltip-action span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.field-tooltip-action span.focusable:active,.field-tooltip-action span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.field-tooltip-action span.focusable:active,.field-tooltip-action span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text:focus+.field-tooltip-content,.field-tooltip:hover .field-tooltip-content{display:block}.field-tooltip-content{display:none;position:absolute;z-index:1;width:320px;background:#fff8d7;padding:15px 25px;right:-66px;border:1px solid #adadad;border-radius:1px;bottom:42px;box-shadow:0 2px 8px 0 rgba(0,0,0,.3)}.field-tooltip-content:after,.field-tooltip-content:before{content:"";display:block;width:0;height:0;border:16px solid transparent;border-top-color:#adadad;position:absolute;right:20px;top:100%;z-index:3}.field-tooltip-content:after{border-top-color:#fff8d7;margin-top:-1px;z-index:4}.form__field.field-error .control [class*=control-]{border-color:#e22626}.form__field.field-error .control [class*=control-]:before{border-color:#e22626}.form__field .mage-error{border:1px solid #e22626;display:block;margin:2px 0 0;padding:6px 10px 10px;background:#fff8d6;color:#555;font-size:12px;font-weight:500;box-sizing:border-box;max-width:380px}.no-flexbox.no-flexboxlegacy .form__field .control-addon+.mage-error{display:inline-block;width:100%}.form__field{position:relative;z-index:1}.form__field:hover{z-index:2}.control .form__field{position:static}.form__field[data-config-scope]:before{content:attr(data-config-scope);display:inline-block;position:absolute;color:gray;right:0;top:6px}.control .form__field[data-config-scope]:nth-child(n+2):before{content:""}.form__field.field-disabled>.label{color:#999}.form__field.field-disabled.field .control [class*=control-][disabled]{background-color:#e9e9e9;opacity:.5;color:#303030;border-color:#adadad}.control-fields .label~.control{width:100%}.form__field{border:0;padding:0}.form__field .note{color:#303030;padding:0;margin:10px 0 0;max-width:380px}.form__field .note:before{display:none}.form__field.form__field{margin-bottom:0}.form__field.form__field+.form__field.form__field{margin-top:15px}.form__field.form__field:not(.choice)~.choice{margin-left:20px;margin-top:5px}.form__field.form__field.choice~.choice{margin-top:9px}.form__field.form__field~.choice:last-child{margin-bottom:8px}.fieldset>.form__field{margin-bottom:30px}.form__field .label{color:#303030}.form__field:not(.choice)>.label{font-size:14px;font-weight:600;width:30%;padding-right:30px;padding-top:0;line-height:33px;white-space:nowrap}.form__field:not(.choice)>.label:before{content:".";visibility:hidden;width:0;margin-left:-7px;overflow:hidden}.form__field:not(.choice)>.label span{white-space:normal;display:inline-block;vertical-align:middle;line-height:1.2}.form__field.required>.label:after{content:"";margin-left:0}.form__field.required>.label span:after{content:"*";color:#eb5202;display:inline;font-weight:500;font-size:16px;margin-top:2px;position:absolute;z-index:1;margin-left:10px}.form__field .control-file{margin-top:6px}.form__field .control-select{line-height:33px}.form__field .control-select:not([multiple]),.form__field .control-text{height:33px;max-width:380px}.form__field .control-addon{max-width:380px}.form__field .control-textarea,.form__field .control-select,.form__field .control-text{border:1px solid #adadad;border-radius:1px;padding:0 10px;color:#303030;background-color:#fff;font-weight:500;font-size:15px;min-width:11em}.form__field .control-textarea:focus,.form__field .control-select:focus,.form__field .control-text:focus{outline:0;border-color:#007bdb;box-shadow:none}.form__field .control-text{line-height:auto}.form__field .control-textarea{padding-top:6px;padding-bottom:6px;line-height:1.18em}.form__field .control-select[multiple],.form__field .control-textarea{width:100%;height:calc(6*1.2em + 14px)}.form__field .control-value{display:inline-block;padding:6px 10px}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:active,.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:active,.form__field .control-fields .form__field:nth-child(n+2):not(.choice)>.label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field .control-select{padding:0}.form__field .control-select option{box-sizing:border-box;padding:4px 10px;display:block}.form__field .control-select optgroup{font-weight:600;display:block;padding:4px 10px;line-height:33px;list-style:inside;font-style:normal}.form__field .control-range>.form__field:nth-child(2):before{content:"\2014";content:":";display:inline-block;margin-left:-25px;float:left;width:20px;line-height:33px;text-align:center}.form__field.choice{position:relative;z-index:1;padding-top:8px;padding-left:26px;padding-right:0}.form__field.choice .label{font-weight:500;padding:0;display:inline;float:none;line-height:18px}.form__field.choice input{position:absolute;top:8px;margin-top:3px!important}.form__field.choice input[disabled]+.label{opacity:.5;cursor:not-allowed}.control>.form__field.choice{max-width:380px}.control>.form__field.choice:nth-child(1):nth-last-child(2),.control>.form__field.choice:nth-child(2):nth-last-child(1){display:inline-block}.control>.form__field.choice:nth-child(1):nth-last-child(2)+.choice,.control>.form__field.choice:nth-child(2):nth-last-child(1)+.choice{margin-left:41px;margin-top:0}.control>.form__field.choice:nth-child(1):nth-last-child(2)+.choice:before,.control>.form__field.choice:nth-child(2):nth-last-child(1)+.choice:before{content:"";position:absolute;display:inline-block;height:20px;top:8px;left:-20px;width:1px;background:#ccc}.form__field.choice .label{cursor:pointer}.form__field.choice .label:before{content:"";position:absolute;z-index:1;border:1px solid #adadad;width:14px;height:14px;top:10px;left:0;border-radius:2px;background:url("../Magento_Ui/images/choice_bkg.png") no-repeat -100% -100%}.form__field.choice input:focus+.label:before{outline:0;border-color:#007bdb}.form__field.choice .control-radio+.label:before{border-radius:8px}.form__field.choice .control-radio:checked+.label:before{background-position:-26px -1px}.form__field.choice .control-checkbox:checked+.label:before{background-position:-1px -1px}.form__field.choice input{opacity:0}.fieldset>.form__field.choice{margin-left:30%}.form__field .control-after,.form__field .control-before{border:0;color:#858585;font-weight:300;font-size:15px;line-height:33px;display:inline-block;height:33px;box-sizing:border-box;padding:0 3px}.no-flexbox.no-flexboxlegacy .form__field .control-before,.no-flexbox.no-flexboxlegacy .form__field .control-addon{float:left;white-space:nowrap}.form__field .control-addon{display:inline-flex;max-width:380px;width:100%;flex-flow:row nowrap;position:relative;z-index:1}.form__field .control-addon>*{position:relative;z-index:1}.form__field .control-addon .control-text[disabled][type],.form__field .control-addon .control-select[disabled][type],.form__field .control-addon .control-select,.form__field .control-addon .control-text{background:transparent!important;border:0;width:auto;vertical-align:top;order:1;flex:1}.form__field .control-addon .control-text[disabled][type]:focus,.form__field .control-addon .control-select[disabled][type]:focus,.form__field .control-addon .control-select:focus,.form__field .control-addon .control-text:focus{box-shadow:none}.form__field .control-addon .control-text[disabled][type]:focus+label:before,.form__field .control-addon .control-select[disabled][type]:focus+label:before,.form__field .control-addon .control-select:focus+label:before,.form__field .control-addon .control-text:focus+label:before{outline:0;border-color:#007bdb}.form__field .control-addon .control-text[disabled][type]+label,.form__field .control-addon .control-select[disabled][type]+label,.form__field .control-addon .control-select+label,.form__field .control-addon .control-text+label{padding-left:10px;position:static!important;z-index:0}.form__field .control-addon .control-text[disabled][type]+label>*,.form__field .control-addon .control-select[disabled][type]+label>*,.form__field .control-addon .control-select+label>*,.form__field .control-addon .control-text+label>*{vertical-align:top;position:relative;z-index:2}.form__field .control-addon .control-text[disabled][type]+label:before,.form__field .control-addon .control-select[disabled][type]+label:before,.form__field .control-addon .control-select+label:before,.form__field .control-addon .control-text+label:before{box-sizing:border-box;border-radius:1px;border:1px solid #adadad;content:"";display:block;position:absolute;top:0;left:0;width:100%;height:100%;z-index:0;background:#fff}.form__field .control-addon .control-text[disabled][type][disabled]+label:before,.form__field .control-addon .control-select[disabled][type][disabled]+label:before,.form__field .control-addon .control-select[disabled]+label:before,.form__field .control-addon .control-text[disabled]+label:before{opacity:.5;background:#e9e9e9}.form__field .control-after{order:3}.form__field .control-after:last-child{padding-right:10px}.form__field .control-before{order:0}.form__field .control-some{display:flex}.form__field [class*=control-grouped]{display:table;width:100%;table-layout:fixed;box-sizing:border-box}.form__field [class*=control-grouped]>.form__field{display:table-cell;width:50%;vertical-align:top}.form__field [class*=control-grouped]>.form__field>.control{width:100%;float:none}.form__field [class*=control-grouped]>.form__field:nth-child(n+2){padding-left:20px}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:active,.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:active,.form__field [class*=control-grouped]>.form__field:nth-child(n+2):not(.choice) .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.form__field [required]{box-shadow:none}fieldset.form__field{position:relative}fieldset.form__field [class*=control-grouped]>.form__field:first-child>.label,fieldset.form__field .control-fields>.form__field:first-child>.label{position:absolute;left:0;top:0;opacity:0;cursor:pointer;width:30%}.control-text+.ui-datepicker-trigger{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;line-height:inherit;font-weight:400;text-decoration:none;margin-left:-40px;display:inline-block}.control-text+.ui-datepicker-trigger img{display:none}.control-text+.ui-datepicker-trigger:focus,.control-text+.ui-datepicker-trigger:active{background:0 0;border:none}.control-text+.ui-datepicker-trigger:hover{background:0 0;border:none}.control-text+.ui-datepicker-trigger.disabled,.control-text+.ui-datepicker-trigger[disabled],fieldset[disabled] .control-text+.ui-datepicker-trigger{cursor:not-allowed;pointer-events:none;opacity:.5}.control-text+.ui-datepicker-trigger>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.control-text+.ui-datepicker-trigger>span.focusable:active,.control-text+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text+.ui-datepicker-trigger>span.focusable:active,.control-text+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.control-text+.ui-datepicker-trigger:after{font-family:'icons-blank-theme';content:'\e612';font-size:38px;line-height:33px;color:#514943;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}[class*=tab-nav-item]:not(ul):active,[class*=tab-nav-item]:not(ul):focus{box-shadow:none;outline:none}.customer-index-edit .col-2-left-layout,.customer-index-edit .col-1-layout{background:#fff}.customer-index-edit{background:#fff}.customer-index-edit .col-2-left-layout{background:#fff}.customer-index-edit .main-col{padding-left:40px}.customer-index-edit .page-main-actions{background:0 0}.tab-nav.block{margin-bottom:40px}.tab-nav.block:first-child{margin-top:16px}.tab-nav.block .block-title{padding:7px 20px}.tab-nav-items{padding:0;border:1px solid #d3d3d3;box-shadow:0 0 4px rgba(50,50,50,.35);margin:0 0 40px;background:#f7f7f7}.tab-nav-item{padding:0;list-style-type:none;border-bottom:1px solid #e0e0e0;position:relative;margin:0 15px;z-index:1}.tab-nav-item:last-child{border-bottom:0}.tab-nav-item.ui-state-active{z-index:2;background:#fff;padding:1px 14px;border:2px solid #eb5202;margin:-1px}.tab-nav-item.ui-state-active .tab-nav-item-link{padding:13px 15px 13px;color:#eb5202}.tab-nav-item.ui-tabs-loading{position:relative;z-index:1}.tab-nav-item.ui-tabs-loading:before{content:"";display:block;position:absolute;z-index:2;background:url("../images/loader-2.gif") no-repeat 50% 50%;background-size:120px;width:20px;height:20px;top:13px;left:-10px}.tab-nav-item.ui-tabs-loading.ui-state-active:before{top:12px;left:4px}.tab-nav-item-link{display:block;padding:15px;color:#666;line-height:1}.tab-nav-item-link:focus,.tab-nav-item-link:active,.tab-nav-item-link:hover{outline:0;color:#eb5202;text-decoration:none}.ui-state-active .tab-nav-item-link{color:#666;font-weight:600}.tab-nav-item-link.changed{font-style:italic}.listing-tiles{overflow:hidden;margin-top:-10px;margin-left:-10px}.listing-tiles .listing-tile{background-color:#f2ebde;display:block;width:238px;height:200px;float:left;border:1px solid #676056;margin-top:10px;margin-left:10px;border-radius:4px;text-align:center}.listing-tiles .listing-tile.disabled{border-color:red}.listing-tiles .listing-tile.enabled{border-color:green}.listing .disabled{color:red}.listing .enabled{color:green}.pager{text-align:left;padding-bottom:10px}.pager:before,.pager:after{content:"";display:table}.pager:after{clear:both}.pager:before,.pager:after{content:"";display:table}.pager:after{clear:both}.pager [data-part=left]{display:inline-block;width:45%;float:left;text-align:left}.pager [data-part=right]{display:inline-block;width:45%;text-align:right;float:right;-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.pager .action-next{cursor:pointer}.pager .action-previous{cursor:pointer}.pager{text-align:left}.pager [data-part=left]{display:inline-block;width:45%;text-align:left}.pager [data-part=right]{display:inline-block;width:45%;text-align:right;float:right}.grid .col-title{min-width:90px;text-align:center}.grid-actions [data-part=search]{display:inline-block;margin:0 30px}.grid-actions [data-part=search] input[type=text]{vertical-align:bottom;width:460px}.grid .actions-split .dropdown-menu{right:auto;left:auto;text-align:left;color:#676056;font-weight:400}.grid .actions-split .dropdown-menu:after{right:auto;left:9px}.grid .actions-split .dropdown-menu:before{right:auto;left:10px}.grid .grid-actions{padding:10px 0}.grid .hor-scroll{padding-top:10px}.grid .select-box{display:inline-block;vertical-align:top;margin:-12px -10px -7px;padding:12px 10px 7px;width:100%}.filters-toggle{color:#645d53;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;box-sizing:border-box;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.filters-toggle:after{font-family:'icons-blank-theme';content:'\e607';font-size:30px;line-height:15px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-toggle:hover:after{color:inherit}.filters-toggle:active:after{color:inherit}.filters-toggle:focus,.filters-toggle:active{background:#cac3b4;border:1px solid #989287}.filters-toggle:hover{background:#cac3b4}.filters-toggle.disabled,.filters-toggle[disabled],fieldset[disabled] .filters-toggle{cursor:default;pointer-events:none;opacity:.5}.filters-toggle:focus,.filters-toggle:active{background:0 0;border:none}.filters-toggle:hover{background:0 0;border:none}.filters-toggle.disabled,.filters-toggle[disabled],fieldset[disabled] .filters-toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.filters-toggle:after{margin-top:2px;margin-left:-3px}.filters-toggle.active:after{content:'\e618'}.filters-current{padding:10px 0;display:none}.filters-current.active{display:block}.filters-items{margin:0;padding:0;list-style:none none;display:inline}.filters-item{display:inline-block;margin:0 5px 5px 0;padding:2px 2px 2px 4px;border-radius:3px;background:#f7f3eb}.filters-item .item-label{font-weight:600}.filters-item .item-label:after{content:": "}.filters-item .action-remove{background-image:none;background:#f2ebde;color:#645d53;border:1px solid #ada89e;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;font-weight:500;line-height:1.4rem;box-sizing:border-box;margin:3px;vertical-align:middle;display:inline-block;text-decoration:none;padding:0}.filters-item .action-remove>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters-item .action-remove>span.focusable:active,.filters-item .action-remove>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-item .action-remove>span.focusable:active,.filters-item .action-remove>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-item .action-remove:before{font-family:'icons-blank-theme';content:'\e616';font-size:16px;line-height:16px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-item .action-remove:hover:before{color:inherit}.filters-item .action-remove:active:before{color:inherit}.filters-item .action-remove:focus,.filters-item .action-remove:active{background:#cac3b4;border:1px solid #989287}.filters-item .action-remove:hover{background:#cac3b4}.filters-item .action-remove.disabled,.filters-item .action-remove[disabled],fieldset[disabled] .filters-item .action-remove{cursor:default;pointer-events:none;opacity:.5}.filters-form{position:relative;z-index:1;margin:14px 0;background:#fff;border:1px solid #bbb;box-shadow:0 3px 3px rgba(0,0,0,.15)}.filters-form .action-close{position:absolute;top:3px;right:7px;color:#645d53;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;box-sizing:border-box;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.filters-form .action-close>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters-form .action-close>span.focusable:active,.filters-form .action-close>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-form .action-close>span.focusable:active,.filters-form .action-close>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters-form .action-close:before{font-family:'icons-blank-theme';content:'\e616';font-size:42px;line-height:42px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.filters-form .action-close:hover:before{color:inherit}.filters-form .action-close:active:before{color:inherit}.filters-form .action-close:focus,.filters-form .action-close:active{background:#cac3b4;border:1px solid #989287}.filters-form .action-close:hover{background:#cac3b4}.filters-form .action-close.disabled,.filters-form .action-close[disabled],fieldset[disabled] .filters-form .action-close{cursor:default;pointer-events:none;opacity:.5}.filters-form .action-close:focus,.filters-form .action-close:active{background:0 0;border:none}.filters-form .action-close:hover{background:0 0;border:none}.filters-form .action-close.disabled,.filters-form .action-close[disabled],fieldset[disabled] .filters-form .action-close{cursor:not-allowed;pointer-events:none;opacity:.5}.filters-actions{margin:18px;text-align:right}.filters-fieldset{padding-bottom:0}.filters-fieldset .field{border:0;margin:0 0 20px;box-sizing:border-box;display:inline-block;padding:0 12px 0 0;width:33.33333333%;vertical-align:top}.filters-fieldset .field:before,.filters-fieldset .field:after{content:"";display:table}.filters-fieldset .field:after{clear:both}.filters-fieldset .field:before,.filters-fieldset .field:after{content:"";display:table}.filters-fieldset .field:after{clear:both}.filters-fieldset .field.choice:before,.filters-fieldset .field.no-label:before{box-sizing:border-box;content:" ";height:1px;float:left;padding:6px 15px 0 0;width:35%}.filters-fieldset .field .description{box-sizing:border-box;float:left;padding:6px 15px 0 0;text-align:right;width:35%}.filters-fieldset .field:not(.choice)>.label{box-sizing:border-box;float:left;padding:6px 15px 0 0;text-align:right;width:35%}.filters-fieldset .field:not(.choice)>.control{float:left;width:65%}.filters-fieldset .field:last-child{margin-bottom:0}.filters-fieldset .field+.fieldset{clear:both}.filters-fieldset .field>.label{font-weight:700}.filters-fieldset .field>.label+br{display:none}.filters-fieldset .field .choice input{vertical-align:top}.filters-fieldset .field .fields.group:before,.filters-fieldset .field .fields.group:after{content:"";display:table}.filters-fieldset .field .fields.group:after{clear:both}.filters-fieldset .field .fields.group:before,.filters-fieldset .field .fields.group:after{content:"";display:table}.filters-fieldset .field .fields.group:after{clear:both}.filters-fieldset .field .fields.group .field{box-sizing:border-box;float:left}.filters-fieldset .field .fields.group.group-2 .field{width:50% !important}.filters-fieldset .field .fields.group.group-3 .field{width:33.3% !important}.filters-fieldset .field .fields.group.group-4 .field{width:25% !important}.filters-fieldset .field .fields.group.group-5 .field{width:20% !important}.filters-fieldset .field .addon{display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-flex-wrap:nowrap;flex-wrap:nowrap;padding:0;width:100%}.filters-fieldset .field .addon textarea,.filters-fieldset .field .addon select,.filters-fieldset .field .addon input{-ms-flex-order:2;-webkit-order:2;order:2;-webkit-flex-basis:100%;flex-basis:100%;box-shadow:none;display:inline-block;margin:0;width:auto}.filters-fieldset .field .addon .addbefore,.filters-fieldset .field .addon .addafter{-ms-flex-order:3;-webkit-order:3;order:3;display:inline-block;box-sizing:border-box;background:#fff;border:1px solid #c2c2c2;border-radius:1px;height:32px;padding:0 9px;font-size:14px;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;line-height:1.428571429;background-clip:padding-box;width:auto;white-space:nowrap;vertical-align:middle}.filters-fieldset .field .addon .addbefore:disabled,.filters-fieldset .field .addon .addafter:disabled{opacity:.5}.filters-fieldset .field .addon .addbefore::-moz-placeholder,.filters-fieldset .field .addon .addafter::-moz-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore::-webkit-input-placeholder,.filters-fieldset .field .addon .addafter::-webkit-input-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore:-ms-input-placeholder,.filters-fieldset .field .addon .addafter:-ms-input-placeholder{color:#c2c2c2}.filters-fieldset .field .addon .addbefore{float:left;-ms-flex-order:1;-webkit-order:1;order:1}.filters-fieldset .field .additional{margin-top:10px}.filters-fieldset .field.required>.label:after{content:'*';font-size:1.2rem;color:#e02b27;margin:0 0 0 5px}.filters-fieldset .field .note{font-size:1.2rem;margin:3px 0 0;padding:0;display:inline-block;text-decoration:none}.filters-fieldset .field .note:before{font-family:'icons-blank-theme';content:'\e618';font-size:24px;line-height:12px;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filters-fieldset .field .label{color:#676056;font-size:13px;font-weight:600;margin:0}.filters .field-date .group .hasDatepicker{width:100%;padding-right:30px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger{background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;line-height:inherit;font-weight:400;text-decoration:none;margin-left:-33px;display:inline-block;width:30px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger img{display:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:focus,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:active{background:0 0;border:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:hover{background:0 0;border:none}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger.disabled,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger[disabled],fieldset[disabled] .filters .field-date .group .hasDatepicker+.ui-datepicker-trigger{cursor:not-allowed;pointer-events:none;opacity:.5}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:active,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:active,.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.filters .field-date .group .hasDatepicker+.ui-datepicker-trigger:after{font-family:'icons-blank-theme';content:'\e612';font-size:35px;line-height:30px;color:#514943;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:middle;text-align:center}.filters .field-range .group .field{margin-bottom:0}.filters .field-range .group .control{width:100%;box-sizing:border-box;padding-right:0;position:relative;z-index:1}.mass-select{position:relative;margin:-6px -10px;padding:6px 2px 6px 10px;z-index:1;white-space:nowrap}.mass-select.active{background:rgba(0,0,0,.2)}.mass-select-toggle{color:#645d53;cursor:pointer;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:1.3rem;box-sizing:border-box;vertical-align:middle;display:inline-block;background-image:none;background:0 0;border:0;margin:0;padding:0;-moz-box-sizing:content-box;box-shadow:none;text-shadow:none;text-decoration:none;line-height:inherit;font-weight:400}.mass-select-toggle>span{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.mass-select-toggle>span.focusable:active,.mass-select-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.mass-select-toggle>span.focusable:active,.mass-select-toggle>span.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}.mass-select-toggle:before{font-family:'icons-blank-theme';content:'\e607';font-size:30px;line-height:15px;color:inherit;overflow:hidden;speak:none;font-weight:400;-webkit-font-smoothing:antialiased;display:inline-block;vertical-align:top;text-align:center;margin:0}.mass-select-toggle:hover:before{color:inherit}.mass-select-toggle:active:before{color:inherit}.mass-select-toggle:focus,.mass-select-toggle:active{background:#cac3b4;border:1px solid #989287}.mass-select-toggle:hover{background:#cac3b4}.mass-select-toggle.disabled,.mass-select-toggle[disabled],fieldset[disabled] .mass-select-toggle{cursor:default;pointer-events:none;opacity:.5}.mass-select-toggle:focus,.mass-select-toggle:active{background:0 0;border:none}.mass-select-toggle:hover{background:0 0;border:none}.mass-select-toggle.disabled,.mass-select-toggle[disabled],fieldset[disabled] .mass-select-toggle{cursor:not-allowed;pointer-events:none;opacity:.5}.mass-select-toggle:before{margin-top:-2px;text-indent:-5px;color:#fff}.mass-select-toggle:hover:before{color:#fff}.mass-select-toggle:active:before,.mass-select-toggle.active:before{content:'\e618'}.mass-select-field{display:inline}.mass-select-menu{display:none;position:absolute;top:100%;left:0;text-align:left;margin:0;padding:0;list-style:none none;background:#fff;border:1px solid #bbb;min-width:175px;box-shadow:0 3px 3px rgba(0,0,0,.15)}.mass-select-menu li{margin:0;padding:4px 15px;border-bottom:1px solid #e5e5e5}.mass-select-menu li:hover{background:#e8e8e8;cursor:pointer}.mass-select-menu span{font-weight:400;font-size:13px;color:#645d53}.mass-select-menu.active{display:block}.grid-loading-mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(255,255,255,.5);z-index:100}.grid-loading-mask .grid-loader{position:absolute;margin:auto;left:0;top:0;right:0;bottom:0;width:218px;height:149px;background:url('../images/loader-2.gif') 50% 50% no-repeat}.addon input{border-width:1px 0 1px 1px}.addon input~.addafter strong{display:inline-block;background:#fff;line-height:24px;margin:0 3px 0 -2px;padding-left:4px;padding-right:4px;position:relative;font-size:12px;top:0}.addon input:focus~.addafter{border-color:#75b9f0;box-shadow:0 0 8px rgba(82,168,236,.6)}.addon input:focus~.addafter strong{margin-top:0}.addon .addafter{background:0 0;color:#a6a6a6;border-width:1px 1px 1px 0;border-radius:2px 2px 0 0;padding:0;border-color:#ada89e}.addon .pager input{border-width:1px}.field .control input[type=text][disabled],.field .control input[type=text][disabled]~.addafter,.field .control select[disabled],.field .control select[disabled]~.addafter{background-color:#fff;border-color:#eee;box-shadow:none;color:#999}.field .control input[type=text][disabled]~.addafter strong,.field .control select[disabled]~.addafter strong{background-color:#fff}.field-price.addon{direction:rtl}.field-price.addon>*{direction:ltr}.field-price.addon .addafter{border-width:1px 0 1px 1px;border-radius:2px 0 0 2px}.field-price.addon input:first-child{border-radius:0 2px 2px 0}.field-price input{border-width:1px 1px 1px 0}.field-price input:focus{box-shadow:0 0 8px rgba(82,168,236,.6)}.field-price input:focus~label.addafter{box-shadow:0 0 8px rgba(82,168,236,.6)}.field-price input~label.addafter strong{margin-left:2px;margin-right:-2px}.field-price.addon>input{width:99px;float:left}.field-price .control{position:relative}.field-price label.mage-error{position:absolute;left:0;top:30px}.version-fieldset .grid-actions{border-bottom:1px solid #f2ebde;margin:0 0 15px;padding:0 0 15px}.navigation>ul,.message-system,.page-header,.page-actions.fixed .page-actions-inner,.page-content,.page-footer{min-width:960px;max-width:1300px;margin:0 auto;padding-left:15px;padding-right:15px;box-sizing:border-box;width:100%}.pager label.page,.filters .field-range .group .label,.mass-select-field .label{clip:rect(0,0,0,0);border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.visually-hidden.focusable:active,.visually-hidden.focusable:focus,.pager label.page.focusable:active,.pager label.page.focusable:focus,.filters .field-range .group .label.focusable:active,.filters .field-range .group .label.focusable:focus,.mass-select-field .label.focusable:active,.mass-select-field .label.focusable:focus{clip:auto;height:auto;margin:0;overflow:visible;position:static;width:auto}table th.required:after,.data-table th.required-entry:after,.data-table td.required-entry:after,.grid-actions .filter.required .label span:after,.grid-actions .required:after,.accordion .config .data-table td.required-entry:after{content:'*';color:#e22626;font-weight:400;margin-left:3px}.grid th.required:after,.grid th .required:after{content:'*';color:#f9d4d4;font-weight:400;margin-left:3px}.grid td.col-period,.grid td.col-date,.grid td.col-date_to,.grid td.col-date_from,.grid td.col-ended_at,.grid td.col-created_at,.grid td.col-updated_at,.grid td.col-customer_since,.grid td.col-session_start_time,.grid td.col-last_activity,.grid td.col-email,.grid td.col-name,.grid td.col-sku,.grid td.col-firstname,.grid td.col-lastname,.grid td.col-title,.grid td.col-label,.grid td.col-product,.grid td.col-set_name,.grid td.col-websites,.grid td.col-time,.grid td.col-billing_name,.grid td.col-shipping_name,.grid td.col-phone,.grid td.col-type,.product-options .grouped-items-table .col-name,.product-options .grouped-items-table .col-sku,.sales-order-create-index .data-table .col-product,[class^=' adminhtml-rma-'] .fieldset-wrapper .data-table td,[class^=' adminhtml-rma-'] .grid .col-product_sku,[class^=' adminhtml-rma-'] .grid .col-product_name,.col-grid_segment_name,.adminhtml-catalog-event-index .col-category,[class^=' catalog-search'] .col-search_query,[class^=' catalog-search'] .col-synonym_for,[class^=' catalog-search'] .col-redirect,.adminhtml-urlrewrite-index .col-request_path,.adminhtml-cms-page-index .col-title,.adminhtml-cms-page-index .col-identifier,.adminhtml-cms-hierarchy-index .col-title,.adminhtml-cms-hierarchy-index .col-identifier,.col-banner_name,.adminhtml-widget-instance-index .col-title,.reports-index-search .col-query_text,.adminhtml-rma-item-attribute-index .grid .col-attr-code,.adminhtml-system-store-index .grid td,.catalog-product-attribute-index .col-attr-code,.catalog-product-attribute-index .col-label,.adminhtml-export-index .col-code,.adminhtml-logging-index .grid .col-fullaction,.adminhtml-system-variable-index .grid .col-code,.adminhtml-logging-index .grid .col-info,.dashboard-secondary .dashboard-item tr>td:first-child,.ui-tabs-panel .dashboard-data .col-name,.data-table-td-max .data-table td,[class^=' adminhtml-rma-'] .fieldset-wrapper .accordion .config .data-table td,.data-table-td-max .accordion .config .data-table td,.order-account-information .data-table td,[class^=' adminhtml-rma-'] .rma-request-details .data-table td{overflow:hidden;text-overflow:ellipsis}td.col-period,td.col-date,td.col-date_to,td.col-date_from,td.col-ended_at,td.col-created_at,td.col-updated_at,td.col-customer_since,td.col-session_start_time,td.col-time,td.col-sku,td.col-type,[class^=' adminhtml-rma-'] #rma_items_grid_table .headings th,.adminhtml-process-list .col-action a,.adminhtml-process-list .col-mode{white-space:nowrap}table thead tr th:first-child,table tfoot tr th:first-child,table tfoot tr td:first-child{border-left:0}table thead tr th:last-child,table tfoot tr th:last-child,table tfoot tr td:last-child{border-right:0}.form-inline .grid-actions .label,.form-inline .massaction .label{padding:0;width:auto}.grid .col-action,.grid .col-actions,.grid .col-qty,.grid .col-purchases,.catalog-product-edit .ui-tabs-panel .grid .col-price,.catalog-product-edit .ui-tabs-panel .grid .col-position{width:50px}.grid .col-order-number,.grid .col-real_order_id,.grid .col-invoice-number,.grid .col-increment_id,.grid .col-transaction-id,.grid .col-parent-transaction-id,.grid .col-reference_id,.grid .col-status,.grid .col-price,.grid .col-position,.grid .col-base_grand_total,.grid .col-grand_total,.grid .col-sort_order,.grid .col-carts,.grid .col-priority,.grid .col-severity,.sales-order-create-index .col-in_products,[class^=' reports-'] [class^=col-total],[class^=' reports-'] [class^=col-average],[class^=' reports-'] [class^=col-ref-],[class^=' reports-'] [class^=col-rate],[class^=' reports-'] [class^=col-tax-amount],[class^=' adminhtml-customer-'] .col-required,.adminhtml-rma-item-attribute-index .col-required,[class^=' adminhtml-customer-'] .col-system,.adminhtml-rma-item-attribute-index .col-system,[class^=' adminhtml-customer-'] .col-is_visible,.adminhtml-rma-item-attribute-index .col-is_visible,[class^=' adminhtml-customer-'] .col-sort_order,.adminhtml-rma-item-attribute-index .col-sort_order,.catalog-product-attribute-index [class^=' col-is_'],.catalog-product-attribute-index .col-required,.catalog-product-attribute-index .col-system,.adminhtml-test-index .col-is_listed,[class^=' tests-report-test'] [class^=col-inv-]{width:70px}.grid .col-phone,.sales-order-view .grid .col-period,.sales-order-create-index .col-phone,[class^=' adminhtml-rma-'] .grid .col-product_sku,.adminhtml-rma-edit .col-product,.adminhtml-rma-edit .col-sku,.catalog-product-edit .ui-tabs-panel .grid .col-name,.catalog-product-edit .ui-tabs-panel .grid .col-type,.catalog-product-edit .ui-tabs-panel .grid .col-sku,.customer-index-index .grid .col-customer_since,.customer-index-index .grid .col-billing_country_id,[class^=' customer-index-'] .fieldset-wrapper .grid .col-created_at,[class^=' customer-index-'] .accordion .grid .col-created_at{max-width:70px;width:70px}.sales-order-view .grid .col-name,.sales-order-create-index .data-table .col-product,[class^=' adminhtml-rma-'] .grid .col-name,[class^=' adminhtml-rma-'] .grid .col-product,[class^=' catalog-search'] .col-search_query,[class^=' catalog-search'] .col-synonym_for,[class^=' catalog-search'] .col-redirect,.adminhtml-urlrewrite-index .col-request_path,.reports-report-shopcart-abandoned .grid .col-name,.tax-rule-index .grid .col-title,.adminhtml-rma-item-attribute-index .grid .col-attr-code,.dashboard-secondary .dashboard-item tr>td:first-child{max-width:150px;width:150px}[class^=' sales-order-'] .grid .col-name,.catalog-category-edit .grid .col-name,.adminhtml-catalog-event-index .col-category,.adminhtml-banner-edit .grid .col-name,.reports-report-product-lowstock .grid .col-sku,.newsletter-problem-index .grid .col-name,.newsletter-problem-index .grid .col-subject,.newsletter-problem-index .grid .col-product,.adminhtml-rma-item-attribute-index .grid .col-label,.adminhtml-export-index .col-label,.adminhtml-export-index .col-code,.adminhtml-scheduled-operation-index .grid .col-name,.adminhtml-logging-index .grid .col-fullaction,.test-report-customer-wishlist-wishlist .grid .col-name,.test-report-customer-wishlist-wishlist .grid .col-subject,.test-report-customer-wishlist-wishlist .grid .col-product{max-width:220px;width:220px}.grid .col-period,.grid .col-date,.grid .col-date_to,.grid .col-date_from,.grid .col-ended_at,.grid .col-created_at,.grid .col-updated_at,.grid .col-customer_since,.grid .col-session_start_time,.grid .col-last_activity,.grid .col-email,.grid .col-items_total,.grid .col-firstname,.grid .col-lastname,.grid .col-status-default,.grid .col-websites,.grid .col-time,.grid .col-billing_name,.grid .col-shipping_name,.sales-order-index .grid .col-name,.product-options .grouped-items-table .col-name,.product-options .grouped-items-table .col-sku,[class^=' sales-order-view'] .grid .col-customer_name,[class^=' adminhtml-rma-'] .grid .col-product_name,.catalog-product-index .grid .col-name,.catalog-product-review-index .grid .col-name,.catalog-product-review-index .grid .col-title,.customer-index-edit .ui-tabs-panel .grid .col-name,.review-product-index .grid .col-name,.adminhtml-cms-page-index .col-title,.adminhtml-cms-page-index .col-identifier,.catalog-product-attribute-index .col-attr-code,.catalog-product-attribute-index .col-label,.adminhtml-logging-index .grid .col-info{max-width:110px;width:110px}.grid .col-name,.grid .col-product,.col-banner_name,.adminhtml-widget-instance-index .col-title,[class^=' adminhtml-customer-'] .col-label,.adminhtml-rma-item-attribute-index .col-label,.adminhtml-system-variable-index .grid .col-code,.ui-tabs-panel .dashboard-data .col-name,.adminhtml-test-index .col-label{max-width:370px;width:370px}.col-grid_segment_name,.reports-index-search .col-query_text{max-width:570px;width:570px}[class^=' adminhtml-rma-'] .fieldset-wrapper .data-table td,.reports-report-product-lowstock .grid .col-name,.reports-report-shopcart-product .grid .col-name,.reports-report-review-customer .grid .col-name,[class^=' adminhtml-rma-'] .fieldset-wrapper .accordion .config .data-table td{max-width:670px;width:670px}.reports-report-sales-invoiced .grid .col-period,.reports-report-sales-refunde .grid .col-period,[class^=' tests-report-test'] .grid .col-period{width:auto}.grid .col-select,.grid .col-id,.grid .col-number{width:40px}.sales-order-create-index .grid,.sales-order-create-index .grid-actions,.adminhtml-export-index .grid-actions,.adminhtml-export-index .grid{padding-left:0;padding-right:0}[class^=' adminhtml-rma-'] .col-actions a,[class^=' customer-index-'] .col-action a,.adminhtml-notification-index .col-actions a{display:block;margin:0 0 3px;white-space:nowrap}.data-table-td-max .accordion .config .data-table td,.order-account-information .data-table td,[class^=' adminhtml-rma-'] .rma-request-details .data-table td{max-width:250px;width:250px}.catalog-product-edit .ui-tabs-panel .grid .hor-scroll,.catalog-product-index .grid .hor-scroll,.review-product-index .grid .hor-scroll,.adminhtml-rma-edit .hor-scroll{overflow-x:auto}.add-clearer:after,.massaction:after,.navigation>ul:after{content:"";display:table;clear:both}.test-content{width:calc(20px + 100*0.2)}.test-content:before{content:'.test {\A ' attr(data-attribute) ': 0.2em;' '\A content:\'';white-space:pre}.test-content:after{content:' Test\';\A}' "\A" '\A.test + .test._other ~ ul > li' " {\A height: @var;\A content: ' + ';\A}";white-space:pre}.test-content-calc{width:calc((100%/12*2) - 10px)}.test-svg-xml-image{background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 38 40"><style>.st0{fill:none;stroke:%23ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}</style><circle cx="14.7" cy="14.7" r="13.7" class="st0"/><path d="M23.9 24.7L37 39" class="st0"/></svg>') no-repeat left center} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/theme/web/css/styles.css b/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/theme/web/css/styles.css index 90ca42321c92..e95c7f72c706 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/theme/web/css/styles.css +++ b/dev/tests/integration/testsuite/Magento/Framework/View/_files/static/theme/web/css/styles.css @@ -484,7 +484,6 @@ table .col-draggable .draggable-handle { border: 0; display: inline; line-height: 1.42857143; - margin: 0; padding: 0; color: #1979c3; text-decoration: none; @@ -621,7 +620,6 @@ fieldset[disabled] .grid-actions .action-reset { background: none; border: 0; display: inline; - line-height: 1.42857143; margin: 0; padding: 0; color: #1979c3; @@ -683,7 +681,6 @@ fieldset[disabled] .pager .action-next { text-decoration: none; } .pager .action-previous > span { - clip: rect(0, 0, 0, 0); border: 0; clip: rect(0 0 0 0); height: 1px; @@ -733,7 +730,6 @@ fieldset[disabled] .pager .action-next { text-decoration: none; } .pager .action-next > span { - clip: rect(0, 0, 0, 0); border: 0; clip: rect(0 0 0 0); height: 1px; @@ -1510,7 +1506,6 @@ fieldset[disabled] .pager .action-next { text-decoration: none; } .search-global-field .label > span { - clip: rect(0, 0, 0, 0); border: 0; clip: rect(0 0 0 0); height: 1px; @@ -1622,7 +1617,6 @@ fieldset[disabled] .pager .action-next { color: #676056; } .notifications-action .text { - clip: rect(0, 0, 0, 0); border: 0; clip: rect(0 0 0 0); height: 1px; @@ -1707,7 +1701,6 @@ fieldset[disabled] .pager .action-next { z-index: 1; top: 12px; right: 12px; - display: inline-block; background-image: none; background: none; border: 0; @@ -2358,7 +2351,6 @@ fieldset[disabled] .notifications-close.action { text-decoration: none; } #product-variations-matrix .actions-image-uploader { - display: inline-block; position: relative; display: block; width: 50px; @@ -3109,7 +3101,6 @@ body > * { background-image: none; background: none; border: 0; - margin: 0; padding: 0; -moz-box-sizing: content-box; box-shadow: none; @@ -3396,7 +3387,6 @@ fieldset[disabled] .page-main-actions .page-actions .action-add.mselect-button-a box-shadow: none; text-shadow: none; text-decoration: none; - line-height: inherit; font-weight: 400; color: #026294; line-height: normal; @@ -3464,7 +3454,6 @@ fieldset[disabled] .store-switcher .actions.dropdown .action.toggle { margin-top: 10px; } .store-switcher .actions.dropdown ul.dropdown-menu .dropdown-toolbar a { - display: inline-block; text-decoration: none; display: block; } @@ -4833,17 +4822,11 @@ fieldset[disabled] .control-text + .ui-datepicker-trigger { width: 100%; } .filters-toggle { - background: #f2ebde; - padding: 6px 13px; color: #645d53; - border: 1px solid #ada89e; cursor: pointer; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.3rem; - font-weight: 500; - line-height: 1.4rem; box-sizing: border-box; - margin: 3px; vertical-align: middle; display: inline-block; background-image: none; @@ -4946,7 +4929,6 @@ fieldset[disabled] .filters-toggle { .filters-item .action-remove { background-image: none; background: #f2ebde; - padding: 6px 13px; color: #645d53; border: 1px solid #ada89e; cursor: pointer; @@ -5038,17 +5020,11 @@ fieldset[disabled] .filters-item .action-remove { position: absolute; top: 3px; right: 7px; - background: #f2ebde; - padding: 6px 13px; color: #645d53; - border: 1px solid #ada89e; cursor: pointer; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.3rem; - font-weight: 500; - line-height: 1.4rem; box-sizing: border-box; - margin: 3px; vertical-align: middle; display: inline-block; background-image: none; @@ -5283,13 +5259,11 @@ fieldset[disabled] .filters-form .action-close { border: 1px solid #c2c2c2; border-radius: 1px; height: 32px; - width: 100%; padding: 0 9px; font-size: 14px; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 1.428571429; background-clip: padding-box; - vertical-align: baseline; width: auto; white-space: nowrap; vertical-align: middle; @@ -5487,17 +5461,11 @@ fieldset[disabled] .filters .field-date .group .hasDatepicker + .ui-datepicker-t background: rgba(0, 0, 0, 0.2); } .mass-select-toggle { - background: #f2ebde; - padding: 6px 13px; color: #645d53; - border: 1px solid #ada89e; cursor: pointer; font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.3rem; - font-weight: 500; - line-height: 1.4rem; box-sizing: border-box; - margin: 3px; vertical-align: middle; display: inline-block; background-image: none; @@ -5754,7 +5722,6 @@ fieldset[disabled] .mass-select-toggle { .page-actions.fixed .page-actions-inner, .page-content, .page-footer { - width: auto; min-width: 960px; max-width: 1300px; margin: 0 auto; @@ -6104,7 +6071,7 @@ table tfoot tr td:last-child { clear: both; } .test-content { - width: calc(20px + 100*0.2); + width: calc(20px + 100 * 0.2); } .test-content:before { content: '.test {\A ' attr(data-attribute) ': 0.2em;' '\A content:\''; diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/AbstractGraphqlCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/AbstractGraphqlCacheTest.php index f25144c308c6..862a924f6579 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/AbstractGraphqlCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/AbstractGraphqlCacheTest.php @@ -7,9 +7,15 @@ namespace Magento\GraphQlCache\Controller; -use PHPUnit\Framework\TestCase; -use Magento\TestFramework\ObjectManager; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\App\Response\HttpInterface as HttpResponse; +use Magento\Framework\Registry; +use Magento\GraphQl\Controller\GraphQl as GraphQlController; +use Magento\GraphQlCache\Model\CacheableQuery; +use Magento\PageCache\Model\Cache\Type as PageCache; use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; +use PHPUnit\Framework\TestCase; /** * Abstract test class for Graphql cache tests @@ -21,40 +27,114 @@ abstract class AbstractGraphqlCacheTest extends TestCase */ protected $objectManager; - /** - * @inheritdoc - */ protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); + $this->enablePageCachePlugin(); + $this->enableCachebleQueryTestProxy(); + } + + protected function tearDown(): void + { + $this->disableCacheableQueryTestProxy(); + $this->disablePageCachePlugin(); + $this->flushPageCache(); + } + + protected function enablePageCachePlugin(): void + { + /** @var $registry Registry */ + $registry = $this->objectManager->get(Registry::class); + $registry->register('use_page_cache_plugin', true, true); + } + + protected function disablePageCachePlugin(): void + { + /** @var $registry Registry */ + $registry = $this->objectManager->get(Registry::class); + $registry->unregister('use_page_cache_plugin'); + } + + protected function flushPageCache(): void + { + /** @var PageCache $fullPageCache */ + $fullPageCache = $this->objectManager->get(PageCache::class); + $fullPageCache->clean(); } /** - * Prepare a query and return a request to be used in the same test end to end + * Regarding the SuppressWarnings annotation below: the nested class below triggers a false rule match. * - * @param string $query - * @return \Magento\Framework\App\Request\Http + * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ - protected function prepareRequest(string $query) : \Magento\Framework\App\Request\Http - { - $cacheableQuery = $this->objectManager->get(\Magento\GraphQlCache\Model\CacheableQuery::class); - $cacheableQueryReflection = new \ReflectionProperty( - $cacheableQuery, - 'cacheTags' - ); - $cacheableQueryReflection->setAccessible(true); - $cacheableQueryReflection->setValue($cacheableQuery, []); - - /** @var \Magento\Framework\UrlInterface $urlInterface */ - $urlInterface = $this->objectManager->create(\Magento\Framework\UrlInterface::class); - //set unique URL - $urlInterface->setQueryParam('query', $query); - - $request = $this->objectManager->get(\Magento\Framework\App\Request\Http::class); - $request->setUri($urlInterface->getUrl('graphql')); + private function enableCachebleQueryTestProxy(): void + { + $cacheableQueryProxy = new class($this->objectManager) extends CacheableQuery { + /** @var CacheableQuery */ + private $delegate; + + public function __construct(ObjectManager $objectManager) + { + $this->reset($objectManager); + } + + public function reset(ObjectManager $objectManager): void + { + $this->delegate = $objectManager->create(CacheableQuery::class); + } + + public function getCacheTags(): array + { + return $this->delegate->getCacheTags(); + } + + public function addCacheTags(array $cacheTags): void + { + $this->delegate->addCacheTags($cacheTags); + } + + public function isCacheable(): bool + { + return $this->delegate->isCacheable(); + } + + public function setCacheValidity(bool $cacheable): void + { + $this->delegate->setCacheValidity($cacheable); + } + + public function shouldPopulateCacheHeadersWithTags(): bool + { + return $this->delegate->shouldPopulateCacheHeadersWithTags(); + } + }; + $this->objectManager->addSharedInstance($cacheableQueryProxy, CacheableQuery::class); + } + + private function disableCacheableQueryTestProxy(): void + { + $this->resetQueryCacheTags(); + $this->objectManager->removeSharedInstance(CacheableQuery::class); + } + + protected function resetQueryCacheTags(): void + { + $this->objectManager->get(CacheableQuery::class)->reset($this->objectManager); + } + + protected function dispatchGraphQlGETRequest(array $queryParams): HttpResponse + { + $this->resetQueryCacheTags(); + + /** @var HttpRequest $request */ + $request = $this->objectManager->get(HttpRequest::class); + $request->setPathInfo('/graphql'); $request->setMethod('GET'); - //set the actual GET query - $request->setQueryValue('query', $query); - return $request; + $request->setParams($queryParams); + + // required for \Magento\Framework\App\PageCache\Identifier to generate the correct cache key + $request->setUri(implode('?', [$request->getPathInfo(), http_build_query($queryParams)])); + + return $this->objectManager->create(GraphQlController::class)->dispatch($request); } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoriesWithProductsCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoriesWithProductsCacheTest.php index fd97399992c1..287353bbd2b8 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoriesWithProductsCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoriesWithProductsCacheTest.php @@ -9,8 +9,6 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\App\Request\Http; -use Magento\GraphQl\Controller\GraphQl; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** @@ -22,31 +20,12 @@ */ class CategoriesWithProductsCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; - - /** - * @var Http - */ - private $request; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); - $this->request = $this->objectManager->create(Http::class); - } /** * Test cache tags and debug header for category with products querying for products and category * * @magentoDataFixture Magento/Catalog/_files/category_product.php */ - public function testToCheckRequestCacheTagsForCategoryWithProducts(): void + public function testRequestCacheTagsForCategoryWithProducts(): void { /** @var ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); @@ -91,17 +70,7 @@ public function testToCheckRequestCacheTagsForCategoryWithProducts(): void 'operationName' => 'GetCategoryWithProducts' ]; - /** @var \Magento\Framework\UrlInterface $urlInterface */ - $urlInterface = $this->objectManager->create(\Magento\Framework\UrlInterface::class); - //set unique URL - $urlInterface->setQueryParam('query', $queryParams['query']); - $urlInterface->setQueryParam('variables', $queryParams['variables']); - $urlInterface->setQueryParam('operationName', $queryParams['operationName']); - $this->request->setUri($urlInterface->getUrl('graphql')); - $this->request->setPathInfo('/graphql'); - $this->request->setMethod('GET'); - $this->request->setParams($queryParams); - $response = $this->graphqlController->dispatch($this->request); + $response = $this->dispatchGraphQlGETRequest($queryParams); $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); $expectedCacheTags = ['cat_c','cat_c_' . $categoryId,'cat_p','cat_p_' . $product->getId(),'FPC']; $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryCacheTest.php index be920fb200ff..90bdc4f75825 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryCacheTest.php @@ -7,8 +7,6 @@ namespace Magento\GraphQlCache\Controller\Catalog; -use Magento\Framework\App\Request\Http; -use Magento\GraphQl\Controller\GraphQl; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** @@ -20,25 +18,12 @@ */ class CategoryCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); - } /** * Test cache tags and debug header for category and querying only for category * * @magentoDataFixture Magento/Catalog/_files/category_product.php */ - public function testToCheckRequestCacheTagsForForCategory(): void + public function testRequestCacheTagsForCategory(): void { $categoryId ='333'; $query @@ -53,11 +38,10 @@ public function testToCheckRequestCacheTagsForForCategory(): void } } QUERY; - $request = $this->prepareRequest($query); - $response = $this->graphqlController->dispatch($request); + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cat_c','cat_c_' . $categoryId,'FPC']; + $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; $this->assertEquals($expectedCacheTags, $actualCacheTags); } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryListCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryListCacheTest.php new file mode 100644 index 000000000000..a8e9059a84eb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/CategoryListCacheTest.php @@ -0,0 +1,145 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQlCache\Controller\Catalog; + +use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; + +/** + * Test caching works for categoryList query + * + * @magentoAppArea graphql + * @magentoCache full_page enabled + * @magentoDbIsolation disabled + */ +class CategoryListCacheTest extends AbstractGraphqlCacheTest +{ + /** + * Test cache tags are generated + * + * @magentoDataFixture Magento/Catalog/_files/category_product.php + */ + public function testRequestCacheTagsForCategoryList(): void + { + $categoryId ='333'; + $query + = <<<QUERY + { + categoryList(filters: {ids: {in: ["$categoryId"]}}) { + id + name + url_key + description + product_count + } + } +QUERY; + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); + $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; + $this->assertEquals($expectedCacheTags, $actualCacheTags); + } + + /** + * Test request is served from cache + * + * @magentoDataFixture Magento/Catalog/_files/category_product.php + */ + public function testSecondRequestIsServedFromCache() + { + $categoryId ='333'; + $query + = <<<QUERY + { + categoryList(filters: {ids: {in: ["$categoryId"]}}) { + id + name + url_key + description + product_count + } + } +QUERY; + $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; + + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + + $cacheResponse = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('HIT', $cacheResponse->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $cacheResponse->getHeader('X-Magento-Tags')->getFieldValue()); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + } + + /** + * Test cache tags are generated + * + * @magentoDataFixture Magento/Catalog/_files/category_tree.php + */ + public function testRequestCacheTagsForCategoryListOnMultipleIds(): void + { + $categoryId1 ='400'; + $categoryId2 = '401'; + $query + = <<<QUERY + { + categoryList(filters: {ids: {in: ["$categoryId1", "$categoryId2"]}}) { + id + name + url_key + description + product_count + } + } +QUERY; + //added the previous category in expected tags as it is cached + $expectedCacheTags = ['cat_c','cat_c_' .'333', 'cat_c_' . $categoryId1, 'cat_c_' . $categoryId2, 'FPC']; + + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + } + + /** + * Test request is served from cache + * + * @magentoDataFixture Magento/Catalog/_files/category_tree.php + */ + public function testSecondRequestIsServedFromCacheOnMultipleIds() + { + $categoryId1 ='400'; + $categoryId2 = '401'; + $query + = <<<QUERY + { + categoryList(filters: {ids: {in: ["$categoryId1", "$categoryId2"]}}) { + id + name + url_key + description + product_count + } + } +QUERY; + //added the previous category in expected tags as it is cached + $expectedCacheTags = ['cat_c','cat_c_' .'333', 'cat_c_' . $categoryId1, 'cat_c_' . $categoryId2, 'FPC']; + + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + + $cacheResponse = $this->dispatchGraphQlGETRequest(['query' => $query]); + $this->assertEquals('HIT', $cacheResponse->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $actualCacheTags = explode(',', $cacheResponse->getHeader('X-Magento-Tags')->getFieldValue()); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + } +} diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php index 746b37a88770..6228feae37c1 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/DeepNestedCategoriesAndProductsTest.php @@ -9,7 +9,6 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Api\CategoryRepositoryInterface; -use Magento\Framework\App\Request\Http; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** @@ -20,24 +19,11 @@ */ class DeepNestedCategoriesAndProductsTest extends AbstractGraphqlCacheTest { - /** @var \Magento\GraphQl\Controller\GraphQl */ - private $graphql; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - $this->graphql = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); - } - /** * Test cache tags and debug header for deep nested queries involving category and products * * @magentoCache all enabled * @magentoDataFixture Magento/Catalog/_files/product_in_multiple_categories.php - * */ public function testDispatchForCacheHeadersOnDeepNestedQueries(): void { @@ -83,15 +69,18 @@ public function testDispatchForCacheHeadersOnDeepNestedQueries(): void $productIdsFromCategory = $category->getProductCollection()->getAllIds(); foreach ($productIdsFromCategory as $productId) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $resolvedCategoryIds = array_merge( $resolvedCategoryIds, $productRepository->getById($productId)->getCategoryIds() ); } + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $resolvedCategoryIds = array_merge($resolvedCategoryIds, [$baseCategoryId]); foreach ($resolvedCategoryIds as $categoryId) { $category = $categoryRepository->get($categoryId); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $productIdsFromCategory= array_merge( $productIdsFromCategory, $category->getProductCollection()->getAllIds() @@ -102,14 +91,15 @@ public function testDispatchForCacheHeadersOnDeepNestedQueries(): void $uniqueCategoryIds = array_unique($resolvedCategoryIds); $expectedCacheTags = ['cat_c', 'cat_p', 'FPC']; foreach ($uniqueProductIds as $uniqueProductId) { - $expectedCacheTags = array_merge($expectedCacheTags, ['cat_p_'.$uniqueProductId]); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge + $expectedCacheTags = array_merge($expectedCacheTags, ['cat_p_' . $uniqueProductId]); } foreach ($uniqueCategoryIds as $uniqueCategoryId) { - $expectedCacheTags = array_merge($expectedCacheTags, ['cat_c_'.$uniqueCategoryId]); + // phpcs:ignore Magento2.Performance.ForeachArrayMerge + $expectedCacheTags = array_merge($expectedCacheTags, ['cat_c_' . $uniqueCategoryId]); } - $request = $this->prepareRequest($query); - $response = $this->graphql->dispatch($request); + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); $this->assertEmpty( diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/ProductsCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/ProductsCacheTest.php index 335067f8408d..038a8c725581 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/ProductsCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Catalog/ProductsCacheTest.php @@ -8,7 +8,6 @@ namespace Magento\GraphQlCache\Controller\Catalog; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\GraphQl\Controller\GraphQl; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** @@ -20,26 +19,12 @@ */ class ProductsCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); - } - /** * Test request is dispatched and response is checked for debug headers and cache tags * * @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php */ - public function testToCheckRequestCacheTagsForProducts(): void + public function testRequestCacheTagsForProducts(): void { /** @var ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); @@ -63,8 +48,7 @@ public function testToCheckRequestCacheTagsForProducts(): void } QUERY; - $request = $this->prepareRequest($query); - $response = $this->graphqlController->dispatch($request); + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); $expectedCacheTags = ['cat_p', 'cat_p_' . $product->getId(), 'FPC']; @@ -74,7 +58,7 @@ public function testToCheckRequestCacheTagsForProducts(): void /** * Test request is checked for debug headers and no cache tags for not existing product */ - public function testToCheckRequestNoTagsForProducts(): void + public function testRequestNoTagsForNonExistingProducts(): void { $query = <<<QUERY @@ -93,11 +77,66 @@ public function testToCheckRequestNoTagsForProducts(): void } QUERY; - $request = $this->prepareRequest($query); - $response = $this->graphqlController->dispatch($request); + $response = $this->dispatchGraphQlGETRequest(['query' => $query]); $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); $actualCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); $expectedCacheTags = ['FPC']; $this->assertEquals($expectedCacheTags, $actualCacheTags); } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php + */ + public function testConsecutiveRequestsAreServedFromThePageCache(): void + { + $query + = <<<QUERY +{ + products(filter: {sku: {eq: "simple1"}}) + { + items { + id + name + sku + description { + html + } + } + } +} +QUERY; + $response1 = $this->dispatchGraphQlGETRequest(['query' => $query]); + $response2 = $this->dispatchGraphQlGETRequest(['query' => $query]); + + $this->assertEquals('MISS', $response1->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $this->assertEquals('HIT', $response2->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php + */ + public function testDifferentProductsRequestsUseDifferentPageCacheRecords(): void + { + $queryTemplate + = <<<QUERY +{ + products(filter: {sku: {eq: "%s"}}) + { + items { + id + name + sku + description { + html + } + } + } +} +QUERY; + $responseProduct1 = $this->dispatchGraphQlGETRequest(['query' => sprintf($queryTemplate, 'simple1')]); + $responseProduct2 = $this->dispatchGraphQlGETRequest(['query' => sprintf($queryTemplate, 'simple2')]); + + $this->assertEquals('MISS', $responseProduct1->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $this->assertEquals('MISS', $responseProduct2->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/BlockCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/BlockCacheTest.php index c9dca2a5a837..bcc7c623eb18 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/BlockCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/BlockCacheTest.php @@ -7,8 +7,9 @@ namespace Magento\GraphQlCache\Controller\Cms; +use Magento\Cms\Api\Data\BlockInterface; use Magento\Cms\Model\BlockRepository; -use Magento\GraphQl\Controller\GraphQl; +use Magento\Framework\App\Response\HttpInterface as HttpResponse; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** @@ -20,23 +21,27 @@ */ class BlockCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; + private function assertPageCacheMissWithTagsForCmsBlock(HttpResponse $response, BlockInterface $block): void + { + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $this->assertCmsBlockCacheTags($response, $block); + } - /** - * @inheritdoc - */ - protected function setUp(): void + private function assertPageCacheHitWithTagsForCmsBlock(HttpResponse $response, BlockInterface $block): void + { + $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + $this->assertCmsBlockCacheTags($response, $block); + } + + private function assertCmsBlockCacheTags(HttpResponse $response, BlockInterface $block): void { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); + $expectedCacheTags = ['cms_b', 'cms_b_' . $block->getId(), 'cms_b_' . $block->getIdentifier(), 'FPC']; + $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); + $actualCacheTags = explode(',', $rawActualCacheTags); + $this->assertEquals($expectedCacheTags, $actualCacheTags); } /** - * Test that the correct cache tags get added to request for cmsBlocks - * * @magentoDataFixture Magento/Cms/_files/block.php * @magentoDataFixture Magento/Cms/_files/blocks.php */ @@ -46,9 +51,9 @@ public function testCmsBlocksRequestHasCorrectTags(): void $blockRepository = $this->objectManager->get(BlockRepository::class); $block1Identifier = 'fixture_block'; - $block1 = $blockRepository->getById($block1Identifier); + $block1 = $blockRepository->getById($block1Identifier); $block2Identifier = 'enabled_block'; - $block2 = $blockRepository->getById($block2Identifier); + $block2 = $blockRepository->getById($block2Identifier); $queryBlock1 = <<<QUERY @@ -77,60 +82,30 @@ public function testCmsBlocksRequestHasCorrectTags(): void QUERY; // check to see that the first entity gets a MISS when called the first time - $request = $this->prepareRequest($queryBlock1); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block1->getId(), 'cms_b_' . $block1->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock1]); + $this->assertPageCacheMissWithTagsForCmsBlock($response, $block1); - // check to see that the second entity gets a miss when called the first time - $request = $this->prepareRequest($queryBlock2); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block2->getId(), 'cms_b_' . $block2->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + // check to see that the second entity gets a MISS when called the first time + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock2]); + $this->assertPageCacheMissWithTagsForCmsBlock($response, $block2); // check to see that the first entity gets a HIT when called the second time - $request = $this->prepareRequest($queryBlock1); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block1->getId(), 'cms_b_' . $block1->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock1]); + $this->assertPageCacheHitWithTagsForCmsBlock($response, $block1); // check to see that the second entity gets a HIT when called the second time - $request = $this->prepareRequest($queryBlock2); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block2->getId(), 'cms_b_' . $block2->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock2]); + $this->assertPageCacheHitWithTagsForCmsBlock($response, $block2); $block1->setTitle('something else that causes invalidation'); $blockRepository->save($block1); // check to see that the first entity gets a MISS and it was invalidated - $request = $this->prepareRequest($queryBlock1); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block1->getId(), 'cms_b_' . $block1->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock1]); + $this->assertPageCacheMissWithTagsForCmsBlock($response, $block1); // check to see that the first entity gets a HIT when called the second time - $request = $this->prepareRequest($queryBlock1); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_b', 'cms_b_' . $block1->getId(), 'cms_b_' . $block1->getIdentifier(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $queryBlock1]); + $this->assertPageCacheHitWithTagsForCmsBlock($response, $block1); } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/CmsPageCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/CmsPageCacheTest.php index 0248f870a5f1..60d84947d87c 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/CmsPageCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/Cms/CmsPageCacheTest.php @@ -7,13 +7,14 @@ namespace Magento\GraphQlCache\Controller\Cms; +use Magento\Cms\Api\Data\PageInterface; use Magento\Cms\Model\GetPageByIdentifier; use Magento\Cms\Model\PageRepository; -use Magento\GraphQl\Controller\GraphQl; +use Magento\Framework\App\Response\HttpInterface as HttpResponse; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; /** - * Test caching works for CMS page + * Test caching works for CMS pages * * @magentoAppArea graphql * @magentoCache full_page enabled @@ -22,123 +23,34 @@ */ class CmsPageCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(\Magento\GraphQl\Controller\GraphQl::class); - } - - /** - * Test that the correct cache tags get added to request for cmsPage query - * - * @magentoDataFixture Magento/Cms/_files/pages.php - */ - public function testToCheckCmsPageRequestCacheTags(): void + private function assertPageCacheMissWithTagsForCmsPage(string $pageId, string $name, HttpResponse $response): void { - $cmsPage100 = $this->objectManager->get(GetPageByIdentifier::class)->execute('page100', 0); - $pageId100 = $cmsPage100->getId(); - - $cmsPageBlank = $this->objectManager->get(GetPageByIdentifier::class)->execute('page_design_blank', 0); - $pageIdBlank = $cmsPageBlank->getId(); - - $queryCmsPage100 = $this->getQuery($pageId100); - $queryCmsPageBlank = $this->getQuery($pageIdBlank); - - // check to see that the first entity gets a MISS when called the first time - $request = $this->prepareRequest($queryCmsPage100); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals( - 'MISS', - $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected MISS on page page100 id {$queryCmsPage100}" - ); - $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageId100 , 'FPC']; - $this->assertEquals($expectedCacheTags, $requestedCacheTags); - - // check to see that the second entity gets a miss when called the first time - $request = $this->prepareRequest($queryCmsPageBlank); - $response = $this->graphqlController->dispatch($request); $this->assertEquals( 'MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected MISS on page pageBlank id {$pageIdBlank}" - ); - $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageIdBlank , 'FPC']; - $this->assertEquals($expectedCacheTags, $requestedCacheTags); - - // check to see that the first entity gets a HIT when called the second time - $request = $this->prepareRequest($queryCmsPage100); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals( - 'HIT', - $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected HIT on page page100 id {$queryCmsPage100}" - ); - $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageId100 , 'FPC']; - $this->assertEquals($expectedCacheTags, $requestedCacheTags); - - // check to see that the second entity gets a HIT when called the second time - $request = $this->prepareRequest($queryCmsPageBlank); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals( - 'HIT', - $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected HIT on page pageBlank id {$pageIdBlank}" + "expected MISS on page {$name} id {$pageId}" ); - $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageIdBlank , 'FPC']; - $this->assertEquals($expectedCacheTags, $requestedCacheTags); - - /** @var PageRepository $pageRepository */ - $pageRepository = $this->objectManager->get(PageRepository::class); - - $page = $pageRepository->getById($pageId100); - $page->setTitle('something else that causes invalidation'); - $pageRepository->save($page); - - // check to see that the first entity gets a MISS and it was invalidated - $request = $this->prepareRequest($queryCmsPage100); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals( - 'MISS', - $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected MISS on page page100 id {$queryCmsPage100}" - ); - $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageId100 , 'FPC']; - $this->assertEquals($expectedCacheTags, $requestedCacheTags); + $this->assertCmsPageCacheTags($pageId, $response); + } - // check to see that the first entity gets a HIT when called the second time - $request = $this->prepareRequest($queryCmsPage100); - $response = $this->graphqlController->dispatch($request); + private function assertPageCacheHitWithTagsForCmsPage(string $pageId, string $name, HttpResponse $response): void + { $this->assertEquals( 'HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue(), - "expected MISS on page page100 id {$queryCmsPage100}" + "expected HIT on page {$name} id {$pageId}" ); + $this->assertCmsPageCacheTags($pageId, $response); + } + + private function assertCmsPageCacheTags(string $pageId, HttpResponse $response): void + { $requestedCacheTags = explode(',', $response->getHeader('X-Magento-Tags')->getFieldValue()); - $expectedCacheTags = ['cms_p', 'cms_p_' .$pageId100 , 'FPC']; + $expectedCacheTags = ['cms_p', 'cms_p_' . $pageId, 'FPC']; $this->assertEquals($expectedCacheTags, $requestedCacheTags); } - /** - * Get cms query - * - * @param string $id - * @return string - */ - private function getQuery(string $id) : string + private function buildQuery(string $id): string { $queryCmsPage = <<<QUERY { @@ -156,4 +68,57 @@ private function getQuery(string $id) : string QUERY; return $queryCmsPage; } + + private function updateCmsPageTitle(string $pageId100, string $newTitle): void + { + /** @var PageRepository $pageRepository */ + $pageRepository = $this->objectManager->get(PageRepository::class); + $page = $pageRepository->getById($pageId100); + $page->setTitle($newTitle); + $pageRepository->save($page); + } + + /** + * @magentoDataFixture Magento/Cms/_files/pages.php + */ + public function testCmsPageRequestCacheTags(): void + { + /** @var PageInterface $cmsPage100 */ + $cmsPage100 = $this->objectManager->get(GetPageByIdentifier::class)->execute('page100', 0); + $pageId100 = (string) $cmsPage100->getId(); + + /** @var PageInterface $cmsPageBlank */ + $cmsPageBlank = $this->objectManager->get(GetPageByIdentifier::class)->execute('page_design_blank', 0); + $pageIdBlank = (string) $cmsPageBlank->getId(); + + $queryCmsPage100 = $this->buildQuery($pageId100); + $queryCmsPageBlank = $this->buildQuery($pageIdBlank); + + // check to see that the first entity gets a MISS when called the first time + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPage100]); + $this->assertPageCacheMissWithTagsForCmsPage($pageId100, 'page100', $response); + + // check to see that the second entity gets a MISS when called the first time + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPageBlank]); + $this->assertPageCacheMissWithTagsForCmsPage($pageIdBlank, 'pageBlank', $response); + + // check to see that the first entity gets a HIT when called the second time + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPage100]); + $this->assertPageCacheHitWithTagsForCmsPage($pageId100, 'page100', $response); + + // check to see that the second entity gets a HIT when called the second time + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPageBlank]); + $this->assertPageCacheHitWithTagsForCmsPage($pageIdBlank, 'pageBlank', $response); + + // invalidate first entity + $this->updateCmsPageTitle($pageId100, 'something else that causes invalidation'); + + // check to see that the second entity gets a HIT to confirm only the first was invalidated + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPageBlank]); + $this->assertPageCacheHitWithTagsForCmsPage($pageIdBlank, 'pageBlank', $response); + + // check to see that the first entity gets a MISS because it was invalidated + $response = $this->dispatchGraphQlGETRequest(['query' => $queryCmsPage100]); + $this->assertPageCacheMissWithTagsForCmsPage($pageId100, 'page100', $response); + } } diff --git a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/UrlRewrite/AllEntitiesUrlResolverCacheTest.php b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/UrlRewrite/AllEntitiesUrlResolverCacheTest.php index 7accb1d7d0b2..81a4988b8193 100644 --- a/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/UrlRewrite/AllEntitiesUrlResolverCacheTest.php +++ b/dev/tests/integration/testsuite/Magento/GraphQlCache/Controller/UrlRewrite/AllEntitiesUrlResolverCacheTest.php @@ -9,7 +9,7 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product; -use Magento\GraphQl\Controller\GraphQl; +use Magento\Framework\App\Response\HttpInterface as HttpResponse; use Magento\GraphQlCache\Controller\AbstractGraphqlCacheTest; use Magento\UrlRewrite\Model\UrlFinderInterface; use Magento\Cms\Api\Data\PageInterface; @@ -24,155 +24,153 @@ */ class AllEntitiesUrlResolverCacheTest extends AbstractGraphqlCacheTest { - /** - * @var GraphQl - */ - private $graphqlController; + private function assertCacheMISSWithTagsForCategory(string $categoryId, HttpResponse $response): void + { + $this->assertCacheMISS($response); + $this->assertCacheTags($categoryId, 'cat_c', $response); + } - /** - * @inheritdoc - */ - protected function setUp(): void + private function assertCacheMISSWithTagsForProduct(string $productId, HttpResponse $response): void + { + $this->assertCacheMISS($response); + $this->assertCacheTags($productId, 'cat_p', $response); + } + + private function assertCacheMISSWithTagsForCmsPage(string $pageId, HttpResponse $response): void + { + $this->assertCacheMISS($response); + $this->assertCacheTags($pageId, 'cms_p', $response); + } + + private function assertCacheHITWithTagsForCategory(string $categoryId, HttpResponse $response): void { - parent::setUp(); - $this->graphqlController = $this->objectManager->get(GraphQl::class); + $this->assertCacheHIT($response); + $this->assertCacheTags($categoryId, 'cat_c', $response); + } + + private function assertCacheHITWithTagsForProduct(string $productId, HttpResponse $response): void + { + $this->assertCacheHIT($response); + $this->assertCacheTags($productId, 'cat_p', $response); + } + + private function assertCacheHITWithTagsForCmsPage(string $pageId, HttpResponse $response): void + { + $this->assertCacheHIT($response); + $this->assertCacheTags($pageId, 'cms_p', $response); + } + + private function assertCacheMISS(HttpResponse $response): void + { + $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + } + + private function assertCacheHIT(HttpResponse $response): void + { + $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); + } + + private function assertCacheTags(string $entityId, string $entityCacheTag, HttpResponse $response) + { + $expectedCacheTags = [$entityCacheTag, $entityCacheTag . '_' . $entityId, 'FPC']; + $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); + $actualCacheTags = explode(',', $rawActualCacheTags); + $this->assertEquals($expectedCacheTags, $actualCacheTags); + } + + private function buildQuery(string $requestPath): string + { + $resolverQuery = <<<QUERY +{ + urlResolver(url:"{$requestPath}") + { + id + relative_url + canonical_url + type + } +} +QUERY; + return $resolverQuery; } /** - * Tests that X-Magento-tags and cache debug headers are correct for category urlResolver + * Tests that X-Magento-Tags and cache debug headers are correct for category urlResolver * * @magentoDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php * @magentoDataFixture Magento/Cms/_files/pages.php * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testAllEntitiesUrlResolverRequestHasCorrectTags() + public function testAllEntitiesUrlResolverRequestHasCorrectTags(): void { $categoryUrlKey = 'cat-1.html'; - $productUrlKey = 'p002.html'; - $productSku = 'p002'; + $productUrlKey = 'p002.html'; + $productSku = 'p002'; /** @var ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); /** @var Product $product */ $product = $productRepository->get($productSku, false, null, true); - $storeId = $product->getStoreId(); + $storeId = (string) $product->getStoreId(); /** @var UrlFinderInterface $urlFinder */ - $urlFinder = $this->objectManager->get(UrlFinderInterface::class); - $actualUrls = $urlFinder->findOneByData( + $urlFinder = $this->objectManager->get(UrlFinderInterface::class); + $actualUrls = $urlFinder->findOneByData( [ 'request_path' => $categoryUrlKey, 'store_id' => $storeId ] ); - $categoryId = $actualUrls->getEntityId(); - $categoryQuery = $this->getQuery($categoryUrlKey); + $categoryId = (string) $actualUrls->getEntityId(); + $categoryQuery = $this->buildQuery($categoryUrlKey); - $productQuery = $this->getQuery($productUrlKey); + $productQuery = $this->buildQuery($productUrlKey); /** @var GetPageByIdentifierInterface $page */ $page = $this->objectManager->get(GetPageByIdentifierInterface::class); /** @var PageInterface $cmsPage */ - $cmsPage = $page->execute('page100', 0); - $cmsPageId = $cmsPage->getId(); + $cmsPage = $page->execute('page100', 0); + $cmsPageId = (string) $cmsPage->getId(); $requestPath = $cmsPage->getIdentifier(); - $pageQuery = $this->getQuery($requestPath); + $pageQuery = $this->buildQuery($requestPath); // query category for MISS - $request = $this->prepareRequest($categoryQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $categoryQuery]); + $this->assertCacheMISSWithTagsForCategory($categoryId, $response); // query product for MISS - $request = $this->prepareRequest($productQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_p', 'cat_p_' . $product->getId(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $productQuery]); + $this->assertCacheMISSWithTagsForProduct((string) $product->getId(), $response); // query page for MISS - $request = $this->prepareRequest($pageQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_p','cms_p_' . $cmsPageId,'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $pageQuery]); + $this->assertCacheMISSWithTagsForCmsPage($cmsPageId, $response); // query category for HIT - $request = $this->prepareRequest($categoryQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $categoryQuery]); + $this->assertCacheHITWithTagsForCategory($categoryId, $response); // query product for HIT - $request = $this->prepareRequest($productQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_p', 'cat_p_' . $product->getId(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $productQuery]); + $this->assertCacheHITWithTagsForProduct((string) $product->getId(), $response); - // query product for HIT - $request = $this->prepareRequest($pageQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('HIT', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cms_p','cms_p_' . $cmsPageId,'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + // query page for HIT + $response = $this->dispatchGraphQlGETRequest(['query' => $pageQuery]); + $this->assertCacheHITWithTagsForCmsPage($cmsPageId, $response); $product->setUrlKey('something-else-that-invalidates-the-cache'); $productRepository->save($product); - $productQuery = $this->getQuery('something-else-that-invalidates-the-cache.html'); + $productQuery = $this->buildQuery('something-else-that-invalidates-the-cache.html'); // query category for MISS - $request = $this->prepareRequest($categoryQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_c','cat_c_' . $categoryId, 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); + $response = $this->dispatchGraphQlGETRequest(['query' => $categoryQuery]); + $this->assertCacheMISSWithTagsForCategory($categoryId, $response); - // query product for HIT - $request = $this->prepareRequest($productQuery); - $response = $this->graphqlController->dispatch($request); - $this->assertEquals('MISS', $response->getHeader('X-Magento-Cache-Debug')->getFieldValue()); - $expectedCacheTags = ['cat_p', 'cat_p_' . $product->getId(), 'FPC']; - $rawActualCacheTags = $response->getHeader('X-Magento-Tags')->getFieldValue(); - $actualCacheTags = explode(',', $rawActualCacheTags); - $this->assertEquals($expectedCacheTags, $actualCacheTags); - } + // query product for MISS + $response = $this->dispatchGraphQlGETRequest(['query' => $productQuery]); + $this->assertCacheMISSWithTagsForProduct((string) $product->getId(), $response); - /** - * Get urlResolver query - * - * @param string $id - * @return string - */ - private function getQuery(string $requestPath) : string - { - $resolverQuery = <<<QUERY -{ - urlResolver(url:"{$requestPath}") - { - id - relative_url - canonical_url - type - } -} -QUERY; - return $resolverQuery; + // query page for HIT + $response = $this->dispatchGraphQlGETRequest(['query' => $pageQuery]); + $this->assertCacheHITWithTagsForCmsPage($cmsPageId, $response); } } diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import/ValidateTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import/ValidateTest.php index a3cf42b48489..d9a758b54966 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import/ValidateTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Import/ValidateTest.php @@ -93,7 +93,7 @@ public function validationDataProvider(): array [ 'file_name' => 'test.txt', 'mime-type' => 'text/csv', - 'message' => '\'txt\' file extension is not supported', + 'message' => 'The file cannot be uploaded.', 'delimiter' => ',', ], [ diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php index 0c1f2d2fcc8d..0f92da2230f7 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Model/ImportTest.php @@ -7,6 +7,8 @@ use Magento\Framework\Phrase; use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface; +use Magento\ImportExport\Model\Import\ImageDirectoryBaseProvider; +use Magento\TestFramework\Helper\Bootstrap; /** * @magentoDataFixture Magento/ImportExport/_files/import_data.php @@ -21,7 +23,7 @@ class ImportTest extends \PHPUnit\Framework\TestCase protected $_model; /** - * @var \Magento\ImportExport\Model\Import\Config + * @var Import\Config */ protected $_importConfig; @@ -65,13 +67,35 @@ class ImportTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $this->_importConfig = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\ImportExport\Model\Import\Config::class + $this->_importConfig = Bootstrap::getObjectManager()->create( + Import\Config::class ); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + /** @var ImageDirectoryBaseProvider $provider */ + $provider = Bootstrap::getObjectManager()->get(ImageDirectoryBaseProvider::class); + $this->_model = Bootstrap::getObjectManager()->create( Import::class, - ['importConfig' => $this->_importConfig] + [ + 'importConfig' => $this->_importConfig + ] + ); + $this->_model->setData('images_base_directory', $provider->getDirectory()); + } + + /** + * Test validation of images directory against provided base directory. + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Images file directory is outside required directory + * @return void + */ + public function testImagesDirBase(): void + { + $this->_model->setData( + Import::FIELD_NAME_VALIDATION_STRATEGY, + ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_SKIP_ERRORS ); + $this->_model->setData(Import::FIELD_NAME_IMG_FILE_DIR, '../_files'); + $this->_model->importSource(); } /** @@ -80,7 +104,7 @@ protected function setUp() public function testImportSource() { /** @var $customersCollection \Magento\Customer\Model\ResourceModel\Customer\Collection */ - $customersCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( + $customersCollection = Bootstrap::getObjectManager()->create( \Magento\Customer\Model\ResourceModel\Customer\Collection::class ); diff --git a/dev/tests/integration/testsuite/Magento/Indexer/Console/Command/IndexerReindexCommandTest.php b/dev/tests/integration/testsuite/Magento/Indexer/Console/Command/IndexerReindexCommandTest.php new file mode 100644 index 000000000000..80b6f887d650 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Indexer/Console/Command/IndexerReindexCommandTest.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Indexer\Console\Command; + +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit_Framework_MockObject_MockObject as Mock; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Tests for \Magento\Indexer\Console\Command\IndexerReindexCommand. + * + * @magentoDbIsolation disabled + * @magentoAppIsolation enabled + */ +class IndexerReindexCommandTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var InputInterface|Mock + */ + private $inputMock; + + /** + * @var OutputInterface|Mock + */ + private $outputMock; + + /** + * @var IndexerReindexCommand + */ + private $command; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + + $this->inputMock = $this->getMockBuilder(InputInterface::class)->getMockForAbstractClass(); + $this->outputMock = $this->getMockBuilder(OutputInterface::class)->getMockForAbstractClass(); + + $this->command = $this->objectManager->get(IndexerReindexCommand::class); + } + + /** + * @magentoDataFixture Magento/Store/_files/second_store_group_with_second_website.php + */ + public function testReindexAll() + { + $status = $this->command->run($this->inputMock, $this->outputMock); + $this->assertEquals( + \Magento\Framework\Console\Cli::RETURN_SUCCESS, + $status, + 'Index wasn\'t success' + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php index 2a472371fd19..023421e4cd2b 100644 --- a/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php +++ b/dev/tests/integration/testsuite/Magento/Multishipping/Fixtures/quote_with_configurable_product.php @@ -118,7 +118,7 @@ $item->setQty(1); $address->setTotalQty(1); $address->addItem($item); - }; + } } $billingAddressData = [ diff --git a/dev/tests/integration/testsuite/Magento/MysqlMq/Model/QueueManagementTest.php b/dev/tests/integration/testsuite/Magento/MysqlMq/Model/QueueManagementTest.php index 56dd77d3da17..cba3334f1b7f 100644 --- a/dev/tests/integration/testsuite/Magento/MysqlMq/Model/QueueManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/MysqlMq/Model/QueueManagementTest.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\MysqlMq\Model; /** @@ -23,27 +25,26 @@ class QueueManagementTest extends \PHPUnit\Framework\TestCase protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->queueManagement = $this->objectManager->create(\Magento\MysqlMq\Model\QueueManagement::class); + $this->queueManagement = $this->objectManager->create(QueueManagement::class); } /** * @magentoDataFixture Magento/MysqlMq/_files/queues.php */ - public function testAllFlows() + public function testMessageReading() { - $this->queueManagement->addMessageToQueues('topic1', 'messageBody1', ['queue1', 'queue2']); - $this->queueManagement->addMessageToQueues('topic2', 'messageBody2', ['queue2', 'queue3']); - $this->queueManagement->addMessageToQueues('topic3', 'messageBody3', ['queue1', 'queue3']); - $this->queueManagement->addMessageToQueues('topic4', 'messageBody4', ['queue1', 'queue2', 'queue3']); + $this->queueManagement->addMessageToQueues('topic1', 'messageBody1', ['queue1']); + $this->queueManagement->addMessageToQueues('topic2', 'messageBody2', ['queue1']); + $this->queueManagement->addMessageToQueues('topic3', 'messageBody3', ['queue1']); $maxMessagesNumber = 2; - $messages = $this->queueManagement->readMessages('queue3', $maxMessagesNumber); + $messages = $this->queueManagement->readMessages('queue1', $maxMessagesNumber); $this->assertCount($maxMessagesNumber, $messages); $firstMessage = array_shift($messages); - $this->assertEquals('topic2', $firstMessage[QueueManagement::MESSAGE_TOPIC]); - $this->assertEquals('messageBody2', $firstMessage[QueueManagement::MESSAGE_BODY]); - $this->assertEquals('queue3', $firstMessage[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals('topic1', $firstMessage[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody1', $firstMessage[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue1', $firstMessage[QueueManagement::MESSAGE_QUEUE_NAME]); $this->assertEquals( QueueManagement::MESSAGE_STATUS_IN_PROGRESS, $firstMessage[QueueManagement::MESSAGE_STATUS] @@ -55,9 +56,9 @@ public function testAllFlows() $this->assertCount(12, date_parse($firstMessage[QueueManagement::MESSAGE_UPDATED_AT])); $secondMessage = array_shift($messages); - $this->assertEquals('topic3', $secondMessage[QueueManagement::MESSAGE_TOPIC]); - $this->assertEquals('messageBody3', $secondMessage[QueueManagement::MESSAGE_BODY]); - $this->assertEquals('queue3', $secondMessage[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals('topic2', $secondMessage[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody2', $secondMessage[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue1', $secondMessage[QueueManagement::MESSAGE_QUEUE_NAME]); $this->assertEquals( QueueManagement::MESSAGE_STATUS_IN_PROGRESS, $secondMessage[QueueManagement::MESSAGE_STATUS] @@ -67,37 +68,130 @@ public function testAllFlows() $this->assertTrue(is_numeric($secondMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID])); $this->assertEquals(0, $secondMessage[QueueManagement::MESSAGE_NUMBER_OF_TRIALS]); $this->assertCount(12, date_parse($secondMessage[QueueManagement::MESSAGE_UPDATED_AT])); + } + + /** + * @magentoDataFixture Magento/MysqlMq/_files/queues.php + */ + public function testMessageReadingMultipleQueues() + { + $this->queueManagement->addMessageToQueues('topic1', 'messageBody1', ['queue1']); + $this->queueManagement->addMessageToQueues('topic2', 'messageBody2', ['queue1', 'queue2']); + $this->queueManagement->addMessageToQueues('topic3', 'messageBody3', ['queue2']); + + $maxMessagesNumber = 2; + $messages = $this->queueManagement->readMessages('queue1', $maxMessagesNumber); + $this->assertCount($maxMessagesNumber, $messages); + + $message = array_shift($messages); + $this->assertEquals('topic1', $message[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody1', $message[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue1', $message[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals( + QueueManagement::MESSAGE_STATUS_IN_PROGRESS, + $message[QueueManagement::MESSAGE_STATUS] + ); + + $message= array_shift($messages); + $this->assertEquals('topic2', $message[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody2', $message[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue1', $message[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals( + QueueManagement::MESSAGE_STATUS_IN_PROGRESS, + $message[QueueManagement::MESSAGE_STATUS] + ); + + $maxMessagesNumber = 2; + $messages = $this->queueManagement->readMessages('queue2', $maxMessagesNumber); + $this->assertCount($maxMessagesNumber, $messages); + + $message= array_shift($messages); + $this->assertEquals('topic2', $message[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody2', $message[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue2', $message[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals( + QueueManagement::MESSAGE_STATUS_IN_PROGRESS, + $message[QueueManagement::MESSAGE_STATUS] + ); + + $message = array_shift($messages); + $this->assertEquals('topic3', $message[QueueManagement::MESSAGE_TOPIC]); + $this->assertEquals('messageBody3', $message[QueueManagement::MESSAGE_BODY]); + $this->assertEquals('queue2', $message[QueueManagement::MESSAGE_QUEUE_NAME]); + $this->assertEquals( + QueueManagement::MESSAGE_STATUS_IN_PROGRESS, + $message[QueueManagement::MESSAGE_STATUS] + ); + } + + /** + * @magentoDataFixture Magento/MysqlMq/_files/queues.php + */ + public function testChangingMessageStatus() + { + $this->queueManagement->addMessageToQueues('topic1', 'messageBody1', ['queue1']); + $this->queueManagement->addMessageToQueues('topic2', 'messageBody2', ['queue1']); + $this->queueManagement->addMessageToQueues('topic3', 'messageBody3', ['queue1']); + $this->queueManagement->addMessageToQueues('topic4', 'messageBody4', ['queue1']); + + $maxMessagesNumber = 4; + $messages = $this->queueManagement->readMessages('queue1', $maxMessagesNumber); + $this->assertCount($maxMessagesNumber, $messages); + + $firstMessage = array_shift($messages); + $secondMessage = array_shift($messages); + $thirdMessage = array_shift($messages); + $fourthMessage = array_shift($messages); + + $this->queueManagement->changeStatus( + [ + $firstMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID] + ], + QueueManagement::MESSAGE_STATUS_ERROR + ); - /** Mark one message as complete or failed and make sure it is not displayed in the list of read messages */ $this->queueManagement->changeStatus( [ $secondMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID] ], QueueManagement::MESSAGE_STATUS_COMPLETE ); - $messages = $this->queueManagement->readMessages('queue3', $maxMessagesNumber); - $this->assertCount(1, $messages); $this->queueManagement->changeStatus( [ - $firstMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID] + $thirdMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID] ], - QueueManagement::MESSAGE_STATUS_ERROR + QueueManagement::MESSAGE_STATUS_NEW + ); + + $this->queueManagement->changeStatus( + [ + $fourthMessage[QueueManagement::MESSAGE_QUEUE_RELATION_ID] + ], + QueueManagement::MESSAGE_STATUS_RETRY_REQUIRED ); - $messages = $this->queueManagement->readMessages('queue3', $maxMessagesNumber); - $this->assertCount(0, $messages); - /** Ensure that message for retry is still accessible when reading messages from the queue */ - $messages = $this->queueManagement->readMessages('queue2', 1); + $messages = $this->queueManagement->readMessages('queue1'); + $this->assertCount(2, $messages); + } + + /** + * @magentoDataFixture Magento/MysqlMq/_files/queues.php + */ + public function testMessageRetry() + { + $this->queueManagement->addMessageToQueues('topic1', 'messageBody1', ['queue1']); + + $messages = $this->queueManagement->readMessages('queue1', 1); $message = array_shift($messages); $messageRelationId = $message[QueueManagement::MESSAGE_QUEUE_RELATION_ID]; for ($i = 0; $i < 2; $i++) { $this->assertEquals($i, $message[QueueManagement::MESSAGE_NUMBER_OF_TRIALS]); $this->queueManagement->pushToQueueForRetry($message[QueueManagement::MESSAGE_QUEUE_RELATION_ID]); - $messages = $this->queueManagement->readMessages('queue2', 1); + $messages = $this->queueManagement->readMessages('queue1', 1); $message = array_shift($messages); $this->assertEquals($messageRelationId, $message[QueueManagement::MESSAGE_QUEUE_RELATION_ID]); } } -} +} \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/Model/CollectRatesTest.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/Model/CollectRatesTest.php new file mode 100644 index 000000000000..1b85f99752cf --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/Model/CollectRatesTest.php @@ -0,0 +1,49 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\OfflineShipping\Model; + +/** + * Integration tests for offline shipping carriers. + * @magentoAppIsolation enabled + */ +class CollectRatesTest extends \Magento\Shipping\Model\CollectRatesAbstract +{ + /** + * @var string + */ + protected $carrier = 'flatrate'; + + /** + * @var string + */ + protected $errorMessage = 'This shipping method is not available. To use this shipping method, please contact us.'; + + /** + * @magentoConfigFixture default_store carriers/flatrate/active 1 + * @magentoConfigFixture default_store carriers/flatrate/sallowspecific 1 + * @magentoConfigFixture default_store carriers/flatrate/specificcountry UK + * @magentoConfigFixture default_store carriers/flatrate/showmethod 1 + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod + public function testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable() + { + parent::testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable(); + } + + /** + * @magentoConfigFixture default_store carriers/flatrate/active 0 + * @magentoConfigFixture default_store carriers/flatrate/sallowspecific 1 + * @magentoConfigFixture default_store carriers/flatrate/specificcountry UK + * @magentoConfigFixture default_store carriers/flatrate/showmethod 1 + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod + public function testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable() + { + parent::testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php b/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php index 3bd966018b94..ff4f3f8a58bc 100644 --- a/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Payment/Block/InfoTest.php @@ -5,9 +5,24 @@ */ namespace Magento\Payment\Block; +use Magento\Framework\View\Element\Text; +use Magento\Framework\View\LayoutInterface; +use Magento\OfflinePayments\Model\Banktransfer; +use Magento\OfflinePayments\Model\Checkmo; +use Magento\Payment\Block\Info as BlockInfo; +use Magento\Payment\Block\Info\Instructions; +use Magento\Payment\Model\Info; +use Magento\Sales\Model\Order; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Class InfoTest + */ class InfoTest extends \PHPUnit\Framework\TestCase { /** + * Tests payment info block. + * * @magentoConfigFixture current_store payment/banktransfer/title Bank Method Title * @magentoConfigFixture current_store payment/checkmo/title Checkmo Title Of The Method * @magentoAppArea adminhtml @@ -15,37 +30,32 @@ class InfoTest extends \PHPUnit\Framework\TestCase public function testGetChildPdfAsArray() { /** @var $layout \Magento\Framework\View\Layout */ - $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\LayoutInterface::class - ); - $block = $layout->createBlock(\Magento\Payment\Block\Info::class, 'block'); + $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class); + $block = $layout->createBlock(BlockInfo::class, 'block'); - /** @var $paymentInfoBank \Magento\Payment\Model\Info */ - $paymentInfoBank = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Payment\Model\Info::class - ); - $paymentInfoBank->setMethodInstance( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\OfflinePayments\Model\Banktransfer::class - ) + /** @var $paymentInfoBank Info */ + $paymentInfoBank = Bootstrap::getObjectManager()->create( + Info::class ); - /** @var $childBank \Magento\Payment\Block\Info\Instructions */ - $childBank = $layout->addBlock(\Magento\Payment\Block\Info\Instructions::class, 'child.one', 'block'); + $order = Bootstrap::getObjectManager()->create(Order::class); + $banktransferPayment = Bootstrap::getObjectManager()->create(Banktransfer::class); + $paymentInfoBank->setMethodInstance($banktransferPayment); + $paymentInfoBank->setOrder($order); + /** @var $childBank Instructions */ + $childBank = $layout->addBlock(Instructions::class, 'child.one', 'block'); $childBank->setInfo($paymentInfoBank); $nonExpectedHtml = 'non-expected html'; - $childHtml = $layout->addBlock(\Magento\Framework\View\Element\Text::class, 'child.html', 'block'); + $childHtml = $layout->addBlock(Text::class, 'child.html', 'block'); $childHtml->setText($nonExpectedHtml); - /** @var $paymentInfoCheckmo \Magento\Payment\Model\Info */ - $paymentInfoCheckmo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Payment\Model\Info::class - ); - $paymentInfoCheckmo->setMethodInstance( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\OfflinePayments\Model\Checkmo::class - ) + /** @var $paymentInfoCheckmo Info */ + $paymentInfoCheckmo = Bootstrap::getObjectManager()->create( + Info::class ); + $checkmoPayment = Bootstrap::getObjectManager()->create(Checkmo::class); + $paymentInfoCheckmo->setMethodInstance($checkmoPayment); + $paymentInfoCheckmo->setOrder($order); /** @var $childCheckmo \Magento\OfflinePayments\Block\Info\Checkmo */ $childCheckmo = $layout->addBlock( \Magento\OfflinePayments\Block\Info\Checkmo::class, diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressSetPaymentMethodTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressSetPaymentMethodTest.php index cfefd7d3e6d6..3528fd744fe0 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressSetPaymentMethodTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PaypalExpressSetPaymentMethodTest.php @@ -113,7 +113,7 @@ public function testResolve(string $paymentMethod): void } placeOrder(input: {cart_id: "{$maskedCartId}"}) { order { - order_id + order_number } } } @@ -205,11 +205,11 @@ public function testResolve(string $paymentMethod): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowLinkTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowLinkTest.php index d55820ccffc1..51745fb6aaf9 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowLinkTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowLinkTest.php @@ -134,7 +134,7 @@ public function testResolvePlaceOrderWithPayflowLinkForCustomer(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } @@ -190,11 +190,11 @@ public function testResolvePlaceOrderWithPayflowLinkForCustomer(): void $responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code'] ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowProTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowProTest.php index 899af918b04b..024340dc91c2 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowProTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Customer/PlaceOrderWithPayflowProTest.php @@ -122,7 +122,7 @@ public function testResolveCustomer(): void } placeOrder(input: {cart_id: "{$cartId}"}) { order { - order_id + order_number } } } @@ -207,11 +207,11 @@ public function testResolveCustomer(): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressSetPaymentMethodTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressSetPaymentMethodTest.php index 1b5f14c7df63..6744b9209281 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressSetPaymentMethodTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalExpressSetPaymentMethodTest.php @@ -112,7 +112,7 @@ public function testResolveGuest(string $paymentMethod): void } placeOrder(input: {cart_id: "{$cartId}"}) { order { - order_id + order_number } } } @@ -191,11 +191,11 @@ public function testResolveGuest(string $paymentMethod): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalPayflowProSetPaymentMethodTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalPayflowProSetPaymentMethodTest.php index 0e1a74fa817d..69fe913a9161 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalPayflowProSetPaymentMethodTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PaypalPayflowProSetPaymentMethodTest.php @@ -122,7 +122,7 @@ public function testResolveGuest(): void } placeOrder(input: {cart_id: "{$cartId}"}) { order { - order_id + order_number } } } @@ -198,11 +198,11 @@ public function testResolveGuest(): void ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithHostedProTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithHostedProTest.php index a8136fda73c0..bf716fe19d17 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithHostedProTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithHostedProTest.php @@ -115,7 +115,7 @@ public function testPlaceOrderWithHostedPro(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } @@ -140,11 +140,11 @@ public function testPlaceOrderWithHostedPro(): void $responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code'] ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } @@ -189,7 +189,7 @@ public function testOrderWithHostedProDeclined(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPayflowLinkTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPayflowLinkTest.php index f4fe3e7e60fd..7f13d11ce98c 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPayflowLinkTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPayflowLinkTest.php @@ -133,7 +133,7 @@ public function testResolvePlaceOrderWithPayflowLink(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } @@ -183,11 +183,11 @@ public function testResolvePlaceOrderWithPayflowLink(): void $responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code'] ); $this->assertTrue( - isset($responseData['data']['placeOrder']['order']['order_id']) + isset($responseData['data']['placeOrder']['order']['order_number']) ); $this->assertEquals( 'test_quote', - $responseData['data']['placeOrder']['order']['order_id'] + $responseData['data']['placeOrder']['order']['order_number'] ); } @@ -235,7 +235,7 @@ public function testResolveWithPayflowLinkDeclined(): void } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } diff --git a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPaymentsAdvancedTest.php b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPaymentsAdvancedTest.php index a40a56be5fae..6a757cbb102e 100644 --- a/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPaymentsAdvancedTest.php +++ b/dev/tests/integration/testsuite/Magento/PaypalGraphQl/Model/Resolver/Guest/PlaceOrderWithPaymentsAdvancedTest.php @@ -149,8 +149,8 @@ public function testResolvePlaceOrderWithPaymentsAdvanced(): void $paymentMethod, $responseData['data']['setPaymentMethodOnCart']['cart']['selected_payment_method']['code'] ); - $this->assertNotEmpty(isset($responseData['data']['placeOrder']['order']['order_id'])); - $this->assertEquals('test_quote', $responseData['data']['placeOrder']['order']['order_id']); + $this->assertNotEmpty(isset($responseData['data']['placeOrder']['order']['order_number'])); + $this->assertEquals('test_quote', $responseData['data']['placeOrder']['order']['order_number']); } /** @@ -265,7 +265,7 @@ private function setPaymentMethodAndPlaceOrder(string $cartId, string $paymentMe } placeOrder(input: {cart_id: "$cartId"}) { order { - order_id + order_number } } } diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php index 0fc98d8d8380..44f37b34660b 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php @@ -3,60 +3,123 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\ProductAlert\Model; +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Model\Session; +use Magento\Framework\App\Area; +use Magento\Framework\Locale\Resolver; +use Magento\Framework\Module\Dir\Reader; +use Magento\Framework\Phrase; +use Magento\Framework\Phrase\Renderer\Translate as PhraseRendererTranslate; +use Magento\Framework\Phrase\RendererInterface; +use Magento\Framework\Translate; +use Magento\Store\Model\StoreRepository; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\CacheCleaner; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\ObjectManager; + /** + * Test for Magento\ProductAlert\Model\Observer + * * @magentoAppIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ObserverTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManager */ protected $_objectManager; /** - * @var \Magento\Customer\Model\Session + * @var Observer */ - protected $_customerSession; + private $observer; /** - * @var \Magento\Customer\Helper\View + * @var TransportBuilderMock */ - protected $_customerViewHelper; + private $transportBuilder; + /** + * @inheritDoc + */ public function setUp() { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_customerSession = $this->_objectManager->get( - \Magento\Customer\Model\Session::class - ); - $service = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Customer\Api\AccountManagementInterface::class - ); + Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND); + $this->_objectManager = Bootstrap::getObjectManager(); + $this->observer = $this->_objectManager->get(Observer::class); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + $service = $this->_objectManager->create(AccountManagementInterface::class); $customer = $service->authenticate('customer@example.com', 'password'); - $this->_customerSession->setCustomerDataAsLoggedIn($customer); - $this->_customerViewHelper = $this->_objectManager->create(\Magento\Customer\Helper\View::class); + $customerSession = $this->_objectManager->get(Session::class); + $customerSession->setCustomerDataAsLoggedIn($customer); } /** - * @magentoConfigFixture current_store catalog/productalert/allow_price 1 + * Test process() method * + * @magentoConfigFixture current_store catalog/productalert/allow_price 1 * @magentoDataFixture Magento/ProductAlert/_files/product_alert.php */ public function testProcess() { - \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); - $observer = $this->_objectManager->get(\Magento\ProductAlert\Model\Observer::class); - $observer->process(); - - /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */ - $transportBuilder = $this->_objectManager->get( - \Magento\TestFramework\Mail\Template\TransportBuilderMock::class - ); + $this->observer->process(); $this->assertContains( 'John Smith,', - $transportBuilder->getSentMessage()->getRawMessage() + $this->transportBuilder->getSentMessage()->getRawMessage() ); } + + /** + * Check translations for product alerts + * + * @magentoDbIsolation disabled + * @magentoAppArea frontend + * @magentoDataFixture Magento/Catalog/_files/category.php + * @magentoConfigFixture current_store catalog/productalert/allow_price 1 + * @magentoDataFixture Magento/Store/_files/second_store.php + * @magentoConfigFixture fixture_second_store_store general/locale/code pt_BR + * @magentoDataFixture Magento/ProductAlert/_files/product_alert_with_store.php + */ + public function testProcessPortuguese() + { + // get second store + $storeRepository = $this->_objectManager->create(StoreRepository::class); + $secondStore = $storeRepository->get('fixture_second_store'); + + // check if Portuguese language is specified for the second store + CacheCleaner::cleanAll(); + $storeResolver = $this->_objectManager->get(Resolver::class); + $storeResolver->emulate($secondStore->getId()); + $this->assertEquals('pt_BR', $storeResolver->getLocale()); + + // set translation data and check it + $modulesReader = $this->createPartialMock(Reader::class, ['getModuleDir']); + $modulesReader->expects($this->any()) + ->method('getModuleDir') + ->willReturn(dirname(__DIR__) . '/_files/i18n'); + /** @var Translate $translator */ + $translator = $this->_objectManager->create(Translate::class, ['modulesReader' => $modulesReader]); + $translation = [ + 'Price change alert! We wanted you to know that prices have changed for these products:' => + 'Alerta de mudanca de preco! Queriamos que voce soubesse que os precos mudaram para esses produtos:' + ]; + $translator->loadData(); + $this->assertEquals($translation, $translator->getData()); + $this->_objectManager->addSharedInstance($translator, Translate::class); + $this->_objectManager->removeSharedInstance(PhraseRendererTranslate::class); + Phrase::setRenderer($this->_objectManager->create(RendererInterface::class)); + + // dispatch process() method and check sent message + $this->observer->process(); + $message = $this->transportBuilder->getSentMessage()->getRawMessage(); + $expectedText = array_shift($translation); + $this->assertContains('/frontend/Magento/luma/pt_BR/', $message); + $this->assertContains(substr($expectedText, 0, 50), $message); + } } diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/_files/i18n/pt_BR.csv b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/i18n/pt_BR.csv new file mode 100644 index 000000000000..0c8218a78923 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/i18n/pt_BR.csv @@ -0,0 +1 @@ +"Price change alert! We wanted you to know that prices have changed for these products:","Alerta de mudanca de preco! Queriamos que voce soubesse que os precos mudaram para esses produtos:",Magento_ProductAlert diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php new file mode 100644 index 000000000000..38f00d49f1d4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; +use Magento\ProductAlert\Model\Price; +use Magento\ProductAlert\Model\Stock; + +require __DIR__ . '/../../../Magento/Customer/_files/customer_for_second_store.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_out_of_stock_without_categories.php'; + +$objectManager = Bootstrap::getObjectManager(); +$price = $objectManager->create(Price::class); +$price->setCustomerId($customer->getId()) + ->setProductId($product->getId()) + ->setPrice($product->getPrice()+1) + ->setWebsiteId(1) + ->setStoreId(2); +$price->save(); + +$stock = $objectManager->create(Stock::class); +$stock->setCustomerId($customer->getId()) + ->setProductId($product->getId()) + ->setWebsiteId(1) + ->setStoreId(2); +$stock->save(); diff --git a/dev/tests/integration/testsuite/Magento/ReleaseNotification/Controller/Adminhtml/Dashboard/IndexTest.php b/dev/tests/integration/testsuite/Magento/ReleaseNotification/Controller/Adminhtml/Dashboard/IndexTest.php index 2f89f70a6c87..ffe3ccf49eba 100644 --- a/dev/tests/integration/testsuite/Magento/ReleaseNotification/Controller/Adminhtml/Dashboard/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/ReleaseNotification/Controller/Adminhtml/Dashboard/IndexTest.php @@ -72,7 +72,7 @@ public function testExecuteEmptyContent() $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); $actual = $this->getResponse()->getBody(); - $this->assertNotContains('"autoOpen":true', $actual); + $this->assertContains('"autoOpen":false', $actual); } public function testExecuteFalseContent() @@ -87,6 +87,6 @@ public function testExecuteFalseContent() $this->assertEquals(200, $this->getResponse()->getHttpResponseCode()); $actual = $this->getResponse()->getBody(); - $this->assertNotContains('"autoOpen":true', $actual); + $this->assertContains('"autoOpen":false', $actual); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php index a07616474a41..3d0eb2d4d75e 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php @@ -55,7 +55,7 @@ public function testLoadBlockAction() $this->getRequest()->setParam('block', ','); $this->getRequest()->setParam('json', 1); $this->dispatch('backend/sales/order_create/loadBlock'); - $this->assertEquals('{"message":""}', $this->getResponse()->getBody()); + $this->assertContains('"message":""}', $this->getResponse()->getBody()); } /** diff --git a/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php new file mode 100644 index 000000000000..1b68bc0520ce --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Cron; + +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Quote\Model\QuoteRepository; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test for Magento\Sales\Cron\CleanExpiredQuotes class. + * + * @magentoAppIsolation enabled + * @magentoDbIsolation enabled + */ +class CleanExpiredQuotesTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var CleanExpiredQuotes + */ + private $cleanExpiredQuotes; + + /** + * @var QuoteRepository + */ + private $quoteRepository; + + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + + /** + * @inheritdoc + */ + protected function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $this->cleanExpiredQuotes = $objectManager->get(CleanExpiredQuotes::class); + $this->quoteRepository = $objectManager->get(QuoteRepository::class); + $this->searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); + } + + /** + * Check if outdated quotes are deleted. + * + * @magentoConfigFixture default_store checkout/cart/delete_quote_after -365 + * @magentoDataFixture Magento/Sales/_files/quotes.php + */ + public function testExecute() + { + $this->cleanExpiredQuotes->execute(); + $searchCriteria = $this->searchCriteriaBuilder->create(); + $totalCount = $this->quoteRepository->getList($searchCriteria)->getTotalCount(); + + $this->assertEquals( + 1, + $totalCount + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php index 1d04a79ae3f8..11499a024b44 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php @@ -117,9 +117,12 @@ public function testAddComment() $saved = $this->shipmentRepository->save($shipment); $comments = $saved->getComments(); - $actual = array_map(function (CommentInterface $comment) { - return $comment->getComment(); - }, $comments); + $actual = array_map( + function (CommentInterface $comment) { + return $comment->getComment(); + }, + $comments + ); self::assertEquals(2, count($actual)); self::assertEquals([$message1, $message2], $actual); } @@ -144,4 +147,59 @@ private function getOrder(string $incrementId): OrderInterface return array_pop($items); } + + /** + * Check that getTracksCollection() returns only order related tracks. + * + * @magentoDataFixture Magento/Sales/_files/two_orders_with_order_items.php + */ + public function testGetTracksCollection() + { + $order = $this->getOrder('100000001'); + $items = []; + foreach ($order->getItems() as $item) { + $items[$item->getId()] = $item->getQtyOrdered(); + } + /** @var \Magento\Sales\Model\Order\Shipment $shipment */ + $shipment = $this->objectManager->get(ShipmentFactory::class) + ->create($order, $items); + + $tracks = $shipment->getTracksCollection(); + self::assertTrue(empty($tracks->getItems())); + + /** @var ShipmentTrackInterface $track */ + $track = $this->objectManager->create(ShipmentTrackInterface::class); + $track->setNumber('Test Number') + ->setTitle('Test Title') + ->setCarrierCode('Test CODE'); + + $shipment->addTrack($track); + $this->shipmentRepository->save($shipment); + $shipmentTracksCollection = $shipment->getTracksCollection(); + + $secondOrder = $this->getOrder('100000002'); + $secondOrderItems = []; + foreach ($secondOrder->getItems() as $item) { + $secondOrderItems[$item->getId()] = $item->getQtyOrdered(); + } + /** @var \Magento\Sales\Model\Order\Shipment $secondOrderShipment */ + $secondOrderShipment = $this->objectManager->get(ShipmentFactory::class) + ->create($secondOrder, $secondOrderItems); + + /** @var ShipmentTrackInterface $secondShipmentTrack */ + $secondShipmentTrack = $this->objectManager->create(ShipmentTrackInterface::class); + $secondShipmentTrack->setNumber('Test Number2') + ->setTitle('Test Title2') + ->setCarrierCode('Test CODE2'); + + $secondOrderShipment->addTrack($secondShipmentTrack); + $this->shipmentRepository->save($secondOrderShipment); + $secondShipmentTrackCollection = $secondOrderShipment->getTracksCollection(); + + self::assertEquals($shipmentTracksCollection->getColumnValues('id'), [$track->getEntityId()]); + self::assertEquals( + $secondShipmentTrackCollection->getColumnValues('id'), + [$secondShipmentTrack->getEntityId()] + ); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderTest.php index d6fe86b6232d..25f759e7b1b9 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/ResourceModel/OrderTest.php @@ -3,8 +3,18 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Model\ResourceModel; +use Magento\Store\Api\StoreRepositoryInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Framework\Event\ManagerInterface; +use Magento\Sales\Model\ResourceModel\Order\CollectionFactory as OrderCollectionFactory; + +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class OrderTest extends \PHPUnit\Framework\TestCase { /** @@ -22,27 +32,48 @@ class OrderTest extends \PHPUnit\Framework\TestCase */ protected $objectManager; + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var StoreRepositoryInterface + */ + private $storeRepository; + + /** + * @inheritdoc + */ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->resourceModel = $this->objectManager->create(\Magento\Sales\Model\ResourceModel\Order::class); $this->orderIncrementId = '100000001'; + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); + $this->storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); } + /** + * @inheritdoc + */ protected function tearDown() { $registry = $this->objectManager->get(\Magento\Framework\Registry::class); $registry->unregister('isSecureArea'); $registry->register('isSecureArea', true); - /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); - $order->loadByIncrementId($this->orderIncrementId); - $order->delete(); + $orderCollection = $this->objectManager->create(OrderCollectionFactory::class)->create(); + foreach ($orderCollection as $order) { + $order->delete(); + } $registry->unregister('isSecureArea'); $registry->register('isSecureArea', false); + $defaultStore = $this->storeRepository->get('default'); + $this->storeManager->setCurrentStore($defaultStore->getId()); + parent::tearDown(); } @@ -108,4 +139,29 @@ public function testSaveOrder() $this->assertNotNull($order->getCreatedAt()); $this->assertNotNull($order->getUpdatedAt()); } + + /** + * Check that store name with length within 255 chars can be saved in table sales_order + * + * @magentoDataFixture Magento/Store/_files/store_with_long_name.php + * @magentoDbIsolation disabled + * @return void + */ + public function testSaveStoreName() + { + $store = $this->storeRepository->get('test_2'); + $this->storeManager->setCurrentStore($store->getId()); + $eventManager = $this->objectManager->get(ManagerInterface::class); + $eventManager->dispatch('store_add', ['store' => $store]); + $order = $this->objectManager->create(\Magento\Sales\Model\Order::class); + $payment = $this->objectManager->create(\Magento\Sales\Model\Order\Payment::class); + $payment->setMethod('checkmo'); + $order->setStoreId($store->getId())->setPayment($payment); + $this->resourceModel->save($order); + $orderRepository = $this->objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class); + $order = $orderRepository->get($order->getId()); + $this->assertEquals(255, strlen($order->getStoreName())); + $this->assertContains($store->getWebsite()->getName(), $order->getStoreName()); + $this->assertContains($store->getGroup()->getName(), $order->getStoreName()); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php new file mode 100644 index 000000000000..3c4c164f0a01 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Store\Model\StoreRepository; +use Magento\Quote\Model\QuoteFactory; +use Magento\Quote\Model\QuoteRepository; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + +require dirname(dirname(__DIR__)) . '/Store/_files/second_store.php'; + +/** @var $objectManager ObjectManager */ +$objectManager = Bootstrap::getObjectManager(); +/** @var QuoteFactory $quoteFactory */ +$quoteFactory = $objectManager->get(QuoteFactory::class); +/** @var QuoteRepository $quoteRepository */ +$quoteRepository = $objectManager->get(QuoteRepository::class); +/** @var StoreRepository $storeRepository */ +$storeRepository = $objectManager->get(StoreRepository::class); + +$defaultStore = $storeRepository->getActiveStoreByCode('default'); +$secondStore = $storeRepository->getActiveStoreByCode('fixture_second_store'); + +$quotes = [ + 'quote for first store' => [ + 'store' => $defaultStore->getId(), + ], + 'quote for second store' => [ + 'store' => $secondStore->getId(), + ], +]; + +foreach ($quotes as $quoteData) { + $quote = $quoteFactory->create(); + $quote->setStoreId($quoteData['store']); + $quoteRepository->save($quote); +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php new file mode 100644 index 000000000000..7b7fd615e534 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes_rollback.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Registry; +use Magento\Quote\Model\QuoteRepository; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); + +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var QuoteRepository $quoteRepository */ +$quoteRepository = $objectManager->get(QuoteRepository::class); +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); +$searchCriteria = $searchCriteriaBuilder->create(); +$items = $quoteRepository->getList($searchCriteria) + ->getItems(); +foreach ($items as $item) { + $quoteRepository->delete($item); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +require dirname(dirname(__DIR__)) . '/Store/_files/second_store_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/two_orders_with_order_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/two_orders_with_order_items.php new file mode 100644 index 000000000000..ade37aed49d5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/two_orders_with_order_items.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Address as OrderAddress; +use Magento\Sales\Model\Order\Item as OrderItem; +use Magento\Sales\Model\Order\Payment; +use Magento\Store\Model\StoreManagerInterface; + +require 'default_rollback.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple.php'; +/** @var \Magento\Catalog\Model\Product $product */ + +$addressData = include __DIR__ . '/address_data.php'; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +$billingAddress = $objectManager->create(OrderAddress::class, ['data' => $addressData]); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +/** @var Payment $payment */ +$payment = $objectManager->create(Payment::class); +$payment->setMethod('checkmo') + ->setAdditionalInformation('last_trans_id', '11122') + ->setAdditionalInformation( + 'metadata', + [ + 'type' => 'free', + 'fraudulent' => false, + ] + ); + +/** @var OrderItem $orderItem */ +$orderItem = $objectManager->create(OrderItem::class); +$orderItem->setProductId($product->getId()) + ->setQtyOrdered(2) + ->setBasePrice($product->getPrice()) + ->setPrice($product->getPrice()) + ->setRowTotal($product->getPrice()) + ->setProductType('simple') + ->setName($product->getName()) + ->setSku($product->getSku()); + +/** @var Order $order */ +$order = $objectManager->create(Order::class); +$order->setIncrementId('100000001') + ->setState(Order::STATE_PROCESSING) + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)) + ->setSubtotal(100) + ->setGrandTotal(100) + ->setBaseSubtotal(100) + ->setBaseGrandTotal(100) + ->setCustomerIsGuest(true) + ->setCustomerEmail('customer@null.com') + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId()) + ->addItem($orderItem) + ->setPayment($payment); + +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->create(OrderRepositoryInterface::class); +$orderRepository->save($order); + +/** @var Payment $payment */ +$secondPayment = $objectManager->create(Payment::class); +$secondPayment->setMethod('checkmo') + ->setAdditionalInformation('last_trans_id', '11122') + ->setAdditionalInformation( + 'metadata', + [ + 'type' => 'free', + 'fraudulent' => false, + ] + ); + +/** @var OrderItem $orderItem */ +$secondOrderItem = $objectManager->create(OrderItem::class); +$secondOrderItem->setProductId($product->getId()) + ->setQtyOrdered(2) + ->setBasePrice($product->getPrice()) + ->setPrice($product->getPrice()) + ->setRowTotal($product->getPrice()) + ->setProductType('simple') + ->setName($product->getName()) + ->setSku($product->getSku()); + +/** @var Order $order */ +$secondOrder = $objectManager->create(Order::class); +$secondOrder->setIncrementId('100000002') + ->setState(Order::STATE_PROCESSING) + ->setStatus($secondOrder->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)) + ->setSubtotal(100) + ->setGrandTotal(100) + ->setBaseSubtotal(100) + ->setBaseGrandTotal(100) + ->setCustomerIsGuest(true) + ->setCustomerEmail('customer@null.com') + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->setStoreId($objectManager->get(StoreManagerInterface::class)->getStore()->getId()) + ->addItem($secondOrderItem) + ->setPayment($secondPayment); +$orderRepository->save($secondOrder); diff --git a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/Product/CustomerSendmailTest.php b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/Product/CustomerSendmailTest.php index 8794dfdff8fd..a94a96c5cbef 100644 --- a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/Product/CustomerSendmailTest.php +++ b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/Product/CustomerSendmailTest.php @@ -17,6 +17,9 @@ use Magento\Framework\Message\MessageInterface; use Magento\Captcha\Helper\Data as CaptchaHelper; +/** + * Class CustomerSendmailTest + */ class CustomerSendmailTest extends AbstractController { /** @@ -58,6 +61,7 @@ protected function setUp() } /** + * @magentoConfigFixture default_store sendfriend/email/enabled 1 * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Catalog/_files/product_simple.php */ @@ -95,6 +99,7 @@ public function testExecute() * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Catalog/_files/product_simple.php * @magentoConfigFixture default_store customer/captcha/forms product_sendtofriend_form + * @magentoConfigFixture default_store sendfriend/email/enabled 1 */ public function testWithCaptchaFailed() { @@ -133,7 +138,7 @@ public function testWithCaptchaFailed() * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Catalog/_files/product_simple.php * @magentoConfigFixture default_store customer/captcha/forms product_sendtofriend_form - * + * @magentoConfigFixture default_store sendfriend/email/enabled 1 */ public function testWithCaptchaSuccess() { diff --git a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php index 8dbe9468923f..1d6adf52466d 100644 --- a/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php +++ b/dev/tests/integration/testsuite/Magento/SendFriend/Controller/SendmailTest.php @@ -24,10 +24,11 @@ class SendmailTest extends AbstractController /** * Share the product to friend as logged in customer * + * @magentoAppArea frontend * @magentoDbIsolation enabled * @magentoAppIsolation enabled - * @magentoConfigFixture default/sendfriend/email/allow_guest 0 - * @magentoConfigFixture default/sendfriend/email/enabled 1 + * @magentoConfigFixture default_store sendfriend/email/allow_guest 0 + * @magentoConfigFixture default_store sendfriend/email/enabled 1 * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Catalog/_files/products.php */ diff --git a/dev/tests/integration/testsuite/Magento/Shipping/Model/CollectRatesAbstract.php b/dev/tests/integration/testsuite/Magento/Shipping/Model/CollectRatesAbstract.php new file mode 100644 index 000000000000..e120f2f64359 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Shipping/Model/CollectRatesAbstract.php @@ -0,0 +1,118 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Shipping\Model; + +use Magento\Framework\DataObject; +use Magento\Framework\ObjectManagerInterface; +use Magento\Quote\Model\Quote\Address\RateResult\Error; +use Magento\Quote\Model\Quote\Address\RateResult\Method; +use Magento\Shipping\Model\Rate\Result; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Abstract class for testing shipping carriers. + */ +abstract class CollectRatesAbstract extends \PHPUnit\Framework\TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var Shipping + */ + protected $shipping; + + /** + * @var string + */ + protected $carrier = ''; + + /** + * @var string + */ + protected $errorMessage = ''; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->shipping = $this->objectManager->get(Shipping::class); + } + + /** + * Tests that an error message is displayed when the shipping method is enabled and not applicable. + * + * @return void + */ + public function testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable() + { + $result = $this->shipping->collectRatesByAddress($this->getAddress(), $this->carrier); + $rate = $this->getRate($result->getResult()); + + static::assertEquals($this->carrier, $rate->getData('carrier')); + static::assertEquals($this->errorMessage, $rate->getData('error_message')); + } + + /** + * Tests that shipping rates don't return when the shipping method is disabled and not applicable. + * + * @return void + */ + public function testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable() + { + $result = $this->shipping->collectRatesByAddress($this->getAddress(), $this->carrier); + $rate = $this->getRate($result->getResult()); + + static::assertNull($rate); + } + + /** + * Returns customer address. + * + * @return DataObject + */ + private function getAddress(): DataObject + { + $address = $this->objectManager->create( + DataObject::class, + [ + 'data' => [ + 'region_id' => 'CA', + 'postcode' => '11111', + 'lastname' => 'John', + 'firstname' => 'Doe', + 'street' => 'Some street', + 'city' => 'Los Angeles', + 'email' => 'john.doe@example.com', + 'telephone' => '11111111', + 'country_id' => 'US', + 'item_qty' => 1, + ], + ] + ); + + return $address; + } + + /** + * Returns shipping rate by the result. + * + * @param Result $result + * @return Method|Error + */ + private function getRate(Result $result) + { + $rates = $result->getAllRates(); + + return array_pop($rates); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php b/dev/tests/integration/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php index 0e158821f180..a1a99ecd32b8 100644 --- a/dev/tests/integration/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php +++ b/dev/tests/integration/testsuite/Magento/Store/App/FrontController/Plugin/RequestPreprocessorTest.php @@ -14,7 +14,7 @@ use Zend\Stdlib\Parameters; /** - * Class RequestPreprocessorTest @covers \Magento\Store\App\FrontController\Plugin\RequestPreprocessor. + * Tests \Magento\Store\App\FrontController\Plugin\RequestPreprocessor. */ class RequestPreprocessorTest extends \Magento\TestFramework\TestCase\AbstractController { @@ -24,6 +24,28 @@ class RequestPreprocessorTest extends \Magento\TestFramework\TestCase\AbstractCo * @var string */ private $baseUrl; + /** + * @var array; + */ + private $config; + + /** + * @inheritDoc + */ + protected function setUp() + { + parent::setUp(); + $this->config = []; + } + + /** + * @inheritDoc + */ + protected function tearDown() + { + $this->setConfig($this->config); + parent::tearDown(); + } /** * Test non-secure POST request is redirected right away on completely secure frontend. @@ -62,6 +84,115 @@ public function testHttpsPassSecureLoginPost() $this->setFrontendCompletelySecureRollback(); } + /** + * Test auto redirect to base URL + * + * @param array $config + * @param string $requestUrl + * @param string $redirectUrl + * @dataProvider autoRedirectToBaseURLDataProvider + */ + public function testAutoRedirectToBaseURL(array $config, string $requestUrl, string $redirectUrl) + { + $request = [ + 'REQUEST_SCHEME' => parse_url($requestUrl, PHP_URL_SCHEME), + 'SERVER_NAME' => parse_url($requestUrl, PHP_URL_HOST), + 'SCRIPT_NAME' => '/index.php', + 'SCRIPT_FILENAME' => 'index.php', + 'REQUEST_URI' => parse_url($requestUrl, PHP_URL_PATH), + ]; + $this->setConfig($config); + $this->setServer($request); + $app = $this->_objectManager->create(\Magento\Framework\App\Http::class, ['_request' => $this->getRequest()]); + $this->_response = $app->launch(); + $this->assertRedirect($this->equalTo($redirectUrl)); + } + + /** + * @return array + */ + public function autoRedirectToBaseURLDataProvider(): array + { + $baseConfig = [ + 'web/unsecure/base_url' => 'http://magento.com/us/', + 'web/session/use_frontend_sid' => 0, + 'web/seo/use_rewrites' => 1, + ]; + + return [ + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c/d/e.html', + 'redirectUrl' => 'http://magento.com/us/a/b/c/d/e.html' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c/d.html', + 'redirectUrl' => 'http://magento.com/us/a/b/c/d.html' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c.html', + 'redirectUrl' => 'http://magento.com/us/a/b/c.html' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b.html', + 'redirectUrl' => 'http://magento.com/us/a/b.html' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a.html', + 'redirectUrl' => 'http://magento.com/us/a.html' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c/d/e', + 'redirectUrl' => 'http://magento.com/us/a/b/c/d/e' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c/d', + 'redirectUrl' => 'http://magento.com/us/a/b/c/d' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b/c', + 'redirectUrl' => 'http://magento.com/us/a/b/c' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a/b', + 'redirectUrl' => 'http://magento.com/us/a/b' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/a', + 'redirectUrl' => 'http://magento.com/us/a' + ], + [ + 'config' => $baseConfig, + 'request' => 'http://magento.com/', + 'redirectUrl' => 'http://magento.com/us/' + ], + [ + 'config' => array_merge($baseConfig, ['web/seo/use_rewrites' => 0]), + 'request' => 'http://magento.com/', + 'redirectUrl' => 'http://magento.com/us/index.php/' + ], + [ + 'config' => array_merge($baseConfig, ['web/seo/use_rewrites' => 0]), + 'request' => 'http://magento.com/a/b/c/d.html', + 'redirectUrl' => 'http://magento.com/us/index.php/a/b/c/d.html' + ], + [ + 'config' => array_merge($baseConfig, ['web/seo/use_rewrites' => 0]), + 'request' => 'http://magento.com/a/b/c/d', + 'redirectUrl' => 'http://magento.com/us/index.php/a/b/c/d' + ], + ]; + } + /** * Assert response is redirect with https protocol. * @@ -83,22 +214,26 @@ private function assertResponseRedirect(Response $response, string $redirectUrl) */ private function prepareRequest(bool $isSecure = false) { - $post = new Parameters([ - 'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(), - 'login' => [ - 'username' => 'customer@example.com', - 'password' => 'password' + $post = new Parameters( + [ + 'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(), + 'login' => [ + 'username' => 'customer@example.com', + 'password' => 'password' + ] ] - ]); + ); $request = $this->getRequest(); $request->setMethod(\Magento\TestFramework\Request::METHOD_POST); $request->setRequestUri('customer/account/loginPost/'); $request->setPost($post); if ($isSecure) { - $server = new Parameters([ - 'HTTPS' => 'on', - 'SERVER_PORT' => 443 - ]); + $server = new Parameters( + [ + 'HTTPS' => 'on', + 'SERVER_PORT' => 443 + ] + ); $request->setServer($server); } @@ -151,4 +286,45 @@ private function setFrontendCompletelySecureRollback() $reinitibleConfig = $this->_objectManager->create(ReinitableConfigInterface::class); $reinitibleConfig->reinit(); } + + private function setConfig(array $config): void + { + foreach ($config as $path => $value) { + $model = $this->_objectManager->create(Value::class); + $model->load($path, 'path'); + if (!isset($this->config[$path])) { + $this->config[$path] = $model->getValue(); + } + if (!$model->getPath()) { + $model->setPath($path); + } + if ($value !== null) { + $model->setValue($value); + $model->save(); + } elseif ($model->getId()) { + $model->delete(); + } + } + $this->_objectManager->create(ReinitableConfigInterface::class)->reinit(); + } + + private function setServer(array $server) + { + $request = $this->getRequest(); + $properties = [ + 'baseUrl', + 'basePath', + 'requestUri', + 'originalPathInfo', + 'pathInfo', + ]; + $reflection = new \ReflectionClass($request); + + foreach ($properties as $name) { + $property = $reflection->getProperty($name); + $property->setAccessible(true); + $property->setValue($request, null); + } + $request->setServer(new Parameters($server)); + } } diff --git a/dev/tests/integration/testsuite/Magento/Store/Model/HashGeneratorTest.php b/dev/tests/integration/testsuite/Magento/Store/Model/HashGeneratorTest.php new file mode 100644 index 000000000000..1bacd79b74f4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/Model/HashGeneratorTest.php @@ -0,0 +1,180 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Store\Model; + +use Magento\Framework\ObjectManagerInterface as ObjectManager; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Store\Model\StoreSwitcher\HashGenerator; +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Model\Session as CustomerSession; +use \Magento\Framework\App\DeploymentConfig as DeploymentConfig; +use Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Framework\Url\Helper\Data as UrlHelper; +use Magento\Store\Model\StoreSwitcher\HashGenerator\HashData; + +/** + * Test class for \Magento\Store\Model\StoreSwitcher\HashGenerator + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class HashGeneratorTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var HashGenerator + */ + private $hashGenerator; + + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var int + */ + private $customerId; + + /** @var AccountManagementInterface */ + private $accountManagement; + + /** + * @var \Magento\Customer\Model\Authorization\CustomerSessionUserContext + */ + private $customerSessionUserContext; + + /** + * @var \Magento\Framework\App\DeploymentConfig + */ + private $deploymentConfig; + + /** + * @var string + */ + private $key; + + /** + * @var UrlHelper + */ + private $urlHelper; + + /** + * @var HashData + */ + private $hashData; + + /** + * @var CustomerSession + */ + private $customerSession; + + /** + * Class dependencies initialization + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->create( + CustomerSession::class + ); + $this->accountManagement = $this->objectManager->create(AccountManagementInterface::class); + $customer = $this->accountManagement->authenticate('customer@example.com', 'password'); + $this->customerSession->setCustomerDataAsLoggedIn($customer); + $this->customerSessionUserContext = $this->objectManager->create( + \Magento\Customer\Model\Authorization\CustomerSessionUserContext::class, + ['customerSession' => $this->customerSession] + ); + $this->hashGenerator = $this->objectManager->create( + StoreSwitcher\HashGenerator::class, + ['currentUser' => $this->customerSessionUserContext] + ); + $this->customerId = $customer->getId(); + $this->deploymentConfig = $this->objectManager->get(DeploymentConfig::class); + $this->key = (string)$this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY); + $this->urlHelper=$this->objectManager->create(UrlHelper::class); + $this->hashData=$this->objectManager->create(HashData::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->customerSession->logout(); + parent::tearDown(); + } + + /** + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer.php + * @return void + */ + public function testSwitch(): void + { + $redirectUrl = "http://domain.com/"; + $fromStoreCode = 'test'; + $fromStore = $this->createPartialMock(Store::class, ['getCode']); + $toStore = $this->createPartialMock(Store::class, ['getCode']); + $fromStore->expects($this->once())->method('getCode')->willReturn($fromStoreCode); + $targetUrl=$this->hashGenerator->switch($fromStore, $toStore, $redirectUrl); + // phpcs:ignore + $urlParts=parse_url($targetUrl, PHP_URL_QUERY); + $signature=''; + // phpcs:ignore + parse_str($urlParts, $params); + + if (isset($params['signature'])) { + $signature=$params['signature']; + } + $this->assertEquals($params['customer_id'], $this->customerId); + $this->assertEquals($params['___from_store'], $fromStoreCode); + + $data = new HashData( + [ + "customer_id" => $this->customerId, + "time_stamp" => $params['time_stamp'], + "___from_store" => $fromStoreCode + ] + ); + $this->assertTrue($this->hashGenerator->validateHash($signature, $data)); + } + + /** + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer.php + * @return void + */ + public function testValidateHashWithInCorrectData(): void + { + $timeStamp = 0; + $customerId = 8; + $fromStoreCode = 'store1'; + $data = new HashData( + [ + "customer_id" => $customerId, + "time_stamp" => $timeStamp, + "___from_store" => $fromStoreCode + ] + ); + $redirectUrl = "http://domain.com/"; + $fromStore = $this->createPartialMock(Store::class, ['getCode']); + $toStore = $this->createPartialMock(Store::class, ['getCode']); + $fromStore->expects($this->once())->method('getCode')->willReturn($fromStoreCode); + $targetUrl = $this->hashGenerator->switch($fromStore, $toStore, $redirectUrl); + // phpcs:ignore + $urlParts = parse_url($targetUrl,PHP_URL_QUERY); + $signature = ''; + // phpcs:ignore + parse_str($urlParts, $params); + + if (isset($params['signature'])) { + $signature = $params['signature']; + } + $this->assertFalse($this->hashGenerator->validateHash($signature, $data)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website.php new file mode 100644 index 000000000000..799cda7e9742 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website.php @@ -0,0 +1,21 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require_once __DIR__ . '/website.php'; + +/** + * @var \Magento\Store\Model\Group $storeGroup + */ +$storeGroup = $objectManager->create(\Magento\Store\Model\Group::class); +$storeGroup->setCode('some_group') + ->setName('custom store group') + ->setWebsite($website); +$storeGroup->save($storeGroup); + +/* Refresh stores memory cache */ +$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website_rollback.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website_rollback.php new file mode 100644 index 000000000000..e014dc940247 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_group_with_second_website_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require_once __DIR__ . '/website_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name.php b/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name.php new file mode 100644 index 000000000000..f1beaee683b8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +/** @var $store \Magento\Store\Model\Store */ +$store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); +$storeName = str_repeat('a', 255); +if (!$store->load('test', 'code')->getId()) { + $store->setData( + [ + 'code' => 'test_2', + 'website_id' => '1', + 'group_id' => '1', + 'name' => $storeName, + 'sort_order' => '10', + 'is_active' => '1', + ] + ); + $store->save(); +} else { + if ($store->getId()) { + /** @var \Magento\TestFramework\Helper\Bootstrap $registry */ + $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + \Magento\Framework\Registry::class + ); + $registry->unregister('isSecureArea'); + $registry->register('isSecureArea', true); + + $store->delete(); + + $registry->unregister('isSecureArea'); + $registry->register('isSecureArea', false); + + $store = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); + $store->setData( + [ + 'code' => 'test_2', + 'website_id' => '1', + 'group_id' => '1', + 'name' => $storeName, + 'sort_order' => '10', + 'is_active' => '1', + ] + ); + $store->save(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name_rollback.php b/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name_rollback.php new file mode 100644 index 000000000000..5fe19e1e97df --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Store/_files/store_with_long_name_rollback.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Registry; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); + +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var Store $store */ +$store = $objectManager->get(Store::class); +$store->load('test_2', 'code'); +if ($store->getId()) { + $store->delete(); +} + +/** @var Store $store */ +$store = $objectManager->get(Store::class); +$store->load('test_2', 'code'); +if ($store->getId()) { + $store->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Swatches/_files/swatch_attribute.php b/dev/tests/integration/testsuite/Magento/Swatches/_files/swatch_attribute.php index 182f4781a963..202fd0a8c73d 100644 --- a/dev/tests/integration/testsuite/Magento/Swatches/_files/swatch_attribute.php +++ b/dev/tests/integration/testsuite/Magento/Swatches/_files/swatch_attribute.php @@ -16,6 +16,7 @@ 'backend_type' => '', 'is_searchable' => 0, 'is_filterable' => 0, + 'is_user_defined' => 1, 'is_filterable_in_search' => 0, 'frontend_label' => 'Attribute ', 'entity_type_id' => 4 diff --git a/dev/tests/integration/testsuite/Magento/Ups/Model/CollectRatesTest.php b/dev/tests/integration/testsuite/Magento/Ups/Model/CollectRatesTest.php new file mode 100644 index 000000000000..7cfaa8c7de73 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Ups/Model/CollectRatesTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Ups\Model; + +/** + * Integration tests for online shipping carriers. + * @magentoAppIsolation enabled + */ +class CollectRatesTest extends \Magento\Shipping\Model\CollectRatesAbstract +{ + /** + * @var string + */ + protected $carrier = 'ups'; + + /** + * @var string + */ + protected $errorMessage = 'This shipping method is currently unavailable. ' . + 'If you would like to ship using this shipping method, please contact us.'; + + /** + * @magentoConfigFixture default_store carriers/ups/active 1 + * @magentoConfigFixture default_store carriers/ups/type UPS + * @magentoConfigFixture default_store carriers/ups/sallowspecific 1 + * @magentoConfigFixture default_store carriers/ups/specificcountry UK + * @magentoConfigFixture default_store carriers/ups/showmethod 1 + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod + public function testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable() + { + parent::testCollectRatesWhenShippingCarrierIsAvailableAndNotApplicable(); + } + + /** + * @magentoConfigFixture default_store carriers/ups/active 0 + * @magentoConfigFixture default_store carriers/ups/type UPS + * @magentoConfigFixture default_store carriers/ups/sallowspecific 1 + * @magentoConfigFixture default_store carriers/ups/specificcountry UK + * @magentoConfigFixture default_store carriers/ups/showmethod 1 + */ + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod + public function testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable() + { + parent::testCollectRatesWhenShippingCarrierIsNotAvailableAndNotApplicable(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php index 8dcc30951473..65cba5947ba0 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Edit/FormTest.php @@ -190,6 +190,7 @@ public function testGetEntityStoresCategoryStoresException() * * @static * @return array + * phpcs:disable Magento2.Functions.StaticFunction */ public static function formPostInitDataProvider() { @@ -226,6 +227,7 @@ public static function formPostInitDataProvider() * * @static * @return array + * phpcs:disable Magento2.Functions.StaticFunction */ public static function getEntityStoresDataProvider() { @@ -234,10 +236,11 @@ public static function getEntityStoresDataProvider() null, ['entity_id' => 3, 'store_ids' => [1]], [ - ['label' => 'Main Website', 'value' => []], + ['label' => 'Main Website', 'value' => [], '__disableTmpl' => true], [ 'label' => '    Main Website Store', - 'value' => [['label' => '    Default Store View', 'value' => 1]] + 'value' => [['label' => '    Default Store View', 'value' => 1]], + '__disableTmpl' => true ] ], ], @@ -245,10 +248,11 @@ public static function getEntityStoresDataProvider() ['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]], null, [ - ['label' => 'Main Website', 'value' => []], + ['label' => 'Main Website', 'value' => [], '__disableTmpl' => true], [ 'label' => '    Main Website Store', - 'value' => [['label' => '    Default Store View', 'value' => 1]] + 'value' => [['label' => '    Default Store View', 'value' => 1]], + '__disableTmpl' => true ] ] ], @@ -256,10 +260,11 @@ public static function getEntityStoresDataProvider() ['entity_id' => 2, 'name' => 'product2', 'url_key' => 'product2', 'store_ids' => [1]], ['entity_id' => 3, 'name' => 'product3', 'url_key' => 'product3', 'store_ids' => [1]], [ - ['label' => 'Main Website', 'value' => []], + ['label' => 'Main Website', 'value' => [], '__disableTmpl' => true], [ 'label' => '    Main Website Store', - 'value' => [['label' => '    Default Store View', 'value' => 1]] + 'value' => [['label' => '    Default Store View', 'value' => 1]], + '__disableTmpl' => true ] ] ] diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php index c3b93efece45..041a2c268a55 100644 --- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Cms/Page/Edit/FormTest.php @@ -78,10 +78,11 @@ public function testGetEntityStores() $form = $this->_getFormInstance($args); $expectedStores = [ - ['label' => 'Main Website', 'value' => []], + ['label' => 'Main Website', 'value' => [], '__disableTmpl' => true], [ 'label' => '    Main Website Store', - 'value' => [['label' => '    Default Store View', 'value' => 1]] + 'value' => [['label' => '    Default Store View', 'value' => 1]], + '__disableTmpl' => true ], ]; $this->assertEquals($expectedStores, $form->getElement('store_id')->getValues()); @@ -110,6 +111,7 @@ public function testGetEntityStoresProductStoresException() * * @static * @return array + * phpcs:disable Magento2.Functions.StaticFunction */ public static function formPostInitDataProvider() { diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index a6fc9999ad26..ba273f3d1b73 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -6,7 +6,6 @@ namespace Magento\User\Model; -use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\Encryption\Encryptor; /** @@ -29,11 +28,6 @@ class UserTest extends \PHPUnit\Framework\TestCase */ protected static $_newRole; - /** - * @var Json - */ - private $serializer; - /** * @var Encryptor */ @@ -47,9 +41,6 @@ protected function setUp() $this->_dateTime = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Framework\Stdlib\DateTime::class ); - $this->serializer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - Json::class - ); $this->encryptor = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( Encryptor::class ); @@ -133,7 +124,7 @@ public function testSaveExtra() $this->_model->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); $this->_model->saveExtra(['test' => 'val']); $this->_model->loadByUsername(\Magento\TestFramework\Bootstrap::ADMIN_NAME); - $extra = $this->serializer->unserialize($this->_model->getExtra()); + $extra = $this->_model->getExtra(); $this->assertEquals($extra['test'], 'val'); } diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute_rollback.php index 1d6e15b2e9a9..bced91f4a07b 100644 --- a/dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/fixed_product_attribute_rollback.php @@ -8,7 +8,7 @@ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -/* @var EavAttribute $attribute */ +/* @var \Magento\Eav\Model\Entity\Attribute $attribute */ $attribute = $objectManager->get(\Magento\Eav\Model\Entity\Attribute::class); $attribute->loadByCode(\Magento\Catalog\Model\Product::ENTITY, 'fixed_product_attribute'); $attribute->delete(); diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt.php b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt.php index 0e67a8947a79..59a5516bd67d 100644 --- a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt.php +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt.php @@ -16,6 +16,7 @@ $entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId(); $groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); +/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ $attribute = Bootstrap::getObjectManager()->create( \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class ); @@ -27,12 +28,15 @@ $groupId )->setAttributeSetId( $attributeSetId +)->setFrontendLabel( + 'fpt_for_all_front_label' )->setFrontendInput( 'weee' )->setIsUserDefined( 1 )->save(); +/** @var Product $product */ $product = Bootstrap::getObjectManager()->create(Product::class); $product->setTypeId( 'simple' diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt_rollback.php b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt_rollback.php index d0305f461eb0..a32c7c03a9f0 100644 --- a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_fpt_rollback.php @@ -13,12 +13,13 @@ /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); -$product->load(101); -if ($product->getId()) { + +$product = $product->loadByAttribute('sku', 'simple-with-ftp'); +if ($product && $product->getId()) { $product->delete(); } -/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */ +/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); $attribute->load('fpt_for_all', 'attribute_code'); diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt.php b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt.php new file mode 100644 index 000000000000..92137a59b1db --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Model\Product; +use Magento\TestFramework\Helper\Bootstrap; + +require __DIR__ . '/product_with_fpt.php'; + +/** @var \Magento\Catalog\Setup\CategorySetup $installer */ +$installer = Bootstrap::getObjectManager()->create( + \Magento\Catalog\Setup\CategorySetup::class +); +$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); +$entityModel = Bootstrap::getObjectManager()->create(\Magento\Eav\Model\Entity::class); +$entityTypeId = $entityModel->setType(Product::ENTITY)->getTypeId(); +$groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); + +/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ +$attribute = Bootstrap::getObjectManager()->create( + \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class +); +$attribute->setAttributeCode( + 'fixed_product_attribute' +)->setEntityTypeId( + $entityTypeId +)->setAttributeGroupId( + $groupId +)->setAttributeSetId( + $attributeSetId +)->setFrontendLabel( + 'fixed_product_attribute_front_label' +)->setFrontendInput( + 'weee' +)->setIsUserDefined( + 1 +)->save(); + +/** @var $product \Magento\Catalog\Model\Product */ +$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class); + +$product = $product->loadByAttribute('sku', 'simple-with-ftp'); +if ($product && $product->getId()) { + $product->setFixedProductAttribute( + [['website_id' => 0, 'country' => 'US', 'state' => 0, 'price' => 10.00, 'delete' => '']] + )->save(); +} diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt_rollback.php b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt_rollback.php new file mode 100644 index 000000000000..5e87438492dc --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/product_with_two_fpt_rollback.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var \Magento\Framework\Registry $registry */ +$registry = $objectManager->get(\Magento\Framework\Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */ +$attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class); +$attribute->load('fixed_product_attribute', 'attribute_code'); +if ($attribute->getId()) { + $attribute->delete(); +} + +require __DIR__ . '/product_with_fpt_rollback.php'; + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/PluginTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/PluginTest.php new file mode 100644 index 000000000000..5303c9f352b8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/PluginTest.php @@ -0,0 +1,72 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Wishlist\Controller\Index; + +use Magento\TestFramework\TestCase\AbstractController; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Catalog\Api\ProductRepositoryInterface; + +/** + * Test for wishlist plugin before dispatch + */ +class PluginTest extends AbstractController +{ + /** + * @var CustomerSession + */ + private $customerSession; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->customerSession = $this->_objectManager->get(CustomerSession::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->customerSession->logout(); + $this->customerSession = null; + parent::tearDown(); + } + + /** + * Test for adding product to wishlist with invalidate credentials + * + * @return void + * @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoAppArea frontend + */ + public function testAddActionProductWithInvalidCredentials(): void + { + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setPostValue( + [ + 'login' => [ + 'username' => 'invalidCustomer@example.com', + 'password' => 'invalidPassword', + ], + ] + ); + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->_objectManager->get(ProductRepositoryInterface::class); + + $product = $productRepository->get('product-with-xss'); + + $this->dispatch('wishlist/index/add/product/' . $product->getId() . '?nocookie=1'); + + $this->assertArrayNotHasKey('login', $this->customerSession->getBeforeWishlistRequest()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php index e020d31838f0..f43133c92fc3 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php @@ -98,9 +98,12 @@ public function testAddActionProductNameXss() { /** @var \Magento\Framework\Data\Form\FormKey $formKey */ $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class); - $this->getRequest()->setPostValue([ - 'form_key' => $formKey->getFormKey(), - ]); + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setPostValue( + [ + 'form_key' => $formKey->getFormKey(), + ] + ); /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js new file mode 100644 index 000000000000..66f7731415c0 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js @@ -0,0 +1,85 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'squire', + 'jquery' +], function (Squire, $) { + 'use strict'; + + var injector = new Squire(), + setPaymentInformation, + serviceUrl = 'http://url', + mocks = { + 'Magento_Checkout/js/model/quote': { + getQuoteId: jasmine.createSpy().and.returnValue(1), + billingAddress: jasmine.createSpy().and.returnValue(null) + }, + 'Magento_Checkout/js/model/url-builder': { + createUrl: jasmine.createSpy().and.returnValue(serviceUrl) + }, + 'mage/storage': { + post: function () {} // jscs:ignore jsDoc + }, + 'Magento_Customer/js/model/customer': { + isLoggedIn: jasmine.createSpy().and.returnValue(false) + }, + 'Magento_Checkout/js/model/full-screen-loader': { + startLoader: jasmine.createSpy(), + stopLoader: jasmine.createSpy() + }, + 'Magento_Checkout/js/action/get-totals': jasmine.createSpy('getTotalsAction'), + 'Magento_Checkout/js/model/error-processor': jasmine.createSpy('errorProcessor') + }; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require( + ['Magento_Checkout/js/action/set-payment-information-extended'], + function (action) { + setPaymentInformation = action; + done(); + }); + }); + + afterEach(function () { + try { + injector.clean(); + injector.remove(); + } catch (e) { + } + }); + + describe('Magento/Checkout/js/action/set-payment-information-extended', function () { + it('Checks that paymentData consist correct data value.', function () { + var messageContainer = jasmine.createSpy('messageContainer'), + deferral = new $.Deferred(), + paymentData = { + method: 'checkmo', + additionalData: null, + __disableTmpl: { + title: true + } + }, + payload = { + cartId: 1, + paymentMethod: { + method: 'checkmo', + additionalData: null + }, + billingAddress: null + }; + + spyOn(mocks['mage/storage'], 'post').and.callFake(function () { + return deferral.resolve({}); + }); + + setPaymentInformation(messageContainer, paymentData, false); + expect(mocks['Magento_Checkout/js/model/full-screen-loader'].startLoader).toHaveBeenCalled(); + expect(mocks['mage/storage'].post).toHaveBeenCalledWith(serviceUrl, JSON.stringify(payload)); + expect(mocks['Magento_Checkout/js/model/full-screen-loader'].stopLoader).toHaveBeenCalled(); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/view/payment/method-renderer/in-context/checkout-express.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/view/payment/method-renderer/in-context/checkout-express.test.js index c2a20c8339c7..8ea992ce30e4 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/view/payment/method-renderer/in-context/checkout-express.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Paypal/frontend/js/view/payment/method-renderer/in-context/checkout-express.test.js @@ -35,7 +35,8 @@ define([ beforeAll(function (done) { window.checkoutConfig = { quoteData: { - entityId: 1 + /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */ + entity_Id: 1 }, formKey: 'formKey' }; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js new file mode 100644 index 000000000000..bf0ff3466c52 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.test.js @@ -0,0 +1,80 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'jquery', + 'Magento_Swatches/js/swatch-renderer' +], function ($, SwatchRenderer) { + 'use strict'; + + describe('Testing "_RenderSwatchOptions" method of SwatchRenderer Widget', function () { + var widget, + html, + optionConfig, + attribute, + optionId = 2, + swathImageHeight = '60', + swathImageWidth = '70', + swathThumbImageHeight = '40', + swathThumbImageWidth = '50'; + + beforeEach(function () { + widget = new SwatchRenderer(); + attribute = { + id: 1, + options: [{ + id: optionId + }] + }; + widget.options = { + classes: { + optionClass: 'swatch-option' + }, + jsonSwatchConfig: { + 1: { + 2: { + type: 2 + } + } + }, + jsonSwatchImageSizeConfig: { + swatchImage: { + width: swathImageWidth, + height: swathImageHeight + }, + swatchThumb: { + width: swathThumbImageWidth, + height: swathThumbImageHeight + } + } + }; + optionConfig = widget.options.jsonSwatchConfig[attribute.id]; + html = $(widget._RenderSwatchOptions(attribute, 'option-label-control-id-1'))[0]; + }); + + it('check if swatch config has attribute id', function () { + expect(widget.options.jsonSwatchConfig.hasOwnProperty(attribute.id)).toEqual(true); + }); + + it('check if option config has option id', function () { + expect(optionConfig.hasOwnProperty(optionId)).toEqual(true); + }); + + it('check swatch thumbnail image height attribute', function () { + expect(html.hasAttribute('thumb-height')).toBe(true); + expect(html.getAttribute('thumb-height')).toEqual(swathThumbImageHeight); + }); + + it('check swatch thumbnail image width attribute', function () { + expect(html.hasAttribute('thumb-width')).toBe(true); + expect(html.getAttribute('thumb-width')).toEqual(swathThumbImageWidth); + }); + + it('check swatch image styles', function () { + expect(html.style.height).toEqual(swathImageHeight + 'px'); + expect(html.style.width).toEqual(swathImageWidth + 'px'); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/lib/mage/translate.test.js b/dev/tests/js/jasmine/tests/lib/mage/translate.test.js index c87cfa227c1a..dc6c6ce7eb96 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/translate.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/translate.test.js @@ -9,11 +9,16 @@ define([ ], function ($) { 'use strict'; + // be careful with test variation order as one variation can affect another one describe('Test for mage/translate jQuery plugin', function () { it('works with one string as parameter', function () { $.mage.translate.add('Hello World!'); expect('Hello World!').toEqual($.mage.translate.translate('Hello World!')); }); + it('works with translation alias __', function () { + $.mage.translate.add('Hello World!'); + expect('Hello World!').toEqual($.mage.__('Hello World!')); + }); it('works with one array as parameter', function () { $.mage.translate.add(['Hello World!', 'Bonjour tout le monde!']); expect('Hello World!').toEqual($.mage.translate.translate('Hello World!')); @@ -40,10 +45,6 @@ define([ $.mage.translate.add('Hello World!', 'Bonjour tout le monde!'); expect('Bonjour tout le monde!').toEqual($.mage.translate.translate('Hello World!')); }); - it('works with translation alias __', function () { - $.mage.translate.add('Hello World!'); - expect('Hello World!').toEqual($.mage.__('Hello World!')); - }); }); }); diff --git a/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php b/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php index 408853141e53..611d5ec15bdc 100644 --- a/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php +++ b/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php @@ -11,9 +11,9 @@ use Magento\CodeMessDetector\Rule\Design\AllPurposeAction; use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\ActionInterface; -use PHPUnit\Framework\TestCase as TestCase; +use PHPUnit\Framework\TestCase; use PHPUnit_Framework_MockObject_MockObject as MockObject; -use PHPUnit\Framework\MockObject\Builder\InvocationMocker as InvocationMocker; +use PHPUnit\Framework\MockObject\Builder\InvocationMocker; use PHPMD\Report; use PHPMD\Node\ClassNode; @@ -40,7 +40,8 @@ public function getCases(): array { return [ [ - new class implements ActionInterface, HttpGetActionInterface { + new class implements ActionInterface, HttpGetActionInterface + { /** * @inheritDoc */ @@ -52,7 +53,8 @@ public function execute() false ], [ - new class implements ActionInterface { + new class implements ActionInterface + { /** * @inheritDoc */ @@ -64,7 +66,8 @@ public function execute() true ], [ - new class implements HttpGetActionInterface { + new class implements HttpGetActionInterface + { /** * @inheritDoc */ @@ -76,7 +79,8 @@ public function execute() false ], [ - new class { + new class + { }, false @@ -94,13 +98,15 @@ private function createNodeMock($dynamicObject): MockObject $node = $this->getMockBuilder(ClassNode::class) ->disableOriginalConstructor() ->disableProxyingToOriginalMethods() - ->setMethods([ - // disable name lookup from AST artifact - 'getNamespaceName', - 'getParentName', - 'getName', - 'getFullQualifiedName', - ]) + ->setMethods( + [ + // disable name lookup from AST artifact + 'getNamespaceName', + 'getParentName', + 'getName', + 'getFullQualifiedName', + ] + ) ->getMock(); $node->expects($this->any()) ->method('getFullQualifiedName') @@ -114,10 +120,8 @@ private function createNodeMock($dynamicObject): MockObject * @param bool $expects * @return InvocationMocker */ - private function expectsRuleViolation( - AllPurposeAction $rule, - bool $expects - ): InvocationMocker { + private function expectsRuleViolation(AllPurposeAction $rule, bool $expects): InvocationMocker + { /** @var Report|MockObject $report */ $report = $this->getMockBuilder(Report::class)->getMock(); if ($expects) { diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php index 5c342614f94f..f9630fd8cc05 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/PhtmlTemplateTest.php @@ -7,6 +7,8 @@ */ namespace Magento\Test\Legacy; +use Magento\Framework\Component\ComponentRegistrar; + /** * Static test for phtml template files. */ @@ -105,4 +107,84 @@ function ($file) { \Magento\Framework\App\Utility\Files::init()->getPhtmlFiles() ); } + + public function testJsComponentsAreProperlyInitializedInDataMageInitAttribute() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $invoker( + /** + * JS components in data-mage-init attributes should be initialized not in php. + * JS components should be initialized in templates for them to be properly statically analyzed for bundling. + * + * @param string $file + */ + function ($file) { + $whiteList = $this->getWhiteList(); + if (!in_array($file, $whiteList, true) + && (strpos($file, '/view/frontend/templates/') !== false + || strpos($file, '/view/base/templates/') !== false) + ) { + self::assertNotRegExp( + '/data-mage-init=(?:\'|")(?!\s*{\s*"[^"]+")/', + file_get_contents($file), + 'Please do not initialize JS component in php. Do it in template.' + ); + } + }, + \Magento\Framework\App\Utility\Files::init()->getPhtmlFiles() + ); + } + + /** + * @return array + */ + private function getWhiteList() + { + $whiteListFiles = []; + $componentRegistrar = new ComponentRegistrar(); + foreach ($this->getFilesData('data_mage_init/whitelist.php') as $fileInfo) { + $whiteListFiles[] = $componentRegistrar->getPath(ComponentRegistrar::MODULE, $fileInfo[0]) + . DIRECTORY_SEPARATOR . $fileInfo[1]; + } + return $whiteListFiles; + } + + /** + * @param string $filePattern + * @return array + */ + private function getFilesData($filePattern) + { + $result = []; + foreach (glob(__DIR__ . '/_files/initialize_javascript/' . $filePattern) as $file) { + $fileData = include $file; + $result = array_merge($result, $fileData); + } + return $result; + } + + public function testJsComponentsAreProperlyInitializedInXMagentoInitAttribute() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $invoker( + /** + * JS components in x-magento-init attributes should be initialized not in php. + * JS components should be initialized in templates for them to be properly statically analyzed for bundling. + * + * @param string $file + */ + function ($file) { + if (strpos($file, '/view/frontend/templates/') !== false + || strpos($file, '/view/base/templates/') !== false + ) { + self::assertNotRegExp( + '@x-magento-init.>(?!\s*+{\s*"[^"]+"\s*:\s*{\s*"[\w/-]+")@i', + file_get_contents($file), + 'Please do not initialize JS component in php. Do it in template.' + ); + } + }, + \Magento\Framework\App\Utility\Files::init()->getPhtmlFiles() + ); + } } diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/initialize_javascript/data_mage_init/whitelist.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/initialize_javascript/data_mage_init/whitelist.php new file mode 100644 index 000000000000..a77b7b28864e --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/initialize_javascript/data_mage_init/whitelist.php @@ -0,0 +1,14 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/** + * List of templates with data-mage-init attribute where JS component is not correctly called. + * + * JS component is initialized in php here. These templates cannot be refactored easily. This list consists of + * module name and template path within module. + */ +return [ + ['Magento_Braintree', 'view/frontend/templates/paypal/button_shopping_cart.phtml'] +]; 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 9417baea67ba..ff8e7db0f426 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 @@ -1982,8 +1982,8 @@ ['_escapeDefaultValue', 'Magento\Framework\Code\Generator\EntityAbstract'], ['urlEncode', 'Magento\Framework\App\Helper\AbstractHelper', 'Magento\Framework\Url\EncoderInterface::encode'], ['urlDecode', 'Magento\Framework\App\Helper\AbstractHelper', 'Magento\Framework\Url\DecoderInterface::decode'], - ['isModuleEnabled', 'Magento\Framework\App\Helper\AbstractHelper', '\Magento\Framework\Module\ModuleManagerInterface::isEnabled()'], - ['isModuleOutputEnabled', 'Magento\Framework\App\Helper\AbstractHelper', '\Magento\Framework\Module\ModuleManagerInterface::isOutputEnabled()'], + ['isModuleEnabled', 'Magento\Framework\App\Helper\AbstractHelper', 'Magento\Framework\Module\Manager::isEnabled()'], + ['isModuleOutputEnabled', 'Magento\Framework\App\Helper\AbstractHelper', 'Magento\Framework\Module\Manager::isOutputEnabled()'], ['_packToTar', 'Magento\Framework\Archive\Tar'], ['_parseHeader', 'Magento\Framework\Archive\Tar'], ['getIdentities', 'Magento\Wishlist\Block\Link'], diff --git a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php index 68762a8a6c04..7f7a4761b17a 100644 --- a/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php +++ b/lib/internal/Magento/Framework/Acl/AclResource/Config/Converter/Dom.php @@ -5,10 +5,13 @@ */ namespace Magento\Framework\Acl\AclResource\Config\Converter; +/** + * @inheritDoc + */ class Dom implements \Magento\Framework\Config\ConverterInterface { /** - * {@inheritdoc} + * @inheritdoc * * @param \DOMDocument $source * @return array @@ -39,6 +42,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode) $resourceAttributes = $resourceNode->attributes; $idNode = $resourceAttributes->getNamedItem('id'); if ($idNode === null) { + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new \Exception('Attribute "id" is required for ACL resource.'); } $resourceData['id'] = $idNode->nodeValue; @@ -53,7 +57,7 @@ protected function _convertResourceNode(\DOMNode $resourceNode) $sortOrderNode = $resourceAttributes->getNamedItem('sortOrder'); $resourceData['sortOrder'] = $sortOrderNode !== null ? (int)$sortOrderNode->nodeValue : 0; $disabledNode = $resourceAttributes->getNamedItem('disabled'); - $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true' ? true : false; + $resourceData['disabled'] = $disabledNode !== null && $disabledNode->nodeValue == 'true'; // convert child resource nodes if needed $resourceData['children'] = []; /** @var $childNode \DOMNode */ diff --git a/lib/internal/Magento/Framework/Acl/Loader/ResourceLoader.php b/lib/internal/Magento/Framework/Acl/Loader/ResourceLoader.php index af781e19d045..567216c29dca 100644 --- a/lib/internal/Magento/Framework/Acl/Loader/ResourceLoader.php +++ b/lib/internal/Magento/Framework/Acl/Loader/ResourceLoader.php @@ -8,7 +8,7 @@ namespace Magento\Framework\Acl\Loader; use Magento\Framework\Acl; -use Magento\Framework\Acl\AclResource as AclResource; +use Magento\Framework\Acl\AclResource; use Magento\Framework\Acl\AclResource\ProviderInterface; use Magento\Framework\Acl\AclResourceFactory; diff --git a/lib/internal/Magento/Framework/Amqp/composer.json b/lib/internal/Magento/Framework/Amqp/composer.json index 796356142058..8c0a3e3070aa 100644 --- a/lib/internal/Magento/Framework/Amqp/composer.json +++ b/lib/internal/Magento/Framework/Amqp/composer.json @@ -12,7 +12,7 @@ "require": { "magento/framework": "*", "php": "~7.1.3||~7.2.0||~7.3.0", - "php-amqplib/php-amqplib": "~2.7.0" + "php-amqplib/php-amqplib": "~2.7.0|~2.10.0" }, "autoload": { "psr-4": { diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessor.php b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessor.php index 28f053e1afa8..4135a2338e64 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessor.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessor.php @@ -7,7 +7,7 @@ namespace Magento\Framework\Api\ExtensionAttribute; use Magento\Framework\Api\ExtensionAttribute\Config; -use Magento\Framework\Api\ExtensionAttribute\Config\Converter as Converter; +use Magento\Framework\Api\ExtensionAttribute\Config\Converter; use Magento\Framework\Data\Collection\AbstractDb as DbCollection; use Magento\Framework\Reflection\TypeProcessor; use Magento\Framework\Api\ExtensibleDataInterface; @@ -61,7 +61,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function process(DbCollection $collection, $extensibleEntityClass = null) { @@ -95,7 +95,7 @@ private function getReferenceTableAlias($attributeCode) } /** - * {@inheritdoc} + * @inheritdoc */ public function extractExtensionAttributes($extensibleEntityClass, array $data) { @@ -127,10 +127,9 @@ public function extractExtensionAttributes($extensibleEntityClass, array $data) * * @param string $attributeCode * @param array $directive - * @param array &$data - * @param array &$extensionData + * @param array $data + * @param array $extensionData * @param string $extensibleEntityClass - * @return void */ private function populateAttributeCodeWithDirective( $attributeCode, diff --git a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessorHelper.php b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessorHelper.php index f49c1fd0b515..24d04dfa01db 100644 --- a/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessorHelper.php +++ b/lib/internal/Magento/Framework/Api/ExtensionAttribute/JoinProcessorHelper.php @@ -7,7 +7,7 @@ namespace Magento\Framework\Api\ExtensionAttribute; use Magento\Framework\Api\ExtensionAttribute\Config; -use Magento\Framework\Api\ExtensionAttribute\Config\Converter as Converter; +use Magento\Framework\Api\ExtensionAttribute\Config\Converter; use Magento\Framework\Api\SimpleDataObjectConverter; /** diff --git a/lib/internal/Magento/Framework/Api/SearchResults.php b/lib/internal/Magento/Framework/Api/SearchResults.php index ad58d0a75265..cf1f11463f6a 100644 --- a/lib/internal/Magento/Framework/Api/SearchResults.php +++ b/lib/internal/Magento/Framework/Api/SearchResults.php @@ -3,11 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\Api; /** * SearchResults Service Data Object used for the search service requests + * + * @SuppressWarnings(PHPMD.NumberOfChildren) */ class SearchResults extends AbstractSimpleObject implements SearchResultsInterface { diff --git a/lib/internal/Magento/Framework/Api/SearchResultsInterface.php b/lib/internal/Magento/Framework/Api/SearchResultsInterface.php index d2bc3053b8d6..ba72685a80f4 100644 --- a/lib/internal/Magento/Framework/Api/SearchResultsInterface.php +++ b/lib/internal/Magento/Framework/Api/SearchResultsInterface.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\Api; diff --git a/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php b/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php index 30cb4a67b9ed..a4c9fb438065 100644 --- a/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php +++ b/lib/internal/Magento/Framework/App/Cache/Frontend/Pool.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\App\Cache\Frontend; use Magento\Framework\App\Cache\Type\FrontendPool; @@ -55,6 +56,7 @@ public function __construct( /** * Create instances of every cache frontend known to the system. + * * Method is to be used for delayed initialization of the iterator. * * @return void @@ -77,18 +79,21 @@ protected function _initialize() protected function _getCacheSettings() { /* - * Merging is intentionally implemented through array_merge() instead of array_replace_recursive() - * to avoid "inheritance" of the default settings that become irrelevant as soon as cache storage type changes + * Merging is intentionally implemented through array_replace_recursive() instead of array_merge(), because even + * though some settings may become irrelevant when the cache storage type is changed, they don't do any harm + * and can be overwritten when needed. + * Also array_merge leads to unexpected behavior, for for example by dropping the + * default cache_dir setting from di.xml when a cache id_prefix is configured in app/etc/env.php. */ $cacheInfo = $this->deploymentConfig->getConfigData(FrontendPool::KEY_CACHE); if (null !== $cacheInfo) { - return array_merge($this->_frontendSettings, $cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]); + return array_replace_recursive($this->_frontendSettings, $cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]); } return $this->_frontendSettings; } /** - * {@inheritdoc} + * @inheritdoc * * @return \Magento\Framework\Cache\FrontendInterface */ @@ -99,7 +104,7 @@ public function current() } /** - * {@inheritdoc} + * @inheritdoc */ public function key() { @@ -108,7 +113,7 @@ public function key() } /** - * {@inheritdoc} + * @inheritdoc */ public function next() { @@ -117,7 +122,7 @@ public function next() } /** - * {@inheritdoc} + * @inheritdoc */ public function rewind() { @@ -126,7 +131,7 @@ public function rewind() } /** - * {@inheritdoc} + * @inheritdoc */ public function valid() { diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php index ff7077213c5c..a53ea9423d44 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Reader.php @@ -16,7 +16,6 @@ /** * Deployment configuration reader. * Loads the merged configuration from config files. - * * @see FileReader The reader for specific configuration file */ class Reader @@ -107,11 +106,9 @@ public function load($fileKey = null) } } } else { - $configFiles = $this->configFilePool->getPaths(); - $allFilesData = []; - $result = []; - foreach (array_keys($configFiles) as $fileKey) { - $configFile = $path . '/' . $this->configFilePool->getPath($fileKey); + $configFiles = $this->getFiles(); + foreach ($configFiles as $file) { + $configFile = $path . '/' . $file; if ($fileDriver->isExists($configFile)) { $fileData = include $configFile; if (!is_array($fileData)) { @@ -120,7 +117,6 @@ public function load($fileKey = null) } else { continue; } - $allFilesData[$configFile] = $fileData; if ($fileData) { $result = array_replace_recursive($result, $fileData); } @@ -136,6 +132,8 @@ public function load($fileKey = null) * @param string $pathConfig The path config * @param bool $ignoreInitialConfigFiles Whether ignore custom pools * @return array + * @throws FileSystemException + * @throws RuntimeException * @deprecated 100.2.0 Magento does not support custom config file pools since 2.2.0 version * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ diff --git a/lib/internal/Magento/Framework/App/Helper/AbstractHelper.php b/lib/internal/Magento/Framework/App/Helper/AbstractHelper.php index 7875e0c8885f..1a76610bc081 100644 --- a/lib/internal/Magento/Framework/App/Helper/AbstractHelper.php +++ b/lib/internal/Magento/Framework/App/Helper/AbstractHelper.php @@ -27,7 +27,7 @@ abstract class AbstractHelper protected $_request; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -125,7 +125,7 @@ protected function _getModuleName() * * @param string $moduleName Full module name * @return boolean - * use \Magento\Framework\Module\ModuleManagerInterface::isOutputEnabled() + * use \Magento\Framework\Module\Manager::isOutputEnabled() */ public function isModuleOutputEnabled($moduleName = null) { diff --git a/lib/internal/Magento/Framework/App/Helper/Context.php b/lib/internal/Magento/Framework/App/Helper/Context.php index cc57f109cc8e..5b90df8c5520 100644 --- a/lib/internal/Magento/Framework/App/Helper/Context.php +++ b/lib/internal/Magento/Framework/App/Helper/Context.php @@ -21,7 +21,7 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface { /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ protected $_moduleManager; @@ -79,7 +79,7 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface * @param \Magento\Framework\Url\EncoderInterface $urlEncoder * @param \Magento\Framework\Url\DecoderInterface $urlDecoder * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\Module\ModuleManagerInterface $moduleManager + * @param \Magento\Framework\Module\Manager $moduleManager * @param \Magento\Framework\App\RequestInterface $httpRequest * @param \Magento\Framework\Cache\ConfigInterface $cacheConfig * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -94,7 +94,7 @@ public function __construct( \Magento\Framework\Url\EncoderInterface $urlEncoder, \Magento\Framework\Url\DecoderInterface $urlDecoder, \Psr\Log\LoggerInterface $logger, - \Magento\Framework\Module\ModuleManagerInterface $moduleManager, + \Magento\Framework\Module\Manager $moduleManager, \Magento\Framework\App\RequestInterface $httpRequest, \Magento\Framework\Cache\ConfigInterface $cacheConfig, \Magento\Framework\Event\ManagerInterface $eventManager, @@ -119,7 +119,7 @@ public function __construct( /** * Get module manager. * - * @return \Magento\Framework\Module\ModuleManagerInterface + * @return \Magento\Framework\Module\Manager */ public function getModuleManager() { diff --git a/lib/internal/Magento/Framework/App/MaintenanceMode.php b/lib/internal/Magento/Framework/App/MaintenanceMode.php index e813522a0151..11347e4220c2 100644 --- a/lib/internal/Magento/Framework/App/MaintenanceMode.php +++ b/lib/internal/Magento/Framework/App/MaintenanceMode.php @@ -110,7 +110,7 @@ public function setAddresses($addresses) throw new \InvalidArgumentException("One or more IP-addresses is expected (comma-separated)\n"); } $result = $this->flagDir->writeFile(self::IP_FILENAME, $addresses); - return false !== $result ? true : false; + return false !== $result; } /** diff --git a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php index 1c05c5847360..b781a92b4714 100644 --- a/lib/internal/Magento/Framework/App/ObjectManagerFactory.php +++ b/lib/internal/Magento/Framework/App/ObjectManagerFactory.php @@ -106,7 +106,10 @@ public function __construct(DirectoryList $directoryList, DriverPool $driverPool public function create(array $arguments) { $writeFactory = new \Magento\Framework\Filesystem\Directory\WriteFactory($this->driverPool); - $generatedFiles = new GeneratedFiles($this->directoryList, $writeFactory); + /** @var \Magento\Framework\Filesystem\Driver\File $fileDriver */ + $fileDriver = $this->driverPool->getDriver(DriverPool::FILE); + $lockManager = new \Magento\Framework\Lock\Backend\FileLock($fileDriver, BP); + $generatedFiles = new GeneratedFiles($this->directoryList, $writeFactory, $lockManager); $generatedFiles->cleanGeneratedFiles(); $deploymentConfig = $this->createDeploymentConfig($this->directoryList, $this->configFilePool, $arguments); diff --git a/lib/internal/Magento/Framework/App/ProductMetadata.php b/lib/internal/Magento/Framework/App/ProductMetadata.php index 631dba8273bc..052119713294 100644 --- a/lib/internal/Magento/Framework/App/ProductMetadata.php +++ b/lib/internal/Magento/Framework/App/ProductMetadata.php @@ -30,9 +30,9 @@ class ProductMetadata implements ProductMetadataInterface const PRODUCT_NAME = 'Magento'; /** - * Cache key for Magento product version + * Magento version cache key */ - private const MAGENTO_PRODUCT_VERSION_CACHE_KEY = 'magento-product-version'; + const VERSION_CACHE_KEY = 'mage-version'; /** * Product version @@ -58,11 +58,14 @@ class ProductMetadata implements ProductMetadataInterface private $cache; /** + * ProductMetadata constructor. * @param ComposerJsonFinder $composerJsonFinder - * @param CacheInterface|null $cache + * @param \Magento\Framework\App\CacheInterface $cache */ - public function __construct(ComposerJsonFinder $composerJsonFinder, CacheInterface $cache = null) - { + public function __construct( + ComposerJsonFinder $composerJsonFinder, + CacheInterface $cache = null + ) { $this->composerJsonFinder = $composerJsonFinder; $this->cache = $cache ?: ObjectManager::getInstance()->get(CacheInterface::class); } @@ -74,9 +77,7 @@ public function __construct(ComposerJsonFinder $composerJsonFinder, CacheInterfa */ public function getVersion() { - if ($cachedVersion = $this->cache->load(self::MAGENTO_PRODUCT_VERSION_CACHE_KEY)) { - $this->version = $cachedVersion; - } + $this->version = $this->version ?: $this->cache->load(self::VERSION_CACHE_KEY); if (!$this->version) { if (!($this->version = $this->getSystemPackageVersion())) { if ($this->getComposerInformation()->isMagentoRoot()) { @@ -84,8 +85,8 @@ public function getVersion() } else { $this->version = 'UNKNOWN'; } + $this->cache->save($this->version, self::VERSION_CACHE_KEY, [Config::CACHE_TAG]); } - $this->cache->save($this->version, self::MAGENTO_PRODUCT_VERSION_CACHE_KEY); } return $this->version; } diff --git a/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php b/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php index f15ce494e9bb..e15a5151942f 100644 --- a/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php +++ b/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php @@ -32,7 +32,7 @@ class InvalidRequestException extends RuntimeException /** * @param ResponseInterface|ResultInterface|NotFoundException $replaceResult * Use this result instead of calling an action instance, - * if NotFoundException is given the the default 404 mechanism will be triggered. + * if NotFoundException is given the default 404 mechanism will be triggered. * @param Phrase[]|null $messages Messages to show to client * as error messages. */ @@ -45,6 +45,8 @@ public function __construct($replaceResult, ?array $messages = null) } /** + * Return replaced result + * * @return ResponseInterface|ResultInterface|NotFoundException */ public function getReplaceResult() @@ -53,6 +55,8 @@ public function getReplaceResult() } /** + * Return messages + * * @return Phrase[]|null */ public function getMessages(): ?array diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php index bfa37311884b..5ec3dd658737 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Cache/Frontend/PoolTest.php @@ -8,6 +8,9 @@ use Magento\Framework\App\Cache\Frontend\Pool; use Magento\Framework\App\Cache\Type\FrontendPool; +/** + * And another docblock to make the sniff shut up. + */ class PoolTest extends \PHPUnit\Framework\TestCase { /** @@ -111,25 +114,38 @@ public function testInitializationParams( public function initializationParamsDataProvider() { return [ - 'default frontend, default settings' => [ + 'no deployment config, default settings' => [ ['frontend' => []], [Pool::DEFAULT_FRONTEND_ID => ['default_option' => 'default_value']], ['default_option' => 'default_value'], ], - 'default frontend, overridden settings' => [ + 'deployment config, default settings' => [ + ['frontend' => [Pool::DEFAULT_FRONTEND_ID => ['configured_option' => 'configured_value']]], + [Pool::DEFAULT_FRONTEND_ID => ['default_option' => 'default_value']], + ['configured_option' => 'configured_value', 'default_option' => 'default_value'], + ], + 'deployment config, overridden settings' => [ ['frontend' => [Pool::DEFAULT_FRONTEND_ID => ['configured_option' => 'configured_value']]], - [Pool::DEFAULT_FRONTEND_ID => ['ignored_option' => 'ignored_value']], + [Pool::DEFAULT_FRONTEND_ID => ['configured_option' => 'default_value']], ['configured_option' => 'configured_value'], ], - 'custom frontend, default settings' => [ - ['frontend' => []], + 'deployment config, default settings, overridden settings' => [ + ['frontend' => [Pool::DEFAULT_FRONTEND_ID => ['configured_option' => 'configured_value']]], + [Pool::DEFAULT_FRONTEND_ID => [ + 'configured_option' => 'default_value', + 'default_setting' => 'default_value' + ]], + ['configured_option' => 'configured_value', 'default_setting' => 'default_value'], + ], + 'custom deployent config, default settings' => [ + ['frontend' => ['custom' => ['configured_option' => 'configured_value']]], ['custom' => ['default_option' => 'default_value']], - ['default_option' => 'default_value'], + ['configured_option' => 'configured_value', 'default_option' => 'default_value'], ], - 'custom frontend, overridden settings' => [ + 'custom deployent config, default settings, overridden settings' => [ ['frontend' => ['custom' => ['configured_option' => 'configured_value']]], - ['custom' => ['ignored_option' => 'ignored_value']], - ['configured_option' => 'configured_value'], + ['custom' => ['default_option' => 'default_value', 'configured_option' => 'default_value']], + ['configured_option' => 'configured_value', 'default_option' => 'default_value'], ] ]; } diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php index 8f8399263384..8a8bebb4d2f8 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfig/ReaderTest.php @@ -43,17 +43,18 @@ protected function setUp() ->willReturn(__DIR__ . '/_files'); $this->fileDriver = $this->createMock(File::class); $this->fileDriver - ->expects($this->any()) ->method('isExists') - ->will($this->returnValueMap([ - [__DIR__ . '/_files/config.php', true], - [__DIR__ . '/_files/custom.php', true], - [__DIR__ . '/_files/duplicateConfig.php', true], - [__DIR__ . '/_files/env.php', true], - [__DIR__ . '/_files/mergeOne.php', true], - [__DIR__ . '/_files/mergeTwo.php', true], - [__DIR__ . '/_files/nonexistent.php', false] - ])); + ->willReturnMap( + [ + [__DIR__.'/_files/config.php', true], + [__DIR__.'/_files/custom.php', true], + [__DIR__.'/_files/duplicateConfig.php', true], + [__DIR__.'/_files/env.php', true], + [__DIR__.'/_files/mergeOne.php', true], + [__DIR__.'/_files/mergeTwo.php', true], + [__DIR__.'/_files/nonexistent.php', false] + ] + ); $this->driverPool = $this->createMock(DriverPool::class); $this->driverPool ->expects($this->any()) @@ -152,8 +153,9 @@ public function testLoadInvalidConfigurationFileWithFileKey() * @expectedException \Magento\Framework\Exception\RuntimeException * @expectedExceptionMessageRegExp /Invalid configuration file: \'.*\/\_files\/emptyConfig\.php\'/ * @return void + * @throws \Magento\Framework\Exception\FileSystemException */ - public function testLoadInvalidConfigurationFile() + public function testLoadInvalidConfigurationFile(): void { $fileDriver = $this->getMockBuilder(File::class) ->disableOriginalConstructor() @@ -173,7 +175,7 @@ public function testLoadInvalidConfigurationFile() $configFilePool = $this->getMockBuilder(ConfigFilePool::class) ->disableOriginalConstructor() ->getMock(); - $configFilePool->expects($this->exactly(2)) + $configFilePool->expects($this->once()) ->method('getPaths') ->willReturn( [ @@ -181,15 +183,6 @@ public function testLoadInvalidConfigurationFile() 'testConfig' => 'emptyConfig.php' ] ); - $configFilePool->expects($this->exactly(2)) - ->method('getPath') - ->withConsecutive( - [$this->identicalTo('configKeyOne')], - [$this->identicalTo('testConfig')] - )->willReturnOnConsecutiveCalls( - 'config.php', - 'emptyConfig.php' - ); $object = new Reader($this->dirList, $driverPool, $configFilePool); $object->load(); } diff --git a/lib/internal/Magento/Framework/App/Utility/Files.php b/lib/internal/Magento/Framework/App/Utility/Files.php index 3460faf854ba..d329a7db029e 100644 --- a/lib/internal/Magento/Framework/App/Utility/Files.php +++ b/lib/internal/Magento/Framework/App/Utility/Files.php @@ -24,44 +24,20 @@ */ class Files { - /** - * Include app code - */ const INCLUDE_APP_CODE = 1; - /** - * Include tests - */ const INCLUDE_TESTS = 2; - /** - * Include dev tools - */ const INCLUDE_DEV_TOOLS = 4; - /** - * Include templates - */ const INCLUDE_TEMPLATES = 8; - /** - * Include lib files - */ const INCLUDE_LIBS = 16; - /** - * Include pub code - */ const INCLUDE_PUB_CODE = 32; - /** - * Include non classes - */ const INCLUDE_NON_CLASSES = 64; - /** - * Include setup - */ const INCLUDE_SETUP = 128; /** @@ -395,11 +371,11 @@ public function getMainConfigFiles($asDataSet = true) } $globPaths = [BP . '/app/etc/config.xml', BP . '/app/etc/*/config.xml']; $configXmlPaths = array_merge($globPaths, $configXmlPaths); - $files = []; + $files = [[]]; foreach ($configXmlPaths as $xmlPath) { - $files = array_merge($files, glob($xmlPath, GLOB_NOSORT)); + $files[] = glob($xmlPath, GLOB_NOSORT); } - self::$_cache[$cacheKey] = $files; + self::$_cache[$cacheKey] = array_merge(...$files); } if ($asDataSet) { return self::composeDataSets(self::$_cache[$cacheKey]); @@ -679,6 +655,7 @@ private function collectModuleLayoutFiles(array $params, $location) } } } else { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $files = array_merge($files, $moduleFiles); } } @@ -713,8 +690,10 @@ private function collectThemeLayoutFiles(array $params, $location) ); if ($params['with_metainfo']) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $files = array_merge($this->parseThemeFiles($themeFiles, $currentThemePath, $theme)); } else { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $files = array_merge($files, $themeFiles); } } @@ -925,14 +904,12 @@ public function getStaticPreProcessingFiles($filePattern = '*') $area = '*'; $locale = '*'; $result = []; - $moduleWebPath = []; $moduleLocalePath = []; foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleDir) { - $moduleWebPath[] = $moduleDir . "/view/{$area}/web"; $moduleLocalePath[] = $moduleDir . "/view/{$area}/web/i18n/{$locale}"; } - $this->_accumulateFilesByPatterns($moduleWebPath, $filePattern, $result, '_parseModuleStatic'); + $this->accumulateStaticFiles($area, $filePattern, $result); $this->_accumulateFilesByPatterns($moduleLocalePath, $filePattern, $result, '_parseModuleLocaleStatic'); $this->accumulateThemeStaticFiles($area, $locale, $filePattern, $result); self::$_cache[$key] = $result; @@ -1043,6 +1020,8 @@ protected function _accumulateFilesByPatterns(array $patterns, $filePattern, arr /** * Parse meta-info of a static file in module * + * @deprecated Replaced with method accumulateStaticFiles() + * * @param string $file * @return array */ @@ -1062,6 +1041,29 @@ protected function _parseModuleStatic($file) return []; } + /** + * Search static files from all modules by the specified pattern and accumulate meta-info + * + * @param string $area + * @param string $filePattern + * @param array $result + * @return void + */ + private function accumulateStaticFiles($area, $filePattern, array &$result) + { + foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) { + $moduleWebPath = $moduleDir . "/view/{$area}/web"; + + foreach (self::getFiles([$moduleWebPath], $filePattern) as $absolutePath) { + $localPath = substr($absolutePath, strlen($moduleDir) + 1); + if (preg_match('/^view\/([a-z]+)\/web\/(.+)$/i', $localPath, $matches) === 1) { + list(, $parsedArea, $parsedPath) = $matches; + $result[] = [$parsedArea, '', '', $moduleName, $parsedPath, $absolutePath]; + } + } + } + } + /** * Parse meta-info of a localized (translated) static file in module * diff --git a/lib/internal/Magento/Framework/Archive/Zip.php b/lib/internal/Magento/Framework/Archive/Zip.php index c41f8b28ce34..20f408a605c1 100644 --- a/lib/internal/Magento/Framework/Archive/Zip.php +++ b/lib/internal/Magento/Framework/Archive/Zip.php @@ -53,10 +53,10 @@ public function unpack($source, $destination) { $zip = new \ZipArchive(); if ($zip->open($source) === true) { - $filename = $this->filterRelativePaths($zip->getNameIndex(0) ?: ''); + $zip->renameIndex(0, basename($destination)); + $filename = $zip->getNameIndex(0) ?: ''; if ($filename) { $zip->extractTo(dirname($destination), $filename); - rename(dirname($destination).'/'.$filename, $destination); } else { $destination = ''; } @@ -67,19 +67,4 @@ public function unpack($source, $destination) return $destination; } - - /** - * Filter file names with relative paths. - * - * @param string $path - * @return string - */ - private function filterRelativePaths(string $path): string - { - if ($path && preg_match('#^\s*(../)|(/../)#i', $path)) { - $path = ''; - } - - return $path; - } } diff --git a/lib/internal/Magento/Framework/Backup/Archive/Tar.php b/lib/internal/Magento/Framework/Backup/Archive/Tar.php index ca8e7caf9884..4ac40c584ee2 100644 --- a/lib/internal/Magento/Framework/Backup/Archive/Tar.php +++ b/lib/internal/Magento/Framework/Backup/Archive/Tar.php @@ -15,6 +15,9 @@ use RecursiveDirectoryIterator; use RecursiveIteratorIterator; +/** + * Class to work with tar archives + */ class Tar extends \Magento\Framework\Archive\Tar { /** @@ -25,8 +28,7 @@ class Tar extends \Magento\Framework\Archive\Tar protected $_skipFiles = []; /** - * Overridden \Magento\Framework\Archive\Tar::_createTar method that does the same actions as it's parent but - * filters files using \Magento\Framework\Backup\Filesystem\Iterator\Filter + * Method same as it's parent but filters files using \Magento\Framework\Backup\Filesystem\Iterator\Filter * * @param bool $skipRoot * @param bool $finalize @@ -38,9 +40,8 @@ class Tar extends \Magento\Framework\Archive\Tar protected function _createTar($skipRoot = false, $finalize = false) { $path = $this->_getCurrentFile(); - $filesystemIterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path), + new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::FOLLOW_SYMLINKS), RecursiveIteratorIterator::SELF_FIRST ); @@ -50,6 +51,10 @@ protected function _createTar($skipRoot = false, $finalize = false) ); foreach ($iterator as $item) { + // exclude symlinks to do not get duplicates after follow symlinks in RecursiveDirectoryIterator + if ($item->isLink()) { + continue; + } $this->_setCurrentFile($item->getPathname()); $this->_packAndWriteCurrentFile(); } diff --git a/lib/internal/Magento/Framework/Code/GeneratedFiles.php b/lib/internal/Magento/Framework/Code/GeneratedFiles.php index bc44b361c57e..28301f7a1fb8 100644 --- a/lib/internal/Magento/Framework/Code/GeneratedFiles.php +++ b/lib/internal/Magento/Framework/Code/GeneratedFiles.php @@ -3,24 +3,36 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\Code; -use Magento\Framework\App\DeploymentConfig\Writer\PhpFormatter; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\RuntimeException; use Magento\Framework\Filesystem\Directory\WriteFactory; use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\Framework\Lock\LockManagerInterface; /** - * Regenerates generated code and DI configuration + * Clean generated code, DI configuration and cache folders */ class GeneratedFiles { /** - * Separator literal to assemble timer identifier from timer names + * Regenerate flag file name */ const REGENERATE_FLAG = '/var/.regenerate'; + /** + * Regenerate lock file name + */ + const REGENERATE_LOCK = self::REGENERATE_FLAG . '.lock'; + + /** + * Acquire regenerate lock timeout + */ + const REGENERATE_LOCK_TIMEOUT = 5; + /** * @var DirectoryList */ @@ -32,19 +44,39 @@ class GeneratedFiles private $write; /** - * Constructor + * @var LockManagerInterface + */ + private $lockManager; + + /** + * GeneratedFiles constructor. * * @param DirectoryList $directoryList * @param WriteFactory $writeFactory + * @param LockManagerInterface $lockManager */ - public function __construct(DirectoryList $directoryList, WriteFactory $writeFactory) - { + public function __construct( + DirectoryList $directoryList, + WriteFactory $writeFactory, + LockManagerInterface $lockManager + ) { $this->directoryList = $directoryList; $this->write = $writeFactory->create(BP); + $this->lockManager = $lockManager; } /** - * Clean generated code and DI configuration + * Create flag for cleaning up generated content + * + * @return void + */ + public function requestRegeneration() + { + $this->write->touch(self::REGENERATE_FLAG); + } + + /** + * Clean generated code, generated metadata and cache directories * * @return void * @@ -57,156 +89,75 @@ public function regenerate() } /** - * Clean generated/code, generated/metadata and var/cache + * Clean generated code, generated metadata and cache directories * * @return void */ public function cleanGeneratedFiles() { - if ($this->write->isExist(self::REGENERATE_FLAG)) { - $enabledCacheTypes = []; - - //TODO: to be removed in scope of MAGETWO-53476 - $deploymentConfig = $this->directoryList->getPath(DirectoryList::CONFIG); - $configPool = new ConfigFilePool(); - $envPath = $deploymentConfig . '/' . $configPool->getPath(ConfigFilePool::APP_ENV); - if ($this->write->isExist($this->write->getRelativePath($envPath))) { - $enabledCacheTypes = $this->getEnabledCacheTypes(); - $this->disableAllCacheTypes(); - } - //TODO: Till here - - $cachePath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::CACHE)); - $generationPath = $this->write->getRelativePath( - $this->directoryList->getPath(DirectoryList::GENERATED_CODE) - ); - $diPath = $this->write->getRelativePath($this->directoryList->getPath(DirectoryList::GENERATED_METADATA)); - - // Clean generated/code dir - if ($this->write->isDirectory($generationPath)) { - $this->write->delete($generationPath); - } - - // Clean generated/metadata - if ($this->write->isDirectory($diPath)) { - $this->write->delete($diPath); + if ($this->isCleanGeneratedFilesAllowed() && $this->acquireLock()) { + try { + $this->write->delete(self::REGENERATE_FLAG); + $this->deleteFolder(DirectoryList::GENERATED_CODE); + $this->deleteFolder(DirectoryList::GENERATED_METADATA); + $this->deleteFolder(DirectoryList::CACHE); + } catch (FileSystemException $exception) { + // A filesystem error occurred, possible concurrency error while trying + // to delete a generated folder being used by another process. + // Request regeneration for the next and unlock + $this->requestRegeneration(); + } finally { + $this->lockManager->unlock(self::REGENERATE_LOCK); } - - // Clean var/cache - if ($this->write->isDirectory($cachePath)) { - $this->write->delete($cachePath); - } - $this->write->delete(self::REGENERATE_FLAG); - $this->enableCacheTypes($enabledCacheTypes); } } /** - * Create flag for cleaning up generated/code, generated/metadata and var/cache directories for subsequent - * regeneration of this content + * Clean generated files is allowed if requested and not locked * - * @return void + * @return bool */ - public function requestRegeneration() + private function isCleanGeneratedFilesAllowed(): bool { - $this->write->touch(self::REGENERATE_FLAG); - } - - /** - * Reads Cache configuration from env.php and returns indexed array containing all the enabled cache types. - * - * @return string[] - */ - private function getEnabledCacheTypes() - { - $enabledCacheTypes = []; - $envPath = $this->getEnvPath(); - if ($this->write->isReadable($this->write->getRelativePath($envPath))) { - $envData = include $envPath; - if (isset($envData['cache_types'])) { - $cacheStatus = $envData['cache_types']; - $enabledCacheTypes = array_filter($cacheStatus, function ($value) { - return $value; - }); - $enabledCacheTypes = array_keys($enabledCacheTypes); - } + try { + $isAllowed = $this->write->isExist(self::REGENERATE_FLAG) + && !$this->lockManager->isLocked(self::REGENERATE_LOCK); + } catch (FileSystemException | RuntimeException $e) { + // Possible filesystem problem + $isAllowed = false; } - return $enabledCacheTypes; - } - /** - * Returns path to env.php file - * - * @return string - * @throws \Exception - */ - private function getEnvPath() - { - $deploymentConfig = $this->directoryList->getPath(DirectoryList::CONFIG); - $configPool = new ConfigFilePool(); - $envPath = $deploymentConfig . '/' . $configPool->getPath(ConfigFilePool::APP_ENV); - return $envPath; + return $isAllowed; } /** - * Disables all cache types by updating env.php. + * Acquire lock for performing operations * - * @return void + * @return bool */ - private function disableAllCacheTypes() + private function acquireLock(): bool { - $envPath = $this->getEnvPath(); - if ($this->write->isWritable($this->write->getRelativePath($envPath))) { - $envData = include $envPath; - - if (isset($envData['cache_types'])) { - $cacheTypes = array_keys($envData['cache_types']); - - foreach ($cacheTypes as $cacheType) { - $envData['cache_types'][$cacheType] = 0; - } - - $formatter = new PhpFormatter(); - $contents = $formatter->format($envData); - - $this->write->writeFile($this->write->getRelativePath($envPath), $contents); - if (function_exists('opcache_invalidate')) { - opcache_invalidate( - $this->write->getAbsolutePath($envPath) - ); - } - } + try { + $lockAcquired = $this->lockManager->lock(self::REGENERATE_LOCK, self::REGENERATE_LOCK_TIMEOUT); + } catch (RuntimeException $exception) { + // Lock not acquired due to possible filesystem problem + $lockAcquired = false; } + + return $lockAcquired; } /** - * Enables appropriate cache types in app/etc/env.php based on the passed in $cacheTypes array - * TODO: to be removed in scope of MAGETWO-53476 + * Delete folder by path * - * @param string[] $cacheTypes + * @param string $pathType * @return void */ - private function enableCacheTypes($cacheTypes) + private function deleteFolder(string $pathType): void { - if (empty($cacheTypes)) { - return; - } - $envPath = $this->getEnvPath(); - if ($this->write->isReadable($this->write->getRelativePath($envPath))) { - $envData = include $envPath; - foreach ($cacheTypes as $cacheType) { - if (isset($envData['cache_types'][$cacheType])) { - $envData['cache_types'][$cacheType] = 1; - } - } - - $formatter = new PhpFormatter(); - $contents = $formatter->format($envData); - - $this->write->writeFile($this->write->getRelativePath($envPath), $contents); - if (function_exists('opcache_invalidate')) { - opcache_invalidate($this->write->getAbsolutePath($envPath)); - } + $relativePath = $this->write->getRelativePath($this->directoryList->getPath($pathType)); + if ($this->write->isDirectory($relativePath)) { + $this->write->delete($relativePath); } } } diff --git a/lib/internal/Magento/Framework/Code/Reader/ClassReader.php b/lib/internal/Magento/Framework/Code/Reader/ClassReader.php index fe96e9cc742a..1f14d5e2db8d 100644 --- a/lib/internal/Magento/Framework/Code/Reader/ClassReader.php +++ b/lib/internal/Magento/Framework/Code/Reader/ClassReader.php @@ -5,12 +5,19 @@ */ namespace Magento\Framework\Code\Reader; +/** + * Class ClassReader + * + * @package Magento\Framework\Code\Reader + */ class ClassReader implements ClassReaderInterface { + private $parentsCache = []; + /** * Read class constructor signature * - * @param string $className + * @param string $className * @return array|null * @throws \ReflectionException */ @@ -28,7 +35,8 @@ public function getConstructor($className) $parameter->getName(), $parameter->getClass() !== null ? $parameter->getClass()->getName() : null, !$parameter->isOptional() && !$parameter->isDefaultValueAvailable(), - $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null, + $this->getReflectionParameterDefaultValue($parameter), + $parameter->isVariadic(), ]; } catch (\ReflectionException $e) { $message = $e->getMessage(); @@ -40,6 +48,21 @@ public function getConstructor($className) return $result; } + /** + * Get reflection parameter default value + * + * @param \ReflectionParameter $parameter + * @return array|mixed|null + */ + private function getReflectionParameterDefaultValue(\ReflectionParameter $parameter) + { + if ($parameter->isVariadic()) { + return []; + } + + return $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null; + } + /** * Retrieve parent relation information for type in a following format * array( @@ -49,11 +72,15 @@ public function getConstructor($className) * ... * ) * - * @param string $className + * @param string $className * @return string[] */ public function getParents($className) { + if (isset($this->parentsCache[$className])) { + return $this->parentsCache[$className]; + } + $parentClass = get_parent_class($className); if ($parentClass) { $result = []; @@ -75,6 +102,9 @@ public function getParents($className) $result = []; } } + + $this->parentsCache[$className] = $result; + return $result; } } diff --git a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php index 8c22170a126f..f0ff31964512 100644 --- a/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php +++ b/lib/internal/Magento/Framework/Code/Reader/NamespaceResolver.php @@ -50,7 +50,7 @@ public function resolveNamespace($type, array $availableNamespaces) ) { $name = explode(self::NS_SEPARATOR, $type); $unqualifiedName = $name[0]; - $isQualifiedName = count($name) > 1 ? true : false; + $isQualifiedName = count($name) > 1; if (isset($availableNamespaces[$unqualifiedName])) { $namespace = $availableNamespaces[$unqualifiedName]; if ($isQualifiedName) { @@ -101,16 +101,22 @@ public function getImportedNamespaces(array $fileContent) $imports[$importsCount][] = $item; } foreach ($imports as $import) { - $import = array_filter($import, function ($token) { - $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS]; - if (isset($token[0]) && in_array($token[0], $whitelist)) { - return true; + $import = array_filter( + $import, + function ($token) { + $whitelist = [T_NS_SEPARATOR, T_STRING, T_AS]; + if (isset($token[0]) && in_array($token[0], $whitelist)) { + return true; + } + return false; } - return false; - }); - $import = array_map(function ($element) { - return $element[1]; - }, $import); + ); + $import = array_map( + function ($element) { + return $element[1]; + }, + $import + ); $import = array_values($import); if ($import[0] === self::NS_SEPARATOR) { array_shift($import); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php index 31462fad1457..9b901005622d 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/GeneratedFilesTest.php @@ -8,110 +8,390 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Code\GeneratedFiles; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Exception\RuntimeException; +use Magento\Framework\Filesystem\Directory\WriteFactory; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\Framework\Lock\Backend\FileLock; +/** + * Class GeneratedFilesTest + */ class GeneratedFilesTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\Framework\App\Filesystem\DirectoryList | \PHPUnit_Framework_MockObject_MockObject + * @var DirectoryList|\PHPUnit_Framework_MockObject_MockObject */ private $directoryList; /** - * @var \Magento\Framework\Filesystem\Directory\WriteInterface | \PHPUnit_Framework_MockObject_MockObject + * @var WriteInterface|\PHPUnit_Framework_MockObject_MockObject */ private $writeInterface; + /** + * @var WriteFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $writeFactory; + + /** + * @var FileLock|\PHPUnit_Framework_MockObject_MockObject + */ + private $lockManager; + /** * @var \Magento\Framework\Code\GeneratedFiles */ private $model; + /** + * @var string + */ + private $pathGeneratedCode = '/var/www/magento/generated/code'; + + /** + * @var string + */ + private $pathGeneratedMetadata = '/var/www/magento/generated/metadata'; + + /** + * @var string + */ + private $pathVarCache = '/var/www/magento/generated/var/cache'; + + /** + * Setup mocks for tests + * + * @return void + */ protected function setUp() { - $this->directoryList = - $this->createPartialMock(\Magento\Framework\App\Filesystem\DirectoryList::class, ['getPath']); - $writeFactory = $this->createMock(\Magento\Framework\Filesystem\Directory\WriteFactory::class); - $this->writeInterface = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\WriteInterface::class) - ->setMethods(['getPath', 'delete']) - ->getMockForAbstractClass(); - $writeFactory->expects($this->once())->method('create')->willReturn($this->writeInterface); - $this->model = new GeneratedFiles($this->directoryList, $writeFactory); + $this->directoryList = $this->createMock(DirectoryList::class); + $this->writeFactory = $this->createMock(WriteFactory::class); + $this->lockManager = $this->createMock(FileLock::class); + $this->writeInterface = $this->getMockForAbstractClass(WriteInterface::class); + + $this->directoryList->expects($this->any())->method('getPath')->willReturnMap( + [ + [DirectoryList::GENERATED_CODE, $this->pathGeneratedCode], + [DirectoryList::GENERATED_METADATA, $this->pathGeneratedMetadata], + [DirectoryList::CACHE, $this->pathVarCache], + ] + ); + $this->writeInterface->expects($this->any())->method('getRelativePath')->willReturnMap( + [ + [$this->pathGeneratedCode, $this->pathGeneratedCode], + [$this->pathGeneratedMetadata, $this->pathGeneratedMetadata], + [$this->pathVarCache, $this->pathVarCache], + ] + ); + $this->writeInterface->expects($this->any())->method('isDirectory')->willReturnMap( + [ + [$this->pathGeneratedCode, true], + [$this->pathGeneratedMetadata, true], + [$this->pathVarCache, true], + ] + ); + + $this->writeFactory->expects($this->once())->method('create')->willReturn($this->writeInterface); + + $this->model = new GeneratedFiles( + $this->directoryList, + $this->writeFactory, + $this->lockManager + ); } /** - * @param array $getPathMap - * @param array $isDirectoryMap - * @param array $deleteMap - * @dataProvider cleanGeneratedFilesDataProvider + * Expect regeneration requested + * + * @param int $times + * @return void */ - public function testCleanGeneratedFiles($getPathMap, $isDirectoryMap, $deleteMap) + private function expectRegenerationRequested(int $times): void { + $this->writeInterface->expects($this->exactly($times))->method('touch')->with(GeneratedFiles::REGENERATE_FLAG); + } - $this->writeInterface - ->expects($this->any()) + /** + * Expect delete not requested + * + * @return void + */ + private function expectDeleteNotRequested(): void + { + $this->writeInterface->expects($this->never())->method('delete'); + } + + /** + * Expect flag present + * + * @param int $times + * @param bool $flagPresent + * @return void + */ + private function expectFlagPresent(int $times, bool $flagPresent): void + { + $this->writeInterface->expects($this->exactly($times)) ->method('isExist') - ->with() - ->willReturnMap([ - [GeneratedFiles::REGENERATE_FLAG, true], - ['path/to/di', false] - ]); - $this->directoryList->expects($this->any())->method('getPath')->willReturnMap($getPathMap); - $this->writeInterface->expects($this->any())->method('getRelativePath')->willReturnMap($getPathMap); - $this->writeInterface->expects($this->any())->method('isDirectory')->willReturnMap($isDirectoryMap); - $this->writeInterface->expects($this->exactly(1))->method('delete')->willReturnMap($deleteMap); + ->with(GeneratedFiles::REGENERATE_FLAG) + ->willReturn($flagPresent); + } + + /** + * Expect process locked + * + * @param int $times + * @param bool|null $processLocked + * @return void + */ + private function expectProcessLocked(int $times, bool $processLocked = null): void + { + $this->lockManager->expects($this->exactly($times)) + ->method('isLocked') + ->with(GeneratedFiles::REGENERATE_LOCK) + ->willReturn($processLocked); + + if ($processLocked) { + $this->expectLockOperation(0); + $this->expectUnlockOperation(0); + } + } + + /** + * Expect lock operation + * + * @param int $times + * @param bool|null $lockResult + * @return void + */ + private function expectLockOperation(int $times, bool $lockResult = null): void + { + $invocationMocker = $this->lockManager->expects($this->exactly($times)) + ->method('lock') + ->with(GeneratedFiles::REGENERATE_LOCK, GeneratedFiles::REGENERATE_LOCK_TIMEOUT); + + if (null !== $lockResult) { + $invocationMocker->willReturn($lockResult); + } + } + + /** + * Expect unlock operation + * + * @param int $times + * @param bool|null $unlockResult + * @return void + */ + private function expectUnlockOperation(int $times, bool $unlockResult = null): void + { + $invocationMocker = $this->lockManager->expects($this->exactly($times)) + ->method('unlock') + ->with(GeneratedFiles::REGENERATE_LOCK); + + if (null !== $unlockResult) { + $invocationMocker->willReturn($unlockResult); + } + } + + /** + * Expect no action performed, it does not execute any statement inside if condition + * + * @return void + */ + private function expectNoActionPerformed(): void + { + $this->expectDeleteNotRequested(); + $this->expectRegenerationRequested(0); + $this->expectUnlockOperation(0); + } + + /** + * Test request regeneration + * + * @test + * @return void + */ + public function itRequestsRegenerationProperly() + { + $this->expectRegenerationRequested(1); + $this->model->requestRegeneration(); + } + + /** + * It does not clean generated files if no flag is present + * + * @test + * @return void + */ + public function itDoesNotCleanGeneratedFilesIfNoFlagIsPresent() + { + $this->expectFlagPresent(1, false); + $this->expectProcessLocked(0); + $this->expectNoActionPerformed(); $this->model->cleanGeneratedFiles(); } /** - * @return array + * It does not clean generated files if process is locked + * + * @test + * @return void */ - public function cleanGeneratedFilesDataProvider() + public function itDoesNotCleanGeneratedFilesIfProcessIsLocked() { - $pathToGeneration = 'path/to/generation'; - $pathToDi = 'path/to/di'; - $pathToCache = 'path/to/di'; - $pathToConfig = 'path/to/config'; + $this->expectFlagPresent(1, true); + $this->expectProcessLocked(1, true); + $this->expectNoActionPerformed(); + $this->model->cleanGeneratedFiles(); + } - $getPathMap = [ - [DirectoryList::GENERATED_CODE, $pathToGeneration], - [DirectoryList::GENERATED_METADATA, $pathToDi], - [DirectoryList::CACHE, $pathToCache], - [DirectoryList::CONFIG, $pathToConfig], - ]; + /** + * It does not clean generated files when checking flag exists due to exceptions + * + * @test + * @param string $exceptionClassName + * @return void + * + * @dataProvider itDoesNotCleanGeneratedFilesDueToExceptionsDataProvider + */ + public function itDoesNotCleanGeneratedFilesWhenCheckingFlagExistsDueToExceptions( + string $exceptionClassName + ) { + // Configure write interface to throw exception upon flag existence check + $this->writeInterface->expects($this->any()) + ->method('isExist') + ->with(GeneratedFiles::REGENERATE_FLAG) + ->willThrowException(new $exceptionClassName(__('Some error has occurred.'))); - $deleteMap = [[BP . '/' . $pathToGeneration, true], - [BP . '/' . $pathToDi, true], - [BP . GeneratedFiles::REGENERATE_FLAG, true], - ]; + $this->expectProcessLocked(0); + $this->expectNoActionPerformed(); + $this->model->cleanGeneratedFiles(); + } + + /** + * It does not clean generated files when checking process lock due to exceptions + * + * @test + * @param string $exceptionClassName + * @return void + * + * @dataProvider itDoesNotCleanGeneratedFilesDueToExceptionsDataProvider + */ + public function itDoesNotCleanGeneratedFilesWhenCheckingProcessLockDueToExceptions( + string $exceptionClassName + ) { + $this->expectFlagPresent(1, true); + // Configure lock to throw exception upon process lock check + $this->lockManager->expects($this->any()) + ->method('isLocked') + ->with(GeneratedFiles::REGENERATE_LOCK) + ->willThrowException(new $exceptionClassName(__('Some error has occurred.'))); + + $this->expectNoActionPerformed(); + $this->model->cleanGeneratedFiles(); + } + + /** + * It does not clean generated files due to exceptions in allowed check data provider + * + * @return array + */ + public function itDoesNotCleanGeneratedFilesDueToExceptionsDataProvider() + { return [ - 'runAll' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true], - [BP . '/' . $pathToDi, true]], $deleteMap ], - 'noDIfolder' => [ $getPathMap, [[BP . '/' . $pathToGeneration, true], - [BP . '/' . $pathToDi, false]], $deleteMap], - 'noGenerationfolder' => [$getPathMap, [[BP . '/' . $pathToGeneration, false], - [BP . '/' . $pathToDi, true]], $deleteMap], - 'nofolders' => [ $getPathMap, [[BP . '/' . $pathToGeneration, false], - [BP . '/' . $pathToDi, false]], $deleteMap], + RuntimeException::class => [RuntimeException::class], + FileSystemException::class => [FileSystemException::class], ]; } - public function testCleanGeneratedFilesWithNoFlag() + /** + * It does not clean generated files if process lock is not acquired + * + * @test + * @return void + */ + public function itDoesNotCleanGeneratedFilesIfProcessLockIsNotAcquired() + { + $this->expectFlagPresent(1, true); + $this->expectProcessLocked(1, false); + + // Expect lock manager try to lock, but fail without exception + $this->lockManager->expects($this->once())->method('lock')->with( + GeneratedFiles::REGENERATE_LOCK, + GeneratedFiles::REGENERATE_LOCK_TIMEOUT + )->willReturn(false); + + $this->expectNoActionPerformed(); + $this->model->cleanGeneratedFiles(); + } + + /** + * It does not clean generated files if process lock is not acquired due to exception + * + * @test + * @return void + */ + public function itDoesNotCleanGeneratedFilesIfProcessLockIsNotAcquiredDueToException() { - $this->writeInterface - ->expects($this->once()) - ->method('isExist') - ->with(GeneratedFiles::REGENERATE_FLAG) - ->willReturn(false); - $this->directoryList->expects($this->never())->method('getPath'); - $this->writeInterface->expects($this->never())->method('getPath'); - $this->writeInterface->expects($this->never())->method('delete'); + $this->expectFlagPresent(1, true); + $this->expectProcessLocked(1, false); + + // Expect lock manager try to lock, but fail with runtime exception + $this->lockManager->expects($this->once())->method('lock')->with( + GeneratedFiles::REGENERATE_LOCK, + GeneratedFiles::REGENERATE_LOCK_TIMEOUT + )->willThrowException(new RuntimeException(__('Cannot acquire a lock.'))); + + $this->expectNoActionPerformed(); + $this->model->cleanGeneratedFiles(); + } + + /** + * It cleans generated files properly, when no errors or exceptions raised + * + * @test + * @return void + */ + public function itCleansGeneratedFilesProperly() + { + $this->expectFlagPresent(1, true); + $this->expectProcessLocked(1, false); + $this->expectLockOperation(1, true); + + $this->writeInterface->expects($this->exactly(4))->method('delete')->withConsecutive( + [GeneratedFiles::REGENERATE_FLAG], + [$this->pathGeneratedCode], + [$this->pathGeneratedMetadata], + [$this->pathVarCache] + ); + + $this->expectRegenerationRequested(0); + $this->expectUnlockOperation(1, true); + $this->model->cleanGeneratedFiles(); } - public function testRequestRegeneration() + /** + * It requests regeneration and unlock upon FileSystemException + * + * @test + * @return void + */ + public function itRequestsRegenerationAndUnlockUponFileSystemException() { - $this->writeInterface->expects($this->once())->method("touch"); - $this->model->requestRegeneration(); + $this->expectFlagPresent(1, true); + $this->expectProcessLocked(1, false); + $this->expectLockOperation(1, true); + + $this->writeInterface->expects($this->any())->method('delete')->willThrowException( + new FileSystemException(__('Some error has occurred.')) + ); + + $this->expectRegenerationRequested(1); + $this->expectUnlockOperation(1, true); + + $this->model->cleanGeneratedFiles(); } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ClassReaderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ClassReaderTest.php new file mode 100644 index 000000000000..e2786bffc10f --- /dev/null +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ClassReaderTest.php @@ -0,0 +1,101 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Code\Test\Unit\Reader; + +use Magento\Framework\Code\Reader\ClassReader; +use PHPUnit\Framework\TestCase; + +require_once __DIR__ . '/_files/ClassesForArgumentsReader.php'; + +class ClassReaderTest extends TestCase +{ + + /** + * @var ClassReader $model + */ + private $model; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->model = new ClassReader(); + } + + /** + * Get constructor test + * + * @param array $testData + * @dataProvider getTestData + * @throws \ReflectionException + */ + public function testGetConstructor(array $testData) + { + $this->assertEquals( + $testData, + $this->model->getConstructor('FirstClassForParentCall') + ); + } + + /** + * Ensure that if we have cached class then returns this class + */ + public function testGetParents() + { + $model = new ClassReader(); + $this->assertEquals([0 => 'FirstClassForParentCall'], $model->getParents('ThirdClassForParentCall')); + $reflection = new \ReflectionClass(ClassReader::class); + $expectedClass = $reflection->getProperty('parentsCache'); + $expectedClass->setAccessible(true); + $this->assertEquals( + $expectedClass->getValue($model)['ThirdClassForParentCall'], + $model->getParents('ThirdClassForParentCall') + ); + } + + /** + * Data provider + * + * @return array + */ + public function getTestData() + { + return + [ + [ + [ + 0 => [ + 0 => 'stdClassObject', + 1 => 'stdClass', + 2 => true, + 3 => null, + 4 => false, + ], + 1 => [ + 0 => 'runeTimeException', + 1 => 'ClassExtendsDefaultPhpType', + 2 => true, + 3 => null, + 4 => false + ], + 2 => [ + 0 => 'arrayVariable', + 1 => null, + 2 => false, + 3 => [ + 'key' => 'value', + ], + 4 => false + ] + ] + ] + ]; + } +} diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php index ab32504baaa0..6bdb74ef7b89 100644 --- a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php +++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php @@ -21,7 +21,6 @@ class ConfigOptionsListConstants const CONFIG_PATH_CRYPT_KEY = 'crypt/key'; const CONFIG_PATH_SESSION_SAVE = 'session/save'; const CONFIG_PATH_RESOURCE_DEFAULT_SETUP = 'resource/default_setup/connection'; - const CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS = 'db/connection/default/driver_options'; const CONFIG_PATH_DB_CONNECTION_DEFAULT = 'db/connection/default'; const CONFIG_PATH_DB_CONNECTIONS = 'db/connection'; const CONFIG_PATH_DB_PREFIX = 'db/table_prefix'; @@ -65,10 +64,6 @@ class ConfigOptionsListConstants const INPUT_KEY_DB_MODEL = 'db-model'; const INPUT_KEY_DB_INIT_STATEMENTS = 'db-init-statements'; const INPUT_KEY_DB_ENGINE = 'db-engine'; - const INPUT_KEY_DB_SSL_KEY = 'db-ssl-key'; - const INPUT_KEY_DB_SSL_CERT = 'db-ssl-cert'; - const INPUT_KEY_DB_SSL_CA = 'db-ssl-ca'; - const INPUT_KEY_DB_SSL_VERIFY = 'db-ssl-verify'; const INPUT_KEY_RESOURCE = 'resource'; const INPUT_KEY_SKIP_DB_VALIDATION = 'skip-db-validation'; const INPUT_KEY_CACHE_HOSTS = 'http-cache-hosts'; @@ -109,20 +104,6 @@ class ConfigOptionsListConstants const KEY_MODEL = 'model'; const KEY_INIT_STATEMENTS = 'initStatements'; const KEY_ACTIVE = 'active'; - const KEY_DRIVER_OPTIONS = 'driver_options'; - /**#@-*/ - - /**#@+ - * Array keys for database driver options configurations - */ - const KEY_MYSQL_SSL_KEY = \PDO::MYSQL_ATTR_SSL_KEY; - const KEY_MYSQL_SSL_CERT = \PDO::MYSQL_ATTR_SSL_CERT; - const KEY_MYSQL_SSL_CA = \PDO::MYSQL_ATTR_SSL_CA; - /** - * Constant \PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT cannot be used as it was introduced in PHP 7.1.4 - * and Magento 2 is currently supporting PHP 7.1.3. - */ - const KEY_MYSQL_SSL_VERIFY = 1014; /**#@-*/ /** diff --git a/lib/internal/Magento/Framework/Config/Test/Unit/ValidationState/ConfigurableTest.php b/lib/internal/Magento/Framework/Config/Test/Unit/ValidationState/ConfigurableTest.php new file mode 100644 index 000000000000..cbd9e4363248 --- /dev/null +++ b/lib/internal/Magento/Framework/Config/Test/Unit/ValidationState/ConfigurableTest.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\Config\Test\Unit\ValidationState; + +use Magento\Framework\Config\ValidationState\Configurable; +use PHPUnit\Framework\TestCase; + +/** + * Tests for configurable validation state + */ +class ConfigurableTest extends TestCase +{ + public function testTrue() + { + $state = new Configurable(true); + self::assertTrue($state->isValidationRequired()); + } + + public function testFalse() + { + $state = new Configurable(false); + self::assertFalse($state->isValidationRequired()); + } +} diff --git a/lib/internal/Magento/Framework/Config/ValidationState/Configurable.php b/lib/internal/Magento/Framework/Config/ValidationState/Configurable.php new file mode 100644 index 000000000000..c996b2a3e135 --- /dev/null +++ b/lib/internal/Magento/Framework/Config/ValidationState/Configurable.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\Config\ValidationState; + +use Magento\Framework\Config\ValidationStateInterface; + +/** + * A configurable validation state + */ +class Configurable implements ValidationStateInterface +{ + /** + * @var bool + */ + private $required; + + /** + * @param bool $required + */ + public function __construct(bool $required) + { + $this->required = $required; + } + + /** + * @inheritdoc + */ + public function isValidationRequired(): bool + { + return $this->required; + } +} diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 34fd6316ce45..6aab9c03ff7b 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -19,6 +19,7 @@ use Magento\Setup\Application; use Magento\Setup\Console\CompilerPreparation; use Magento\Setup\Model\ObjectManagerProvider; +use Psr\Log\LoggerInterface; use Symfony\Component\Console; use Magento\Framework\Config\ConfigOptionsListConstants; @@ -61,6 +62,11 @@ class Cli extends Console\Application */ private $objectManager; + /** + * @var LoggerInterface + */ + private $logger; + /** * @param string $name the application name * @param string $version the application version @@ -94,6 +100,7 @@ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') parent::__construct($name, $version); $this->serviceManager->setService(\Symfony\Component\Console\Application::class, $this); + $this->logger = $this->objectManager->get(LoggerInterface::class); } /** @@ -107,7 +114,9 @@ public function doRun(Console\Input\InputInterface $input, Console\Output\Output try { $exitCode = parent::doRun($input, $output); } catch (\Exception $e) { - $output->writeln($e->getTraceAsString()); + $errorMessage = $e->getMessage() . PHP_EOL . $e->getTraceAsString(); + $this->logger->error($errorMessage); + $this->initException = $e; } if ($this->initException) { diff --git a/lib/internal/Magento/Framework/Console/Test/Unit/CliTest.php b/lib/internal/Magento/Framework/Console/Test/Unit/CliTest.php new file mode 100644 index 000000000000..6e7bf049c430 --- /dev/null +++ b/lib/internal/Magento/Framework/Console/Test/Unit/CliTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Console\Test\Unit; + +use Magento\Framework\Console\Cli; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Test for Magento\Framework\Console\Cli class. + */ +class CliTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var Cli + */ + private $cli; + + /** + * @var InputInterface|MockObject + */ + private $inputMock; + + /** + * @var OutputInterface|MockObject + */ + private $outputMock; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->inputMock = $this->getMockBuilder(InputInterface::class) + ->getMockForAbstractClass(); + $this->outputMock = $this->getMockBuilder(OutputInterface::class) + ->getMockForAbstractClass(); + $this->cli = new Cli(); + } + + /** + * Make sure exception message is displayed and trace is logged. + * + * @expectedException \Exception + * @expectedExceptionMessage Test message + */ + public function testDoRunExceptionLogging() + { + $e = new \Exception('Test message'); + $this->inputMock->expects($this->once())->method('getFirstArgument')->willThrowException($e); + $loggerMock = $this->createMock(LoggerInterface::class); + $loggerMock->expects($this->once()) + ->method('error') + ->with($e->getMessage() . PHP_EOL . $e->getTraceAsString()); + $this->injectMock($loggerMock, 'logger'); + + $this->cli->doRun($this->inputMock, $this->outputMock); + } + + /** + * Inject mock to Cli property. + * + * @param MockObject $mockObject + * @param string $propertyName + * @throws \ReflectionException + */ + private function injectMock(MockObject $mockObject, string $propertyName): void + { + $reflection = new \ReflectionClass(Cli::class); + $reflectionProperty = $reflection->getProperty($propertyName); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->cli, $mockObject); + } +} diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php index 87adadbd34e3..df08e7776262 100644 --- a/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php +++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Router/Route/FactoryTest.php @@ -9,7 +9,7 @@ use \Magento\Framework\Controller\Router\Route\Factory; use Magento\Framework\Controller\Router\Route\Factory as RouteFactory; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class FactoryTest extends \PHPUnit\Framework\TestCase { diff --git a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php index f3b26dc7a9bf..4a082d71ddd4 100644 --- a/lib/internal/Magento/Framework/Data/Form/AbstractForm.php +++ b/lib/internal/Magento/Framework/Data/Form/AbstractForm.php @@ -67,9 +67,11 @@ public function __construct(Factory $factoryElement, CollectionFactory $factoryC * Please override this one instead of overriding real __construct constructor * * @return void + * @codingStandardsIgnoreStart */ protected function _construct() { + //@codingStandardsIgnoreEnd } /** @@ -137,14 +139,14 @@ public function addElement(AbstractElement $element, $after = null) /** * Add child element * - * if $after parameter is false - then element adds to end of collection - * if $after parameter is null - then element adds to befin of collection - * if $after parameter is string - then element adds after of the element with some id + * If $after parameter is false - then element adds to end of collection + * If $after parameter is null - then element adds to befin of collection + * If $after parameter is string - then element adds after of the element with some id * - * @param string $elementId - * @param string $type - * @param array $config - * @param bool|string|null $after + * @param string $elementId + * @param string $type + * @param array $config + * @param bool|string|null $after * @return AbstractElement */ public function addField($elementId, $type, $config, $after = false) diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/Adapter/McryptTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/Adapter/McryptTest.php index 452357003630..4fc9ec992a3e 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/Adapter/McryptTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/Adapter/McryptTest.php @@ -28,6 +28,11 @@ protected function setUp() $this->key = substr(__CLASS__, -32, 32); } + /** + * @param int $length + * + * @return string + */ protected function getRandomString(int $length): string { $result = ''; @@ -48,18 +53,33 @@ private function requireCipherInfo() } } + /** + * @param string $cipherName + * @param string $modeName + * + * @return int + */ private function getKeySize(string $cipherName, string $modeName): int { $this->requireCipherInfo(); return self::$cipherInfo[$cipherName][$modeName]['key_size']; } + /** + * @param string $cipherName + * @param string $modeName + * + * @return int + */ private function getInitVectorSize(string $cipherName, string $modeName): int { $this->requireCipherInfo(); return self::$cipherInfo[$cipherName][$modeName]['iv_size']; } + /** + * @return array + */ public function getCipherModeCombinations(): array { $result = []; @@ -87,6 +107,9 @@ public function testConstructor(string $cipher, string $mode) $this->assertEquals($initVector, $crypt->getInitVector()); } + /** + * @return array + */ public function getConstructorExceptionData(): array { $key = substr(__CLASS__, -32, 32); @@ -130,6 +153,9 @@ public function testConstructorDefaults() $this->assertEquals($cryptExpected->getInitVector(), $cryptActual->getInitVector()); } + /** + * @return array + */ public function getCryptData(): array { $fixturesFilename = __DIR__ . '/../Crypt/_files/_crypt_fixtures.php'; diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/KeyValidatorTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/KeyValidatorTest.php index 85faa0aa4676..b7a9ae3bc1e3 100644 --- a/lib/internal/Magento/Framework/Encryption/Test/Unit/KeyValidatorTest.php +++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/KeyValidatorTest.php @@ -33,6 +33,9 @@ public function testIsValid($key, $expected = true) $this->assertEquals($expected, $this->keyValidator->isValid($key)); } + /** + * @return array + */ public function isValidDataProvider() : array { return [ diff --git a/lib/internal/Magento/Framework/Escaper.php b/lib/internal/Magento/Framework/Escaper.php index 68a18964d342..1b766dea2105 100644 --- a/lib/internal/Magento/Framework/Escaper.php +++ b/lib/internal/Magento/Framework/Escaper.php @@ -28,6 +28,11 @@ class Escaper */ private $logger; + /** + * @var \Magento\Framework\Translate\InlineInterface + */ + private $translateInline; + /** * @var string[] */ @@ -80,7 +85,7 @@ public function escapeHtml($data, $allowedTags = null) set_error_handler( function ($errorNumber, $errorString) { // phpcs:ignore Magento2.Exceptions.DirectThrow - throw new \Exception($errorString, $errorNumber); + throw new \InvalidArgumentException($errorString, $errorNumber); } ); $data = $this->prepareUnescapedCharacters($data); @@ -95,6 +100,7 @@ function ($errorNumber, $errorString) { } restore_error_handler(); + $this->removeComments($domDocument); $this->removeNotAllowedTags($domDocument, $allowedTags); $this->removeNotAllowedAttributes($domDocument); $this->escapeText($domDocument); @@ -141,7 +147,7 @@ private function removeNotAllowedTags(\DOMDocument $domDocument, array $allowedT . '\']' ); foreach ($nodes as $node) { - if ($node->nodeName != '#text' && $node->nodeName != '#comment') { + if ($node->nodeName != '#text') { $node->parentNode->replaceChild($domDocument->createTextNode($node->textContent), $node); } } @@ -164,6 +170,21 @@ private function removeNotAllowedAttributes(\DOMDocument $domDocument) } } + /** + * Remove comments + * + * @param \DOMDocument $domDocument + * @return void + */ + private function removeComments(\DOMDocument $domDocument) + { + $xpath = new \DOMXPath($domDocument); + $nodes = $xpath->query('//comment()'); + foreach ($nodes as $node) { + $node->parentNode->removeChild($node); + } + } + /** * Escape text * @@ -318,8 +339,11 @@ public function escapeJsQuote($data, $quote = '\'') */ public function escapeXssInUrl($data) { + $data = html_entity_decode((string)$data); + $this->getTranslateInline()->processResponseBody($data); + return htmlspecialchars( - $this->escapeScriptIdentifiers(html_entity_decode((string)$data)), + $this->escapeScriptIdentifiers($data), $this->htmlSpecialCharsFlag | ENT_HTML5 | ENT_HTML401, 'UTF-8', false @@ -421,4 +445,19 @@ private function filterProhibitedTags(array $allowedTags): array return $allowedTags; } + + /** + * Resolve inline translator. + * + * @return \Magento\Framework\Translate\InlineInterface + */ + private function getTranslateInline() + { + if ($this->translateInline === null) { + $this->translateInline = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\Translate\InlineInterface::class); + } + + return $this->translateInline; + } } diff --git a/lib/internal/Magento/Framework/File/Test/Unit/UploaderTest.php b/lib/internal/Magento/Framework/File/Test/Unit/UploaderTest.php new file mode 100644 index 000000000000..d0aa65818445 --- /dev/null +++ b/lib/internal/Magento/Framework/File/Test/Unit/UploaderTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\File\Test\Unit; + +/** + * Unit Test class for \Magento\Framework\File\Uploader + */ +class UploaderTest extends \PHPUnit\Framework\TestCase +{ + /** + * @param string $fileName + * @param string|bool $expectedCorrectedFileName + * + * @dataProvider getCorrectFileNameProvider + */ + public function testGetCorrectFileName($fileName, $expectedCorrectedFileName) + { + $isExceptionExpected = $expectedCorrectedFileName === true; + + if ($isExceptionExpected) { + $this->expectException(\InvalidArgumentException::class); + } + + $this->assertEquals( + $expectedCorrectedFileName, + \Magento\Framework\File\Uploader::getCorrectFileName($fileName) + ); + } + + /** + * @return array + */ + public function getCorrectFileNameProvider() + { + return [ + [ + '^&*&^&*^$$$$()', + 'file.' + ], + [ + '^&*&^&*^$$$$().png', + 'file.png' + ], + [ + '_', + 'file.' + ], + [ + '_.jpg', + 'file.jpg' + ], + [ + 'a.' . str_repeat('b', 88), + 'a.' . str_repeat('b', 88) + ], + [ + 'a.' . str_repeat('b', 89), + true + ] + ]; + } +} diff --git a/lib/internal/Magento/Framework/File/Uploader.php b/lib/internal/Magento/Framework/File/Uploader.php index 328a748cfd5d..f9b41709ec7c 100644 --- a/lib/internal/Magento/Framework/File/Uploader.php +++ b/lib/internal/Magento/Framework/File/Uploader.php @@ -5,12 +5,18 @@ */ namespace Magento\Framework\File; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Validation\ValidationException; + /** * File upload class * * ATTENTION! This class must be used like abstract class and must added * validation by protected file extension list to extended class * + * @SuppressWarnings(PHPMD.TooManyFields) + * * @api */ class Uploader @@ -75,7 +81,7 @@ class Uploader protected $_allowRenameFiles = false; /** - * If this variable is set to TRUE, files dispertion will be supported. + * If this variable is set to TRUE, files dispersion will be supported. * * @var bool * @access protected @@ -157,21 +163,31 @@ class Uploader */ protected $_result; + /** + * @var DirectoryList + */ + private $directoryList; + /** * Init upload * * @param string|array $fileId * @param \Magento\Framework\File\Mime|null $fileMime - * @throws \Exception + * @param DirectoryList|null $directoryList + * @throws \DomainException */ public function __construct( $fileId, - Mime $fileMime = null + Mime $fileMime = null, + DirectoryList $directoryList = null ) { + $this->directoryList= $directoryList ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(DirectoryList::class); + $this->_setUploadFileId($fileId); if (!file_exists($this->_file['tmp_name'])) { $code = empty($this->_file['tmp_name']) ? self::TMP_NAME_EMPTY : 0; - throw new \Exception('The file was not uploaded.', $code); + throw new \DomainException('The file was not uploaded.', $code); } else { $this->_fileExists = true; } @@ -256,7 +272,7 @@ public function save($destinationFolder, $newFileName = null) * * @param string $destinationFolder * @return void - * @throws \Exception + * @throws FileSystemException */ private function validateDestination($destinationFolder) { @@ -265,7 +281,7 @@ private function validateDestination($destinationFolder) } if (!is_writable($destinationFolder)) { - throw new \Exception('Destination folder is not writable or does not exists.'); + throw new FileSystemException(__('Destination folder is not writable or does not exists.')); } } @@ -302,7 +318,7 @@ protected function _moveFile($tmpPath, $destPath) * Validate file before save * * @return void - * @throws \Exception + * @throws ValidationException */ protected function _validateFile() { @@ -312,7 +328,7 @@ protected function _validateFile() //is file extension allowed if (!$this->checkAllowedExtension($this->getFileExtension())) { - throw new \Exception('Disallowed file type.'); + throw new ValidationException(__('Disallowed file type.')); } //run validate callbacks foreach ($this->_validateCallbacks as $params) { @@ -366,19 +382,27 @@ public function removeValidateCallback($callbackName) } /** - * Correct filename with special chars and spaces + * Correct filename with special chars and spaces; also trim excessively long filenames * * @param string $fileName * @return string + * @throws \InvalidArgumentException */ public static function getCorrectFileName($fileName) { $fileName = preg_replace('/[^a-z0-9_\\-\\.]+/i', '_', $fileName); $fileInfo = pathinfo($fileName); + $fileInfo['extension'] = $fileInfo['extension'] ?? ''; + + // account for excessively long filenames that cannot be stored completely in database + if (strlen($fileInfo['basename']) > 90) { + throw new \InvalidArgumentException('Filename is too long; must be 90 characters or less'); + } if (preg_match('/^_+$/', $fileInfo['filename'])) { $fileName = 'file.' . $fileInfo['extension']; } + return $fileName; } @@ -533,17 +557,19 @@ private function _getMimeType() * * @param string|array $fileId * @return void - * @throws \Exception + * @throws \DomainException + * @throws \InvalidArgumentException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ private function _setUploadFileId($fileId) { if (is_array($fileId)) { + $this->validateFileId($fileId); $this->_uploadType = self::MULTIPLE_STYLE; $this->_file = $fileId; } else { if (empty($_FILES)) { - throw new \Exception('$_FILES array is empty'); + throw new \DomainException('$_FILES array is empty'); } preg_match("/^(.*?)\[(.*?)\]$/", $fileId, $file); @@ -565,17 +591,68 @@ private function _setUploadFileId($fileId) $this->_uploadType = self::SINGLE_STYLE; $this->_file = $_FILES[$fileId]; } elseif ($fileId == '') { - throw new \Exception('Invalid parameter given. A valid $_FILES[] identifier is expected.'); + throw new \InvalidArgumentException( + 'Invalid parameter given. A valid $_FILES[] identifier is expected.' + ); } } } + /** + * Validates explicitly given uploaded file data. + * + * @param array $fileId + * @return void + * @throws \InvalidArgumentException + */ + private function validateFileId(array $fileId): void + { + $isValid = false; + if (isset($fileId['tmp_name'])) { + $tmpName = trim($fileId['tmp_name']); + + if (preg_match('/\.\.(\\\|\/)/', $tmpName) !== 1) { + $allowedFolders = [ + sys_get_temp_dir(), + $this->directoryList->getPath(DirectoryList::MEDIA), + $this->directoryList->getPath(DirectoryList::VAR_DIR), + $this->directoryList->getPath(DirectoryList::TMP), + $this->directoryList->getPath(DirectoryList::UPLOAD), + ]; + + $disallowedFolders = [ + $this->directoryList->getPath(DirectoryList::LOG), + ]; + + foreach ($allowedFolders as $allowedFolder) { + if (stripos($tmpName, $allowedFolder) === 0) { + $isValid = true; + break; + } + } + + foreach ($disallowedFolders as $disallowedFolder) { + if (stripos($tmpName, $disallowedFolder) === 0) { + $isValid = false; + break; + } + } + } + } + + if (!$isValid) { + throw new \InvalidArgumentException( + __('Invalid parameter given. A valid $fileId[tmp_name] is expected.') + ); + } + } + /** * Create destination folder * * @param string $destinationFolder * @return \Magento\Framework\File\Uploader - * @throws \Exception + * @throws FileSystemException */ private function _createDestinationFolder($destinationFolder) { @@ -590,7 +667,7 @@ private function _createDestinationFolder($destinationFolder) if (!(@is_dir($destinationFolder) || @mkdir($destinationFolder, 0777, true) )) { - throw new \Exception("Unable to create directory '{$destinationFolder}'."); + throw new FileSystemException(__('Unable to create directory %1.', $destinationFolder)); } return $this; } @@ -620,7 +697,7 @@ public static function getNewFileName($destinationFile) } /** - * Get dispertion path + * Get dispersion path * * @param string $fileName * @return string @@ -632,7 +709,7 @@ public static function getDispretionPath($fileName) } /** - * Get dispertion path + * Get dispersion path * * @param string $fileName * @return string @@ -640,17 +717,17 @@ public static function getDispretionPath($fileName) public static function getDispersionPath($fileName) { $char = 0; - $dispertionPath = ''; + $dispersionPath = ''; while ($char < 2 && $char < strlen($fileName)) { - if (empty($dispertionPath)) { - $dispertionPath = '/' . ('.' == $fileName[$char] ? '_' : $fileName[$char]); + if (empty($dispersionPath)) { + $dispersionPath = '/' . ('.' == $fileName[$char] ? '_' : $fileName[$char]); } else { - $dispertionPath = self::_addDirSeparator( - $dispertionPath + $dispersionPath = self::_addDirSeparator( + $dispersionPath ) . ('.' == $fileName[$char] ? '_' : $fileName[$char]); } $char++; } - return $dispertionPath; + return $dispersionPath; } } diff --git a/lib/internal/Magento/Framework/Filter/Template.php b/lib/internal/Magento/Framework/Filter/Template.php index 6a04e8e8c695..0cd2935a24b1 100644 --- a/lib/internal/Magento/Framework/Filter/Template.php +++ b/lib/internal/Magento/Framework/Filter/Template.php @@ -9,9 +9,6 @@ */ namespace Magento\Framework\Filter; -use Magento\Framework\Model\AbstractExtensibleModel; -use Magento\Framework\Model\AbstractModel; - /** * Template filter * @@ -81,7 +78,29 @@ class Template implements \Zend_Filter_Interface 'settemplateprocessor', 'gettemplateprocessor', 'vardirective', - 'delete' + 'delete', + 'getdatausingmethod', + '__destruct', + '__call', + '__callstatic', + '__set', + '__unset', + '__sleep', + '__wakeup', + '__invoke', + '__set_state', + '__debuginfo', + '___callparent', + '___callplugins' + ]; + + /** + * @var array[] + */ + private $restrictedMethodsByInstanceType = [ + \Magento\Framework\DB\Adapter\AdapterInterface::class => [ + '*' + ] ]; /** @@ -400,36 +419,23 @@ protected function getParameters($value) */ private function validateVariableMethodCall($object, string $method): void { - if ($object === $this) { + if ($object instanceof self || $object instanceof \Magento\Framework\DataObject) { if (in_array(mb_strtolower($method), $this->restrictedMethods)) { throw new \InvalidArgumentException("Method $method cannot be called from template."); } - } - } - - /** - * Check allowed methods for data objects. - * - * Deny calls for methods that may disrupt template processing. - * - * @param object $object - * @param string $method - * @return bool - * @throws \InvalidArgumentException - */ - private function isAllowedDataObjectMethod($object, string $method): bool - { - if ($object instanceof AbstractExtensibleModel || $object instanceof AbstractModel) { - if (in_array(mb_strtolower($method), $this->restrictedMethods)) { - throw new \InvalidArgumentException("Method $method cannot be called from template."); + } else { + foreach ($this->restrictedMethodsByInstanceType as $instanceType => $restrictedMethods) { + if ($object instanceof $instanceType && + (in_array('*', $restrictedMethods) || in_array(mb_strtolower($method), $restrictedMethods)) + ) { + throw new \InvalidArgumentException("Method $method cannot be called from template."); + } } } - - return true; } /** - * Return variable value for var construction + * Return variable value for var construction. * * @param string $value raw parameters * @param string $default default value @@ -448,45 +454,18 @@ protected function getVariable($value, $default = '{no_value_defined}') if ($i == 0 && isset($this->templateVars[$stackVars[$i]['name']])) { // Getting of template value $stackVars[$i]['variable'] = & $this->templateVars[$stackVars[$i]['name']]; - } elseif (isset($stackVars[$i - 1]['variable']) - && $stackVars[$i - 1]['variable'] instanceof \Magento\Framework\DataObject - ) { - // If data object calling methods or getting properties + } elseif (isset($stackVars[$i - 1]['variable']) && is_object($stackVars[$i - 1]['variable'])) { if ($stackVars[$i]['type'] == 'property') { - $caller = 'get' . $this->string->upperCaseWords($stackVars[$i]['name'], '_', ''); - $stackVars[$i]['variable'] = method_exists( + $stackVars[$i]['variable'] = $this->evaluateObjectPropertyAccess( $stackVars[$i - 1]['variable'], - $caller - ) ? $stackVars[$i - 1]['variable']->{$caller}() : $stackVars[$i - 1]['variable']->getData( $stackVars[$i]['name'] ); } elseif ($stackVars[$i]['type'] == 'method') { - // Calling of data object method - if (method_exists($stackVars[$i - 1]['variable'], $stackVars[$i]['name']) - || substr($stackVars[$i]['name'], 0, 3) == 'get' - ) { - $stackVars[$i]['args'] = $this->getStackArgs($stackVars[$i]['args']); - - if ($this->isAllowedDataObjectMethod($stackVars[$i - 1]['variable'], $stackVars[$i]['name'])) { - $stackVars[$i]['variable'] = call_user_func_array( - [$stackVars[$i - 1]['variable'], $stackVars[$i]['name']], - $stackVars[$i]['args'] - ); - } - } - } - $last = $i; - } elseif (isset($stackVars[$i - 1]['variable']) - && is_object($stackVars[$i - 1]['variable']) - && $stackVars[$i]['type'] == 'method' - ) { - // Calling object methods - $object = $stackVars[$i - 1]['variable']; - $method = $stackVars[$i]['name']; - if (method_exists($object, $method)) { - $args = $this->getStackArgs($stackVars[$i]['args']); - $this->validateVariableMethodCall($object, $method); - $stackVars[$i]['variable'] = call_user_func_array([$object, $method], $args); + $stackVars[$i]['variable'] = $this->evaluateObjectMethodCall( + $stackVars[$i - 1]['variable'], + $stackVars[$i]['name'], + $stackVars[$i]['args'] + ); } $last = $i; } @@ -500,6 +479,45 @@ protected function getVariable($value, $default = '{no_value_defined}') return $result; } + /** + * Evaluate object property access. + * + * @param object $object + * @param string $property + * @return null + */ + private function evaluateObjectPropertyAccess($object, $property) + { + $method = 'get' . $this->string->upperCaseWords($property, '_', ''); + $this->validateVariableMethodCall($object, $method); + return method_exists($object, $method) + ? $object->{$method}() + : (($object instanceof \Magento\Framework\DataObject) ? $object->getData($property) : null); + } + + /** + * Evaluate object method call. + * + * @param object $object + * @param string $method + * @param array $arguments + * @return mixed|null + */ + private function evaluateObjectMethodCall($object, $method, $arguments) + { + if (method_exists($object, $method) + || ($object instanceof \Magento\Framework\DataObject && substr($method, 0, 3) == 'get') + ) { + $arguments = $this->getStackArgs($arguments); + $this->validateVariableMethodCall($object, $method); + return call_user_func_array( + [$object, $method], + $arguments + ); + } + return null; + } + /** * Loops over a set of stack args to process variables into array argument values * diff --git a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php index 0ee3a06ce542..b7f76cb35953 100644 --- a/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php +++ b/lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php @@ -445,7 +445,8 @@ public function disallowedMethods() ['setTemplateProcessor'], ['getTemplateProcessor'], ['varDirective'], - ['delete'] + ['delete'], + ['getDataUsingMethod'] ]; } } diff --git a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php index 429b7c04b747..28b91c753c7e 100644 --- a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php +++ b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php @@ -7,13 +7,15 @@ namespace Magento\Framework\GraphQl\Exception; -use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\AggregateExceptionInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; +use GraphQL\Error\ClientAware; /** * Exception for GraphQL to be thrown when user supplies invalid input */ -class GraphQlInputException extends InputException implements \GraphQL\Error\ClientAware +class GraphQlInputException extends LocalizedException implements AggregateExceptionInterface, ClientAware { const EXCEPTION_CATEGORY = 'graphql-input'; @@ -22,6 +24,13 @@ class GraphQlInputException extends InputException implements \GraphQL\Error\Cli */ private $isSafe; + /** + * The array of errors that have been added via the addError() method + * + * @var \Magento\Framework\Exception\LocalizedException[] + */ + private $errors = []; + /** * Initialize object * @@ -51,4 +60,26 @@ public function getCategory() : string { return self::EXCEPTION_CATEGORY; } + + /** + * Add child error if used as aggregate exception + * + * @param LocalizedException $exception + * @return $this + */ + public function addError(LocalizedException $exception): self + { + $this->errors[] = $exception; + return $this; + } + + /** + * Get child errors if used as aggregate exception + * + * @return LocalizedException[] + */ + public function getErrors(): array + { + return $this->errors; + } } diff --git a/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php b/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php index 2661034116f9..b3d78790892f 100644 --- a/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php +++ b/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php @@ -7,7 +7,7 @@ namespace Magento\Framework\GraphQl\Query; -use GraphQL\Error\ClientAware; +use Magento\Framework\Exception\AggregateExceptionInterface; use Psr\Log\LoggerInterface; /** @@ -36,13 +36,20 @@ public function __construct( */ public function handle(array $errors, callable $formatter): array { - return array_map( - function (ClientAware $error) use ($formatter) { - $this->logger->error($error); - - return $formatter($error); - }, - $errors - ); + $formattedErrors = []; + foreach ($errors as $error) { + $this->logger->error($error); + $previousError = $error->getPrevious(); + if ($previousError instanceof AggregateExceptionInterface && !empty($previousError->getErrors())) { + $aggregatedErrors = $previousError->getErrors(); + foreach ($aggregatedErrors as $aggregatedError) { + $this->logger->error($aggregatedError); + $formattedErrors[] = $formatter($aggregatedError); + } + } else { + $formattedErrors[] = $formatter($error); + } + } + return $formattedErrors; } } diff --git a/lib/internal/Magento/Framework/GraphQl/Query/IntrospectionConfiguration.php b/lib/internal/Magento/Framework/GraphQl/Query/IntrospectionConfiguration.php index 2fdb3df5f6d7..2c498b0b7fd0 100644 --- a/lib/internal/Magento/Framework/GraphQl/Query/IntrospectionConfiguration.php +++ b/lib/internal/Magento/Framework/GraphQl/Query/IntrospectionConfiguration.php @@ -31,7 +31,7 @@ public function __construct( } /** - * Check the the environment config to determine if introspection should be disabled. + * Check the environment config to determine if introspection should be disabled. * * @return bool */ diff --git a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php index dfb8b748469b..ebcbbeaa04ca 100644 --- a/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php +++ b/lib/internal/Magento/Framework/GraphQl/Schema/Type/ScalarTypes.php @@ -21,7 +21,7 @@ class ScalarTypes public function isScalarType(string $typeName) : bool { $standardTypes = \GraphQL\Type\Definition\Type::getStandardTypes(); - return isset($standardTypes[$typeName]) ? true : false; + return isset($standardTypes[$typeName]); } /** diff --git a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php index 2cc2da62e71c..17d748260762 100644 --- a/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php +++ b/lib/internal/Magento/Framework/HTTP/PhpEnvironment/Response.php @@ -1,22 +1,24 @@ <?php /** - * Base HTTP response object - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\HTTP\PhpEnvironment; +/** + * Base HTTP response object + */ class Response extends \Zend\Http\PhpEnvironment\Response implements \Magento\Framework\App\Response\HttpInterface { /** * Flag; is this response a redirect? + * * @var boolean */ protected $isRedirect = false; /** - * {@inheritdoc} + * @inheritdoc */ public function getHeader($name) { @@ -29,8 +31,7 @@ public function getHeader($name) } /** - * Send the response, including all headers, rendering exceptions if so - * requested. + * Send the response, including all headers, rendering exceptions if so requested. * * @return void */ @@ -40,7 +41,7 @@ public function sendResponse() } /** - * {@inheritdoc} + * @inheritdoc */ public function appendBody($value) { @@ -50,7 +51,7 @@ public function appendBody($value) } /** - * {@inheritdoc} + * @inheritdoc */ public function setBody($value) { @@ -60,6 +61,7 @@ public function setBody($value) /** * Clear body + * * @return $this */ public function clearBody() @@ -69,7 +71,7 @@ public function clearBody() } /** - * {@inheritdoc} + * @inheritdoc */ public function setHeader($name, $value, $replace = false) { @@ -84,7 +86,7 @@ public function setHeader($name, $value, $replace = false) } /** - * {@inheritdoc} + * @inheritdoc */ public function clearHeader($name) { @@ -111,7 +113,7 @@ public function clearHeaders() } /** - * {@inheritdoc} + * @inheritdoc */ public function setRedirect($url, $code = 302) { @@ -122,7 +124,7 @@ public function setRedirect($url, $code = 302) } /** - * {@inheritdoc} + * @inheritdoc */ public function setHttpResponseCode($code) { @@ -130,14 +132,14 @@ public function setHttpResponseCode($code) throw new \InvalidArgumentException('Invalid HTTP response code'); } - $this->isRedirect = (300 <= $code && 307 >= $code) ? true : false; + $this->isRedirect = (300 <= $code && 307 >= $code); $this->setStatusCode($code); return $this; } /** - * {@inheritdoc} + * @inheritdoc */ public function setStatusHeader($httpCode, $version = null, $phrase = null) { @@ -152,7 +154,7 @@ public function setStatusHeader($httpCode, $version = null, $phrase = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function getHttpResponseCode() { @@ -170,7 +172,10 @@ public function isRedirect() } /** + * @inheritDoc + * * @return string[] + * @SuppressWarnings(PHPMD.SerializationAware) */ public function __sleep() { diff --git a/lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php b/lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php index 42f7e42960ef..b06f2f9e6239 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php +++ b/lib/internal/Magento/Framework/Image/Adapter/AbstractAdapter.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\Framework\Image\Adapter; @@ -175,7 +174,7 @@ abstract public function open($fileName); /** * Save image to specific path. * - * If some folders of path does not exist they will be created + * If some folders of the path do not exist they will be created. * * @param null|string $destination * @param null|string $newName @@ -292,7 +291,7 @@ public function getMimeType() if ($this->_fileMimeType) { return $this->_fileMimeType; } else { - $this->_fileMimeType = image_type_to_mime_type($this->getImageType()); + $this->_fileMimeType = image_type_to_mime_type((int) $this->getImageType()); return $this->_fileMimeType; } } @@ -524,7 +523,7 @@ public function backgroundColor($value = null) */ protected function _getFileAttributes() { - $pathinfo = pathinfo($this->_fileName); + $pathinfo = pathinfo((string) $this->_fileName); $this->_fileSrcPath = $pathinfo['dirname']; $this->_fileSrcName = $pathinfo['basename']; @@ -626,6 +625,7 @@ protected function _checkDimensions($frameWidth, $frameHeight) $frameHeight !== null && $frameHeight <= 0 || empty($frameWidth) && empty($frameHeight) ) { + //phpcs:ignore Magento2.Exceptions.DirectThrow throw new \InvalidArgumentException('Invalid image dimensions.'); } } @@ -675,7 +675,7 @@ protected function _prepareDestination($destination = null, $newName = null) $destination = $this->_fileSrcPath; } else { if (empty($newName)) { - $info = pathinfo($destination); + $info = pathinfo((string) $destination); $newName = $info['basename']; $destination = $info['dirname']; } @@ -693,6 +693,7 @@ protected function _prepareDestination($destination = null, $newName = null) $this->directoryWrite->create($this->directoryWrite->getRelativePath($destination)); } catch (\Magento\Framework\Exception\FileSystemException $e) { $this->logger->critical($e); + //phpcs:ignore Magento2.Exceptions.DirectThrow throw new \DomainException( 'Unable to write file into directory ' . $destination . '. Access forbidden.' ); @@ -726,14 +727,23 @@ protected function _canProcess() public function validateUploadFile($filePath) { if (!file_exists($filePath)) { - throw new \InvalidArgumentException("File '{$filePath}' does not exists."); + throw new \InvalidArgumentException('Upload file does not exist.'); } + if (filesize($filePath) === 0) { throw new \InvalidArgumentException('Wrong file size.'); } - if (!getimagesize($filePath)) { + + try { + $imageSize = getimagesize($filePath); + } catch (\Exception $e) { + $imageSize = false; + } + + if (!$imageSize) { throw new \InvalidArgumentException('Disallowed file type.'); } + $this->checkDependencies(); $this->open($filePath); diff --git a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php index d52e70ef56a1..7e92b336cfdc 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/Gd2.php +++ b/lib/internal/Magento/Framework/Image/Adapter/Gd2.php @@ -296,8 +296,9 @@ private function _fillBackgroundColor(&$imageResourceTo) imagecolortransparent($imageResourceTo, $transparentColor); return $transparentColor; } + // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch } catch (\Exception $e) { - throw new \DomainException('Failed to fill image.'); + // fallback to default background color } } list($r, $g, $b) = $this->_backgroundColor; diff --git a/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php b/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php index b55ace9bdec3..60bbc092469c 100644 --- a/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php +++ b/lib/internal/Magento/Framework/Indexer/Test/Unit/MultiDimensionProviderTest.php @@ -210,6 +210,11 @@ public function testMultiDimensionProviderWithMixedDataProvider() } } + /** + * @param $dimensions + * + * @return \PHPUnit\Framework\MockObject\MockObject + */ private function getDimensionProviderMock($dimensions) { $dimensionProviderMock = $this->getMockBuilder(DimensionProviderInterface::class) @@ -233,6 +238,12 @@ function () use ($dimensions) { return $dimensionProviderMock; } + /** + * @param string $name + * @param string $value + * + * @return \PHPUnit\Framework\MockObject\MockObject + */ private function getDimensionMock(string $name, string $value) { $dimensionMock = $this->getMockBuilder(Dimension::class) diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php index a4f728454a52..bf1372dc007a 100644 --- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php +++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php @@ -138,7 +138,7 @@ public function __construct( protected function _inheritPlugins($type) { $type = ltrim($type, '\\'); - if (!array_key_exists($type, $this->_inherited)) { + if (!isset($this->_inherited[$type])) { $realType = $this->_omConfig->getOriginalInstanceType($type); if ($realType !== $type) { @@ -292,28 +292,7 @@ protected function _loadScopedData() $this->_loadedScopes[$scopeCode] = true; } } else { - $virtualTypes = []; - foreach ($this->_scopePriorityScheme as $scopeCode) { - if (false == isset($this->_loadedScopes[$scopeCode])) { - $data = $this->_reader->read($scopeCode) ?: []; - unset($data['preferences']); - if (count($data) > 0) { - $this->_inherited = []; - $this->_processed = []; - $this->merge($data); - foreach ($data as $class => $config) { - if (isset($config['type'])) { - $virtualTypes[] = $class; - } - } - } - $this->_loadedScopes[$scopeCode] = true; - } - if ($this->isCurrentScope($scopeCode)) { - break; - } - } - foreach ($virtualTypes as $class) { + foreach ($this->_loadScopedVirtualTypes() as $class) { $this->_inheritPlugins($class); } foreach ($this->getClassDefinitions() as $class) { @@ -328,6 +307,37 @@ protected function _loadScopedData() } } + /** + * Load virtual types for current scope + * + * @return array + */ + private function _loadScopedVirtualTypes() + { + $virtualTypes = []; + foreach ($this->_scopePriorityScheme as $scopeCode) { + if (!isset($this->_loadedScopes[$scopeCode])) { + $data = $this->_reader->read($scopeCode) ?: []; + unset($data['preferences']); + if (count($data) > 0) { + $this->_inherited = []; + $this->_processed = []; + $this->merge($data); + foreach ($data as $class => $config) { + if (isset($config['type'])) { + $virtualTypes[] = $class; + } + } + } + $this->_loadedScopes[$scopeCode] = true; + } + if ($this->isCurrentScope($scopeCode)) { + break; + } + } + return $virtualTypes; + } + /** * Whether scope code is current scope code * diff --git a/lib/internal/Magento/Framework/Locale/Config.php b/lib/internal/Magento/Framework/Locale/Config.php index 499c3bd26a3a..f02ba78ccc3e 100644 --- a/lib/internal/Magento/Framework/Locale/Config.php +++ b/lib/internal/Magento/Framework/Locale/Config.php @@ -91,7 +91,8 @@ class Config implements \Magento\Framework\Locale\ConfigInterface 'sk_SK', /*Slovak (Slovakia)*/ 'sl_SI', /*Slovenian (Slovenia)*/ 'sq_AL', /*Albanian (Albania)*/ - 'sr_Cyrl_RS', /*Serbian (Serbia)*/ + 'sr_Cyrl_RS', /*Serbian (Cyrillic, Serbia)*/ + 'sr_Latn_RS', /*Serbian (Latin, Serbia)*/ 'sv_SE', /*Swedish (Sweden)*/ 'sv_FI', /*Swedish (Finland)*/ 'sw_KE', /*Swahili (Kenya)*/ diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php index 5e1dfdc16635..149f6b5e33b6 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/ConfigTest.php @@ -15,7 +15,7 @@ class ConfigTest extends \PHPUnit\Framework\TestCase 'es_MX', 'eu_ES', 'es_PE', 'et_EE', 'fa_IR', 'fi_FI', 'fil_PH', 'fr_CA', 'fr_FR', 'gu_IN', 'he_IL', 'hi_IN', 'hr_HR', 'hu_HU', 'id_ID', 'is_IS', 'it_CH', 'it_IT', 'ja_JP', 'ka_GE', 'km_KH', 'ko_KR', 'lo_LA', 'lt_LT', 'lv_LV', 'mk_MK', 'mn_Cyrl_MN', 'ms_Latn_MY', 'nl_NL', 'nb_NO', - 'nn_NO', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sk_SK', 'sl_SI', 'sq_AL', 'sr_Cyrl_RS', + 'nn_NO', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sk_SK', 'sl_SI', 'sq_AL', 'sr_Cyrl_RS', 'sr_Latn_RS', 'sv_SE', 'sw_KE', 'th_TH', 'tr_TR', 'uk_UA', 'vi_VN', 'zh_Hans_CN', 'zh_Hant_HK', 'zh_Hant_TW', 'es_CL', 'lo_LA', 'es_VE', 'en_IE', ]; diff --git a/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php index 9e247a8e21ac..0d51d6fbda30 100644 --- a/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php +++ b/lib/internal/Magento/Framework/Locale/Test/Unit/TranslatedListsTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\Locale\Test\Unit; @@ -17,23 +18,62 @@ class TranslatedListsTest extends TestCase /** * @var TranslatedLists */ - protected $listsModel; + private $listsModel; /** - * @var MockObject | ConfigInterface + * @var MockObject | ConfigInterface */ - protected $mockConfig; + private $mockConfig; /** - * @var MockObject | ResolverInterface + * @var MockObject | ResolverInterface */ - protected $mockLocaleResolver; + private $mockLocaleResolver; + + /** + * @var array + */ + private $expectedCurrencies = [ + 'USD', + 'EUR', + 'UAH', + 'GBP', + ]; + + /** + * @var array + */ + private $expectedLocales = [ + 'en_US' => 'English (United States)', + 'en_GB' => 'English (United Kingdom)', + 'uk_UA' => 'Ukrainian (Ukraine)', + 'de_DE' => 'German (Germany)', + 'sr_Cyrl_RS' => 'Serbian (Cyrillic, Serbia)', + 'sr_Latn_RS' => 'Serbian (Latin, Serbia)' + ]; + + /** + * @var array + */ + private $expectedTranslatedLocales = [ + 'en_US' => 'English (United States) / English (United States)', + 'en_GB' => 'English (United Kingdom) / English (United Kingdom)', + 'uk_UA' => 'українська (Україна) / Ukrainian (Ukraine)', + 'de_DE' => 'Deutsch (Deutschland) / German (Germany)', + 'sr_Cyrl_RS' => 'српски (ћирилица, Србија) / Serbian (Cyrillic, Serbia)', + 'sr_Latn_RS' => 'Srpski (latinica, Srbija) / Serbian (Latin, Serbia)' + ]; protected function setUp() { $this->mockConfig = $this->getMockBuilder(ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); + $this->mockConfig->method('getAllowedLocales') + ->willReturn(array_keys($this->expectedLocales)); + $this->mockConfig->method('getAllowedCurrencies') + ->willReturn($this->expectedCurrencies); + $this->mockLocaleResolver = $this->getMockBuilder(ResolverInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -69,12 +109,6 @@ public function testGetOptionAllCurrencies() public function testGetOptionCurrencies() { - $allowedCurrencies = ['USD', 'EUR', 'GBP', 'UAH']; - - $this->mockConfig->expects($this->once()) - ->method('getAllowedCurrencies') - ->willReturn($allowedCurrencies); - $expectedResults = ['USD', 'EUR', 'GBP', 'UAH']; $currencyList = $this->listsModel->getOptionCurrencies(); @@ -134,44 +168,34 @@ public function testGetOptionTimezones() public function testGetOptionLocales() { - $this->setupForOptionLocales(); - - $expectedResults = ['en_US', 'uk_UA', 'de_DE']; - - $list = $this->listsModel->getOptionLocales(); - foreach ($expectedResults as $value) { - $found = false; - foreach ($list as $item) { - $found = $found || ($value == $item['value']); - } - $this->assertTrue($found); - } + $locales = array_intersect( + $this->expectedLocales, + $this->convertOptionLocales($this->listsModel->getOptionLocales()) + ); + $this->assertEquals($this->expectedLocales, $locales); } public function testGetTranslatedOptionLocales() { - $this->setupForOptionLocales(); - - $expectedResults = ['en_US', 'uk_UA', 'de_DE']; - - $list = $this->listsModel->getOptionLocales(); - foreach ($expectedResults as $value) { - $found = false; - foreach ($list as $item) { - $found = $found || ($value == $item['value']); - } - $this->assertTrue($found); - } + $locales = array_intersect( + $this->expectedTranslatedLocales, + $this->convertOptionLocales($this->listsModel->getTranslatedOptionLocales()) + ); + $this->assertEquals($this->expectedTranslatedLocales, $locales); } /** - * Setup for option locales + * @param array $optionLocales + * @return array */ - protected function setupForOptionLocales() + private function convertOptionLocales($optionLocales): array { - $allowedLocales = ['en_US', 'uk_UA', 'de_DE']; - $this->mockConfig->expects($this->once()) - ->method('getAllowedLocales') - ->willReturn($allowedLocales); + $result = []; + + foreach ($optionLocales as $optionLocale) { + $result[$optionLocale['value']] = $optionLocale['label']; + } + + return $result; } } diff --git a/lib/internal/Magento/Framework/Locale/TranslatedLists.php b/lib/internal/Magento/Framework/Locale/TranslatedLists.php index 2087564dcec2..e409ca2f0335 100644 --- a/lib/internal/Magento/Framework/Locale/TranslatedLists.php +++ b/lib/internal/Magento/Framework/Locale/TranslatedLists.php @@ -81,17 +81,23 @@ protected function _getOptionLocales($translatedName = false) } $language = \Locale::getPrimaryLanguage($locale); $country = \Locale::getRegion($locale); + $script = \Locale::getScript($locale); + $scriptTranslated = ''; if (!$languages[$language] || !$countries[$country]) { continue; } + if ($script !== '') { + $script = \Locale::getDisplayScript($locale) . ', '; + $scriptTranslated = \Locale::getDisplayScript($locale, $locale) . ', '; + } if ($translatedName) { $label = ucwords(\Locale::getDisplayLanguage($locale, $locale)) - . ' (' . \Locale::getDisplayRegion($locale, $locale) . ') / ' + . ' (' . $scriptTranslated . \Locale::getDisplayRegion($locale, $locale) . ') / ' . $languages[$language] - . ' (' . $countries[$country] . ')'; + . ' (' . $script . $countries[$country] . ')'; } else { $label = $languages[$language] - . ' (' . $countries[$country] . ')'; + . ' (' . $script . $countries[$country] . ')'; } $options[] = ['value' => $locale, 'label' => $label]; } diff --git a/lib/internal/Magento/Framework/Lock/Backend/Database.php b/lib/internal/Magento/Framework/Lock/Backend/Database.php index 096e77a11768..a5a76ba60f4e 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Database.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Database.php @@ -76,7 +76,7 @@ public function lock(string $name, int $timeout = -1): bool { if (!$this->deploymentConfig->isDbAvailable()) { return true; - }; + } $name = $this->addPrefix($name); /** @@ -117,7 +117,7 @@ public function unlock(string $name): bool { if (!$this->deploymentConfig->isDbAvailable()) { return true; - }; + } $name = $this->addPrefix($name); @@ -145,7 +145,7 @@ public function isLocked(string $name): bool { if (!$this->deploymentConfig->isDbAvailable()) { return false; - }; + } $name = $this->addPrefix($name); diff --git a/lib/internal/Magento/Framework/Mail/EmailMessage.php b/lib/internal/Magento/Framework/Mail/EmailMessage.php index aaef97507518..02c75977cd09 100644 --- a/lib/internal/Magento/Framework/Mail/EmailMessage.php +++ b/lib/internal/Magento/Framework/Mail/EmailMessage.php @@ -10,19 +10,13 @@ use Magento\Framework\Mail\Exception\InvalidArgumentException; use Zend\Mail\Address as ZendAddress; use Zend\Mail\AddressList; -use Zend\Mail\Message as ZendMessage; use Zend\Mime\Message as ZendMimeMessage; /** - * Class EmailMessage + * Email message */ -class EmailMessage implements EmailMessageInterface +class EmailMessage extends Message implements EmailMessageInterface { - /** - * @var ZendMessage - */ - private $message; - /** * @var MimeMessageInterfaceFactory */ @@ -64,38 +58,35 @@ public function __construct( ?array $replyTo = null, ?Address $sender = null, ?string $subject = '', - ?string $encoding = '' + ?string $encoding = 'utf-8' ) { - $this->message = new ZendMessage(); + parent::__construct($encoding); $mimeMessage = new ZendMimeMessage(); $mimeMessage->setParts($body->getParts()); - $this->message->setBody($mimeMessage); - if ($encoding) { - $this->message->setEncoding($encoding); - } + $this->zendMessage->setBody($mimeMessage); if ($subject) { - $this->message->setSubject($subject); + $this->zendMessage->setSubject($subject); } if ($sender) { - $this->message->setSender($sender->getEmail(), $sender->getName()); + $this->zendMessage->setSender($sender->getEmail(), $sender->getName()); } if (count($to) < 1) { throw new InvalidArgumentException('Email message must have at list one addressee'); } if ($to) { - $this->message->setTo($this->convertAddressArrayToAddressList($to)); + $this->zendMessage->setTo($this->convertAddressArrayToAddressList($to)); } if ($replyTo) { - $this->message->setReplyTo($this->convertAddressArrayToAddressList($replyTo)); + $this->zendMessage->setReplyTo($this->convertAddressArrayToAddressList($replyTo)); } if ($from) { - $this->message->setFrom($this->convertAddressArrayToAddressList($from)); + $this->zendMessage->setFrom($this->convertAddressArrayToAddressList($from)); } if ($cc) { - $this->message->setCc($this->convertAddressArrayToAddressList($cc)); + $this->zendMessage->setCc($this->convertAddressArrayToAddressList($cc)); } if ($bcc) { - $this->message->setBcc($this->convertAddressArrayToAddressList($bcc)); + $this->zendMessage->setBcc($this->convertAddressArrayToAddressList($bcc)); } $this->mimeMessageFactory = $mimeMessageFactory; $this->addressFactory = $addressFactory; @@ -106,7 +97,7 @@ public function __construct( */ public function getEncoding(): string { - return $this->message->getEncoding(); + return $this->zendMessage->getEncoding(); } /** @@ -114,7 +105,7 @@ public function getEncoding(): string */ public function getHeaders(): array { - return $this->message->getHeaders()->toArray(); + return $this->zendMessage->getHeaders()->toArray(); } /** @@ -122,7 +113,7 @@ public function getHeaders(): array */ public function getFrom(): ?array { - return $this->convertAddressListToAddressArray($this->message->getFrom()); + return $this->convertAddressListToAddressArray($this->zendMessage->getFrom()); } /** @@ -130,7 +121,7 @@ public function getFrom(): ?array */ public function getTo(): array { - return $this->convertAddressListToAddressArray($this->message->getTo()); + return $this->convertAddressListToAddressArray($this->zendMessage->getTo()); } /** @@ -138,7 +129,7 @@ public function getTo(): array */ public function getCc(): ?array { - return $this->convertAddressListToAddressArray($this->message->getCc()); + return $this->convertAddressListToAddressArray($this->zendMessage->getCc()); } /** @@ -146,7 +137,7 @@ public function getCc(): ?array */ public function getBcc(): ?array { - return $this->convertAddressListToAddressArray($this->message->getBcc()); + return $this->convertAddressListToAddressArray($this->zendMessage->getBcc()); } /** @@ -154,7 +145,7 @@ public function getBcc(): ?array */ public function getReplyTo(): ?array { - return $this->convertAddressListToAddressArray($this->message->getReplyTo()); + return $this->convertAddressListToAddressArray($this->zendMessage->getReplyTo()); } /** @@ -163,7 +154,7 @@ public function getReplyTo(): ?array public function getSender(): ?Address { /** @var ZendAddress $zendSender */ - if (!$zendSender = $this->message->getSender()) { + if (!$zendSender = $this->zendMessage->getSender()) { return null; } @@ -178,18 +169,10 @@ public function getSender(): ?Address /** * @inheritDoc */ - public function getSubject(): ?string - { - return $this->message->getSubject(); - } - - /** - * @inheritDoc - */ - public function getBody(): MimeMessageInterface + public function getMessageBody(): MimeMessageInterface { return $this->mimeMessageFactory->create( - ['parts' => $this->message->getBody()->getParts()] + ['parts' => $this->zendMessage->getBody()->getParts()] ); } @@ -198,15 +181,7 @@ public function getBody(): MimeMessageInterface */ public function getBodyText(): string { - return $this->message->getBodyText(); - } - - /** - * @inheritdoc - */ - public function getRawMessage(): string - { - return $this->toString(); + return $this->zendMessage->getBodyText(); } /** @@ -214,7 +189,7 @@ public function getRawMessage(): string */ public function toString(): string { - return $this->message->toString(); + return $this->zendMessage->toString(); } /** diff --git a/lib/internal/Magento/Framework/Mail/EmailMessageInterface.php b/lib/internal/Magento/Framework/Mail/EmailMessageInterface.php index 95f83ff679cd..93eaa4acde3a 100644 --- a/lib/internal/Magento/Framework/Mail/EmailMessageInterface.php +++ b/lib/internal/Magento/Framework/Mail/EmailMessageInterface.php @@ -9,7 +9,7 @@ /** * Interface EmailMessageInterface */ -interface EmailMessageInterface +interface EmailMessageInterface extends MailMessageInterface { /** * Get the message encoding @@ -72,14 +72,14 @@ public function getSender(): ?Address; * * @return null|string */ - public function getSubject(): ?string; + public function getSubject(); /** * Return the currently set message body * * @return MimeMessageInterface */ - public function getBody(): MimeMessageInterface; + public function getMessageBody(): MimeMessageInterface; /** * Get the string-serialized message body text diff --git a/lib/internal/Magento/Framework/Mail/MailMessageInterface.php b/lib/internal/Magento/Framework/Mail/MailMessageInterface.php index da010be27025..5179e6057c4c 100644 --- a/lib/internal/Magento/Framework/Mail/MailMessageInterface.php +++ b/lib/internal/Magento/Framework/Mail/MailMessageInterface.php @@ -9,6 +9,8 @@ * Mail Message interface * * @api + * @deprecated + * @see \Magento\Framework\Mail\EmailMessageInterface */ interface MailMessageInterface extends MessageInterface { diff --git a/lib/internal/Magento/Framework/Mail/Message.php b/lib/internal/Magento/Framework/Mail/Message.php index b15b75ca9ac6..1f423e801087 100644 --- a/lib/internal/Magento/Framework/Mail/Message.php +++ b/lib/internal/Magento/Framework/Mail/Message.php @@ -10,13 +10,16 @@ /** * Class Message for email transportation + * + * @deprecated + * @see \Magento\Framework\Mail\EmailMessage */ class Message implements MailMessageInterface { /** * @var \Zend\Mail\Message */ - private $zendMessage; + protected $zendMessage; /** * Message type diff --git a/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php b/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php index 4a8d6572faaf..830d9b0f722e 100644 --- a/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php +++ b/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php @@ -87,7 +87,7 @@ class TransportBuilder /** * Message * - * @var EmailMessageInterface + * @var MessageInterface */ protected $message; @@ -377,6 +377,7 @@ protected function prepareMessage() { $template = $this->getTemplate(); $content = $template->processTemplate(); + switch ($template->getType()) { case TemplateTypesInterface::TYPE_TEXT: $part['type'] = MimeInterface::TYPE_TEXT; @@ -391,7 +392,10 @@ protected function prepareMessage() new Phrase('Unknown template type') ); } + + /** @var \Magento\Framework\Mail\MimePartInterface $mimePart */ $mimePart = $this->mimePartInterfaceFactory->create(['content' => $content]); + $this->messageData['encoding'] = $mimePart->getCharset(); $this->messageData['body'] = $this->mimeMessageInterfaceFactory->create( ['parts' => [$mimePart]] ); @@ -400,6 +404,7 @@ protected function prepareMessage() (string)$template->getSubject(), ENT_QUOTES ); + $this->message = $this->emailMessageInterfaceFactory->create($this->messageData); return $this; @@ -427,6 +432,8 @@ private function addAddressByType(string $addressType, $email, ?string $name = n $this->messageData[$addressType], $convertedAddressArray ); + } else { + $this->messageData[$addressType] = $convertedAddressArray; } } } diff --git a/lib/internal/Magento/Framework/MessageQueue/MessageValidator.php b/lib/internal/Magento/Framework/MessageQueue/MessageValidator.php index a40bb9af1e0c..7c1a947623e9 100644 --- a/lib/internal/Magento/Framework/MessageQueue/MessageValidator.php +++ b/lib/internal/Magento/Framework/MessageQueue/MessageValidator.php @@ -5,14 +5,13 @@ */ namespace Magento\Framework\MessageQueue; -use Doctrine\Instantiator\Exception\InvalidArgumentException; +use InvalidArgumentException; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Phrase; use Magento\Framework\Communication\ConfigInterface as CommunicationConfig; /** - * Class MessageValidator to validate message with topic schema - * + * Class MessageValidator to validate message with topic schema. */ class MessageValidator { @@ -58,6 +57,7 @@ protected function getTopicSchema($topic, $requestType) * @param bool $requestType * @return void * @throws InvalidArgumentException + * @throws LocalizedException */ public function validate($topic, $message, $requestType = true) { @@ -89,6 +89,8 @@ public function validate($topic, $message, $requestType = true) } /** + * Validate queue message. + * * @param string $message * @param string $messageType * @param string $topic @@ -104,6 +106,8 @@ protected function validateMessage($message, $messageType, $topic) } /** + * Validate message primitive type. + * * @param string $message * @param string $messageType * @param string $topic @@ -135,6 +139,8 @@ protected function validatePrimitiveType($message, $messageType, $topic) } /** + * Validate class type + * * @param string $message * @param string $messageType * @param string $topic @@ -167,6 +173,8 @@ protected function validateClassType($message, $messageType, $topic) } /** + * Returns message real type + * * @param string $message * @return string */ diff --git a/lib/internal/Magento/Framework/Module/Manager.php b/lib/internal/Magento/Framework/Module/Manager.php index 659ada3c20ac..b47349631a03 100644 --- a/lib/internal/Magento/Framework/Module/Manager.php +++ b/lib/internal/Magento/Framework/Module/Manager.php @@ -12,9 +12,14 @@ namespace Magento\Framework\Module; /** - * @inheritdoc + * Module status manager + * + * Usage: + * ```php + * $manager->isEnabled('Vendor_Module'); + * ``` */ -class Manager implements ModuleManagerInterface +class Manager { /** * @var Output\ConfigInterface @@ -49,9 +54,12 @@ public function __construct( } /** - * @inheritdoc + * Whether a module is enabled in the configuration or not + * + * @param string $moduleName Fully-qualified module name + * @return boolean */ - public function isEnabled(string $moduleName): bool + public function isEnabled($moduleName) { return $this->moduleList->has($moduleName); } diff --git a/lib/internal/Magento/Framework/Module/ModuleList/Loader.php b/lib/internal/Magento/Framework/Module/ModuleList/Loader.php index 72421f793f13..b1d21a6db5f1 100644 --- a/lib/internal/Magento/Framework/Module/ModuleList/Loader.php +++ b/lib/internal/Magento/Framework/Module/ModuleList/Loader.php @@ -78,6 +78,8 @@ public function __construct( public function load(array $exclude = []) { $result = []; + $excludeSet = array_flip($exclude); + foreach ($this->getModuleConfigs() as list($file, $contents)) { try { $this->parser->loadXML($contents); @@ -93,7 +95,7 @@ public function load(array $exclude = []) $data = $this->converter->convert($this->parser->getDom()); $name = key($data); - if (!in_array($name, $exclude)) { + if (!isset($excludeSet[$name])) { $result[$name] = $data[$name]; } } @@ -140,7 +142,7 @@ private function sortBySequence(array $origList): array $expanded[] = [ 'name' => $moduleName, - 'sequence' => $sequence, + 'sequence_set' => array_flip($sequence), ]; } @@ -148,7 +150,7 @@ private function sortBySequence(array $origList): array $total = count($expanded); for ($i = 0; $i < $total - 1; $i++) { for ($j = $i; $j < $total; $j++) { - if (in_array($expanded[$j]['name'], $expanded[$i]['sequence'], true)) { + if (isset($expanded[$i]['sequence_set'][$expanded[$j]['name']])) { $temp = $expanded[$i]; $expanded[$i] = $expanded[$j]; $expanded[$j] = $temp; @@ -196,18 +198,19 @@ private function prearrangeModules(array $modules): array */ private function expandSequence($list, $name, $accumulated = []) { - $accumulated[] = $name; + $accumulated[$name] = true; $result = $list[$name]['sequence']; + $allResults = []; foreach ($result as $relatedName) { - if (in_array($relatedName, $accumulated)) { - throw new \Exception("Circular sequence reference from '{$name}' to '{$relatedName}'."); + if (isset($accumulated[$relatedName])) { + throw new \LogicException("Circular sequence reference from '{$name}' to '{$relatedName}'."); } if (!isset($list[$relatedName])) { continue; } - $relatedResult = $this->expandSequence($list, $relatedName, $accumulated); - $result = array_unique(array_merge($result, $relatedResult)); + $allResults[] = $this->expandSequence($list, $relatedName, $accumulated); } - return $result; + $allResults[] = $result; + return array_unique(array_merge(...$allResults)); } } diff --git a/lib/internal/Magento/Framework/Module/ModuleManagerInterface.php b/lib/internal/Magento/Framework/Module/ModuleManagerInterface.php deleted file mode 100644 index decc91200354..000000000000 --- a/lib/internal/Magento/Framework/Module/ModuleManagerInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Module; - -/** - * Module status manager - * - * Usage: - * ```php - * $manager->isEnabled('Vendor_Module'); - * ``` - */ -interface ModuleManagerInterface -{ - /** - * Retrieve whether or not a module is enabled by configuration - * - * @param string $moduleName Fully-qualified module name, e.g. Magento_Config - * @return boolean Whether or not the module is enabled in the configuration - */ - public function isEnabled(string $moduleName): bool; -} diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php index e4cf4c41599e..748474943a43 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ManagerTest.php @@ -16,7 +16,7 @@ class ManagerTest extends \PHPUnit\Framework\TestCase const XML_PATH_OUTPUT_ENABLED = 'custom/is_module_output_enabled'; /** - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $_model; @@ -73,7 +73,6 @@ public function testIsEnabled() public function testIsOutputEnabledReturnsFalseForDisabledModule() { - $this->_moduleList->expects($this->once())->method('has')->with('Disabled_Module')->willReturn(false); $this->_outputConfig->expects($this->any())->method('isSetFlag')->will($this->returnValue(true)); $this->assertFalse($this->_model->isOutputEnabled('Disabled_Module')); } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php index 7a631eed1adb..bfd916dbfba5 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Plugin/DbStatusValidatorTest.php @@ -35,7 +35,7 @@ class DbStatusValidatorTest extends \PHPUnit\Framework\TestCase protected $requestMock; /** - * @var \Magento\Framework\Module\ModuleManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Module\Manager|\PHPUnit_Framework_MockObject_MockObject */ private $moduleManager; diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php index 3f806b319ef4..54f6351e9651 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php @@ -51,7 +51,10 @@ protected function setUp() ['getView'] ); $this->actionFactoryMock = $this->createPartialMock(\Magento\Framework\Mview\ActionFactory::class, ['get']); - $this->stateMock = $this->createPartialMock(\Magento\Indexer\Model\Mview\View\State::class, ['getViewId', + $this->stateMock = $this->createPartialMock( + \Magento\Indexer\Model\Mview\View\State::class, + [ + 'getViewId', 'loadByView', 'getVersionId', 'setVersionId', @@ -62,7 +65,8 @@ protected function setUp() 'setMode', 'save', '__wakeup', - ]); + ] + ); $this->changelogMock = $this->createPartialMock( \Magento\Framework\Mview\View\Changelog::class, ['getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList', 'clear'] @@ -182,11 +186,11 @@ public function testSubscribeWithException() $this->changelogMock->expects($this->once()) ->method('create') - ->will($this->returnCallback( + ->willReturnCallback( function () { throw new \Exception(); } - )); + ); $this->loadView(); $this->model->subscribe(); @@ -245,11 +249,11 @@ public function testUnsubscribeWithException() $subscriptionMock = $this->createPartialMock(\Magento\Framework\Mview\View\Subscription::class, ['remove']); $subscriptionMock->expects($this->exactly(1)) ->method('remove') - ->will($this->returnCallback( + ->willReturnCallback( function () { throw new \Exception(); } - )); + ); $this->subscriptionFactoryMock->expects($this->exactly(1)) ->method('create') ->will($this->returnValue($subscriptionMock)); @@ -273,6 +277,9 @@ public function testUpdate() $this->stateMock->expects($this->once()) ->method('setVersionId') ->will($this->returnSelf()); + $this->stateMock->expects($this->atLeastOnce()) + ->method('getMode') + ->willReturn(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED); $this->stateMock->expects($this->exactly(2)) ->method('getStatus') ->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::STATUS_IDLE)); @@ -335,6 +342,9 @@ public function testUpdateWithException() ->will($this->returnValue($lastVersionId)); $this->stateMock->expects($this->never()) ->method('setVersionId'); + $this->stateMock->expects($this->atLeastOnce()) + ->method('getMode') + ->willReturn(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED); $this->stateMock->expects($this->exactly(2)) ->method('getStatus') ->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::STATUS_IDLE)); diff --git a/lib/internal/Magento/Framework/Mview/View.php b/lib/internal/Magento/Framework/Mview/View.php index e6f2d9fe0399..b2372eaaafaa 100644 --- a/lib/internal/Magento/Framework/Mview/View.php +++ b/lib/internal/Magento/Framework/Mview/View.php @@ -240,7 +240,7 @@ public function unsubscribe() */ public function update() { - if ($this->getState()->getStatus() !== View\StateInterface::STATUS_IDLE) { + if (!$this->isIdle() || !$this->isEnabled()) { return; } @@ -293,7 +293,7 @@ private function executeAction(ActionInterface $action, int $lastVersionId, int { $versionBatchSize = self::$maxVersionQueryBatch; $batchSize = isset($this->changelogBatchSize[$this->getChangelog()->getViewId()]) - ? $this->changelogBatchSize[$this->getChangelog()->getViewId()] + ? (int) $this->changelogBatchSize[$this->getChangelog()->getViewId()] : self::DEFAULT_BATCH_SIZE; for ($vsFrom = $lastVersionId; $vsFrom < $currentVersionId; $vsFrom += $versionBatchSize) { diff --git a/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php b/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php index 9bc023645eca..6663732ec8d3 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php +++ b/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php @@ -7,6 +7,11 @@ */ namespace Magento\Framework\ObjectManager\Definition; +/** + * Class Runtime + * + * @package Magento\Framework\ObjectManager\Definition + */ class Runtime implements \Magento\Framework\ObjectManager\DefinitionInterface { /** @@ -45,7 +50,7 @@ public function __construct(\Magento\Framework\Code\Reader\ClassReaderInterface */ public function getParameters($className) { - if (!array_key_exists($className, $this->_definitions)) { + if (!isset($this->_definitions[$className])) { $this->_definitions[$className] = $this->_reader->getConstructor($className); } return $this->_definitions[$className]; diff --git a/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php b/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php index 15c4cb098b84..7094b116ead3 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php +++ b/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php @@ -11,6 +11,9 @@ use Psr\Log\LoggerInterface; use Magento\Framework\App\ObjectManager; +/** + * Class AbstractFactory + */ abstract class AbstractFactory implements \Magento\Framework\ObjectManager\FactoryInterface { /** @@ -49,10 +52,10 @@ abstract class AbstractFactory implements \Magento\Framework\ObjectManager\Facto protected $creationStack = []; /** - * @param \Magento\Framework\ObjectManager\ConfigInterface $config - * @param ObjectManagerInterface $objectManager + * @param \Magento\Framework\ObjectManager\ConfigInterface $config + * @param ObjectManagerInterface $objectManager * @param \Magento\Framework\ObjectManager\DefinitionInterface $definitions - * @param array $globalArguments + * @param array $globalArguments */ public function __construct( \Magento\Framework\ObjectManager\ConfigInterface $config, @@ -91,6 +94,8 @@ public function setArguments($arguments) } /** + * Get definitions + * * @return \Magento\Framework\ObjectManager\DefinitionInterface */ public function getDefinitions() @@ -105,7 +110,7 @@ public function getDefinitions() * Create object * * @param string $type - * @param array $args + * @param array $args * * @return object * @throws RuntimeException @@ -115,7 +120,9 @@ protected function createObject($type, $args) try { return new $type(...array_values($args)); } catch (\TypeError $exception) { - /** @var LoggerInterface $logger */ + /** + * @var LoggerInterface $logger + */ $logger = ObjectManager::getInstance()->get(LoggerInterface::class); $logger->critical( sprintf('Type Error occurred when creating object: %s, %s', $type, $exception->getMessage()) @@ -130,9 +137,9 @@ protected function createObject($type, $args) /** * Resolve an argument * - * @param array &$argument + * @param array $argument * @param string $paramType - * @param mixed $paramDefault + * @param mixed $paramDefault * @param string $paramName * @param string $requestedType * @@ -214,8 +221,8 @@ protected function parseArray(&$array) * Resolve constructor arguments * * @param string $requestedType - * @param array $parameters - * @param array $arguments + * @param array $parameters + * @param array $arguments * * @return array * @@ -226,27 +233,44 @@ protected function resolveArgumentsInRuntime($requestedType, array $parameters, { $resolvedArguments = []; foreach ($parameters as $parameter) { - list($paramName, $paramType, $paramRequired, $paramDefault) = $parameter; - $argument = null; - if (!empty($arguments) && (isset($arguments[$paramName]) || array_key_exists($paramName, $arguments))) { - $argument = $arguments[$paramName]; - } elseif ($paramRequired) { - if ($paramType) { - $argument = ['instance' => $paramType]; - } else { - $this->creationStack = []; - throw new \BadMethodCallException( - 'Missing required argument $' . $paramName . ' of ' . $requestedType . '.' - ); - } + $resolvedArguments[] = $this->getResolvedArgument((string)$requestedType, $parameter, $arguments); + } + + return empty($resolvedArguments) ? [] : array_merge(...$resolvedArguments); + } + + /** + * Get resolved argument from parameter + * + * @param string $requestedType + * @param array $parameter + * @param array $arguments + * @return array + */ + private function getResolvedArgument(string $requestedType, array $parameter, array $arguments): array + { + list($paramName, $paramType, $paramRequired, $paramDefault, $isVariadic) = $parameter; + $argument = null; + if (!empty($arguments) && (isset($arguments[$paramName]) || array_key_exists($paramName, $arguments))) { + $argument = $arguments[$paramName]; + } elseif ($paramRequired) { + if ($paramType) { + $argument = ['instance' => $paramType]; } else { - $argument = $paramDefault; + $this->creationStack = []; + throw new \BadMethodCallException( + 'Missing required argument $' . $paramName . ' of ' . $requestedType . '.' + ); } + } else { + $argument = $paramDefault; + } - $this->resolveArgument($argument, $paramType, $paramDefault, $paramName, $requestedType); - - $resolvedArguments[] = $argument; + if ($isVariadic) { + return is_array($argument) ? $argument : [$argument]; } - return $resolvedArguments; + + $this->resolveArgument($argument, $paramType, $paramDefault, $paramName, $requestedType); + return [$argument]; } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php index c1c1e7c17709..90e014d5ee17 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php +++ b/lib/internal/Magento/Framework/ObjectManager/Profiler/Log.php @@ -3,9 +3,10 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\ObjectManager\Profiler; -use Magento\Framework\ObjectManager\Profiler\Tree\Item as Item; +use Magento\Framework\ObjectManager\Profiler\Tree\Item; /** * Class Log @@ -133,17 +134,19 @@ public function display() { $this->stats['used'] = count($this->used); $this->stats['unused'] = $this->stats['total'] - $this->stats['used']; + //phpcs:disable echo '<table border="1" cellspacing="0" cellpadding="2">', - '<thead><tr><th>', - "Creation chain (Red items are never used) Total: {$this->stats['total']}\n", - "Used: {$this->stats['used']} Not used: {$this->stats['unused']}", - '</th></tr></thead>', - '<tbody>', - '<tr><th>Instance class</th></tr>'; + '<thead><tr><th>', + "Creation chain (Red items are never used) Total: {$this->stats['total']}\n", + "Used: {$this->stats['used']} Not used: {$this->stats['unused']}", + '</th></tr></thead>', + '<tbody>', + '<tr><th>Instance class</th></tr>'; foreach ($this->roots as $root) { $this->displayItem($root); } echo '</tbody></table>'; + //phpcs:enable } /** @@ -156,9 +159,10 @@ public function display() protected function displayItem(Item $item, $level = 0) { $colorStyle = isset($this->used[$item->getHash()]) ? '' : ' style="color:red" '; - + //phpcs:disable echo "<tr><td $colorStyle>" . str_repeat('· ', $level) . $item->getClass() . ' - ' . $item->getHash() . '</td></tr>'; + //phpcs:enable foreach ($item->getChildren() as $child) { $this->displayItem($child, $level + 1); diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php index 000e9fb529a6..e61d8f089065 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Config/CompiledTest.php @@ -6,7 +6,7 @@ namespace Magento\Framework\ObjectManager\Test\Unit\Config; use Magento\Framework\ObjectManager\Config\Compiled; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManager; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class CompiledTest extends \PHPUnit\Framework\TestCase { diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php index 779a0d04ebc5..648a74b91495 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/CompiledTest.php @@ -38,6 +38,9 @@ class CompiledTest extends \PHPUnit\Framework\TestCase /** @var ObjectManager */ private $objectManager; + /** + * Setup tests + */ protected function setUp() { $this->objectManager = new ObjectManager($this); @@ -57,6 +60,9 @@ protected function setUp() $this->objectManager->setBackwardCompatibleProperty($this->factory, 'definitions', $this->definitionsMock); } + /** + * Test create simple + */ public function testCreateSimple() { $expectedConfig = $this->getSimpleConfig(); @@ -106,6 +112,9 @@ public function testCreateSimple() $this->assertNull($result->getNullValue()); } + /** + * Test create simple configured arguments + */ public function testCreateSimpleConfiguredArguments() { $expectedConfig = $this->getSimpleNestedConfig(); @@ -170,6 +179,9 @@ public function testCreateSimpleConfiguredArguments() $this->assertNull($result->getNullValue()); } + /** + * Test create get arguments in runtime + */ public function testCreateGetArgumentsInRuntime() { // Stub OM to create test assets @@ -308,18 +320,21 @@ private function getRuntimeParameters() 1 => DependencyTesting::class, 2 => true, 3 => null, + 4 => false, ], 1 => [ 0 => 'sharedDependency', 1 => DependencySharedTesting::class, 2 => true, 3 => null, + 4 => false, ], 2 => [ 0 => 'value', 1 => null, 2 => false, 3 => 'value', + 4 => false, ], 3 => [ 0 => 'valueArray', @@ -329,18 +344,21 @@ private function getRuntimeParameters() 0 => 'default_value1', 1 => 'default_value2', ], + 4 => false, ], 4 => [ 0 => 'globalValue', 1 => null, 2 => false, 3 => '', + 4 => false, ], 5 => [ 0 => 'nullValue', 1 => null, 2 => false, 3 => null, + 4 => false, ], ]; } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php index 309bf48548ec..cc86d794bd80 100644 --- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/FactoryTest.php @@ -10,6 +10,9 @@ use Magento\Framework\ObjectManager\Factory\Dynamic\Developer; use Magento\Framework\ObjectManager\ObjectManager; +/** + * Class FactoryTest + */ class FactoryTest extends \PHPUnit\Framework\TestCase { /** @@ -27,6 +30,9 @@ class FactoryTest extends \PHPUnit\Framework\TestCase */ private $objectManager; + /** + * Setup tests + */ protected function setUp() { $this->config = new Config(); @@ -35,28 +41,43 @@ protected function setUp() $this->factory->setObjectManager($this->objectManager); } + /** + * Test create without args + */ public function testCreateNoArgs() { $this->assertInstanceOf('StdClass', $this->factory->create(\StdClass::class)); } /** - * @expectedException \UnexpectedValueException + * @expectedException \UnexpectedValueException * @expectedExceptionMessage Invalid parameter configuration provided for $firstParam argument */ public function testResolveArgumentsException() { $configMock = $this->createMock(\Magento\Framework\ObjectManager\Config\Config::class); - $configMock->expects($this->once())->method('getArguments') - ->will($this->returnValue([ - 'firstParam' => 1, - ])); + $configMock->expects($this->once())->method('getArguments')->will( + $this->returnValue( + [ + 'firstParam' => 1, + ] + ) + ); $definitionsMock = $this->createMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); - $definitionsMock->expects($this->once())->method('getParameters') - ->will($this->returnValue([[ - 'firstParam', 'string', true, 'default_val', - ]])); + $definitionsMock->expects($this->once())->method('getParameters')->will( + $this->returnValue( + [ + [ + 'firstParam', + 'string', + true, + 'default_val', + false + ] + ] + ) + ); $this->factory = new Developer( $configMock, @@ -71,9 +92,14 @@ public function testResolveArgumentsException() ); } + /** + * Test create with one arg + */ public function testCreateOneArg() { - /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar $result */ + /** + * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar $result + */ $result = $this->factory->create( \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, ['foo' => 'bar'] @@ -82,6 +108,9 @@ public function testCreateOneArg() $this->assertEquals('bar', $result->getFoo()); } + /** + * Test create with injectable + */ public function testCreateWithInjectable() { // let's imitate that One is injectable by providing DI configuration for it @@ -92,7 +121,9 @@ public function testCreateWithInjectable() ], ] ); - /** @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two $result */ + /** + * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two $result + */ $result = $this->factory->create(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two::class); $this->assertInstanceOf(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Two::class, $result); $this->assertInstanceOf( @@ -104,8 +135,8 @@ public function testCreateWithInjectable() } /** - * @param string $startingClass - * @param string $terminationClass + * @param string $startingClass + * @param string $terminationClass * @dataProvider circularDataProvider */ public function testCircular($startingClass, $terminationClass) @@ -130,23 +161,30 @@ public function circularDataProvider() ]; } + /** + * Test create using reflection + */ public function testCreateUsingReflection() { $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Polymorphous::class; $definitions = $this->createMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); // should be more than defined in "switch" of create() method - $definitions->expects($this->once())->method('getParameters')->with($type)->will($this->returnValue([ - ['one', null, false, null], - ['two', null, false, null], - ['three', null, false, null], - ['four', null, false, null], - ['five', null, false, null], - ['six', null, false, null], - ['seven', null, false, null], - ['eight', null, false, null], - ['nine', null, false, null], - ['ten', null, false, null], - ])); + $definitions->expects($this->once())->method('getParameters')->with($type)->will( + $this->returnValue( + [ + ['one', null, false, null, false], + ['two', null, false, null, false], + ['three', null, false, null, false], + ['four', null, false, null, false], + ['five', null, false, null, false], + ['six', null, false, null, false], + ['seven', null, false, null, false], + ['eight', null, false, null, false], + ['nine', null, false, null, false], + ['ten', null, false, null, false], + ] + ) + ); $factory = new Developer($this->config, null, $definitions); $result = $factory->create( $type, @@ -165,4 +203,257 @@ public function testCreateUsingReflection() ); $this->assertSame(10, $result->getArg(9)); } + + /** + * Test create objects with variadic argument in constructor + * + * @param $createArgs + * @param $expectedArg0 + * @param $expectedArg1 + * @dataProvider testCreateUsingVariadicDataProvider + */ + public function testCreateUsingVariadic( + $createArgs, + $expectedArg0, + $expectedArg1 + ) { + $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic::class; + $definitions = $this->createMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); + + $definitions->expects($this->once())->method('getParameters')->with($type)->will( + $this->returnValue( + [ + [ + 'oneScalars', + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, + false, + [], + true + ], + ] + ) + ); + $factory = new Developer($this->config, null, $definitions); + + /** + * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic + */ + $variadic = is_null($createArgs) + ? $factory->create($type) + : $factory->create($type, $createArgs); + + $this->assertSame($expectedArg0, $variadic->getOneScalarByKey(0)); + $this->assertSame($expectedArg1, $variadic->getOneScalarByKey(1)); + } + + /** + * @return array + */ + public function testCreateUsingVariadicDataProvider() + { + $oneScalar1 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + $oneScalar2 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + + return [ + 'without_args' => [ + null, + null, + null, + ], + 'with_empty_args' => [ + [], + null, + null, + ], + 'with_empty_args_value' => [ + [ + 'oneScalars' => [] + ], + null, + null, + ], + 'with_single_arg' => [ + [ + 'oneScalars' => $oneScalar1 + ], + $oneScalar1, + null, + ], + 'with_full_args' => [ + [ + 'oneScalars' => [ + $oneScalar1, + $oneScalar2, + ] + ], + $oneScalar1, + $oneScalar2, + ], + ]; + } + + /** + * Test data can be injected into variadic arguments from di config + */ + public function testCreateVariadicFromDiConfig() + { + $oneScalar1 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + $oneScalar2 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + + // let's imitate that Variadic is configured by providing DI configuration for it + $this->config->extend( + [ + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic::class => [ + 'arguments' => [ + 'oneScalars' => [ + $oneScalar1, + $oneScalar2, + ] + ] + ], + ] + ); + /** + * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic $variadic + */ + $variadic = $this->factory->create(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\Variadic::class); + + $this->assertSame($oneScalar1, $variadic->getOneScalarByKey(0)); + $this->assertSame($oneScalar2, $variadic->getOneScalarByKey(1)); + } + + /** + * Test create objects with non variadic and variadic argument in constructor + * + * @param $createArgs + * @param $expectedFooValue + * @param $expectedArg0 + * @param $expectedArg1 + * @dataProvider testCreateUsingSemiVariadicDataProvider + */ + public function testCreateUsingSemiVariadic( + $createArgs, + $expectedFooValue, + $expectedArg0, + $expectedArg1 + ) { + $type = \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::class; + $definitions = $this->createMock(\Magento\Framework\ObjectManager\DefinitionInterface::class); + + $definitions->expects($this->once())->method('getParameters')->with($type)->will( + $this->returnValue( + [ + [ + 'foo', + null, + false, + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + false + ], + [ + 'oneScalars', + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class, + false, + [], + true + ], + ] + ) + ); + $factory = new Developer($this->config, null, $definitions); + + /** + * @var \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic $semiVariadic + */ + $semiVariadic = is_null($createArgs) + ? $factory->create($type) + : $factory->create($type, $createArgs); + + $this->assertSame($expectedFooValue, $semiVariadic->getFoo()); + $this->assertSame($expectedArg0, $semiVariadic->getOneScalarByKey(0)); + $this->assertSame($expectedArg1, $semiVariadic->getOneScalarByKey(1)); + } + + /** + * @return array + */ + public function testCreateUsingSemiVariadicDataProvider() + { + $oneScalar1 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + $oneScalar2 = $this->createMock(\Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\OneScalar::class); + + return [ + 'without_args' => [ + null, + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + null, + null, + ], + 'with_empty_args' => [ + [], + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + null, + null, + ], + 'only_with_foo_value' => [ + [ + 'foo' => 'baz' + ], + 'baz', + null, + null, + ], + 'only_with_oneScalars_empty_value' => [ + [ + 'oneScalars' => [] + ], + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + null, + null, + ], + 'only_with_oneScalars_single_value' => [ + [ + 'oneScalars' => $oneScalar1 + ], + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + $oneScalar1, + null, + ], + 'only_with_oneScalars_full_value' => [ + [ + 'oneScalars' => [ + $oneScalar1, + $oneScalar2, + ] + ], + \Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture\SemiVariadic::DEFAULT_FOO_VALUE, + $oneScalar1, + $oneScalar2, + ], + 'with_all_values_defined_in_right_order' => [ + [ + 'foo' => 'baz', + 'oneScalars' => [ + $oneScalar1, + $oneScalar2, + ] + ], + 'baz', + $oneScalar1, + $oneScalar2, + ], + 'with_all_values_defined_in_reverse_order' => [ + [ + 'oneScalars' => [ + $oneScalar1, + $oneScalar2, + ], + 'foo' => 'baz', + ], + 'baz', + $oneScalar1, + $oneScalar2, + ], + ]; + } } diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/SemiVariadic.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/SemiVariadic.php new file mode 100644 index 000000000000..8773dec1c48d --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/SemiVariadic.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture; + +/** + * Constructor with non variadic and variadic argument in constructor + */ +class SemiVariadic +{ + const DEFAULT_FOO_VALUE = 'bar'; + + /** + * @var OneScalar[] + */ + private $oneScalars; + + /** + * @var string + */ + private $foo; + + /** + * SemiVariadic constructor. + * + * @param string $foo + * @param OneScalar[] ...$oneScalars + */ + public function __construct( + string $foo = self::DEFAULT_FOO_VALUE, + OneScalar ...$oneScalars + ) { + $this->foo = $foo; + $this->oneScalars = $oneScalars; + } + + /** + * @param mixed $key + * @return mixed + */ + public function getOneScalarByKey($key) + { + return $this->oneScalars[$key] ?? null; + } + + /** + * @return string + */ + public function getFoo(): string + { + return $this->foo; + } +} diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Variadic.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Variadic.php new file mode 100644 index 000000000000..af26f7456fdd --- /dev/null +++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Variadic.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Framework\ObjectManager\Test\Unit\Factory\Fixture; + +/** + * Constructor with variadic argument in constructor + */ +class Variadic +{ + /** + * @var OneScalar[] + */ + private $oneScalars; + + /** + * Variadic constructor. + * @param OneScalar[] ...$oneScalars + */ + public function __construct(OneScalar ...$oneScalars) + { + $this->oneScalars = $oneScalars; + } + + /** + * @param string $key + * @return mixed + */ + public function getOneScalarByKey($key) + { + return $this->oneScalars[$key] ?? null; + } +} diff --git a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonHexTagTest.php b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonHexTagTest.php index c867dced0fc6..f6bf61708dd8 100644 --- a/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonHexTagTest.php +++ b/lib/internal/Magento/Framework/Serialize/Test/Unit/Serializer/JsonHexTagTest.php @@ -17,7 +17,7 @@ class JsonHexTagTest extends \PHPUnit\Framework\TestCase * @var \Magento\Framework\Serialize\Serializer\Json */ private $json; - + protected function setUp() { $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -37,6 +37,9 @@ public function testSerialize($value, $expected) ); } + /** + * @return array + */ public function serializeDataProvider() { $dataObject = new DataObject(['something']); diff --git a/lib/internal/Magento/Framework/Session/SidResolver.php b/lib/internal/Magento/Framework/Session/SidResolver.php index 1208aeb31eae..041995d20fcd 100644 --- a/lib/internal/Magento/Framework/Session/SidResolver.php +++ b/lib/internal/Magento/Framework/Session/SidResolver.php @@ -11,6 +11,7 @@ /** * Class SidResolver + * @deprecated 2.3.3 SIDs in URLs are no longer used */ class SidResolver implements SidResolverInterface { diff --git a/lib/internal/Magento/Framework/Setup/Lists.php b/lib/internal/Magento/Framework/Setup/Lists.php index 1ee5baf28658..4e0f7277b7b7 100644 --- a/lib/internal/Magento/Framework/Setup/Lists.php +++ b/lib/internal/Magento/Framework/Setup/Lists.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\Setup; @@ -12,6 +13,9 @@ use Magento\Framework\Locale\ConfigInterface; use Magento\Framework\Locale\Resolver; +/** + * Retrieves lists of allowed locales and currencies + */ class Lists { /** @@ -92,17 +96,22 @@ public function getLocaleList() $languages = (new LanguageBundle())->get(Resolver::DEFAULT_LOCALE)['Languages']; $countries = (new RegionBundle())->get(Resolver::DEFAULT_LOCALE)['Countries']; $locales = \ResourceBundle::getLocales('') ?: []; + $allowedLocales = array_flip($this->allowedLocales); $list = []; foreach ($locales as $locale) { - if (!in_array($locale, $this->allowedLocales)) { + if (!isset($allowedLocales[$locale])) { continue; } $language = \Locale::getPrimaryLanguage($locale); $country = \Locale::getRegion($locale); + $script = \Locale::getScript($locale); if (!$languages[$language] || !$countries[$country]) { continue; } - $list[$locale] = $languages[$language] . ' (' . $countries[$country] . ')'; + if ($script !== '') { + $script = \Locale::getDisplayScript($locale) . ', '; + } + $list[$locale] = $languages[$language] . ' (' . $script . $countries[$country] . ')'; } asort($list); return $list; diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php index a25771b4519f..c9c6dfe6d7dc 100644 --- a/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php +++ b/lib/internal/Magento/Framework/Setup/Test/Unit/ListsTest.php @@ -3,27 +3,31 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Framework\Setup\Test\Unit; +use Magento\Framework\Locale\ConfigInterface; use Magento\Framework\Setup\Lists; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; -class ListsTest extends \PHPUnit\Framework\TestCase +class ListsTest extends TestCase { /** * @var Lists */ - protected $lists; + private $lists; /** - * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Locale\ConfigInterface + * @var MockObject|ConfigInterface */ - protected $mockConfig; + private $mockConfig; /** * @var array */ - protected $expectedTimezones = [ + private $expectedTimezones = [ 'Australia/Darwin', 'America/Los_Angeles', 'Europe/Kiev', @@ -33,7 +37,7 @@ class ListsTest extends \PHPUnit\Framework\TestCase /** * @var array */ - protected $expectedCurrencies = [ + private $expectedCurrencies = [ 'USD', 'EUR', 'UAH', @@ -43,23 +47,23 @@ class ListsTest extends \PHPUnit\Framework\TestCase /** * @var array */ - protected $expectedLocales = [ - 'en_US', - 'en_GB', - 'uk_UA', - 'de_DE', + private $expectedLocales = [ + 'en_US' => 'English (United States)', + 'en_GB' => 'English (United Kingdom)', + 'uk_UA' => 'Ukrainian (Ukraine)', + 'de_DE' => 'German (Germany)', + 'sr_Cyrl_RS' => 'Serbian (Cyrillic, Serbia)', + 'sr_Latn_RS' => 'Serbian (Latin, Serbia)' ]; protected function setUp() { - $this->mockConfig = $this->getMockBuilder(\Magento\Framework\Locale\ConfigInterface::class) + $this->mockConfig = $this->getMockBuilder(ConfigInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->mockConfig->expects($this->any()) - ->method('getAllowedLocales') - ->willReturn($this->expectedLocales); - $this->mockConfig->expects($this->any()) - ->method('getAllowedCurrencies') + $this->mockConfig->method('getAllowedLocales') + ->willReturn(array_keys($this->expectedLocales)); + $this->mockConfig->method('getAllowedCurrencies') ->willReturn($this->expectedCurrencies); $this->lists = new Lists($this->mockConfig); @@ -73,13 +77,10 @@ public function testGetTimezoneList() public function testGetLocaleList() { - $locales = array_intersect($this->expectedLocales, array_keys($this->lists->getLocaleList())); + $locales = array_intersect($this->expectedLocales, $this->lists->getLocaleList()); $this->assertEquals($this->expectedLocales, $locales); } - /** - * Test Lists:getCurrencyList() considering allowed currencies config values. - */ public function testGetCurrencyList() { $currencies = array_intersect($this->expectedCurrencies, array_keys($this->lists->getCurrencyList())); diff --git a/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php b/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php index 629b81074e3f..cde91cbda489 100644 --- a/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php +++ b/lib/internal/Magento/Framework/Test/Unit/EscaperTest.php @@ -7,6 +7,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Escaper; +use Magento\Framework\Translate\Inline; /** * \Magento\Framework\Escaper test case @@ -16,26 +17,40 @@ class EscaperTest extends \PHPUnit\Framework\TestCase /** * @var \Magento\Framework\Escaper */ - protected $escaper = null; + protected $escaper; /** * @var \Magento\Framework\ZendEscaper */ private $zendEscaper; + /** + * @var Inline + */ + private $translateInline; + /** * @var \Psr\Log\LoggerInterface */ private $loggerMock; + /** + * @inheritdoc + */ protected function setUp() { + $objectManagerHelper = new ObjectManager($this); $this->escaper = new Escaper(); $this->zendEscaper = new \Magento\Framework\ZendEscaper(); + $this->translateInline = $objectManagerHelper->getObject(Inline::class); $this->loggerMock = $this->getMockForAbstractClass(\Psr\Log\LoggerInterface::class); - $objectManagerHelper = new ObjectManager($this); $objectManagerHelper->setBackwardCompatibleProperty($this->escaper, 'escaper', $this->zendEscaper); $objectManagerHelper->setBackwardCompatibleProperty($this->escaper, 'logger', $this->loggerMock); + $objectManagerHelper->setBackwardCompatibleProperty( + $this->escaper, + 'translateInline', + $this->translateInline + ); } /** @@ -224,7 +239,12 @@ public function escapeHtmlDataProvider() ], 'text with html comment' => [ 'data' => 'Only <span><b>2</b></span> in stock <!-- HTML COMMENT -->', - 'expected' => 'Only <span><b>2</b></span> in stock <!-- HTML COMMENT -->', + 'expected' => 'Only <span><b>2</b></span> in stock ', + 'allowedTags' => ['span', 'b'], + ], + 'text with multi-line html comment' => [ + 'data' => "Only <span><b>2</b></span> in stock <!-- --!\n\n><img src=#>-->", + 'expected' => 'Only <span><b>2</b></span> in stock ', 'allowedTags' => ['span', 'b'], ], 'text with non ascii characters' => [ @@ -393,6 +413,10 @@ public function escapeDataProvider() 'http://test.com/?redirect=\x64\x61\x74\x61\x3a\x74\x65\x78\x74x2cCPHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg', 'http://test.com/?redirect=:\x74\x65\x78\x74x2cCPHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg', ], + [ + 'http://test.com/?{{{test}}{{test_translated}}{{tes_origin}}{{theme}}}', + 'http://test.com/?test', + ], ]; } } diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php index 11aeb1c0c79b..c67a20f0a157 100644 --- a/lib/internal/Magento/Framework/Url.php +++ b/lib/internal/Magento/Framework/Url.php @@ -62,6 +62,7 @@ * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class Url extends \Magento\Framework\DataObject implements \Magento\Framework\UrlInterface { @@ -675,8 +676,7 @@ protected function _getControllerName($default = null) } /** - * Set Action name - * Reseted route path if action name has change + * Set Action name, reseated route path if action name has change * * @param string $data * @return \Magento\Framework\UrlInterface @@ -1067,7 +1067,7 @@ public function sessionUrlVar($html) */ // @codingStandardsIgnoreEnd function ($match) { - if ($this->useSessionIdForUrl($match[2] == 'S' ? true : false)) { + if ($this->useSessionIdForUrl($match[2] == 'S')) { return $match[1] . $this->_sidResolver->getSessionIdQueryParam($this->_session) . '=' . $this->_session->getSessionId() . (isset($match[3]) ? $match[3] : ''); } else { diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource.php index 7016bbdb08ab..b05a12deb384 100644 --- a/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource.php +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/AlternativeSource.php @@ -6,9 +6,9 @@ namespace Magento\Framework\View\Asset\PreProcessor; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Asset\ContentProcessorInterface; use Magento\Framework\View\Asset\File\FallbackContext; use Magento\Framework\View\Asset\LockerProcessInterface; -use Magento\Framework\View\Asset\ContentProcessorInterface; use Magento\Framework\View\Asset\PreProcessor\AlternativeSource\AssetBuilder; /** @@ -139,11 +139,13 @@ private function processContent($path, $content, $module, FallbackContext $conte ->setTheme($context->getThemePath()) ->setLocale($context->getLocale()) ->setModule($module) - ->setPath(preg_replace( - '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#', - '.' . $name, - $path - ))->build(); + ->setPath( + preg_replace( + '#\.' . preg_quote(pathinfo($path, PATHINFO_EXTENSION)) . '$#', + '.' . $name, + $path + ) + )->build(); $processor = $this->objectManager->get($alternative[self::PROCESSOR_CLASS]); if (!$processor instanceof ContentProcessorInterface) { @@ -168,4 +170,15 @@ public function getAlternativesExtensionsNames() { return array_keys($this->alternatives); } + + /** + * Check if file extension supported + * + * @param string $ext + * @return bool + */ + public function isExtensionSupported($ext) + { + return isset($this->alternatives[$ext]); + } } diff --git a/lib/internal/Magento/Framework/View/Asset/PreProcessor/FileNameResolver.php b/lib/internal/Magento/Framework/View/Asset/PreProcessor/FileNameResolver.php index 2afb97b918ea..bae2ff53a54e 100644 --- a/lib/internal/Magento/Framework/View/Asset/PreProcessor/FileNameResolver.php +++ b/lib/internal/Magento/Framework/View/Asset/PreProcessor/FileNameResolver.php @@ -5,6 +5,11 @@ */ namespace Magento\Framework\View\Asset\PreProcessor; +/** + * Class FileNameResolver + * + * @package Magento\Framework\View\Asset\PreProcessor + */ class FileNameResolver { /** @@ -38,7 +43,7 @@ public function resolve($fileName) $compiledFile = $fileName; $extension = pathinfo($fileName, PATHINFO_EXTENSION); foreach ($this->alternativeSources as $name => $alternative) { - if (in_array($extension, $alternative->getAlternativesExtensionsNames(), true) + if ($alternative->isExtensionSupported($extension) && strpos(basename($fileName), '_') !== 0 ) { $compiledFile = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1); diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php index c40d26ab2f50..2691bc21357b 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php @@ -3,16 +3,27 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Framework\View\Element\UiComponent\Argument\Interpreter; +use Magento\Framework\Code\Reader\ClassReader; +use Magento\Framework\Data\OptionSourceInterface; +use Magento\Framework\ObjectManager\ConfigInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Data\Argument\InterpreterInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; /** * Class ConfigurableObject */ class ConfigurableObject implements InterpreterInterface { + /** + * @var array + */ + private $classWhitelist = []; + /** * @var ObjectManagerInterface */ @@ -23,20 +34,41 @@ class ConfigurableObject implements InterpreterInterface */ protected $argumentInterpreter; + /** + * @var ClassReader|null + */ + private $classReader; + + /** + * @var ConfigInterface + */ + private $objectManagerConfig; + /** * Constructor * * @param ObjectManagerInterface $objectManager * @param InterpreterInterface $argumentInterpreter + * @param array $classWhitelist + * @param ClassReader|null $classReader + * @param ConfigInterface|null $objectManagerConfig */ - public function __construct(ObjectManagerInterface $objectManager, InterpreterInterface $argumentInterpreter) - { + public function __construct( + ObjectManagerInterface $objectManager, + InterpreterInterface $argumentInterpreter, + array $classWhitelist = [], + ClassReader $classReader = null, + ConfigInterface $objectManagerConfig = null + ) { $this->objectManager = $objectManager; $this->argumentInterpreter = $argumentInterpreter; + $this->classWhitelist = $classWhitelist; + $this->classReader = $classReader ?? $objectManager->get(ClassReader::class); + $this->objectManagerConfig = $objectManagerConfig ?? $objectManager->get(ConfigInterface::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function evaluate(array $data) { @@ -53,10 +85,44 @@ public function evaluate(array $data) if (!isset($arguments['class'])) { throw new \InvalidArgumentException('Node "argument" with name "class" is required for this type.'); } + $className = $arguments['class']; unset($arguments['class']); + + $type = $this->objectManagerConfig->getInstanceType( + $this->objectManagerConfig->getPreference($className) + ); + + $classParents = $this->getParents($type); + + $whitelistIntersection = array_intersect($classParents, $this->classWhitelist); + + if (empty($whitelistIntersection)) { + throw new \InvalidArgumentException( + sprintf('Class argument is invalid: %s', $className) + ); + } } return $this->objectManager->create($className, $arguments); } + + /** + * Retrieves all the parent classes and interfaces for a class including the ones implemented by the class itself + * + * @param string $type + * @return string[] + */ + private function getParents(string $type) + { + $classParents = $this->classReader->getParents($type); + foreach ($classParents as $parent) { + if (empty($parent)) { + continue; + } + $classParents = array_merge($classParents, $this->getParents($parent)); + } + + return $classParents; + } } diff --git a/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php index 71fa8d2c0ae6..34f32b2f6b7b 100644 --- a/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php +++ b/lib/internal/Magento/Framework/View/File/Collector/Decorator/ModuleOutput.php @@ -6,7 +6,7 @@ namespace Magento\Framework\View\File\Collector\Decorator; -use Magento\Framework\Module\ModuleManagerInterface; +use Magento\Framework\Module\Manager; use Magento\Framework\View\Design\ThemeInterface; use Magento\Framework\View\File; use Magento\Framework\View\File\CollectorInterface; @@ -26,7 +26,7 @@ class ModuleOutput implements CollectorInterface /** * Module manager * - * @var \Magento\Framework\Module\ModuleManagerInterface + * @var \Magento\Framework\Module\Manager */ private $moduleManager; @@ -38,7 +38,7 @@ class ModuleOutput implements CollectorInterface */ public function __construct( CollectorInterface $subject, - ModuleManagerInterface $moduleManager + Manager $moduleManager ) { $this->subject = $subject; $this->moduleManager = $moduleManager; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/UiComponent/Argument/Interpreter/ConfigurableObjectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/UiComponent/Argument/Interpreter/ConfigurableObjectTest.php new file mode 100644 index 000000000000..0d4be68a4c1b --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/UiComponent/Argument/Interpreter/ConfigurableObjectTest.php @@ -0,0 +1,278 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Test\Unit\UiComponent\Argument\Interpreter; + +use Magento\Framework\Code\Reader\ClassReader; +use Magento\Framework\Data\Argument\InterpreterInterface; +use Magento\Framework\ObjectManager\ConfigInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; + +/** + * Unit tests for ConfigurableObject + */ +class ConfigurableObjectTest extends TestCase +{ + /** + * @var ConfigurableObject + */ + private $configurableObject; + + /** + * @var ObjectManagerInterface|MockObject + */ + private $objectManager; + + /** + * @var InterpreterInterface|MockObject + */ + private $interpreter; + + /** + * @var ClassReader|MockObject + */ + private $classReader; + + /** + * @var ConfigInterface|MockObject + */ + private $objectManagerConfig; + + protected function setUp() + { + $objectManager = new ObjectManager($this); + $this->objectManager = $this->createMock(ObjectManagerInterface::class); + $this->interpreter = $this->createMock(InterpreterInterface::class); + $this->classReader = $this->createMock(ClassReader::class); + $this->objectManagerConfig = $this->createMock(ConfigInterface::class); + $this->configurableObject = $objectManager->getObject( + ConfigurableObject::class, + [ + 'objectManager' => $this->objectManager, + 'argumentInterpreter' => $this->interpreter, + 'classWhitelist' => [ + \Foo\Bar\ClassA::class, + \Foo\Bar\InterfaceA::class, + ], + 'classReader' => $this->classReader, + 'objectManagerConfig' => $this->objectManagerConfig, + ] + ); + } + + /** + * @dataProvider validDataProvider + */ + public function testValidCombinations( + $data, + $expectedClass, + $classParentsValueMap, + $expectedArguments + ) { + $this->objectManagerConfig + ->method('getPreference') + ->with($expectedClass) + ->WillReturn('bar'); + $this->objectManagerConfig + ->method('getInstanceType') + ->with('bar') + ->willReturn($expectedClass); + + $this->classReader + ->method('getParents') + ->willReturnMap($classParentsValueMap); + + $this->objectManager + ->expects($this->once()) + ->method('create') + ->with($expectedClass, $expectedArguments) + ->willReturn('an object yay!'); + + $this->interpreter + ->method('evaluate') + ->will( + $this->returnCallback( + function (array $arg) { + return $arg['value']; + } + ) + ); + + $actualResult = $this->configurableObject->evaluate($data); + self::assertSame('an object yay!', $actualResult); + } + + /** + * @dataProvider invalidDataProvider + */ + public function testInvalidCombinations( + $data, + $expectedClass, + $classParentsValueMap, + $expectedException, + $expectedExceptionMessage + ) { + + $this->expectException($expectedException); + $this->expectExceptionMessage($expectedExceptionMessage); + + $this->objectManagerConfig + ->method('getPreference') + ->with($expectedClass) + ->WillReturn('bar'); + $this->objectManagerConfig + ->method('getInstanceType') + ->with('bar') + ->willReturn($expectedClass); + + $this->classReader + ->method('getParents') + ->willReturnMap($classParentsValueMap); + + $this->objectManager + ->expects($this->never()) + ->method('create'); + + $this->interpreter + ->method('evaluate') + ->will( + $this->returnCallback( + function (array $arg) { + return $arg['value']; + } + ) + ); + + $actualResult = $this->configurableObject->evaluate($data); + self::assertSame('an object yay!', $actualResult); + } + + public function validDataProvider() + { + return [ + // Test most basic syntax with no arguments + [ + [ + 'value' => 'MyObject', + ], + 'MyObject', + [], + [] + ], + // Test alternative data syntax + [ + [ + 'argument' => [ + 'class' => ['value' => 'MyFooClass'] + ] + ], + 'MyFooClass', + [ + ['MyFooClass', ['Something', 'skipme']], + ['Something', ['dontcare', 'SomethingElse']], + ['SomethingElse', [\Foo\Bar\ClassA::class, 'unrelated']], + ['skipme', []], + ['dontcare', []], + ['unrelated', []], + [\Foo\Bar\ClassA::class, []] + ], + [] + ], + // Test arguments + [ + [ + 'argument' => [ + 'class' => ['value' => 'MyFooClass'], + 'myarg' => ['value' => 'bar'], + ] + ], + 'MyFooClass', + [ + ['MyFooClass', ['Something', 'skipme']], + ['Something', ['dontcare', 'SomethingElse']], + ['SomethingElse', [\Foo\Bar\ClassA::class, 'unrelated']], + ['skipme', []], + ['dontcare', []], + ['unrelated', []], + [\Foo\Bar\ClassA::class, []] + ], + ['myarg' => 'bar'] + ], + // Test multiple matching whitelisted classes + [ + [ + 'argument' => [ + 'class' => ['value' => 'MyFooClass'], + 'myarg' => ['value' => 'bar'], + ] + ], + 'MyFooClass', + [ + ['MyFooClass', ['Something', 'skipme']], + ['Something', ['dontcare', 'SomethingElse']], + ['SomethingElse', [\Foo\Bar\ClassA::class, 'unrelated']], + ['skipme', []], + ['dontcare', []], + ['unrelated', [\Foo\Bar\InterfaceA::class]], + [\Foo\Bar\ClassA::class, []], + [\Foo\Bar\InterfaceA::class, []] + ], + ['myarg' => 'bar'] + ], + ]; + } + + public function invalidDataProvider() + { + return [ + [ + [ + 'notvalid' => 'sup' + ], + '', + [], + \InvalidArgumentException::class, + 'Node "argument" required for this type.' + ], + [ + [ + 'argument' => [ + 'notclass' => ['value' => 'doesntmatter'] + ] + ], + '', + [], + \InvalidArgumentException::class, + 'Node "argument" with name "class" is required for this type.' + ], + [ + [ + 'argument' => [ + 'class' => ['value' => 'MyFooClass'], + 'myarg' => ['value' => 'bar'], + ] + ], + 'MyFooClass', + [ + ['MyFooClass', ['Something', 'skipme']], + ['Something', ['dontcare', 'SomethingElse']], + ['SomethingElse', ['unrelated']], + ['skipme', []], + ['dontcare', []], + ['unrelated', []], + ], + \InvalidArgumentException::class, + 'Class argument is invalid: MyFooClass' + ], + ]; + } +} diff --git a/lib/internal/Magento/Framework/composer.json b/lib/internal/Magento/Framework/composer.json index af2eb913fe3f..dfbfb5a25deb 100644 --- a/lib/internal/Magento/Framework/composer.json +++ b/lib/internal/Magento/Framework/composer.json @@ -19,7 +19,6 @@ "ext-intl": "*", "ext-openssl": "*", "ext-simplexml": "*", - "ext-spl": "*", "ext-xsl": "*", "ext-bcmath": "*", "lib-libxml": "*", diff --git a/lib/web/css/docs/layout.html b/lib/web/css/docs/layout.html index 77ed0597f074..b338c66ffae7 100644 --- a/lib/web/css/docs/layout.html +++ b/lib/web/css/docs/layout.html @@ -55,25 +55,25 @@ <tr> <th>@layout-class-1column</th> <td class="vars_value">page-layout-1column</td> - <td class="vars_value">'' | false | <nobr>page-layout-1column</nobr> | <nobr>page-layout-2columns-left</nobr> | <nobr>page-layout-2columns-right</nobr> | <nobr>page-layout-3columns</nobr></td> + <td class="vars_value">'' | false | <span style="white-space: nowrap">page-layout-1column</span> | <span style="white-space: nowrap">page-layout-2columns-left</span> | <span style="white-space: nowrap">page-layout-2columns-right</span> | <span style="white-space: nowrap">page-layout-3columns</span></td> <td>Class name for one column layout</td> </tr> <tr> <th>@layout-class-2columns__left</th> <td class="vars_value">page-layout-2columns-left</td> - <td class="vars_value">'' | false | <nobr>page-layout-1column</nobr> | <nobr>page-layout-2columns-left</nobr> | <nobr>page-layout-2columns-right</nobr> | <nobr>page-layout-3columns</nobr></td> + <td class="vars_value">'' | false | <span style="white-space: nowrap">page-layout-1column</span> | <span style="white-space: nowrap">page-layout-2columns-left</span> | <span style="white-space: nowrap">page-layout-2columns-right</span> | <span style="white-space: nowrap">page-layout-3columns</span></td> <td>Class name for two columns layout with left sidebar</td> </tr> <tr> <th nowrap="nowrap">@layout-class-2columns__right</th> <td class="vars_value">page-layout-2columns-right</td> - <td class="vars_value">'' | false | <nobr>page-layout-1column</nobr> | <nobr>page-layout-2columns-left</nobr> | <nobr>page-layout-2columns-right</nobr> | <nobr>page-layout-3columns</nobr></td> + <td class="vars_value">'' | false | <span style="white-space: nowrap">page-layout-1column</span> | <span style="white-space: nowrap">page-layout-2columns-left</span> | <span style="white-space: nowrap">page-layout-2columns-right</span> | <span style="white-space: nowrap">page-layout-3columns</span></td> <td>Class name for two columns layout with right sidebar</td> </tr> <tr> <th>@layout-class-3columns</th> <td class="vars_value">page-layout-3columns</td> - <td class="vars_value">'' | false | <nobr>page-layout-1column</nobr> | <nobr>page-layout-2columns-left</nobr> | <nobr>page-layout-2columns-right</nobr> | <nobr>page-layout-3columns</nobr></td> + <td class="vars_value">'' | false | <span style="white-space: nowrap">page-layout-1column</span> | <span style="white-space: nowrap">page-layout-2columns-left</span> | <span style="white-space: nowrap">page-layout-2columns-right</span> | <span style="white-space: nowrap">page-layout-3columns</span></td> <td>Class name for three columns layout with left sidebar</td> </tr> <tr> diff --git a/lib/web/css/docs/responsive.html b/lib/web/css/docs/responsive.html index 48d0bd551bd9..ebc42e698f60 100644 --- a/lib/web/css/docs/responsive.html +++ b/lib/web/css/docs/responsive.html @@ -7,7 +7,7 @@ <!DOCTYPE html><html><head><title>responsive | Magento UI Library

Responsive

-

Magento UI library provides a strong approach for working with media queries. It`s based on recursive call of .media-width() mixin defined anywhere in project but invoked in one place in lib/web/css/source/lib/_responsive.less. That's why in the resulting styles.css we have every media query only once with all the rules there, not a multiple calls for the same query.

+

Magento UI library provides a strong approach for working with media queries. It`s based on recursive call of .media-width() mixin defined anywhere in project but invoked in one place in lib/web/css/source/lib/_responsive.less. That's why in the resulting styles.css we have every media query only once with all the rules there, not a multiple calls for the same query.

To see the media queries work resize window to understand which breakpoint is applied.